code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; int n; string s; int[] os; void main(){ n = readln.chomp.to!int; s = readln.chomp; os = s.map!(x => (x == 'o')? 1: 0).array; int[] sheeps; char[] ans = cast(char[...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, m; rd(n, m); auto x=readln.split.to!(long[]); auto y=readln.split.to!(long[]); int cnt=0; for(int i=0, j=0, sx=0, sy=0; i<n; i++){ sx+=x[i]; while(j<m && (sy+=y[j])<sx) j++; if(sy==sx) sx=sy=0, j++, cnt++; else sy-=...
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 S = readln.split[0], T = readln.split[0]; int[26] s_data, t_data; int[26] s_ord, t_ord; int ord = 1; foreach ( c; S ) { if (s_ord[c-'a'] == 0) { s_ord[...
D
/+ dub.sdl: name "F" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; // import dcomp.numeric.prime; // import dcomp.numeric.primitive; import std.numeric; long powmod(long x, long n, long md) { long r = 1; while (...
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; import std.datetime; void main() { auto res = iota(0, 1000001).array; foreach_reverse (i; 0..1000001) { foreach (y; 2..1001) { auto py = y ...
D
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.array; void main() { auto inp = readln().chomp; int max; for(int i; i<=(inp.length-1)/2; i++){ if(inp[0..i]==inp[i..i*2]){max=i*2;} } max.writeln; }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto md1 = readln.split.to!(int[]); auto md2 = readln.split.to!(int[]); writeln(md1[0] == md2[0] ? 0 : 1); }
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional; void main() { auto S = readln.chomp; if(S == "Sunny") { "Cloudy".writeln; } else if (S=="Cloudy") { "Rainy".writeln; } else if(S=="Rainy") { "Sunny".writeln; } }
D
void main() { auto n = ri; n %= 10; switch(n) { case 2, 4, 5, 7, 9: writeln("hon"); break; case 0, 1, 6, 8: writeln("pon"); break; case 3: writeln("bon"); break; default: assert(0); } } // =================================== import std.stdio; import std.stri...
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.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
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 File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(T = long)() ...
D
void solve(){ } void main(){ string s = instr(); writeln( s==s.dup.reverse.to!string?"Yes":"No" ); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range; const long mod = 10^^9+7; alias instr = () => readln().chomp(); T inelm(T= int)(){ return to!(T)( readln().chomp() ); } T[...
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; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.container; import std.datetime; void main() { foreach (line; stdin.byLine) { auto str = line.chomp; if (str == "#") break; int s, cnt; foreach (e; s...
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() { int n...
D
import std.stdio, std.string; void main() { readln.chomp.replace(",", " ").writeln; }
D
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons; T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); } ...
D
import std.stdio, std.string, std.conv; void main() { auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1], C = ip[2], D = ip[3]; if(A+B > C+D){ writeln("Left"); } else if(A+B < C+D){ writeln("Right"); } else { writeln("Balanced"); } }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm; void main() { int a,b; scan(a,b); writeln(a*b % 2 ? "Odd" : "Even"); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(...
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
//dlang template---{{{ import std.stdio; import std.conv; import std.string; import std.array; import std.algorithm; import std.typecons; import std.math; import std.range; // MIT-License https://github.com/kurokoji/nephele class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : ...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); ulong bignu...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; int solve() { auto s = readln.chomp; int i=0, j=(s.length-1).to!int; char x = 'x'; int res = 0; while(i<j) { if(s[i]==x&&s[j]==x) { i++; j--; continue; } if(s[i]==x&&s[j]!=x) { i++; res++; ...
D
import std.stdio; import std.string; import std.conv; import std.range; import std.array; import std.algorithm; void main(){ auto a=readln.chomp.to!int; auto b=readln.chomp.to!int; auto c=readln.chomp.to!int; auto d=readln.chomp.to!int; if(a>=b&&c>=d)writeln(b+d); else if(a>=b&&c<=d)writeln(b+c); else if...
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() { auto d = new int[](4); foreach (i ; 0 .. 3) { ...
D
import std; alias Book = Tuple!(int, "cost", int[], "ss"); int calc(int x, Book[] books) { auto n = books.length; auto m = books[0].ss.length; int ans = int.max; for (int i = 0; i < (1 << n); i++) { int cost = 0; auto ss = new int[m]; for (int j = 0; j < n; j++) { ...
D
// Vicfred // https://atcoder.jp/contests/abc176/tasks/abc176_c // greedy import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; void main() { long n = readln.chomp.to!long; long[] a = readln.split.map!(to!long).array; long last = a[0]; long ans = 0; for(int...
D
void main() { long n = rdElem; string s = rdStr; s.count("ABC").writeln; } 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() { //import std.conv : to; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; long P = 10^^9+7; long[1001] F, RF; long pow(long x, long n) { long y = 1; while (n) { if (n%2 == 1) y = (y * x) % P; x = x^^2 % P; n /= 2; } return y; } long ...
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
module aoj; import std.conv; import std.stdio; import std.string; int getInt() { return to!int(chomp(readln())); } void main() { int n; while ((n = getInt()) != 0) { int sum = 0; foreach (i; 0 .. n/4) { sum += getInt(); } writeln(sum); } }
D
import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container, std.format; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } /* a[i]: i番目を踏むときの最善 漸化式は a...
D
import std.stdio, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int N; scan(N); auto S = readln...
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; alias T = Tuple!(int, int); void main() { immutable n = readln.strip.to!int; long res; int[4] c; foreach (qid; 0 .. n) { auto s = readln.strip; int t1 =...
D
void main() { long n, k; rdVals(n, k); long[] a = rdRow; long[] b = new long[n+1]; long[] p = new long[n+1]; foreach (i, x; a) { b[i+1] = b[i] + x; p[i+1] = p[i] + max(0, x); } long result; foreach (i; k .. n+1) { long diff = b[i] - b[i-k]; l...
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; void main() { int x; scan(x); if (x == 3 || x == 5 || x == 7) { writeln("YES"); } else { writeln("NO"); } } ...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; void main() { string input; int div; while ((input = readln().chomp()).length != 0) { div = input.to!int(); int[] position = iota(600).filter!(a => a % div == 0).array(); ...
D
/* imports all std modules {{{*/ import std.algorithm, std.array, std.ascii, std.base64, std.bigint, std.bitmanip, std.compiler, std.complex, std.concurrency, std.container, std.conv, std.csv, std.datetime, std.demangle, std.encoding, std.exception, std.file, std.format, std.functi...
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; int calc(string s) { ...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; 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 = Tuple!(long, "y", ...
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; // }}} // tbh.scanner {{{ class Scanner { import std.stdio; import std.conv ...
D
import std.stdio; import std.string; import std.conv; import std.range; import std.array; import std.algorithm; import std.typecons; import std.math; int calc(int x,int r){ return x * (r+100) / 100; } void main() { while(true) { string[] cin; cin=split(readln()); int a=to!int(cin[0]),b=to!int(cin[1]),x=to!int...
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; void main() { readln.chomp.count!"a == '2'".writeln; } void scan(T...)(ref T args) { import std.stdio : readln; import std....
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; void solve() { auto s = readln.split.map!(to!long); auto A = s[0]; auto B = s[1]; if (A > B) swap(A, B); long ans = 2 * ...
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; void main(){ ulong ai, ao, at, aj, al, as, az; { ulong[] tmp = readln.chomp.split.map!(to!ulong).array; ai = tmp[0], ao = tmp[1], at = tmp[2], aj = tmp[3], al = tmp[...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto H = readln.split.to!(int[])[0]; foreach (A; readln.split.to!(int[])) H -= A; writeln(H <= 0 ? "Yes" : "No"); }
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.numeric; import std.stdio; import std.string; void main() { string s = readln().chomp; long w = readln().chomp.to!long; for (int i = 0; i < s.length; i += w) { write(s[i]); } 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, 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.algorithm; import std.conv; import std.range; import std.stdio; import std.string; void main () { auto tests = readln.strip.to !(int); foreach (test; 0..tests) { auto n = readln.strip.to !(int); auto s = readln.strip; int cur = 1; foreach (i; 1..n) { cur += (s[i - 1] == s[i]); } writeln ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { auto N = to!int(split(readln())[0]); auto input = split(readln()); auto D = to!int(input[0]), X = to!int(input[1]); int[] A; int n = X; foreach (i; 0..N) { n += (D-1) / ( to!int(split(readln())[0]) ) + 1; } writ...
D
import std.stdio, std.string, std.conv; void main() { writeln((readln.chomp.split.join.to!int % 4) == 0? "YES" : "NO"); }
D
import std.algorithm; import std.array; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return read...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto s = readln.chomp.to!(char[]); auto K = readln.chomp.to!int; foreach (ref c; s) { if (c == 'a') continue; int i = c-'a'; if (K < 26-i) continue; c = 'a'; ...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii; import std.typecons, std.functional; import std.algorithm, std.container; void main() { long N = scanElem; long[] list = scanArray; long res; long m=-1; foreach(e; list) { if(m<=e){ ...
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 abc = readln.split.to!(int[]); auto A = abc[0]; auto B = abc[1]; auto C = abc[2]; auto K = readln.chomp.to!int; int k; while (B <= A) { ...
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; import std.ascii; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; bool ...
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 mod = 10L^^9 + 7; enum inf = 10^^9; void main() { int n; scan(n); string s; scan(s); int q; scan(q); auto k = readln.split.to!(in...
D
import std.stdio; import std.conv; import std.numeric; long f(long n, long c, long d) { return n - (n / c) - (n / d) + (n / (c * d / gcd(c, d))); } void main() { long a, b, c, d; scanf("%ld %ld %ld %ld", &a, &b, &c, &d); write(f(b, c, d) - f(a-1, c, d)); }
D
void main() { long n = readln.chomp.to!long; long[] a = new long[n]; long[][] x = new long[][](n), y = new long[][](n); foreach (i; 0 .. n) { a[i] = readln.chomp.to!long; foreach (j; 0 .. a[i]) { long[] tmp = readln.split.to!(long[]); x[i] ~= tmp[0] - ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nkc = readln.split.to!(int[]); auto N = nkc[0]; auto K = nkc[1]; auto C = nkc[2]; auto S = readln.chomp; foreach (_; 0..N) S ~= 'x'; auto left = new int[](N); int la...
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() { long N; scan(N); foreach(h ; 1 .. 3501) { foreach (n ; 1 .. 3501) { long x = 4L * h * n; long hn = 1L * h * n; /...
D
import std.stdio, std.string, std.algorithm, std.array, std.conv; void main() { auto input = readln.chomp.split.map!(to!int).array; auto a = input[0]; auto b = input[1]; if (a < b) { "a < b".writeln; } else if (a > b) { "a > b".writeln; } else { "a == b".writeln; } }
D
// tested by Hightail - https://github.com/dj3500/hightail import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; import std.datetime, std.bigint; void main() { int n, k; int[] a; scan(n, k); a = readln.split.to!(int[]); ...
D
import std.algorithm, std.string, std.array, std.range, std.stdio, std.conv; void main() { ulong[] NK = readln.chomp.split.to!(ulong[]); ulong N = NK[0], K = NK[1]; writeln(K * (K-1)^^(N-1)); }
D
void main() { (700 + rs.count!(a => a == 'o') * 100).writeln; } // =================================== import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.bigint; import std.numeric; import std.conv; import std.typecons; import ...
D
import std; void main() { int N, M; scan(N, M); auto to1 = new bool[](N); auto toN = new bool[](N); foreach (i; 0 .. M) { int ai, bi; scan(ai, bi); ai--, bi--; if (ai == 0) { to1[bi] = true; } if (bi == N - 1) { toN[ai] = true; } } bool ok; foreach (i; 0 .. N) { ...
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, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int N; scan(N); auto a = readln....
D
void main() { long n = rdElem; long[] a = rdRow; long total; long[long] lists; ++lists[total]; foreach (i; 0 .. n) { total += a[i]; ++lists[total]; } long result; foreach (x; lists.byValue) { result += x * (x - 1) / 2; } result.writeln; } e...
D
import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.conv, std.stdio, std.typecons; void main() { auto n = readln.chomp.to!size_t; auto ai = readln.split; ai.reverse(); writeln(ai.join(" ")); }
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n, k; rd(n, k); auto a = readln.split.to!(long[]); long[] bits; foreach (i; 0 .. n) { long s = 0; foreach (j; i .. n) { s += a[j]; bits ~= s; } } auto good = new bool[](bits.length); fill(good, true); ...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); ulong bignu...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto xab = readln.split.to!(long[]); writeln( xab[1] - xab[2] >= 0 ? "delicious" : xab[1] + xab[0] >= xab[2] ? "safe" : "dangerous" ); }
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.7.4" +/ import std.stdio, std.algorithm, std.range, std.conv, std.math; // import dcomp.foundation, dcomp.scanner; // import dcomp.geo.primitive, dcomp.geo.circle, dcomp.geo.polygon; bool solve() { alias P = Point2D!double; alias L = Line2D!double;...
D
import std.stdio; import std.conv; import std.string; void main(string[] args){ int n = to!int(readln().chomp()); for(int i = 0; i < n; i ++){ string[] cs = readln().chomp().split(" "); // x1 y1 x2 y2 x3 y3 x4 y4 double dx1 = to!double(cs[0]) - to!double(cs[2]); double dx2 = to!double(cs[4]) - to!double(cs[6...
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; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; 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 = Tuple!(long, "y", ...
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 m, k; readV(m, k); if (m ==...
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 a, b, c, d; readV(a, b, c, d);...
D
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; import core.bitop; string my_readln() { return chomp(readln()); } long mod = pow(10, 9) + 7; long moda(long x, long y) { return (x + y) % mod; } long mods(long x, long y) { return ((x + mod) - (y % mo...
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; final class InputReader { private: ubyte[] p, buffer; bool eof; bool rawRead () { if (eof) { return fals...
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 INF = 1L << 59; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[1]...
D
import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; import core.stdc.stdlib; import core.stdc.string; void log(A...)(A arg) { stderr.writeln(arg); } int size(T)(i...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; 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 = Tuple!(long, "y", ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.random, std.array; // const int n=10; // auto rnd=Random(unpredictableSeed); // auto a=new char[](n), b=new char[](n); // foreach(i; 0..n){ // a[i]=(uniform!"[]"(0, 1, rnd)+'0').to!(char); // b[i]=(uniform!"[]"(0, 1, rnd...
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; import std.ascii; void main() { int k; long[] a; scan(k); a = readln.split.to!(long[]); auto u = new long[](k), b = new long[](k); if (a[k-1] ==...
D
import std.stdio ,std.conv , std.string; void main(){ auto input = readLine!size_t(); solve(input[0],input[1]).writeln(); } auto solve( size_t x, size_t y ) { if( x < y ){ return 0; } else { return x-y; } } unittest{ assert(1); } T[] readLine( T )(){ T[] ret; foreach( val ; readln().chomp().split() ){ ...
D
import std.stdio, std.string, std.conv; void main() { int[] a = readln.chomp.split.to!(int[]); writeln((a[0] + a[1] >= a[2]) ? "Yes" : "No"); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; void main() { auto data = readln().split(); auto M = data[1].to!long(), N = data[0].to!long(); long[] A, B; foreach (i; 0 .. M) { data = readln().split(); B ~= data[1].to!long(), A ~= data[0].to!lon...
D
import std; enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;} T scan(T=long)(){return readln.chomp.to!T;} void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;} T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);} alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; void main() { string[] inputs = split(readln()); int x = to!int(inputs[0]); int a = to!int(inputs[1]); int b = to!int(inputs[2]); if(abs(x - a) < abs(x - b)) 'A'.writeln; else 'B'.writeln; }
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.algorithm; import std.array; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return read...
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(); } void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE...
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() { auto A = ri, B = ri; writeln(6-(A+B)); } // =================================== 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 s...
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, std.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; import core.bitop; string RD() { return chomp(readln()); } long mod = pow(10, 9) + 7; long moda(long x, long y) { return (x + y) % mod; } long mods(long x, long y) { return ((x + mod) - (y % mod)) % m...
D
import std.stdio; import std.algorithm; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() {//try{ auto tokens = split(my_readln()); auto N = to!ulong(tokens[0]); ulong big, result; foreach (i; 0..N) { auto p...
D