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, std.bitmanip; void main() { auto S = readln.chomp; auto N = S.length.to!int; string A = ""; string B = ""; foreach (i; ...
D
// Cheese-Cracker: cheese-cracker.github.io void theCode(){ ll l = scan; ll r = scan; if(l == r){ writeln(0); return; } ll d = r/2 + 1; d = max(l, d); writeln(r % d); } void main(){ long tests = scan; // Toggle! while(tests--) theCode(); } /********* That's...
D
import std.stdio, std.algorithm, std.conv, std.string; void main(){ while(true){ ulong[int] sales; int[] order; int data=readln.chomp.to!int; if(data==0)break; foreach(_;0..data){ auto inp=readln.split.map!(to!int); int id=inp[0],sale=inp[1],num=inp[2...
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.conv, std.string, std.math, std.algorithm; void main(){ auto ip = readln.chomp; if(ip[0] == 'H'){ if(ip[2] == 'H') 'H'.writeln; else if(ip[2] == 'D') 'D'.writeln; } else if(ip[0] == 'D') { if(ip[2] == 'H') 'D'.writeln; else if(ip[2] == 'D') 'H'.writeln; } }
D
import std; long calc(long[] a) { long ans = 0; long[long] d; for (int i = 0; i < a.length; i++) { ans += d.get(i + 1 - a[i], 0); d[i + 1 + a[i]]++; } return ans; } void main() { read; auto a = reads!long; writeln(calc(a)); } void scan(T...)(ref T a) { string[] ss ...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random; import std.typecons, std.functional, std.traits,std.concurrency; import std.algorithm, std.container; import core.bitop, core.time, core.memory; import std.bitmanip; import std.regex; enum INF = long....
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; // }}} // nep.scanner {{{ class Scanner { import std.stdio; import std.conv...
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.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.functional; void main() { char[] s = readln.chomp.to!(char[]); int n = s.length.to!int; bool[] app = new bool[](26); foreach (ch ; s) { app[ch - 'a'] = 1; } debug { ...
D
import std.algorithm; import std.range; import std.stdio; import std.typecons; import std.traits; import std.array; struct Input { T next(T)() { import std.conv; return to!T(nextWord); } string nextWord() { if (_nextWords.empty) _nextWords.insertFront(readln().split); string word = _nextWords...
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, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int q; scan(q); while (q--) { long ai, bi; scan(ai, bi); solve(ai, bi); } } void solve(long ai, long bi) { long l = sqrt(ai*bi); debug { writefln("l:%s", l); ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.exception, std.typecons; int n, m; rd(n, m); auto edges=new Tuple!(int, int)[](m); auto g=new int[][](n, 0); foreach(i; 0..m){ int a, b; rd(a, b); a--; b--; g[a]~=b; g[b]~=a; edges[i]=tuple(a, b); } auto vis...
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.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; auto w = readln.chomp.to!int; string x = ""; foreach (i;...
D
void main() { problem(); } void problem() { const N = scan!long; const M = scan!long; const An = scan!long(cast(int)M); long solve() { const slack = N - An.sum; return slack >= 0 ? slack : -1; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, ...
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 n; scan(n); int k; while (10L^^(k+1)-1 <= 2*n - 1) k++; debug { writeln(k); } long ans; foreach (d ; 1 .. 10...
D
import std.stdio,std.string,std.conv,std.array,std.algorithm; void main(){ int[string] mark; mark["S"]=0; mark["H"]=1; mark["C"]=2; mark["D"]=3; bool[13][4] card; readln(); for(;;){ auto rcs = readln().chomp().split(); if(!rcs){break;} card[mark[rcs[0]]][to!int(rcs[1])-1]=true; } foreach(m;0..4){foreach...
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; void main() { int sum = 0; foreach(i; 0..10) sum += readln.chomp.to!int; ...
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!int; bool[string] res; foreach (_; 0..N) { res[readln.chomp] = true; } writeln(res.length); }
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, 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 S = readln.chomp; auto cnt = new long[string][](N+1); long an...
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() { string s; readV(s); writeln("ABC...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.traits; void main() { auto s = readln.strip.split.map!(to!int).array; immutable h = s[0], w = s[1]; auto a = new string[h]; foreach (i; 0 .. h) { a[i] = readln.strip; ...
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, m; readV(n, m); auto g =...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { readln; auto r = readln.chomp.split(" ").map!(to!uint).all!((a) => (a % 2 == 1) || (a % 3 == 0) || (a % 5 == 0)); if (r) { writeln("APPROVED"); } else { writeln("DENIED"); } }
D
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; stri...
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() { string s; readV(s); auto c = ne...
D
import std.stdio; import std.conv; import std.algorithm; import std.range; import std.string; import std.typecons; import std.math; import std.range; void main() { auto count = readln().strip.to!int; auto m = new int[(count + 1) * (count + 1)].chunks(count + 1); auto p = new int[count + 1]; foreach (i; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp; auto DP = new long[][](N.length, 2); foreach (ref dp; DP) dp[] = -1; long solve(int i, bool k) { if (i == N.length) return k == 0 ? 0 : long.max/3; ...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; void main() { auto n = readln.chomp.to!int; auto ds = readln.chomp.split.to!(int[]); auto m = r...
D
import std.stdio, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; void main() { string w; scan(w); auto c = new int[](26); foreach (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; void main() { auto ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; int r; foreach (h; readln.split.to!(int[])) if (h >= K) ++r; writeln(r); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum as = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]; void main() { writeln(as[readln.chomp.to!int-1]); }
D
import std.stdio, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; void main() { int n; scan(n); void solve(int i, int shu, string s) { ...
D
unittest { assert( [ "000" ].parse.expand.solve == 1 ); assert( [ "10010010" ].parse.expand.solve == 3 ); assert( [ "0" ].parse.expand.solve == 0 ); } import std.algorithm; import std.conv; import std.range; import std.stdio; import std.typecons; void main() { stdin.byLineCopy.parse.expand.solve.writeln; } aut...
D
import std.algorithm; import std.array; import std.stdio; import std.string; void main() { string[] blocks; loop: for (;;) { auto command = readln.strip.split; auto operation = command[0]; final switch (operation) { case "push": auto block = command[1]; blocks ~= block; break; case "pop": aut...
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
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.functional, std.math, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = () ...
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
void main() { int n = readln.chomp.to!int; string s = readln.chomp; int cnt; foreach (i; 1 .. n) { int tmp; foreach (x; lowercase) { if (s[0..i].canFind(x) && s[i..$].canFind(x)) { ++tmp; } } cnt = max(cnt, tmp); } cnt.write...
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 D = s[1]; auto A = iota(N).map!(_ => rea...
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() { ulong n = readln.chomp.to!ulong; ulong[] a = readln.ch...
D
import std.stdio, std.range, std.random, std.conv, std.string, std.math; import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting; void main() { long[] input = readln().strip.split().to!(long[]); long K = input[0]; long A = input[1]; ...
D
import std; auto input() { return readln().chomp(); } alias sread = () => readln.chomp(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { string s; s = input(); // writeln(s); string key; key = "keyence"; // riteln(s[0 .. 7]); // if (s[0 .. 7] == key) // { ...
D
import std.stdio; import std.array; import std.string; import std.container; import std.ascii; import std.random; import std.algorithm; import std.conv; import std.range; import std.math; import std.format; import std.typecons; import std.numeric; import std.datetime; /* ??????????????????, ?????§??¨?????¨, ??¨?????...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum inf3 = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int n, k; scan(n, k); int ans = n - k + 1...
D
import std.stdio; import std.string; import std.conv; import std.array; import std.math; void main() { int N = readln.chomp.to!int; int[] h = readln.split.to!(int[]); int[] cost = new int[N]; cost[0] = 0; cost[1] = abs(h[1] - h[0]); foreach (i; 2..N){ int c0 = cost[i - 2] + abs(h[i] - ...
D
import std.stdio; import std.conv; import std.string; import std.range; import std.algorithm; void main(){ foreach(i; 0..readln().chomp().to!int()){ auto input = readln().split(); (input[0].decode() + input[1].decode()).encode().writeln(); } } int decode(string input){ int res; int qua...
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 a = readln.chomp.split.to!(i...
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 core.bitop; import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.format; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; void main() { auto a = readln.chomp.split.map!(to!int); writeln = max(0, a[0] - a[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; void main(){ auto ip = readln.split.to!(int[]); ((ip[0] + ip[1]) ...
D
void main(){ string[] s = inln!string(); string ans; foreach(elm; s)ans ~= elm[0]; ans.writeln(); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range; const long mod = 10^^9+7; // 1要素のみの入力 T inelm(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力...
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, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}} void main() { int n, a, b; readV(n, a, b); writeln(min(n*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; void main() { auto ...
D
import std; auto input() { return readln().chomp(); } alias sread = () => readln.chomp(); void main() { long h, m; scan(h, m); auto s = new string[](h); foreach (i; 0 .. h) { s[i] = sread(); } //writeln(s); foreach (i; 0 .. h) { foreach (j; 0 .. m) { ...
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((...
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)() { 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 mod = pow...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; auto Px = [-1, 0, 1, 0]; auto Py = [ 0, 1, 0,-1]; void main() { auto line = split(readln()).map!(a => to!int(a)); int z = 0; auto ret = solve(line[z++], line[z++], line[z++], line[z++], line[z++]); writeln(ret ? "Yes" : "No...
D
// url: http://abc075.contest.atcoder.jp/tasks/abc075_c import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1]; struct Edge { size_t a, b; } auto e = new Edge[](m); foreach (i; 0..m) { auto rd2 = readln.split.to!(size_...
D
import std.stdio, std.array, std.conv, std.typecons, std.algorithm; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } void main() { immutable ip = readln.split.to!(ulong[]); immutable n = ip[0], x = ip[1]; immutable ls = readln.split.to!(ulong[]); ulong cnt = 0; ulong xi =...
D
// import chie template :) {{{ static if (__VERSION__ < 2090) { 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, std.numeric; } else { import std; } // }}} // nep.scanner {{{ class Scanner { ...
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 a, b, x, y, z; scan(a, b); scan(x, y, z); writeln(max(0, 2*x + y - a) + max(0, y + 3*z - b)); } void scan(T...)(ref T args) { str...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[100] WS, VS; void main() { auto nw = readln.split.to!(int[]); auto N = nw[0]; auto W = nw[1]; long[][] MEMO; MEMO.length = N; foreach (i; 0..N) { auto wv = readln.split.to!(int[...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; long x, y; rd(x, y); long count(long st, long ed){ if(st>ed) return 0; long ret=1; while(st*2<=ed) st*=2, ret++; return ret; } writeln(max(count(x, y), count(x+1, y))); } void rd(T...)(ref T x){ import std.stdio, std...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); struct P { int y, x; } auto xs = new int[](n), ys = new int[](n); bool[P] seen; foreach (i; 0 .. n) { rd(xs[i], ys[i]); if (i > 0) { seen[P(xs[i], ys[i])] = true; } } auto vy = new int[](n), vx...
D
import std.stdio; import std.conv; import std.array; import std.algorithm; void main() { int n = readln.split[0].to!int; int[] v = readln.split.to!(int[]); int[][] counter = new int[][](2, 100000); foreach (i; 0..n) counter[i % 2][v[i] - 1]++; ulong[][] max_i = new ulong[][](2, 2); 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, core.stdc.stdio; int solve() { auto s = readln.split.map!(to!int); int M = s[0]; int N = s[1]; if (M == 0) return -1; 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; void main() { string INF = "|"; string[] input; while(true) { inp...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional; void main() { auto input = readln.split.to!(int[]); auto N = input[0], Q = input[1]; auto tree = new int[][N]; auto cnt = new int[N]; foreach(i; 0..(N-1)) { input = readln.split.to!(int[]); auto a = input[0]...
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; final class InputReader { private: ubyte[] p, buffer; bool eof; bool rawRead () { if (eof) { return fals...
D
import std.stdio, std.string, std.conv; void main() { int a,b; scanf("%d %d",&a, &b); writeln(2*b-a); }
D
import std.stdio; import std.string; import std.algorithm; void main() { readln; auto a = readln.chomp.dup; int count; int left, right = cast(int)a.length - 1; for (;;) { while (left < a.length) { if (a[left] == 'W') { break; } ++left; } while (right >= 0) { if (a[right] == 'R') { brea...
D
import std.stdio; import std.string; import std.range; import std.conv; void main() { auto X = readln.chomp.to!int; auto A = readln.chomp.to!int; auto B = readln.chomp.to!int; writeln((X-A)%B); }
D
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm; 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!int; if(N-K <= 0){ writeln(N*X); }else{ writeln(K*X + (N-K)*Y); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ab = readln.split.to!(int[]); auto A = ab[0]; auto B = ab[1]; writeln(max(0, A - B*2)); }
D
void main() { writeln(readln.chomp.to!int ^^ 2 - readln.chomp.to!int); } 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.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int A, B, C, D, E, F; scan(A, B, C, D, E, F); int ans_w = 100*A, ans_s = 0; foreach (x ; 0 .. 31) { foreach (y ; 0 .. 31) { int wat...
D
import std.stdio,std.string,std.conv,std.algorithm; void main(){ while(1){ auto rd = readln().chomp(); if(rd){ auto v = to!double( rd ); auto t = v/9.8; auto y = 4.9*t*t; for(int i=1;i<100000;i++){ if( y <= 5*i-5 ){ writeln(i); break; } } }else{ break; } } }
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 as=readln.split.map!(to!long).array; long fromNega; long fromPosi; long current...
D
import std.stdio; import std.conv; import std.array; import std.string; import std.algorithm; int main(string[] argv) { while (1) { auto s = readln().chomp().split().map!(to!int); int mf = s[0] + s[1]; if (s[0] + s[1] + s[2] == -3) break; if (s[0] == -1 || s[1] == -1) writeln("F"); else if (80 ...
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; long x; readV(n, x); aut...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto S = readln.chomp; long solve(size_t i, long sum) { if (i == S.length) return sum; long r; foreach (j; i+1..S.length+1) { r += solve(j, sum + S[i..j].to!l...
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.stdio : writeln; void main() { foreach(i; 1..10){ foreach(j; 1..10){ writeln(i, "x", j, "=", i*j); } } }
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!int; if (N == 3) { writeln("2 5 63"); } else if (N == 4) { writeln("2 5 20 63"); } else if (N == 5) { writeln("2 3 5 8 12"); } else {...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.typecons; alias T = Tuple!(long, long, long); long[] vs; long[T] memo; long n, k; long f(long l, long r, long m) { auto key = tuple(l, r, m); if (key in memo) return memo[key]; if (m < 0 || n-r-1 < l) return 0; long[] cands = [...
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; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; int n; void main(){ n = readln.chomp.to!int; bool[][] xss; foreach(i; 0 .. n){ xss ~= readln.chomp.map!(x => (x == '#')).array; } int donecolumncount = 0; foreach(...
D
import std.algorithm; import std.range; import std.math; import std.regex; import std.array; import std.container; import std.stdio; import std.string; import std.conv; string[] readStrs() { return readln.chomp.split(' '); } T[] readInts(T)() { return readln.chomp.split(' ').map!(to!T).array(); } void main() { a...
D
import std.stdio,std.string,std.conv,std.array; void main(){ //for(;;){ auto rc = readln().chomp(); auto transTable1 = makeTrans("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); writeln( translate(rc, transTable1) ); //} }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; long[] make_lucas() { long[] ls = [2,1]; for (int i = 2; i < 87; ++i) { ls ~= ls[i-1] + ls[i-2]; } return ls; } enum LS = make_lucas(); void main() { writeln(LS[readln.chomp.to!int]); }
D
void main() { long n, k; rdVals(n, k); long[] a = rdRow; long b = bsr(k << 1); long[] cnt = new long[b]; foreach (x; a) { foreach (i; 0 .. b) { if ((x >> i) & 1) ++cnt[i]; } } long x; foreach_reverse (i, c; cnt) { if ((x | (1L << ...
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.chomp; auto T = readln.chomp; long hatena = 0; foreach (s; S) if (s == '?') ...
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