code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.conv; import std.stdio; import std.string; void main(){ int N = readln.chomp.to!int; writeln(factorial(N)); } long factorial(long N){ if(N == 1) return 1; else return N * factorial(N-1); }
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; 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 x = readln.chomp.to!int; auto a = readln.chomp.to!int; auto b = readln.chomp...
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; immutable long MOD = 10^^9 + 7; void main() { auto N = readln.chomp.to!int; auto dp = new long[][](N+1, 2); dp[0...
D
import std.conv, std.stdio, std.algorithm, std.string, std.range, std.math; void main() { const input = readln.split.map!(to!int).array; max(input[0]-input[1]*2, 0).writeln; }
D
import std.stdio, std.string, std.array, std.conv; void main () { int[] tmp = readln.chomp.split.to!(int[]); int n = tmp[0], m = tmp[1]; int[][] a = new int[][](n, m); foreach (i; 0 .. n) { int[] row = readln.chomp.split.to!(int[]); foreach (j; 0 .. m) { a[i][j] = row[j]; ...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; long n, m; rd(n, m); import std.math : sqrt; for (long k = m; k >= 1; k--) { if (m >= k * n && (m - k * n) % k == 0) { writeln(k); return; } } import std.exception : enforce; enforce(false); } void rd(T...)(ref...
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; string t = readln.chomp; for (long diff = 0; diff < s.length; ++diff) { char[] n; n.length = s.length; for (l...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd1 = readln.split.to!(long[]), n = rd1[0], ws = rd1[1]; auto w = new long[](n), v = new long[](n); foreach (i; 0..n) { auto rd2 = readln.split.to!(long[]), wi = rd2[0], vi = rd2[1]; w[i] = wi; v[i] = vi; } auto ...
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() { foreach(int i;1..10) foreach(int j; 1..10) { writeln(i, "x"...
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; immutable int letters = 26; string solve (string s) { int [letters] d; foreach (ref c; s) { d[c - 'a'] += 1; } foreach (let; 0..letters) { if (d[let] == 1) { string res; res ~= cast (char) (let + 'a'); ...
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, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp.to!int; auto BS = readln.split.to!(int[]); int r; foreach (i; 0..N) { if (i == 0) { r += BS[i]; } else if (i == N-1) { r +=...
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; void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primiti...
D
import std.stdio; import core.stdc.stdio; void main() { uint n, r = 1; scanf(`%u`, &n); uint l = 3; foreach(i; 0..n) { uint k; scanf(`%u`, &k); uint a = k / 10; uint b = k % 10; if(l == a) r++; l = b; } write(r); }
D
import std.stdio, std.array, std.conv, std.typecons, std.algorithm; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } void main() { immutable i = readln.split.to!(ulong[]); immutable R = i[0], G = i[1], B = i[2], N = i[3]; ulong cnt = 0; for(ulong r = 0; r <= N / R; r++) { ...
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, 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; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; foreach (i; 0..N-1) { if (S[i] > ...
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
module _; void main() { import std.stdio, std.conv, std.string; int n =readln.strip.to!int; int[char] cnt; foreach(i; 0..n) { cnt[readln[0]]++; } int ans = 0; foreach(k; cnt.byKey) { ans += cnt[k]*(cnt[k]-1)/2; int half = cnt[k]/2; ans -= half * (cnt[k]-half); } writeln(ans); }
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; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; auto ans = new long[](...
D
import std.algorithm; import std.conv; import std.math; import std.numeric; 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 a = readln.splitter.map !(to !(long)).array; long [] b; for...
D
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; stri...
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 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 r = readln.chomp.to!int; writeln(r * r); }
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.7.3" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; int main() { Scanner sc = new Scanner(stdin); string s; sc.read(s); if (s.count("AC")) { writeln("Yes"); } else { w...
D
void main() { long n = rdElem; long limit = 55555; auto sieve = new Prime(limit); long cnt; foreach (i; 1.iota(limit+1).stride(5)) { if (sieve.isPrime(i)) { i.write; ++cnt; if (cnt >= n) { writeln; b...
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; } bool isPrime(int n) { if (n < 2) return ...
D
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range; pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); } alias reads = Reads!int; pragma(inline, true) void scan(Args...)(ref Args args) { string[] ss = readln.split; foreach (i, ref arg ; args) ar...
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(); alias Point...
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; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; void main(){ int n; long x; { long[] tmp = readln.chomp.split.map!(to!long).array; n = cast(int) tmp[0]; x = tmp[1]; } long[] as = readln.chomp.split.map!(to!lon...
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 a = readln.chomp.to!int; auto b = readln.chomp.to!int; auto c = readln.chomp...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random; import std.typecons, std.functional, std.traits,std.concurrency; import std.algorithm, std.container; import core.bitop, core.time, core.memory; import std.bitmanip; import std.regex; enum INF = long....
D
void main() { long n, r; rdVals(n, r); writeln(n >= 10 ? r : r + 100 * (10 - n)); } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdElem(T = long)() if (!is(T == struct)) { return readln.chomp.to!T; } alias rdStr = rdElem!string; alias rdDchar = rdElem!(dchar[]); T rdElem(T)() if (is(T == ...
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 a, b, c; scan(a, b, c); int ans = ma...
D
import std.algorithm; void main() { import std.stdio, std.conv, std.string; readln.chomp.to!int.solve.writeln; } int solve(int x) { auto result = int.max; foreach (i; 0..x+1) result = min(result, simulate(x, i)); return result; } int simulate(int x, int i) { return i.withdraw(6) + (x ...
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; static import std.ascii; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return r...
D
void main() { problem(); } void problem() { auto N = scan.map!(x => x - '0').array; bool solve() { ulong sumDecimal; foreach(n; N) sumDecimal += n; return sumDecimal % 9 == 0; } writeln(solve() ? "Yes" : "No"); } // ---------------------------------------------- import std.stdio, std.conv, s...
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!long; char[] res; while (N) { auto n = N % 26; if (n == 0) { n = 25; N -= 1; } else { n -= 1; } ...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { if(readln.chomp=="ABC") writeln("ARC"); else writeln("ABC"); }
D
import std.algorithm, std.array, std.container, std.range; import std.string, std.uni, std.regex; import std.stdio, std.conv, std.typecons; void main() { for (;;) { auto s = readln.chomp; if (s == "-") break; auto m = readln.chomp.to!size_t; auto hi = iota(m).map!(_ => readln.chomp.to!int); for...
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; 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.stdio, std.algorithm, std.range, std.conv, std.string; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { int n; scanf("%d", &n); int[] x = new int[n*2]; int[] c = new int[n*2]; foreach (color; 0..2) { foreach (i; 0..n) { int a, b; scanf("%d%d", &a, &b); x[b] = a; c[b...
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; void main() { while (1) { auto n = readln.chomp.to!int; if (!n) break; auto f = new bool[][](n, n); auto a...
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() { int n; scan(n); foreach (i ; 0 .. n) { string s; scan(s); solve(s); } } void solve(string s) { auto a = [".,!?...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; import std.range : iota; int h, w; rd(h, w); const int n = 10; auto c = new int[][](n, n); iota(0, n).each!((i) => (c[i] = readln.split.to!(int[]))); foreach (_; 0 .. n) foreach (i; 0 .. n) foreach (j; 0 .. n) c[i][j...
D
import std.stdio; import std.conv; import std.string; void main() { int n = readln.chomp.to!int; if (n % 2) (n/2 +1).writeln; else (n/2).writeln; }
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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void main() { int N = readln.chomp.to!int; long[] xs, ys; foreach (_; 0..N) { auto xy = readln.split.to!(long[]); xs ~= xy[0]; ys ~= xy[1]; } long...
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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ...
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; long m, b; void main() { scan(m, b); long ans = -1; foreach (long a ; 0L .. m * b + 1) { long ya = (m*...
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; auto S = readln.chomp; auto es = new int[](N); auto ws = new int[](N); foreach (i; 0..N) { if (i > 0) ws[i] += ws[i-1]; if (S[i] == 'W')...
D
import std.stdio; import std.array; import std.conv; int gcd(int x, int y) { if(x < y) { int t = x; x = y; y = t; } if(y == 0) { return x; } return gcd(y, x % y); } void main() { int a, b; while(true) { string[] input = split(readln()); if(in...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ns = readln.split; foreach (a; ns) { foreach (b; ns) { foreach (c; ns) { foreach (d; ns) { if (a~b~c~d == "1974") { ...
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 S = readln.chomp; auto T = readln.chomp; int r = 1000; foreach (i; 0..S.length - T.length + 1) { int rr; foreach (j, t; T) if (S[i+j] != t)...
D
void main() { problem(); } void problem() { auto a = scan!long; string solve() { return a >= 30 ? "Yes" : "No"; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math...
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; import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.format; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; void main() { foreach (i, c; readln.chomp) { if (i % 2 == 1) { continue; } ...
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.algorithm; import std.conv; import std.exception; import std.stdio; import std.string; import std.typecons; struct Queue(T){ T[900] content; size_t head; size_t tail; T front(){ enforce(head != tail); return content[head]; } void popFront(){ enforce(head !=...
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; ulong MOD = 1_000_000_007; ulong INF = 1_000_00...
D
unittest { assert( [ "rng gorilla apple" ].parse.expand.solve == "YES" ); assert( [ "yakiniku unagi sushi" ].parse.expand.solve == "NO" ); assert( [ "a a a" ].parse.expand.solve == "YES" ); assert( [ "aaaaaaaaab aaaaaaaaaa aaaaaaaaab" ].parse.expand.solve == "NO" ); } import std.conv; import std.range; import st...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { writeln(readln.chomp.to!int / 3); }
D
import std.algorithm; import std.array; import std.conv; import std.stdio; void main() { string n; n = readln; if ( n[0..1] == "7" || n[1..2] == "7" || n[2..3] == "7" ) { writeln("Yes"); } else { writeln("No"); } }
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(){ string s = readln.chomp; int n = s.length.to!int; int ans = 0; foreach(i; 0 .. n){ if(i % 2){ // 自分はp if(s[i] == 'p') ans += 0; // pp else ans += ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd1 = readln.split, w = rd1[0].to!int, h = rd1[1].to!int, n = rd1[2].to!size_t; auto x1 = 0, x2 = w, y1 = 0, y2 = h; foreach (_; 0..n) { auto rd2 = readln.split.to!(int[]), x = rd2[0], y = rd2[1], a = rd2[2]; switch (a)...
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; immutable long mod = 10^^9 + 7; int n; int[] t, a; void main() { scan(n); t = readl...
D
import std.stdio; import std.algorithm; import std.string; import std.functional; import std.array; import std.conv; import std.math; import std.typecons; import std.regex; import std.range; void main(){ string n = readln(); while(true){ char[5][8] s; for(int i=0;i<5;i++){ s[0][i] = '*'; s[1][i] =...
D
void main() { long n = readln.chomp.to!long; long[] a = readln.split.to!(long[]); writeln(a.count!"a % 2 == 1" % 2 == 0 ? "YES" : "NO"); } 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.contain...
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 s = readln.split.map!(to!long); auto A = s[0]; auto B = s[1]; auto C = s[2]; auto X = s...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); int sum=0; for(int div=1; n/div>0; div*=10){ sum+=(n/div)%10; } assert(sum>0); if(n%sum==0) writeln("Yes"); else writeln("No"); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.spli...
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.string, std.array, std.conv; void main() { int[] tmp = readln.chomp.split.to!(int[]); int a = tmp[0] - 1, b = tmp[1] - 1; writeln((a + b - 1) / a); }
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.splitter.map !(to !(int)).array; s ~= 0; long res = 0; auto p = iota (n + 1).array; ...
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.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random; import std.typecons, std.functional, std.traits,std.concurrency; import std.algorithm, std.container; import core.bitop, core.time, core.memory; import std.bitmanip; import std.regex; enum INF = long....
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; immutable long MOD = 10^^9 + 7; long[] F; long[] G; void main() { auto N = readln.chomp.to!int; auto A = readln.split...
D
void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1], x = tmp[2]; writeln(a <= x && x <= a + b ? "YES" : "NO"); } 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.containe...
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; int[] e; e.length = N+1; foreach (i; 2..N+1) { auto cur = i; foreach (j; 2..i+1) { while (cur % j == 0) { ++e[j...
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, std.datetime; bool is_p(string s) { int n = s.length.to!int; foreach (i; 0..n/2) if (s[i] != s[n-i-1]) return false; ...
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 std.conv; import std.stdio; import std.string; void main() { auto nk = readln.split.to!( int[] ); auto as = readln.split.to!( int[] ); writeln( solve( nk[ 1 ], as ) ); } auto solve( in int k, in int[] as ) { auto as_r = as.length - k; auto k_r = k - 1; auto c = 1 + as_r / k_r; auto re = ( as_r % k_r == ...
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.stdio; import std.stdio; import std.algorithm; import std.range; import std.functional; import std.conv; import std.string; import std.math; import core.bitop; void main() { int tt = readln().chomp.to!int; foreach (t; 0 .. tt) { auto arr = readln().chomp.split(" ").map!(to!ulong); ulong a = arr[0]; ...
D
import std.stdio; import std.string; import std.conv; import std.math; int main() { double x=0.0,y=0.0,angle=90; while(true) { string[] s = readln.chomp.split(","); if(s[0] == "0" && s[1] == "0") break; int value = s[0].to!int; int value_2 = s[1].to!int; x += cos(angle*PI/180)*value; y += sin(angle*P...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { long N; scan(N); long ans = in...
D
void main() { problem(); } void problem() { auto X = scan!long; long solve() { return 8 - (X - 400) / 200; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std...
D
import std.stdio; void main() { int x; scanf("%d", &x); if ((x % 100 + 4) / 5 <= x / 100) { 1.write; } else { 0.write; } }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { while(true) { auto NM = readln().split(); int N = to!int(NM[0]); int M = to!int(NM[1]); if(N == 0) break; const int INF = 200*1000*1000*2; int[200][200] ldist; int[200][200] sdist; for(int i; i < N; ++i){ f...
D
import std.stdio, std.array, std.conv, std.string, std.algorithm; void main(){ int kane = 100000; string s; for(;;){ s=readln(); if(stdin.eof()) break; int weeks = to!int(chomp(s)); for(int i = 0;i < weeks; ++i){ kane = kane + cast(int)(kane/100)*5; if(kane > cast(int)...
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
void main() { long n, m; rdVals(n, m); long[] tree = new long[n]; foreach (i; 0 .. m) { long a, b; rdVals(a, b); --a, --b; ++tree[a], ++tree[b]; } writeln(tree.all!"a % 2 == 0" ? "YES" : "NO"); } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdEle...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; long P = 10^^9+7; long[10^^5+50] 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; } ret...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int x; rd(x); auto ushi="ai1333".to!(char[]); while(x){ ushi~='3'; x-=100; } writeln(ushi); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, r...
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(int n, int s) ...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; long n, m; rd(n, m); auto s = readln.chomp.to!(char[]); auto t = readln.chomp.to!(char[]); import std.numeric : gcd; auto l = n * m / gcd(n, m); char[long] ch; foreach (i; 0 .. n) { auto j = i * (l / n); ch[j] = s[i]; } ...
D
import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range; void main() { int n; while((n=readln.strip.to!int)!=0){ char[char] con; foreach(i; 0..n){ auto r = readln.strip.split(' '); con[r[0][0...
D
import std.algorithm, std.stdio, std.string; void main() { auto s = readln.chomp; (cast(ubyte[])s).sort; writeln(s == "abc" ? "Yes" : "No"); }
D