code
stringlengths
4
1.01M
language
stringclasses
2 values
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a = new char[][](n); foreach (i; 0 .. n) { a[i] = readln.chomp.to!(char[]); } if (a[0][0] == '.' || a[0][n - 1] == '.' || a[n - 1][0] == '.' || a[n - 1][n - 1] == '.') { writeln("NO"); return; } for (i...
D
void main() { int[] tmp = readln.split.to!(int[]); int h = tmp[0], w = tmp[1]; string[] s = new string[h]; foreach (i; 0 .. h) { s[i] = readln.chomp; } foreach (i; 0 .. 2*h) { s[i/2].writeln; } } import std.stdio; import std.string; import std.array; import std.conv; import ...
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; void main() { int N; scan(N); long ans; foreach (i ; 1 .. N + 1) { ...
D
import std.stdio, std.string, std.conv, std.algorithm; void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1]; max(a+b, a-b, a*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.ascii; import std.bigint; import std.complex; import std.container; import std.conv; import std.functional; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; auto readInts() { return array(map!(to!int)(readln().strip().split...
D
import std; void main() { int N; long M; scan(N, M); auto a = readln.split.to!(long[]).map!(x => x % M).array; long[long] cnt; cnt[0] = 1; long rem; long ans; foreach (i; 0 .. N) { rem = (rem + a[i]) % M; if (rem in cnt) ans += cnt[rem]; cnt[rem]++; } writeln(ans); } void ...
D
void main(){ string[] str = readln().chomp().split(); if( str[0] > str[1] )writeln(">"); else if( str[0] < str[1] )writeln("<"); else writeln("="); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 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 h, w; scan(h, w); int a, b; scan(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.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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nr = readln.split.to!(int[]); auto N = nr[0]; auto R = nr[1]; if (N >= 10) { writeln(R); } else { writeln(R + 100 * (10-N)); } }
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); auto dp1 = new...
D
void main() { long h = rdElem; long cnt = 1; long result; while (h) { h >>= 1; result += cnt; cnt <<= 1; } result.writeln; } T rdElem(T = long)() if (!is(T == struct)) { return readln.chomp.to!T; } alias rdStr = rdElem!string; alias rdDchar = rdElem!(dchar[]);...
D
void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], m = tmp[1], x = tmp[2], y = tmp[3]; int[] a = readln.split.to!(int[]); int[] b = readln.split.to!(int[]); a ~= x; b ~= y; writeln(a.reduce!max < b.reduce!min ? "No War" : "War"); } import std.stdio; import std.string; import...
D
import std.stdio; import std.string; import std.conv; void main() { for (int i = 1; ; i++) { int a = to!(int)(chomp(readln())); if (a != 0) { writeln("Case ", i, ": ", a); } else { break; } } }
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; void main() { int n; string s; scan(n); scan(s); auto w = new int[](n + 1); auto b = new int[](n + 1); foreach (i; 1 .. n + 1) { b[i] = b[i-1] + (s[i-1]=='#'); } foreach_reverse (i; 0 .. n) { w[i] = w[i+1] + (s[i]=='.'); } auto ans = 1_000_000_000; foreach (i; 0 .. n + 1) { ...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { int n; scanf("%d\n", &n); int[][] g = new int[][n]; int[] degree = new int[n]; foreach (i; 0..n-1) { int x, y; scanf("%d %d\n", &x, &y); --x; ...
D
void main() { problem(); } void problem() { auto a = scan!long; long solve() { return a == 0 ? 1 : 0; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.type...
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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; alias MP = Tuple!(int, "i", int, "p"); int[11] PS, CS; void main() { auto dg = readln.split.to!(int[]); auto D = dg[0]; auto G = dg[1] / 100; foreach (i; 1..D+1) { auto pc = readln.split.to!(int[]); ...
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.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
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 G = new Tuple!(int, int)[][](N); foreach (i; 0..N-1) { ...
D
/+ dub.sdl: name "D" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; // import dkh.functional; string s; memoCont!calcBase calc; int calcBase(int l, int r, int k) { if (l == r) return 1; if (l > r) return 0; ...
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); auto a = readln.split.to!(int[]); int ans = 100; foreach (ai ; a) { int cnt; while (ai % 2 ==...
D
import std.stdio, std.string, std.array, std.conv; void main() { int n = readln.chomp.to!int; int[] h = readln.split.to!(int[]); bool ok = true; int cnt = 1; foreach (i; 1 .. n) { if (h[i] > h[i-1]) { ++cnt; } else if (h[i] < h[i-1]) { if (h[i-1] - h[i] > cnt...
D
import std.stdio, std.string, std.algorithm, std.range, std.conv; void main() { auto N = readln.chomp.to!int; if(N%2==1) { writeln(N*2); } else { writeln(N); } }
D
import std.stdio, std.string, std.conv; void main() { writeln(readln.chomp.to!int ^^ 3); }
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 a = readln.chomp.split.to!(int[]); if (a[0] <= a[2] && a[1]...
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 main() { int a, b, c; scan(a, b, c); int k; scan(k); int ans = a + b + c + max(a, b, c) * (2^^k - 1); wri...
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.string, std.array, std.conv; struct Dice6 { int[string] dice6; int[] _dice6 = new int[6]; this(int[] _dice6) { dice6["top"] = _dice6[0]; dice6["front"] = _dice6[1]; dice6["right"] = _dice6[2]; dice6["left"] = _dice6[3]; dice6["back"] = _dice6[4...
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.bigint; import std.bitmanip; import std.conv; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; 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!(...
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; readV(a, b); if (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, K; scan(N, K); auto a = r...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; import std.numeric; void main() { int k = readln.chomp.to!int; long sum = 0; for(int i=0; i<k; i++) for(int j=0; j<k; j++) for(int l=0; l<k; l++) { sum += gcd(i+1, gcd(j+1, l+1)); ...
D
import std.stdio; import std.algorithm; import std.math; import std.string; import std.conv; import std.range; void main() { while (true) { int n = readln.chomp.to!int; if (n == 0) break; int[] ice = new int[10]; foreach (i; 0..n) { ice[readln.chomp.to!int]++; }...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; /// [..) struct SegTree(alias _fun, alias def, T) if (is(typeof(def) : T)) { import std.functional : binaryFun; alias fun = binaryFun!_fun; /// this(size_t n, T[] ts) { this.n = 1; wh...
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); //aryread!string(); //auto PS = new Tuple!(long,string)[](M); //x[]=1;でlong[]全要素1に初期化 void main() { long h, w; scan(h, w); auto a = new string[](h); foreach...
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; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; auto W = new int[](N+1); aut...
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.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; void main() { int a, b, c, d; scan(a, b, c, d); foreach (i; 0 .. 1000) {...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { string s = readln.chomp; if(s[0]=='7' || s[1]=='7' || s[2]=='7') writeln("Yes"); else writeln("No"); }
D
import std.stdio, std.conv, std.string; void main() { int N, K; N = readln().chomp().to!(int); K = readln().chomp().to!(int); int res = 1; foreach(int i; 0..N) { if(res + K < res*2) { res += K; } else { res *= 2; } } writeln(res); }
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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.array; int n; long c; rd(n, c); auto x=new long[](n), v=new long[](n); foreach(i; 0..n) rd(x[i], v[i]); // import std.exception; // enforce(n<=100); x=0L~x~c; v=0L~v~0L; long mx=0, inf=2e18.to!(long); mx=max(mx, f...
D
import std.stdio; import std.string; import std.conv; void main() { auto X = readln.split.to!(int[]),A = X[0],B = X[1]; if((A + B) % 2 == 0) { writeln((A + B) / 2); } else { writeln((A + B) / 2 + 1); }}
D
// Vicfred // https://atcoder.jp/contests/abc047/tasks/arc063_a // greedy import std.stdio; import std.string; void main() { string s = readln.strip; long n = s.length; long count = 0; for(long i = 0; i < s.length-1; i++) { if(s[i] != s[i + 1]) count += 1; } count.writeln; }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; scan(n); int ans; int ls, rs; ans = query(0); if (ans == 2) return; ls = ans; ans = query(n-1); if (ans == 2) return; rs = ans; int left = 0, right = n - 1; whil...
D
import std.conv; import std.stdio; import std.string; void main() { auto ab = readln.split.to!( int[] ); writeln( solve( ab[ 0 ], ab[ 1 ] ) ); } auto solve( in int a, in int b ) { return ( a <= 8 && b <= 8 ) ? "Yay!" : ":(" ; } unittest { assert( solve( 5, 4 ) == "Yay!" ); assert( solve( 8, 8 ) == "Yay!" ); a...
D
void main(){ int a, b, x; scanf("%d %d %d", &a, &b, &x); writeln(a+b>=x&&a<=x?"YES":"NO"); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range; const long mod = 10^^9+7; // 1要素のみの入力 T inelm(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] inl...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ab = readln.split.to!(int[]); writeln(ab[0] < 10 && ab[1] < 10 ? ab[0] * ab[1] : -1); }
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 M = readln.chomp.to!int; long r, x = -1; while (M--) { auto dc = readln.split.to!(long[]); auto d = dc[0]; auto c = dc[1]; if (...
D
void main() { long d, n; rdVals(d, n); writeln(n == 100 ? (n + 1) * 100 ^^ d : n * 100 ^^ d); } 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)() ...
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
void main() { // ((A, B) => A > B ? "GREATER" : A < B ? "LESS" : "EQUAL")(BigInt(rs), BigInt(rs)).writeln; auto A = rs, B = rs; if(A.length == B.length) { if(A[0] > B[0]) writeln("GREATER"); else if(A[0] == B[0]) writeln("EQUAL"); else writeln("LESS"); } else { if(A.length > B.length) writeln("GREATER"); ...
D
void main() { import std.stdio; (readln>"2019/05"?"TBD":"Heisei").writeln; }
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!int; if (N == 1) { writeln("Hello World"); } else if (N == 2) { auto A = readln.split[0].to!int; auto B = readln.split[0].to!int; w...
D
void main() { string n = readln.chomp; int total; foreach (d; n) { total += d - '0'; } if (total == 1) total *= 10; total.writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import std.numeric;...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto N = readln.chomp.to!int; auto T = new int[][N]; foreach (_; 1..N) { auto ab = readln.split.to!(int[]); auto a = ab[0]-1; auto b = ab[1]-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; static import std.ascii; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return r...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.container; import std.array; import std.math; import std.range; import std.typecons; import std.ascii; import std.format; void main() { int[101] imos; auto d = readln.chomp.split.map!(to!int); imos[d[0]]++; imos[d[1]]--; i...
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
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nm = readln.split.to!(long[]); auto N = nm[0]; auto M = nm[1]; auto as = readln.split.to!(long[]); auto x = as[0]/2; int k; while (x % 2 == 0) { ++k; x /...
D
import std.stdio, std.ascii; void main() { auto d = stdin.readln.dup; foreach (c; d) { if (c.isLower) c -= 32; else if (c.isUpper) c+= 32; c.write; } }
D
import std.stdio; import std.string, std.conv, std.array, std.algorithm; import std.uni, std.math, std.container; import core.bitop, std.datetime; void main(){ auto s = readln.chomp; auto n = s.length.to!int; if(n == 2){ if(s[0] == s[1]){ writeln(1, " ", 2); return; ...
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); writeln(24 + 24 - n); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { a...
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.conv, std.string, std.range, std.array, std.algorithm; import std.bigint; bool[1000001] p; void main() { int[10002] sum; p[2 .. 1000001] = true; for (int i = 2; i <= 1000000; i++){ if (p[i]){ for (int j = i * 2; j <= 1000000; j += i){ p[j] = false; } } } fo...
D
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math; struct LazySegTree(alias opt, alias opu, alias _add, alias mul, alias E, alias F, T, U) if (is(typeof(E) : T)) { import std.functional : binaryFun; alias OPT = binaryFun!opt; alias OPU = binaryFun!opu; ...
D
import std.stdio; import std.array; import std.conv; import std.algorithm; void main() { while ( true ) { string[] line = split( readln() ); int n = to!int( line[ 0 ] ); int q = to!int( line[ 1 ] ); if ( n == 0 && q == 0 ) break; int[ 101 ] date; foreach ( i; 0 .. n ) { line = split( readln() ); int m = ...
D
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons; const dx = [1,0,-1,0]; const dy = [0,1,0,-1]; void read(T...)(auto ref T args){ auto line = readln().split(); foreach(i,ref arg; args) arg = line[i].to!(typeof(arg)); } int sum(int n){return n * (n + 1)/ 2;} void ma...
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
void main() { long n = readln.chomp.to!int; long mod = 10 ^^ 9 + 7; long power = 1; foreach (i; 1 .. n+1) { power = power * i % mod; } power.writeln; } 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto Q = readln.split.to!(long[]); auto N = readln.chomp.to!long * 100; long[] A = [25, 50, 100, 200]; long r = long.max; auto ss = [0,1,2,3]; do { auto a = ss[0]; ...
D
import std.stdio; import std.array; import std.conv; import std.math; import std.algorithm; void main() { string[] input = split(readln()); int w = to!int(input[0]), h = to!int(input[1]), n = to!int(input[2]), ans = 0; input = split(readln()); int x = to!int(input[0]), y = to!int(input[1]); for(auto i = 0...
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.array; immutable long MD = 10^^9 + 7; int main() { auto sc = new Scanner(stdin); int q; sc.read(q); long[2][] base = [...
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() { readln; auto a = readln.chomp.split.to!(int[]); int[int] cnt; int sum; foreac...
D
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons, std.typetuple; import core.bitop, std.datetime; immutable long mod = 10^^9 + 7; immutable int inf = mod; void main(){ int N, W; readVars(N, W); auto v = new int[](N); au...
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 n = readln.chomp.to!int; foreach (i; 1..8) { auto p = 2 ^^ i; if (p > ...
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.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() { int n = readint; for (int i = ...
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 n = readln.chomp.to!int; auto w = readln.chomp.split.to!(int[]); int s1, s2;...
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() { int n = readln.chomp.to!int; int[] p = readln.chomp.split.map!(to!int).ar...
D
import std.stdio; import std.array; import std.algorithm; import std.string; import std.conv; import std.format; long[][] map; long n; long hai(int i, int j) { long a = 0; if (j < n-1) { a = max(a, hai(i, j+1) + map[i][j]); } if (i == 0) { a = max(a, hai(i+1, j)+map[i][j]); } return a; } void main() { n =...
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); //aryread!string(); //auto PS = new Tuple!(long,string)[](M); //x[]=1;でlong[]全要素1に初期化 void main() { long n, m; scan(n, m); writeln((n - 1) * (m - 1)); } void ...
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
/+ dub.sdl: name "F" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv, std.typecons; // import dkh.foundation, dkh.scanner, dkh.container.pairingheap; alias P = Tuple!(long, "d", int, "p"); alias Q = PairingHeap!(P, "a.d>b.d"); int main() { Scanner sc = ne...
D
import std.stdio, std.range, std.algorithm, std.conv, std.string, std.math, std.typecons; void main() { auto N = readln.chomp.to!int; foreach (i; 0..N) { auto a = readln.split.to!(int[]).map!(a => a * a).array; writeln((a[0] + a[1] == a[2] || a[1] + a[2] == a[0] || a[2] + a[0] == a[1]) ? "Y...
D
import std.stdio; import std.conv; import std.string; import std.array; void main() { ulong D = 1000000007; string S = readln.chomp; ulong[] b_mod = new ulong[13]; b_mod[0] = 1; ulong[] c_mod; foreach (char c; S){ c_mod = new ulong[13]; for (int i = 0; i < 13; i++){ ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; import std.conv; void main() { auto n = (readln.chomp.to!int % 500); auto A = readln.chomp.to!int; if(n > A) "No".writeln; else "Yes".writeln; }
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
unittest { assert( [ "6", "ooxoox" ].parse.expand.solve == "SSSWWS" ); assert( [ "3", "oox" ].parse.expand.solve == "-1" ); assert( [ "10", "oxooxoxoox" ].parse.expand.solve == "SSWWSSSWWS" ); } import std.conv; import std.range; import std.stdio; import std.typecons; void main() { stdin.byLineCopy.parse.expand...
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
// 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
/+ dub.sdl: name "B" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner, dcomp.array; import std.container.rbtree; // import dcomp.algorithm; int main() { auto sc = new Scanner(stdin); int n; int[] a; sc.read(...
D