code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const N = readln.chomp.to!long;
const S = readln.chomp;
auto whiteCount = new long[N+1];
auto blackCount = new long[N+1];
foreach (i; 0..N) {
whiteCount[i+1] = S[i] == '.' ? ... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n;
scan(n);
auto p = iota(n).map!(i =>... | D |
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import s... | D |
void main()
{
long[] tmp = rdRow;
long k = tmp[0], x = tmp[1];
writeln(500 * k >= x ? "Yes" : "No");
}
T rdElem(T = long)()
{
//import std.stdio : readln;
//import std.string : chomp;
//import std.conv : to;
return readln.chomp.to!T;
}
alias rdStr = rdElem!string;
dchar[] rdDchar()
{
... | D |
import core.bitop;
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
immutable int mod = 10 ^^ 9 + 7;
immutable int limit = 1003;
void add (ref int a, int b)
{
a = (a + b) % mod;
}
void main ()
{
auto h = new int [limit];
h[1] = 0;
foreach (i; 2..limi... | D |
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outb... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
while (true) {
int n, a, b, c, x;
scan(n, a, b, c, x);
if (!n) return;
auto y = readln.split.to!(int[]);
solve(... | D |
//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.random;
import std.datetime.systime : Clock;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
si... | D |
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
void main() {
int n;
scanf("%d\n", &n);
auto hs = readln.chomp.split.to!(int[]);
int m = hs[0];
foreach(h; hs){
if (m - h > 1) {
write("No");
return;
}
m = max(m, h);
}
write("Yes");
}
| D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
string s = readln().chomp;
int n = s.to!(int);
if (s[$ - 1] == '0' ||
s[$ - 1] == '2' ||
s[$ - 1] == '4' ||
s[$ - 1] == '6' ||
s[$ - 1] == '8' ) {
writeln(s);
} else {
writeln(n*2);
... | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
import std.numeric;
void main()
{
immutable n = readln.chomp.to!int;
auto a = readln.chomp.split.to!(int[]);
int i = 1;
a = a.find(i);
if (a.empty)
return (-1).writeln;
while (!a.empty)
{
i +=... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int N;
int[] A;
scan(N);
A = readln.split.to!(int[]);
long ans;
void dfs(int i, int even) {
if (i == N) {
if (!even) ans++... | D |
import std.stdio, std.conv, std.string, std.math;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[2] >= ip[0] && ip[2] <= ip[1]){
writeln("Yes");
} else {
writeln("No");
}
} | D |
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
import std.numeric;
void main(){
foreach(string line; lines(stdin))
writeln(patternN(line.parse!int));
}
int patternN(int N = 1)(int n){
static if(N == 4){
if(n >= 0 && n < 10)
return 1;
... | D |
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
foreach(i; 0..n) pred();
}
auto ... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | D |
void main(){
if(inelm() >= 30){
writeln("Yes");
}else{
writeln("No");
}
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
// 1要素のみの入力
T inelm(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] inln(T = int)(){
T[] ln;
foreach(string el... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
long ... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;
void main()
{
auto k = readln.chomp.to!int;
long sum;
foreach (int i; 1..k+... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n;
rd(n);
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
if (i * 4 + j * 7 == n) {
writeln("Yes");
return;
}
}
}
writeln("No");
}
void rd(T...)(ref T x) {
import std.stdio : r... | D |
import std.stdio;
import std.string;
/+
const int LEFT = 0;
const int RIGHT = 1;
const int UP = 2;
const int DOWN = 3;
+/
enum {
LEFT,
RIGHT,
UP,
DOWN
}
void main()
{
string[9] kabe;
int x, y;
int direction;
foreach (i; 0..9) {
kabe[i] = readln().chomp;
kabe[i].l... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
int n = read... | D |
void main() {
auto n = ri;
writeln(n/3);
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecon... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
auto ... | D |
import std;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i]... | D |
import std.stdio, std.string, std.conv;
void main()
{
auto n = readln.split.to!(int[]), a = n[0], b = n[1];
int m;
if((a + b) % 2 == 0){
m = 0;
} else {
m = 1;
}
writeln((a + b) / 2 + m);
} | D |
import std.stdio, std.string, std.algorithm, std.conv;
int[] a;
void main(){
string[] s;
while (1) {
s = split(readln());
a = [];
foreach (i; s) a ~= to!int(i);
if (a[0] == 0) break;
writeln(solve(0, 0));
}
}
int solve(int p, int n){
if (n > 21) return 0;
if (p >= a.length) return n;
if (a[p] == 1) ... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
void main()
{
dchar[] c = rdDchar;
dchar[] d = rdDchar;
dchar[] e = c.dup;
dchar[] f = d.dup;
reverse(e);
reverse(f);
writeln(c == f && d == e ? "YES" : "NO");
}
enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;
T rdElem(T = long)()
if (!is(T == struct))
{
... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
auto ... | D |
void main() {
problem();
}
void problem() {
auto N = scan!int;
auto D = scan!long;
auto P = N.iota.map!(_ => Point(scan!long, scan!long)).array;
long solve() {
long ans;
auto d = D*D;
foreach(p; P) {
auto dd = p.x*p.x + p.y*p.y;
if (dd <= d) ans++;
}
return ans;
}
solve(... | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
alias sread = () => readln.chomp();
alias Point2 =... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!ptrdiff_t;
auto a = readln.split.to!(int[]);
if (n == 1) {
write(a[0]);
} else if (n % 2 == 0) {
for (auto i = n-1; i >= 1; i -= 2) write(a[i], " ");
for (auto i = 0; i <= n-2; i += 2) write(a[... | D |
void main() {
long m = readln.chomp.to!long;
long x, y;
foreach (i; 0 .. m) {
long[] tmp = readln.split.to!(long[]);
long d = tmp[0], c = tmp[1];
x += c, y += d * c;
}
writeln(x - 1 + (y - 1) / 9);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
i... | D |
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void main()
{
auto ip = readln.split.to!(int[]);
if(ip[1] == 100... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto b = readln.chomp;
if (b == "A") {
writeln("T");
} else... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
if (N == 0) {
writeln(0);
return;
}
char[] r;
foreach (i; 0..40) {
if (N == 0) break;
if (abs(N) & (1<<i)) {
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
foreach(i... | D |
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(... | D |
void main()
{
long n = readln.chomp.to!long;
long[] a = readln.split.to!(long[]);
long ud;
long cnt = 1;
foreach (i; 1 .. n)
{
if (ud == 0)
{
if (a[i] > a[i-1]) ud = 1;
if (a[i] < a[i-1]) ud = -1;
}
else
{
if (ud == 1 &... | D |
import std.stdio, std.string, std.conv, std.range, std.algorithm;
void main() {
auto N = readln.chomp.to!int;
((1 + N) * N / 2).writeln;
}
| D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
immutable long MOD = 10^^9 + 7;
immutable long INF = 1L << 59;
void main() {
auto N = readln.chomp.to!int;
auto a... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
std.random, std.typecons, std.container;
ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = (... | D |
import std.stdio,
std.range,
std.string,
std.conv,
std.math,
std.algorithm;
void main(){
int base = 100000;
real p = 1.05;
int n = readln.chomp.to!int;
n.iota.each!((e){
base *= p;
base += (base % 1000) ? 1000 - base % 1000 : 0;
});
writeln(base);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
auto hwk = readln.split.to!(int[]);
auto H = hwk[0];
auto W = hwk[1];
auto K = hwk[2];
char[][] MAP;
foreach (_; 0..H) MAP ~= readln.chomp.to!(char[]);... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long a = tmp[0], b = tmp[1];
if (a * b <= 0)
{
"Zero".writeln;
}
else if (a < 0 && b < 0 && (b - a) % 2 == 0)
{
"Negative".writeln;
}
else
{
"Positive".writeln;
}
}
import std.stdio;
import std.str... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto str = readln.chomp.dup;
auto q = readln.chomp.to!size_t;
foreach (_; 0..q) {
auto rd = readln.split, cmd = rd[0];
auto a = rd[1].to!int, b = rd[2].to!int;
switch (cmd) {
case "print":
writeln(str[a..b+1])... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ad = readln.split.to!(int[]);
auto a = ad[0];
auto b = ad[1];
auto c = ad[2];
auto d = ad[3];
writeln(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d) ? "Yes" : "No");
} | D |
import std.stdio,
std.array,
std.conv,
std.string,
std.algorithm,
std.math;
void main(){
string s;
for(;;){
s=readln();
if(stdin.eof()) break;
int num = to!int(chomp(s));
int result = 0;
int[] nums = new int[num];
for(int i=0;i < num;++i) nums[i] = 1;
nums[0] = 0;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto N = readln.to!(wchar[]);
writeln(N[0] == '9' || N[1] == '9' ? "Yes" : "No");
} | D |
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;
void main()
{
auto nk = readln.split.to!(long[]);
auto n = nk[0];
auto k = nk[1];
long a;
long b;
foreac... | D |
import std.stdio;
import std.string;
bool isK(C)(C[] a) {
if (a.length <= 1) return true;
size_t l = 0, r = a.length - 1;
while (l < r) {
if (a[l] != a[r]) {
return false;
}
++l;
--r;
}
return true;
}
void main() {
auto s = readln.chomp;
if (s.isK && s[0.. $ / 2].isK && s[$ / 2 + 1..$].isK) {
... | D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto n=readln.chomp.to!int;
long ans=1;
for(int i=1;i<=n;i++){
ans*=i;
ans%=1000000000+7;
}
writeln(ans);
} | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
auto xs = readints;
long q = x... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
int n; readV(n);
string s; readV... | D |
void main() {
int a = readln.chomp.to!int;
int b = readln.chomp.to!int;
int h = readln.chomp.to!int;
writeln((a + b) * h / 2);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
imp... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
int ans = 0;
for (int i... | D |
import std.stdio, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
immutable int[dchar] L = ['I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000];
foreach(w;stdin.byLine())
{
int s=0,t=0,c=0;
foreach(n;w.map!(a=>L[a])())
{
if(n==c) t+=c;
if(... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln(2^^cast(int)readln.chomp.to!int.log2);
}
| D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
string s;
scan(s);
writeln(s[0 .. $ - 8]);
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (ref arg; args) {
arg = l... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
void main() {
int maxN = 10^^6;
int[] f, f_odd;
for(int n=1; ;n++) {
... | D |
import std.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main()
{
auto ip = readln.split.to!(int[]);
if(ip[0] < ip[1] && ip[1] < ip[2... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
int n, m; readV(n, m);
writeln((... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TL... | D |
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;
// }}}
// nep.scanner {{{
class Scanner {
import std.stdio : File, stdin;
import std.conv : to;
import std.array : ... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;
void main()
{
immutable int MD... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n, a;
scan(n);
scan(a);
if (n % 500 <= a) {
writeln("Yes");
}
else {
writeln("No");
}
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algo... | D |
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
int DEBUG_LEVEL = 0;
void pr... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
T readNum(T)(){
return readStr.to!T;
}
T[] readNums(T)(){
return readStr.split.to!(T[]);
}
string readStr(){
return readln.chomp;
}
void main(){
auto s = readStr;
auto t = readStr;
if(s == t[0 .. $-1]){
wri... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
void main()
{
auto x = readln.split.map!(to!int);
auto t = x[1] - 1;
auto tp = readln.split.map!(to!int);
int i;
while (i < tp.length) {
if ... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto tmp = readln.split.to!(long[]);
const H = tmp[0], W = tmp[1];
tmp = readln.split.to!(long[]);
const h = tmp[0], w = tmp[1];
writeln(H * W - (h * W + w * H - h * w));
}
| D |
unittest
{
assert( [ "abaababaab" ].parse.expand.solve == 6 );
assert( [ "xxxx" ].parse.expand.solve == 2 );
assert( [ "abcabcabcabc" ].parse.expand.solve == 6 );
assert( [ "akasakaakasakasakaakas" ].parse.expand.solve == 14 );
}
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
std.random, std.typecons, std.container;
ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = (... | D |
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;
void main() {
auto n = readln.split[0].to!ulong;
auto v = readln.split.to!(ulong[]);
ulong[] v_odd, v_even;
iota(1, n, 2).each!(x => v_even ~= v[x]);
iota(0, n, 2).each!(x => v_... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto s = readln.chomp;
auto w = ["Sunny", "Cloudy", "Rainy"];
... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
immutable long MOD = 10^^9 + 7;
long[] F, FI;
void main() {
auto N = readln.chomp.to!int;
auto G = new int[][](N)... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | D |
void main() {
problem();
}
void problem() {
auto X = scan!long;
long solve() {
foreach(t; 1..999_999) {
if (t * X % 360 == 0) return t;
}
return 0;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.numeric, std.conv, std.array, std.string, std... | D |
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import c... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
string s, t, u;
uint a, b;
auto st = readln.chomp.split(" ");
s = st[0];
t = st[1];
auto ab = readln.chomp.split(" ");
a = to!uint(ab[0]);
b = to!uint(ab[1]);
u = readln.chomp;
if (u == s) {
--a;
} else if (u == t) {
--b;
}
writeln... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
void main() {
int[] ary = [1,5,10,50,100,500];
writeln(readln.split.to!(int[]... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto T = readln.chomp;
auto ss = new int[](S.length+1);
foreach (i, c; S) {
ss[i+1] = ss[i];
if (c == 'A') {
ss[i+1] += 1;
} el... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
void main() {
auto N = readln.chomp.to!int;
auto a = ['M': 0, 'A': 1, 'R': 2, 'C': 3, 'H': 4];
auto b = new ulong[](5);
foreach(_; 0..N) {
auto c = readln.chomp[0];
if(c in a) b[a[c]]++;
}
auto A = ... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a,b,c,d;
scan(a, b, c, d);
if (a + b < c + d) {
writeln("Right");
}
else if (a + b > c + d) {
writeln("Left");
}
else {
writeln("Balanced");
}
}
void scan(T... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a,b;
scan(a,b);
writeln(a*b % 2 ? "Odd" : "Even");
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.pri... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto o = readln.chomp;
auto e = readln.chomp;
foreach (i; 0..(o.length + e.length... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
... | D |
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
long count;
void main()
{
readln();
int[] list = readln().split.to!(int[]);
mergeSort(list);
wr... | D |
void main() {
int a = readln.chomp.to!int;
int b = readln.chomp.to!int;
int c = readln.chomp.to!int;
int d = readln.chomp.to!int;
writeln(min(a, b) + min(c, d));
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import... | D |
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;
T diff(T)(const T a, const T b) { return a > b ? a - b : b - a; }
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
T[] readToArray(T)() {
return readln.split.to!(T[]);
}
void main() {
const s = readln;
char prev ... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] AR... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
std.random, std.typecons, std.container;
ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = (... | D |
import std.stdio;
import std.range;
import std.string;
import std.algorithm;
import std.conv;
void main() {
ulong x = readln.chomp.to!ulong;
(x/11*2 + (x%11 <= 6 ? 1 : 2) + (x%11 == 0 ? -1 : 0)).writeln;
} | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.