code
stringlengths
4
1.01M
language
stringclasses
2 values
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; bool[][] G; G.length = N; foreach (i; 0..N) { G[i].length = N; foreach (j, x; readln.chomp) { if (x == '1') G[i][j] = true; ...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional, std.container, std.typecons; void main() { auto input = readln.split.to!(int[]); auto N = input[0], D = input[1]; auto r = 2*D + 1; ((N + r -1) / r).writeln; }
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 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; import std.string; import std.conv; import std.bigint; import std.typecons; import std.algorithm; import std.array; import std.math; import std.range; void main() { auto tmp = readln.split.to!(int[]); if (tmp[0] == tmp[1]) writeln(tmp[2]); else if (tmp[1] == tmp[2]) writeln(tmp[0]); ...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii; import std.typecons, std.functional, std.traits; import std.algorithm, std.container; import core.stdc.stdlib, core.bitop; void main(){ auto S = scanString; string NS; bool B; for(int i = 0;i < S.length-1;i++...
D
import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ long a = read.to!long; ...
D
// Vicfred // https://atcoder.jp/contests/abc135/tasks/abc135_c // greedy import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; void main() { long n = readln.chomp.to!long; long[] as = readln.split.map!(to!long).array; long[] bs = readln.split.map!(to!long).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; enum inf = 1L << 50; enum mod = 10L^^9 + 7; void main() { int n; scan(n); auto adj = new int[][](n, 0); foreach (i ; 0 .. n-1) { int x, y; ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.container; import std.bigint; import std.math; void main() { while (1) { auto x = readln.chomp.split.map!(to!int); if (x[0] == 0) break; foreach (i; 0..x[0]) { foreach (j; 0..x[1]) { if (...
D
void main() { long n = rdElem; long[][] lists = new long[][](10, 10); foreach (i; 1 .. n+1) { long f = i; long b = f % 10; while (f > 9) f /= 10; ++lists[f][b]; } long result; foreach (i; 0 .. 10) { foreach (j; 0 .. 10) { resu...
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
/+ dub.sdl: name "C" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.range, std.algorithm, std.conv; // import dcomp.scanner; // import dcomp.algorithm; int main() { auto sc = new Scanner(stdin); int n, m; sc.read(n, m); int[][] g = new int[][](n); foreach (i; 0..m) { ...
D
import std.stdio, std.conv, std.array,std.string; void main() { string[] input=readln.split(","); writeln(input[0]~" "~input[1]~" "~input[2]); }
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 h = readln.chomp.to!int; auto w = readln.chomp...
D
import std.stdio,std.conv,std.string,std.algorithm,std.array; void main(){ auto s=readln().chomp().split().map!(to!int); int a,b,c,d; a=s[0]; b=s[1]; c=s[2]; d=s[3]; if(a+b>c+d) writeln("Left"); else if(a+b==c+d) writeln("Balanced"); else writeln("Right"); }
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.to!(char[]).array; int i, res; i = res = 0; while (i != s...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { writeln(min(readln.chomp.to!int, readln.chomp.to!int) + min(readln.chomp.to!int, readln.chomp.to!int)); }
D
import std.stdio; import std.conv; import std.string; void main() { int S = to!int(chomp(readln())); int s = S % 60; S /= 60; int m = S % 60; S /= 60; int h = S; writeln(to!string(h) ~ ":" ~ to!string(m) ~ ":" ~ to!string(s)); }
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 long inf = mod; void main(){ int n = readln.chomp.to!int; int ans; foreach(i ; 0 ....
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 inf = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int r1, c1, r2, c2; scan(r1, c1, r2, c2); a...
D
// import chie template :) {{{ import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip; // }}} // nep.scanner {{{ class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { 3.iota.map!(i => readln.chomp[i]).array.writeln; }
D
void main() { string s = readln.chomp; foreach (x; lowercase) { if (!s.canFind(x)) { x.writeln; break; } if (x == 'z') "None".writeln; } } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import s...
D
void main() { problem(); } void problem() { const S = scan; auto N = S.length; long solve() { if (N < 4) return 0; const P = 2019; long ans; auto cs = new long[](P); cs[0] = 1; long x, t = 1; foreach_reverse (c; S) { x = ((c-'0').to!long * t + x) % P; t = (t ...
D
import std; auto input() { return readln().chomp(); } alias sread = () => readln.chomp(); void main() { long n, m; scan(n, m); //writeln(n, m); auto color = new bool[](n); color[0] = true; auto cup = new long[](n); cup[] = 1; foreach (i; 0 .. m) { long x, y; sc...
D
import std.stdio; void main() { for (int i = 0; i < 1000; i++) { writeln("Hello World"); } }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; scan(n); int d, x; scan(d, x); foreach (i ; 0 .. n) { int ai; scan(ai); x += (d + ai - 1) / ai; } writeln(x); } void scan(T...)(ref T args) { import std.s...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { writeln(readln.chomp.replace(" ", "").to!int % 4 ? "NO" : "YES"); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range....
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(){ char[] s = readln.chomp.to!(char[]); long k = readln.chomp.to!long; foreach(i, c; s){ int x = 'z' + 1 - c; if(s[i] > 'a' && x <= k){ s[i] = 'a'; ...
D
import std.stdio, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; void main() { int a, b, c; scan(a, b, c); int k; scan(k); int cnt; while (a >= b) { b *= 2; cnt++; } wh...
D
import std.stdio; import std.string; void main() { string ans = "WA"; string s = readln.strip; if (s[0] == 'A') { ulong c = 0; foreach(i, e; s[0..$ - 1]) { if (e == 'C' && i > 1) { c = i; break; } } if (c > 1) { ...
D
class UnionFind{ int[] root; this(int n){ root.length=n; foreach(i; 0..n) root[i]=i; } int find(int x){ if(x==root[x]) return x; else return root[x]=find(root[x]); } void merge(int x, int y){ x=find(x); y=find(y); if(x==y) return; root[x]=y; } } void main(){ import std.stdio...
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(); long bignum...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container; int n, k, c; bool[] solve() { scanf("%d %d %d\n", &n, &k, &c); string s = readln.chomp; bool[] banned = s.map!(c => c=='x').array; int[] l = new int[k]; int k_cnt = 0; for(int i=0; i<n; i++) { if(!banned[i]) { ...
D
import std.stdio; //import std.string; //import std.conv; import core.stdc.stdio; void main(){ //int a = to!int(chomp(readln())); //int b = to!int(chomp(readln())); int a; int b; scanf("%d",&a); scanf("%d",&b); if(a == b) writeln("a == b"); else writeln((a < b) ? "a < b" : "a > b"); }
D
import std.stdio; import std.string; import std.conv; int main() { while (true) { string[] str = readln().split(); if (str[0] == "0" && str[1] == "0") break; for (int i = 0; i < str[0].to!int(); i++) { for (int j = 0; j < str[1].to!int(); j++) { write("#"); ...
D
void main() { (700 + readln.chomp.count!"a == 'o'" * 100).writeln; } // =================================== import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.bigint; import std.numeric; import std.conv; import std.typecons; im...
D
import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.math; void main() { string w = chomp(readln()); int[26] alphabet_list; for(int i = 0;i < w.length;i ++) { alphabet_list[to!int(w[i])-97] ++; } int odd_num_count = 0; for(int i=0;i < 26;i ++) { if(alp...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; int[(10^^5)*2] AS; void main() { auto N = readln.chomp.to!int; foreach (i; 0..N) AS[i] = readln.chomp.to!int; if (AS[0]) { writeln("-1"); return; } long cnt; foreach (i; 1..N) { if (AS[i] > AS[i-1]+1) {...
D
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.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; 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
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 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.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.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.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
// 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
//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.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
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.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; 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
//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
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