code
stringlengths
4
1.01M
language
stringclasses
2 values
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 main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1]; auto edges = new int[][](N); Tuple!(int,...
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 route...
D
void main() { long[] tmp = readln.split.to!(long[]); long n = tmp[0], x = tmp[1]; long[] a = readln.split.to!(long[]); long cnt; foreach (i; 1 .. n) { long diff = a[i] + a[i-1] - x; if (diff > 0) { a[i] = max(0, a[i]-diff); cnt += diff; } ...
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; long[100][8] DP; long P = 1_000_000_007; void main() { foreach (ref h; DP) foreach (ref e; h) e = -1; auto hwk = readln.split.to!(int[]); auto H = hwk[0]; auto W = hwk[1]; auto K = hwk[2]; ...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { int n; scanf("%d", &n); int[] v = new int[n]; foreach (i; 0..n) { scanf("%d", &v[i]); } int ans = 0; int memkey = -1; int memdif...
D
import std.stdio, std.string, std.array, std.conv; void main() { int[] tmp = readln.chomp.split.to!(int[]); int a = tmp[0], b = tmp[1], c = tmp[2]; int cnt = 0; foreach (i; a .. b+1) { if (c % i == 0) ++cnt; } cnt.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, std.bitmanip; const long MOD = 10^^9 + 7; void main() { auto N = readln.chomp.to!int; auto A = 2.iota.map!(_ => readln.split.map!(t...
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.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, std.datetime; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generat...
D
void main() { long x = readln.chomp.to!long; long result = x / 11 * 2; long r = x % 11; if (r > 0) ++result; if (r > 6) ++result; result.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
void main() { dchar[] s = readln.chomp.to!(dchar[]); dchar[] t = readln.chomp.to!(dchar[]); long last = t.length - 1; bool ok; foreach_reverse (i, x; s) { if (x == t[last] || x == '?') { bool check = true; if (i.to!long - last >= 0) { ...
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.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; alias Key = Tuple!(int, "cost", int, "mask"); int calc(int num, Key[] keys) { int n = cast(int)keys.length; auto dp = ...
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 s = readln.chomp; if (s.length < 4) writeln("No"); else if (s[0..4] != "YAKI...
D
void main() { long n = rdElem; dchar[] s = rdDchar; s.uniq.array.length.writeln; } 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 == s...
D
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional; void main(){ auto nk=readln().split.array; auto n=nk[0].to!int; string[] ds=readln().split.array; bool isSafe(int cur){ string str=cur.t...
D
import std.stdio, std.string, std.conv; void main() { while(true) { auto line = readln; if(!line)break; auto f = line.chomp.to!real; f.classify.writeln; } } string classify(real w) { if(w <= 48) return "light fly"; if(w <= 51) return "fly"; if(w <= 54) return "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; import std.bigint; void main() { auto n = readln.chomp.to!int; auto k = readln.chomp.to!int; auto x = readln.chomp...
D
void main() { auto N = ri, A = ri; writeln(N*N-A); } // =================================== import std.stdio; import std.string; import std.functional; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.container; import std.bigint; import std.numeric; import std...
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() { while (1) { auto x = readln.chomp.split.map!(to!int); if (x[0] == -1) break; (Date(x[3], x[4], x[5]) - Da...
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 m = n; int cnt; int k = 1; while (n) { ...
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; void main() { for(int t=1; ; ++t) { immutable W = readln().chomp().to!int(); if(!W) break; auto dp = new int[W+1]; foreach(_;0..readln().chomp().to!int()) { auto m = readln()....
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; import std.math; void main() { foreach(_;0..readln().chomp().to!int()) { auto m = readln().split().map!(to!real); immutable xa=m[0], ya=m[1], ra=m[2], xb=m[3], yb=m[4], rb=m[5]; immutable d = hypot(xa-xb...
D
import std.stdio; import std.ascii; import std.string; import std.range; import std.algorithm; import core.stdc.stdio; int main() { int k = readInt!int; char[] s = readString.dup.reverse; int n = cast(int)s.length; int q = readInt!int; long[] pos = new long[](n + 1); void calculate(int v) ...
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; import std.typecons; import std.bigint; // import dcomp.foundation, dcomp.scanner; // import dcomp.container.deque; int main() { auto sc = new Scanner(stdin); int n, m, k; sc.read(...
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.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens....
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.split.to!(int[]); auto x = a[0] + a[1]; auto y = a[0] * a[1...
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.stdio, std.bitmanip; bool ok(ref long[] A, ref long[] B, long n) { long s = n * (n+1) / 2; if (A.sum % s != 0) re...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto xy = readln.split.to!(long[]); auto X = xy[0]; auto Y = xy[1]; writeln(abs(X - Y) <= 1 ? "Brown" : "Alice"); }
D
import std.stdio; import std.string; void main(){ string a,s=readln.chomp; for(int i=0;i<s.length;++i){ if('a'<=s[i]&&s[i]<='z')a~=s[i]-'a'+'A'; else if('A'<=s[i]&&s[i]<='Z')a~=s[i]-'A'+'a'; else a~=s[i]; } writeln(a); }
D
import std.stdio; import std.algorithm; import std.range; import std.array; import std.string; import std.conv; void main(){ auto n = readln.chomp.to!long; writeln(get_lucas(n)); } long get_lucas(long n, long pre = 2, long after = 1){ if(n == 1){ return after; }else if(n == 0){ return 2; }else{ return get_...
D
// Try Codeforces // author: Leonardone @ NEETSDKASU import std.stdio : readln, writeln; import std.string : chomp; import std.array : split; import std.conv : to; import std.algorithm : sum; auto gets() { return readln.chomp; } auto getNum(T)() { return gets.to!T; } auto getVals(T)() { return gets.spl...
D
import std; void main() { int t; scanf("%d", &t); getchar(); foreach(_; 0..t) { int k; scanf("%d\n", &k); int[] s = readln.strip.split.to!(int[]); auto end = countUntil(retro(s), 0); auto start = countUntil(s, 0); if (start == -1) 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.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.datetime; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto L = s[1].to!long; auto C = readln.split....
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.conv; import std.range; import std.stdio; import std.string; import std.utf; void main () { auto tests = readln.strip.to !(int); foreach (test; 0..tests) { auto n = readln.strip.to !(int); auto s = readln.strip; alias mirror = len => s[0..len] ~ s[0..len].byChar.retro.array; ...
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.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.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!int); auto N = s[0]; auto K = s[1]; auto S = readln.chomp; au...
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 a = readln.splitter.map !(to !(int)).array; long res = 0; foreach (i; 1..n) { res += max (0,...
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.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.string, std.conv, std.algorithm; import std.range, std.array, std.container, std.math; immutable int mod = 10^^9 + 7; long n, s; void main() { readVariables(n, s); long top, btm, mid; if (n - dsum(n) < s) { writeln(0); return; } top = n; while (top - ...
D
import std.conv, std.stdio; import std.string; void main() { auto n = readln.chomp.to!int; long s; foreach (i; 1..n+1) if (i % 3 && i % 5) s += i; s.writeln; }
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, m, k; rd(n, m, k); foreach(i; 0..n+1)foreach(j; 0..m+1){ int s=0; s+=i*m; s-=j*i; s+=j*(n-i); if(s==k){writeln("Yes"); return;} } writeln("No"); } void rd(T...)(ref T x){ import std.stdio, std.string, std.co...
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; // }}} // tbh.scanner {{{ class Scanner { import std.stdio; import std.conv : to; import std.ar...
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 readC(T...)(size_t n,ref T t){foreach(ref v;t)...
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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { foreach (i, x; readln.split.to!(int[])) if (x == 0) { writeln(i+1); return; } }
D
import std.functional, std.algorithm, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; void main() { string[] XY = readln.chomp.split.to!(string[]); string X = XY[0], Y = XY[1]; if (X < Y) { writeln("<"); } else...
D
void main() { auto N = readln.chomp.to!int; dchar last; string[] m; foreach(i; 0..N) { auto S = readln.chomp; if(i==0) { m ~= S; last = S.back; continue; } if(last == S[0]) { last = S.back; } else { writeln("No"); return; } foreach(j; m) { if(S == j) { writeln("No"); retur...
D
// url: http://tenka1-2017-beginner.contest.atcoder.jp/tasks/tenka1_2017_a import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto s = readln.chomp; writeln(s.count('1')); }
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; void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return 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
import std.algorithm; import std.array; import std.conv; import std.math; 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 readln.chomp.to!T; } T[] reads(T)() { return r...
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 g = new int[][](n); foreach (i; 0..n) { auto s = readln....
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; scan(n); if (!n) return; auto a = readln.split; if (n&1) { n--; ...
D
void main() { problem(); } void problem() { auto N = scan!long, M = scan!long; long solve() { long answer; if (N > 0) answer += N*(N-1)/2; if (M > 0) answer += M*(M-1)/2; return answer; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std....
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto S = readln.chomp; int x = 0; int cnt = 0; while (x+1 < S.length) { if (S[x] == S[x+1]) { x++; } else { S = S[0..x] ~ S[x+2..$]; cn...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto dg = readln.split.to!(long[]); auto D = dg[0]; auto G = dg[1]; long[] ps, cs; foreach (_; 0..D) { auto pc = readln.split.to!(long[]); ps ~= pc[0]; cs ~= ...
D
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric; void main(){ auto nt=readln.split.map!(to!long).array; auto ts=readln.split.map!(to!long).array; auto T=nt[1]; long l...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { writeln("Christmas", " Eve".repeat(25 - readln.chomp.to!int).join); }
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; immutable int steps = 10; int solve (string s, int team) { int [2] goals; foreach (step; 0..steps) { auto cur = (s[step] == '0') ? 0 : (s[step] == '1') ? 1 : (step % 2 == team); goals[step % 2] += cur; if (goa...
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 n = readln.chomp.to!int; auto h = readln.chomp.split.to!(i...
D
import std.conv; import std.stdio; import std.string; void main() { auto n = readln.chomp.to!int; (n%2==0 ? n : 2*n).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; import std.string; import std.conv; import std.math; void main() { auto num = readln().chomp().to!int(); writeln(pow(num, 3)); }
D
import std.stdio, std.conv, std.string; void main() { int a,b,c; scanf("%d %d %d", &a, &b, &c); if (a <= c && c <= b) { writeln("Yes"); } else { writeln("No"); } }
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.string; import std.conv; int count(int n) { int ans = 0; for(int a = 0; a < 10; a++) for(int b = 0; b < 10; b++) for(int c = 0; c < 10; c++) for(int d = 0; d < 10; d++) if(a + b + c + d == n) ans++; return ans; } void main() { int[] data; while(true) ...
D
import std.stdio,std.string,std.conv; void main(){ for(;;){ auto rc = readln().chomp(); if( rc == "0" ){ break; } int sum=0; foreach( c ; rc ){ sum += c-'0'; } writeln(sum); } }
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; bool solve (int n, int [] a) { n = min (n, 30); a = a[0..n]; remove_loop: while (!a.empty) { foreach_reverse (i; 0..n) { if (a[i] % (i + 2) != 0) { a = a[0..i] ~ a[i + 1..$]; n -= 1; continue remove_...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { const int MOD = 1_000_000_007; int n; scanf("%d", &n); int[] cb = new int[n+1]; cb[0] = 1; foreach (i; 2..n+1) { if (i&1) continue...
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; 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.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
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 m = n; int cnt; foreach_reverse(i; 0..10) { ...
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; int[char] cnt; foreach (e; s) { cnt[...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(int[]), h = rd[0], w = rd[1]; auto n = readln.chomp.to!size_t; auto a = readln.split.to!(int[]); auto k = 0; foreach (i; 0..h) { auto r = new int[](w), j = 0; for (;;) { auto m = min(a[k]...
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.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; bool check(string s) { if (s.length % 2) { return false; } while...
D
import std; int calc(int k) { int sum = 0; foreach (a; 1..k+1) { foreach (b; 1..k+1) { foreach (c; 1..k+1) { sum += gcd(a, gcd(b, c)); } } } return sum; } void main() { int k; scan(k); writeln(calc(k)); } void scan(T...)(ref T a) { s...
D
import std.stdio; import std.string; import std.conv; import std.math; import std.algorithm; void main(){ auto S = readln.split.to!(int[]); auto A = S[0]; auto B = S[1]; if(A+B>=10) writeln("error"); else writeln (A+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; 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 calc(int n) { ...
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; struct S{ long x=long.min; long[] pair; long[] cost; } S[] sList; bool resolve(S s){ if(s.x==long.min) { s.x=0; } ...
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
void main() { writeln(readln.chomp.to!int / 3); } 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; import std.typecons; import std.ascii; import std.uni;
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { long n, m; scan(n, m); auto ab = new long[][](n, 2); auto cd = new long[][](m, 2); // writeln(ab); // writeln(cd); auto ans = new...
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; immutable long MOD = 10^^9 + 7; void main() { auto N = readln.chomp.to!int; auto G = new int[][](N); foreach (i; 0..N-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 std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; immutable mod = 10^^9 + 7; immutable inf = 2 * 10^^9; void main() { int n, k; scan(n, k); auto x = new int[](n), y = new int[](n); foreach (i ; 0 .. n) {scan(x[i], y...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; void main(){ auto F=readln.split.to!(int[]),a=F[0],b=F[1]; if((a+b)%2==0)writeln((a+b)/2); else writeln((a+b)/2+1); }
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; char calc(string s, lon...
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() { string s; scan(s); writeln(s.count('+').to!int - s.count('-').to!int); } void scan(T...)(ref T a...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int x, y, z; rd(x, y, z); writeln((x - z) / (y + z)); } void rd(T...)(ref T x) { import std.stdio : readln; import std.string : split; import std.conv : to; auto l = readln.split; assert(l.length == x.length); foreach (i, ref e;...
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.algorithm; import std.array; import std.range; import std.math; void main(){ auto z=readln.split.to!(int[]),a=z[0],b=z[1]; if(a<=8&&b<=8)writeln("Yay!"); else writeln(":("); }
D