code
stringlengths
4
1.01M
language
stringclasses
2 values
void main() { import std.stdio, std.string, std.conv, std.algorithm; int a; rd(a); int digit_sum(int x) { int ret = 0; while (x) { ret += x % 10; x /= 10; } return ret; } for (int n = a;; n++) { if (digit_sum(n) % 4 == 0) { writeln(n); break; } } } void...
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 rd = readln.split.map!(to!int); auto a = rd[0], b = rd[1]; writeln(a * b, " ", (a + b) * 2); }
D
import std.stdio; import std.string; import std.array; import std.range; import std.algorithm; import std.conv; void main(string[] args) { readln(); string input = readln().chomp; int[2][char] range; foreach(int i, char c; input) { if(c in range){ range[c][1] = i; }else{ range[c] = [i,0];...
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<=b)writeln(a); else writeln(a-1); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import 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[]);} //END OF TEMPLATE void main(){ long a,b,c,k; ...
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; 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(string s) { ...
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; void main() { auto b = iota(42, 133, 10); auto ptr = new int[](10); auto str = readln.chomp; int pos; foreach (c; st...
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.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; scan(n); auto adj = new int[][](n, 0); foreach (i ; 0 .. n-1) { int ai,bi; scan(ai,bi); adj[ai] ~= bi; adj[bi] ~= ai; } int dfs(int v, int p) { if (...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional; void main() { auto N = readln.split[0].to!int; auto h = readln.split.to!(int[]); h ~= 0; auto res = 0; while(h.reduce!max > 0) { foreach(i; 0..N) { if(h[i] > 0) { h[i]--; if(h[i+1] == 0) r...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { readln; auto AS = readln.split.to!(int[]); long ret; foreach (a; AS) { while (!(a&1)) { a >>= 1; ++ret; } } writeln(ret); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nxy = readln.split.to!(int[]); auto N = nxy[0]; auto X = nxy[1]-1; auto Y = nxy[2]-1; auto G = new int[][](N, N); auto memo = new int[](N); void run(int i, int p, int n...
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 p = readln.chomp.split.to!(i...
D
import std.stdio; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.ascii; void main(){ auto ip = readln.split, s = ip[1]; writeln("A", s[0]...
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!(int[]); auto X = xy[0]; auto Y = xy[1]; writeln(X + Y / 2); }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto s = readln.chomp; auto p = readln.chomp; foreach (i; 0..s.length) if ((s[i..$] ~ s[0..i]).canFind(p)) { writeln("Yes"); return; } writeln("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
void main(){ int k,a,b; k = _scan(); scanf("%d %d", &a, &b); for(int i=a; i<=b; i++){ if( i%k==0 ){ writeln("OK"); return; } } writeln("NG"); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型...
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; import core.bitop : popcnt; alias Generator ...
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 n; scan(n); int pmax = 0; int ps = 0; foreach (i ; 0 .. n) { int pi; scan(pi); ps += pi; pm...
D
import std.stdio, std.conv, std.array; import std.math; void main(){ double r = readln.split[0].to!double; r = 2 * PI * r; printf("%lf\n",r); }
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; alias Pair = Tuple!(int, "l", int, "x"); void main(){ int N, M; int li, ri, xi; readVars(N, M)...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { const tmp = readln.split.to!(int[]); const N = tmp[0], M = tmp[1]; auto res = new int[M]; foreach (i; 0..N) { auto input = readln.split.to!(int[]); input[1..$].each!(a => r...
D
void main() { dchar[] n = readln.chomp.to!(dchar[]); auto g = n.group.array; writeln(g.any!(t => t[1] >= 3) ? "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.container; import st...
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() { int sum, tmp; foreach (i; 0..5) { auto o = readln.chomp.to!int; if (o % 10 ...
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { long a, b; scan(a, b); writeln(a * b); } void scan(L...)(ref L A) { auto l = readln.split; foreach (i, T; L) { A[i] = l[i]....
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional; enum N = 1_000_000_007; void main() { const tmp = readln.split.to!(int[]); const H = tmp[0], W = tmp[1], K = tmp[2]; ulong _countCase(int x) { if (x <= 0) return 1; return ...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math, std.functional, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container, std.format; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generate(()=>readln.c...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=new int[][](2, n); a[0]=readln.split.to!(int[]); a[1]=readln.split.to!(int[]); int mx=0; foreach(i; 0..n){ int sub=0; for(auto j=0; j<=i; j++) sub+=a[0][j]; for(auto j=i; j<n; j++) sub+=a[1][j]; mx=m...
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.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
void main() { auto S = rs; if(S[2] == S[3] && S[4] == S[5]) writeln("Yes"); else writeln("No"); } // =================================== 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; i...
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 g = Graph...
D
import std.stdio,std.array; void main(){ string[] n = split(readln()); int sevenCount = 0; for(int i=0;i<3;i++){ if("7" == n[i]) sevenCount++; } int fiveCount =0; for(int i=0;i<3;i++){ if("5" == n[i]) fiveCount++; } if(fiveCount == 2 && sevenCount == 1){ writeln...
D
void main() { auto N = ri; auto S = rs; auto K = ri; auto c = S[K-1]; foreach(v; S) { if(v == c) c.write; else '*'.write; } writeln; } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.mat...
D
void main() { int n = readln.chomp.to!int; string s = readln.chomp; string t1 = s[0..n/2], t2 = s[n/2..$]; writeln(n % 2 == 0 && t1 == t2 ? "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.numeri...
D
import std.stdio,std.string,std.conv; int main() { string s; while((s = readln.chomp).length != 0) { double d = s.to!double; if(91.00 < d) "heavy".writeln; if(81.00 < d && d <= 91.00) "light heavy".writeln; if(75.00 < d && d <= 81.00) "middle".writeln; if(69.00 < d && d <= 75.00) "light middle".writeln; ...
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; void main(){ auto n=readln().chomp.to!int; auto k=readln().chomp.to!int; auto x=readln().chomp.to!int; auto y=readln().chomp.to!in...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math, std.functional, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return readln.split.to!(T[])();} void scan(TL...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { iota(2).map!(i => readln.chomp.to!int).reduce!((a, b) => a^^2 - b).writeln; } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto S = readln.chomp; auto T = readln.chomp; foreach (i; 0..S.length) { if (S[i..$] ~ S[0..i] == T) { writeln("Yes"); return; } } writeln("No")...
D
import std.stdio; import std.math; import std.conv; void main(){ int n; scanf("%d", &n); int digit = log10(n.to!float).floor.to!int; if (digit == 0) { write(n); } else if (digit == 1) { write(9); } else if (digit == 2) { write(9 + (n-99)); } else if (digit == 3) { write(9 + 900); } else if (digit =...
D
import std.stdio; import std.string; import std.algorithm; import std.conv; void main() { int A, B, r, K; auto input = readln.split.to!(int[]); A = input[0]; B = input[1]; K = input[2]; while(A%B) { r = A%B; A = B; B = r; } int[] ans = new int[100]; ans[0]...
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; // 0, 1, 2, ..., n の xo...
D
import std.stdio; void main() { foreach (i; 1..10) { foreach (j; 1..10) { write(i); write("x"); write(j); write("="); writeln(i*j); } } }
D
import std.stdio; void main(){ foreach(x;1..10)foreach(y;1..10)writeln(x,"x",y,"=",x*y); }
D
import std.stdio; import std.string; import std.conv; import std.array; import std.algorithm; immutable MAX_SCORE = 20; immutable MAX_CARDS = 10; void main() { string[] input; while ((input = readln.chomp.split(" ")).length != 0) { auto cards = new bool[](10); //未出現カード auto openedCards = in...
D
import std.stdio, std.conv, std.array, std.string; import std.algorithm; import std.container; void main() { auto S = readln.chomp; auto T = readln.chomp; int correct_count = 0; for(int i=0; i<S.length; i++) { if (S[i] == T[i]) correct_count++; } writeln(correct_count); }
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
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
// Vicfred // https://atcoder.jp/contests/abc152/tasks/abc152_c // greedy import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; void main() { int n = readln.chomp.to!int; int[] p = readln.split.map!(to!int).array; int minima = 1<<30; int answer = 0; 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; void main() { auto s = readln.split.map!(to!int); auto M = s[0].to!long; auto N = s[1]; auto P = new int[](N);...
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 S = N.iota.map!(_ => readln.chomp).arr...
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.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
//prewritten code: https://github.com/antma/algo import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.traits; import std.random; void main() { immutable n = readln.strip.to!int; auto s = readln.take(n).array; int[] st; auto x...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto T = readln.chomp.to!int; foreach (_t; 0..T) { auto N = readln.chomp.to!int; auto ss = readln.split.to!(int[]); auto DP = new int[](N+1); foreach_reverse (i; ...
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, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; string f0 = "What are you doing at the end of the world? Are you busy? Will you save us?"; string str1 = "What are you doing while sending \""; string str2 = "\"? Are you ...
D
import std.stdio; import std.algorithm; void main() { long x1, x2, y1, y2; scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2); long dx = (x2 - x1) / 2; long dy = (y2 - y1) / 2; printf("%lld\n", (dx + 1) * (dy + 1) + dx * dy); }
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
module main; import core.stdc.stdio; int main(string[] argv) { int n; scanf("%d", &n); if(n%2==1){ printf("7"); }else{ printf("1"); } for(int i = 0; i<n/2-1; i++) printf("1"); return 0; }
D
import std.stdio; void main() { int n; int res = 0; char[200 + 1] s; scanf("%d%s", &n, &s[0]); for (int i = 0; i < n; i++) { int vertical = 0; int horizontal = 0; for (int j = i; j < n; j++) { if (s[j] == 'U') vertical--; if (s[j] == 'D') vertical++; if (s[j] == 'L') horizontal--; ...
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; int[] dist, prev; void main() { int N, K; scan(N,...
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; void main() { auto s = readln.split.map!(to!long); auto N = s[0]; auto A = s[1]; auto B = s[2]; auto C ...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio, 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; long div = 1_000_000_007; void main() { long n, m; scanf("%ld %ld\n", &n, &m); auto dp = new long[n+2]; dp[0] = 1; auto check = new bool[1_0000]; long before = -1; foreach(_; 0..m) { long a; scanf("%ld\n", &a); assert(before < a); before = a; check[a] = true; } foreach(i; 0..n) { ...
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.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.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; void main() { auto K = readln.chomp.to!long; int N = 50; auto A = new long[](N); auto X = K / 50; au...
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
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; import std.typecons; // import dcomp.foundation, dcomp.scanner; // import dcomp.array; // import dcomp.barrettint; int[] primeList(int n) { bool[] used = new bool[n+1]; FastAppender!(i...
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; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; void main() { int n; scan(n); int ans = n; foreach (a ; 0 .. n + 1) { int tmp; int b = n - a; while (a > 0) { ...
D
void main() { int n = readln.chomp.to!int; int[] a = readln.split.to!(int[]); writeln(a.reduce!max - a.reduce!min); } 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.typecon...
D
import core.stdc.stdio; import std.algorithm; void main(){ int n,m; scanf("%d%d",&n,&m); int[] p = new int[m]; foreach(ref v;p) scanf("%d",&v); int[] a=new int[n-1],b=new int[n-1],c=new int[n-1]; foreach(i;0..n-1) scanf("%d%d%d",&a[i],&b[i],&c[i]); int[] sum=new int[n-1]; foreach(i;0..m-1){ int s=p[i]-1,...
D
import std.stdio; import std.conv; import std.string; import std.algorithm; void main() { auto n = map!(to!int)(readln.strip.split); while(n[0]!=-1 || n[1] != -1 || n[2] != -1) { string grade; int m=n[0],f=n[1],r=n[2],score=0; score = m+f; if(m==-1 || f ==-1) { ...
D
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.range; void main() { string s = readln.strip; long cnt = 0; char[] last = new char[](10000); long p = -1; for (long i = 0; i < s.length; i++) { if (i+1 < s.length && s[i] != s[i+1]) { cnt += 2; i++; } else { if ...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.format; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 =...
D
import std.stdio; import std.conv; import std.array; void main() { int N = readln.split[0].to!int; int[] V = readln.split.to!(int[]); int[] C = readln.split.to!(int[]); int ans = 0; foreach (i; 0..N){ if (V[i] > C[i]) ans += V[i] - C[i]; } writeln(ans); }
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
/+ dub.sdl: name "D" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; int n; int[][] g; long[] mp = new long[110]; void dfs(int p, int b, int ndps) { int ch = 0; foreach (d; g[p]) { if (d == b) continue; ...
D
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range; T Read(T)() { return readln.chomp.to!(T); } T[] Reads(T)() { return readln.split.to!(T[]); } alias read = Read!(int); alias reads = Reads!(int); void main() { int d = read(); if (d == 25) writeln("Chr...
D
import std.stdio, std.array, std.conv; void main() { while (true) { string[] input = split(readln()); int H = to!int(input[0]); int W = to!int(input[1]); if (H == 0 && W == 0) return; for (int i = 0; i < H; ++i) { for (int j= 0; j < W; ++j) { write(is_side(i, j, H, W) ? "#" : ".")...
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.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, core.stdc.stdlib; void main() { immutable long INF = 1L << 59; auto s = readln.split.map!(to!int); auto N = s[...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto N = readln.chomp.to!int; auto a = readln.split.to!(int[]); int cnt = 0; while (a.all!"a%2==0") { a[] /= 2; cnt++; } writeln(cnt); }
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { auto n = lread(); auto h = aryread(); long cnt; foreach (i; 0 .. n - 1) { if (h[i] < h[i + 1]) { h[i + 1] -= ...
D
void main() { long n = readln.chomp.to!long; writeln(2 * n / gcd(2, n)); } 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.uni;
D
void main() { writeln(ri^^3); } // =================================== 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.conv; import std.type...
D
import std.stdio; import std.string; import std.format; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.concurrency; import std.traits; import std.uni; import c...
D
import std.stdio; import std.algorithm; import std.string; import std.range; import std.array; import std.conv; import std.complex; import std.math; import std.ascii; import std.bigint; import std.container; import std.typecons; auto readInts() { return array(map!(to!int)(readln().strip().split())); } auto readInt() ...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { auto nk = readln.split.to!(int[]); writeln(nk[0] % nk[1] ? 1 : 0); }
D