code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio; void main(){ for(int i = 1; i < 10; ++i){ for(int j = 1; j < 10; ++j){ writeln(i,"x",j,"=",i*j); } } }
D
import std.stdio; void main(){ foreach(i; 1..10) foreach(j; 1..10) writeln(i,"x",j,"=",i*j); }
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
// tested by Hightail - https://github.com/dj3500/hightail import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; int n; int[] a; void main() { scan(n); a = readln.split.to!(int[]); int b1, b2, b3; foreach (ai ; a) { ...
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.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 s = readln.split.map!(to!long); auto N = s[0].to!int; auto K = s[1]; auto A = readln.sp...
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.typecons; immutable int infinity = int.max / 2; immutable int NA = -1; void main () { string s; while ((s = readln.strip) != "") { auto t = readln.strip; auto k = s.length.to !(int); auto n = t.length.to ...
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^^6 + 3; long powmod(long a, long x, long m) { long ret = 1; while (x) { if (x % 2) ret = ret * a % ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.array; int n; rd(n); auto a=readln.split.to!(int[]); if(a.length%2==0){writeln("No"); return;} if(a.front%2==1 && a.back%2==1){ writeln("Yes"); }else{ writeln("No"); } } void rd(T...)(ref T x){ import std.stdio,...
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 = 998244353; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; if (N == 1) {...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; import std.numeric; void main() { int n = readln.chomp.to!int; long sum = 0; for(int i=1; i<=n; i++) { if(!(i%3==0 || i%5==0)) sum += i; } writeln(sum); }
D
void main(){ long n = _scan!long(); long[] a = _scanln!long(); long q = _scan!long(); long[long] dic; long ans; // 合計値と参照辞書の作成 foreach(elm; a){ ans += elm; dic[elm]++; } // replace 操作 foreach(i; 0..q){ long[] bc = _scanln!long(); ans += bc[1]*dic.get(bc[0], 0) - bc[0]*dic.get(bc[0], 0); dic[bc[1]] ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum P = 10L^^9+7; void main() { auto S = readln.chomp; auto DP = new long[][](S.length, 4); foreach (ref dp; DP) dp[] = -1; long solve(int i, int s) { if (i == S.length) return s == 3 ? 1 : ...
D
import std.stdio; import std.algorithm; import std.conv; import std.string; import std.math; void main(string[] args) { auto n = to!int(strip(readln)); int[1001] a; auto x = split(strip(readln)); foreach (j; 0 .. n) { a[to!int(x[j])]++; } int count; int ze = s(a); while(ze >= 1) { count += ze - 1; ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { char x, y; scan(x, y); if (x < y) { writeln("<"); } else if (x > y) { writeln(">"); } else { writeln("="); } } void scan(T...)(ref T args) { import std.stdi...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math, std.functional, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container, std.format; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return readln.split.to!(T[])();} ...
D
import std.stdio; import std.string; import std.array; // split import std.conv; // to import std.math; import std.algorithm; void main() { string n = chomp(readln()); int N = to!int(n); // 第0要素を整数に変換 string[] input = split(readln()); int a = to!int(input[0]); int min = a,max = a; for(int i =1;i...
D
import std.stdio; import std.string; import std.algorithm; import std.range; import std.array; import std.conv; void main() { while(1){ auto N = readln().chomp().to!uint; if(N == 0) break; auto seq = readln().chomp().split(); uint state; uint cnt; uint...
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.regex, std.conv, std.stdio, std.typecons; void main() { for (;;) { auto rd = readln.split.map!(to!int); auto m = rd[0], f = rd[1], r = rd[2]; i...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm; void main() { int d = readln.chomp.to!int; ("Christmas " ~ repeat("Eve", 25 - d).join(" ")).writeln; }
D
import std.stdio, std.string, std.conv, std.array, std.algorithm; import std.uni, std.range, std.math, std.container, std.datetime; import core.bitop, std.typetuple, std.typecons; immutable long MOD = 1_000_000_007; alias tie = TypeTuple; alias triplet = Tuple!(int, int, int); void main(){ int A, B, C; readVa...
D
void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], m = tmp[1]; string[] a = new string[n], b = new string[m]; foreach (i; 0 .. n) { a[i] = readln.chomp; } foreach (i; 0 .. m) { b[i] = readln.chomp; } bool ok; foreach (i; 0 .. n-m+1) { foreach (...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto S = readln.chomp.to!(char[]); auto K = readln.chomp.to!long; if (S.length == 1) { writeln(K/2); return; } long[] ns; long cnt; char last; foreach (...
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 mod = 10L^^9 + 7; enum inf = 10^^9; void main() { int n, m; scan(n, m); auto c = new int[][](n, n); foreach (i ; 0 .. n) { foreach (j...
D
import std.algorithm; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; bool test (string s) { if (s.length % 2) return false; foreach (i; 0 .. s.length) { if (i % 2) { if (s[i] != 'i') return false; } else { if (s[i] != 'h') return fa...
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
/+ dub.sdl: name "A" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; int main() { Scanner sc = new Scanner(stdin); int n; string s; sc.read(n, s); int ans = 10^^9; int wc, ec = s.count('E').to!in...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional, std.container, std.typecons; void main() { int B = readln.chomp.to!int; foreach(i; 1..10) { foreach(k; 1..10) { if(B == i*k) { "Yes".writeln; return; } } } "No".writeln; }
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.split; if (s[0][$-1] == s[1][0] && s[1][$-1...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { writeln(readln.chomp.to!int / 3); }
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; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { 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 times(alias pred)(int n) { foreach(i; 0..n) pred(); } auto ...
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
void main() { string s = readln.chomp; long k = readln.chomp.to!long; long n = s.countUntil!(x => x != '1'); if (n == -1 || n >= k) { s[0].writeln; } else { s[n].writeln; } } import std.stdio; import std.string; import std.array; import std.conv; import std.algorith...
D
void main() { string s = readln.chomp; int cnt; foreach (x; s) { if (x == '+') ++cnt; else --cnt; } cnt.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; import std.containe...
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; immutable long MOD = 10^^9 + 7; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1...
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.random; import std.range; import std.stdio; import std.string; import std.typecons; void main() { string f = readln.chomp; string s = readln.chomp; au...
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.to!(int[]); if(ip[0] <= 8 &&...
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, m; scanf("%d%d", &n, &m); bool[][] g = new bool[][](n,n); foreach (i; 0..n) foreach (j; 0..n) { if (i != j) g[i][j] = true; }...
D
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.array; void main() { readln(); auto inp = readln().chomp.split; string[] b1, b2; for(int i; i<inp.length; i++){ auto a = inp[i]; if(i%2==0){b1 ~= a;} else{b2 ~= a;} } if(inp.length%2==0){b2.reverse(); (b2 ~ b1).join(" ").writ...
D
void main() { int x = readln.chomp.to!int; bool[] ok = new bool[x+1]; ok[1] = true; for (int i = 2; i * i <= x; ++i) { for (int j = 2; i ^^ j <= x; ++j) { ok[i^^j] = true; } } foreach_reverse (i, y; ok) { if (y) { i.writeln; break; ...
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 d, n; readV(d, n); writeln((...
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() { auto d = ['A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'];...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; readln; int cnt = 1; N -= K; --K; while (N > 0) { ++cnt; N -= K; } writeln(cnt); }
D
import std.stdio, std.string, std.conv; void main() { int[][] c; for (int i = 0; i < 3; i++) { c ~= to!(int[])(readln.chomp.split); } int[3] a, b; // a[0] = 0 と仮定 foreach (i, e; c[0]) { b[i] = e; } for (int i = 1; i < 3; i++) { a[i] = c[i][i] - b[i]; } bool f = true; f...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); ulong MOD =...
D
import core.stdc.stdlib; import std.algorithm; import std.array; import std.conv; import std.math; import std.numeric; import std.stdio; import std.string; // void toBaseMinus2(in long rest, in long digit, in string result) // { // // stderr.writeln(rest, ", ", digit, ", ", result.dup.reverse); // if (rest ==...
D
import std.stdio, std.string, std.conv; long solve(long n) { import std.algorithm; long result = long.max; for (long i = 1; i * i <= n; ++i) { if (n % i == 0) result = min(result, i+n/i-2); } return result; } void main() { long n = readln.chomp.to!long; solve(n).writeln; }
D
import std.stdio, std.string; void main(){ int w, h; while(true){ scanf("%d %d", &h, &w); if( w== 0&&h == 0) break; for(int i = 0; i < h; ++i){ for(int j = 0; j < w; ++j){ if (i == 0 || i == h-1){ write("#"); } else if (j == 0 || j == w-1){ write("#"); }else{ write(".")...
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; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ int n = read.to!int; int m = read...
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.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
// tested by Hightail - https://github.com/dj3500/hightail import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; int a, b; void main() { scan(a, b); if (!(a > 0 || b < 0)) { writeln("Zero"); } else if (b < 0 && (...
D
void main() { problem(); } void problem() { auto a = scan; string solve() { return a[$-1] == 's' ? a ~ "es" : a ~ "s"; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, s...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; long a, b, c, d, e, f; rd(a, b, c, d, e, f); /* 100b/(a+b) < 100b'/(a'+b') 100b*(a'+b') < 100b'*(a+b) */ long mx_w=100*a, mx_s; for(long w1=100*a; w1<=f; w1+=100*a){ for(long w2=0; w2<=f; w2+=100*b){ for(long s1=0; s1...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; void main() { int input; immutable limitList = 500000; bool[] listNumbers = new bool[](limitList); int[] listPrimeNumbers; listNumbers.fill(true); foreach (i; 2..limitList.to!double.sqrt.to!int) { ...
D
void main() { (rs.canFind("9") ? "Yes" : "No").writeln; } // =================================== import std.stdio; import std.string; 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.t...
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 s...
D
import std.functional, std.algorithm, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; ulong M = 10UL^^9 + 7; ulong fact(ulong n) { if (n <= 1) { return 1; } else { return n * fact(n - 1) % M; } } void main() { ulong n ...
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; int main() { auto sc = new Scanner(stdin); long q, h, s, d; sc.read(q, h, s, d); h = min(h, 2*q); s = min(s, 2*h); d = min(d, 2*...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto a = readln.chomp.to!int; auto b = readln.chomp.to!int; auto h = readln.chomp.to!int; writeln((a + b) * h / 2); }
D
import std.stdio, std.string, std.range, std.conv, std.algorithm, std.typecons; void main(){ alias Tuple!(int, "x", int, "y") Point; int W, H, N; auto input = readln.split.map!(to!int); W = input[0], H = input[1], N = input[2]; int total; Point before; foreach (i; 0..N) { input = readln.split.map!(to!int); ...
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[] a = new int[n]; foreach (i; 0..n) scanf("%d", &a[i]); int[int] t; t[0] = 0; long ans = 0; foreach (i;...
D
import std.stdio,std.string,std.conv; int main() { int[char] roman = ['I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000]; string s; while((s = readln.chomp).length != 0) { int ans = 0; for(int i=0;i<s.length-1;i++) { if(roman[s[i]] >= roman[s[i+1]]) ans += roman[s[i]]; else ans -= roman[s[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 m = 0, a ...
D
import std.stdio,std.string,std.conv,std.algorithm,std.range,std.array; void main(){ foreach(_;0..readln.chomp.to!int){ readln.replace("Hoshino","Hoshina").write; } }
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
// 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.conv; import std.algorithm; import std.string; import std.file; int main() { int[] hs; string l; readln(); while((l = readln()).length >= 2){ int a, b, c; a = to!int(l.split()[0]), b = to!int(l.split()[1]), c = to!int(l.split...
D
import std.stdio; import core.stdc.stdio; import std.array; import std.conv; import std.algorithm; import std.range; void main() { int n,a; scanf("%d%d",&n,&a); int x = n % 500; writeln(x <= a ? "Yes" : "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.algorithm; import std.range; import std.conv; import std.format; import std.array; import std.math; import std.string; import std.container; void main() { string S, T; readlnTo(S); readlnTo(T); int[] a = new int[26]; int[] b = new int[26]; a.fill(-1); b.fill(-1); bool ok...
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 data = readln.split; auto H = data[0].to!int, W = data[1].to!int; data = readln.split; auto h = data[0].to!int, w = data[1].to!int; writeln(H*W - h*W - w*H ...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); ulong MOD =...
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; 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 times(alias pred)(int n) { foreach(i; 0..n) pred(); } auto ...
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() { auto n = lread(); auto s = sread(); auto t = sread(); if...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp; writeln(n[0] == n[2] ? "Yes" : "No"); }
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math, std.functional, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container, std.format; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return readln.split.to!(T[])();} ...
D
import std.stdio; import std.array; import std.conv; void main(){ string[] input = readln.split; int A = input[0].to!int; int B = input[1].to!int; int C = input[2].to!int; int cnt; while(C > 0){ C--; cnt++; if(B > 0){ B--; cnt++; } else if(A > 0){ A--; } else{ break; } } if(B > 0) c...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); int tot = 0; for (int i = 1; i <= n; i += 2) { int k = 2; for (int j = 2; j * j <= i; j++) { if (i % j == 0) k += 2; } if (k == 8) { tot++; } } writeln(tot); } void rd(T...)(ref T ...
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() { long k, a, b; scan(k, a, b); long ans; if (k <= a) { ans = 1; } else if (a <= b) { ans = -1; } else { ...
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; } int[] group(string s, string t) { int[] gs; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto X = readln.chomp; int s, r; foreach (c; X) { if (c == 'S') { ++s; } else if (s > 0) { --s; } else { ++r; } } ...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void main() { auto nq = readints(); int n = ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto S = readln.chomp; long[] Ls; long[] Rs; foreach (i; 0..S.length) { if (S[i] == 'L') Ls ~= i; else Rs ~= i; } auto Lss = assumeSorted(Ls); auto Rss = assum...
D
void main() { problem(); } void problem() { auto N = scan!int; int countF(int n) { int c; foreach(x; 1..101) { auto tx = x^^2; if (tx > n) break; foreach(y; x..101) { auto ty = tx + y^^2 + x*y; if (ty > n) break; foreach(z; y..101) { auto t = ...
D
import std.stdio; import std.conv; import std.array; void main(){ string x = readln.split[0]; if (x == "3" || x == "5" || x == "7"){ writeln("YES"); }else{ writeln("NO"); } }
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; bool [int] b; b[a[0]] = true; foreach (i; 1..n) {...
D
import std.stdio; import std.string; import std.conv; int main() { string str; while((str = readln()).length != 0) { int d = str.chomp.to!int; int value = 0,s = 0; while(value != 600-d) { value += d; int line = value*value; s += line * d; } writeln(s); } return 0; }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp.to!long; if (N%2 == 1 || N <= 10) { writeln(0); } else { long r; N /= 10; while (N) { r += N; N /= 5; }...
D
import std.stdio; import std.algorithm; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() {//try{ auto tokens = split(my_readln()); auto S = to!string(tokens[0]); ulong best = 999; foreach (i; 0..S.length-2) {...
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); writeln(a...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; import std.range; void main() { auto S = readln.chomp.to!(char[]); auto ni = (iota('a', 'z').chain('z'.only)).find!(c => !S.canFind(c)); ni.empty ? writeln("None") : writeln(ni.front); }
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.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.chomp; auto T = S.to!(dchar[]); T.reverse(); S = T.to!string; auto N = S.length.to!int; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { writeln(readln.split.join.to!int % 4 == 0 ? "YES" : "NO"); }
D
// Cheese-Cracker: cheese-cracker.github.io void solve(){ auto n = scan; auto m = scan; long a = n / 3; long b = m / 3; long lefa = n % 3; long lefb = m % 3; long res = lefb * a + lefa * b + min(lefa, lefb) + (a * b * 3); writeln(res); } void main(){ long tests = scan; // To...
D
import std.stdio, std.string, std.conv; void main() { string s = readln.chomp; int K = readln.chomp.to!(int); // s.to!(char[]); char[] ans; foreach (char c; s[0..(s.length - 1)]) { if (c == 'a') { ans ~= c; } else if ('z' - c + 1 <= K) { ans ~= 'a'; K -= 'z' - c + ...
D