code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio; import std.algorithm; import std.math; import std.conv; import std.string; T readNum(T)(){ return readStr.to!T; } T[] readNums(T)(){ return readStr.split.to!(T[]); } string readStr(){ return readln.chomp; } void main(){ bool finished = false; auto tax = readNums!int; foreach(i; 0 .. 1001)...
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.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.container; import std.datetime; void main() { while (1) { auto n = readln.chomp.to!int; if (!n) break; auto m = new int[][](n); foreach (i; 0..n) { ...
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 N = data[0].to!int; int[] prime_list = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,91,97]; if (1<=N && N<=...
D
import std.stdio; import std.string; import std.range; import std.conv; void main() { /*auto N = readln.chomp.to!int; auto D = readln.chomp.to!int; */ auto ip = readln.split.to!(int[]), D = ip[0], N = ip[1]; if(N==100){ writeln(101*100^^D); }else{ writeln(100^^D*N); } }
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(s.pr...
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() { int[3][3] c; foreach (i; 0..3) { c[i] = readln.chomp.split....
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, k; rd(n, k); auto dp=new int[][](4, k+10); const int mod=998244353; void add(ref int x, int y){ x+=y; if(x>=mod) x-=mod; } dp[0][1]=dp[3][1]=1; dp[1][2]=dp[2][2]=1; for(int i=1; i<n; i++){ auto nex=new int[][](4,...
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.algorithm, std.conv, std.array, std.string; void main() { auto a = readln.chomp; auto b = readln.chomp; writeln( a.length > b.length ? "GREATER" : a.length < b.length ? "LESS" : a > b ? "GREATER" : a < b ? "LESS" : "EQUAL" ); }
D
import std.stdio, std.algorithm, std.conv, std.string, std.array; void main() { const N = readln.chomp.to!long; auto ans = long.max; for (long i = 1; i*i <= N; ++i) { if (N%i == 0) ans = ans.min(i+N/i-2); } ans.writeln; }
D
import std.conv, std.stdio, std.string, std.array, std.range, std.algorithm; string s = "CODEFORCES"; void main() { char[] t = readln.strip.dup; int len; foreach (i, e; s) { if (e == t[i]) { ++len; } else { break; } } if (len == 10) { writeln("YES"); return; } len = 0; int j; 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; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; if (N == 2) { A.reduce!max.write...
D
import std.stdio; import std.algorithm; void main() { int w, h, n; scanf("%d\n%d\n%d", &w, &h, &n); write((n + max(w,h) - 1) / max(w, h)); }
D
void main() { long[] tmp = rdRow; long n = tmp[0], k = tmp[1]; long result = (n / k) ^^ 3; if (!(k & 1)) { result += ((n + k / 2) / k) ^^ 3; } result.writeln; } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdElem(T = long)() if (!is(T == struct)) { return readln.cho...
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
void main() { long n = rdElem; Input[] input = n.rdCol!Input; foreach (x; 0 .. 101) { foreach (y; 0 .. 101) { long h; foreach (a; input) { if (a.h) h = a.h + abs(a.x-x) + abs(a.y-y); } bool ok = true; ...
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.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(); } T readInt(T)() { retu...
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, 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 N = data[0].to!int, T = data[1].to!int; int cost = 10_000; foreach (i; 0 .. N) { data = readln.split; auto c = data[0].to!int, ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int a, b, h; scan(a); scan(b); scan(h); writeln((a + b) * h / 2); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; i...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long P = 10^^9+7; long pow(long x, long n) { long y = 1; while (n) { if (n%2 == 1) y = (y * x) % P; x = x^^2 % P; n /= 2; } return y; } void main() { auto nm = readln.sp...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; alias R = Tuple!(long, "x", long, "y", long, "p"); void main() { auto N = readln.chomp.to!int; R[] rs; foreach (_; 0..N) { auto r = readln.split.to!(long[]); aut...
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; import std.algorithm; import std.conv; import std.numeric; import std.math; import std.string; void main() { auto n = to!int(chomp(readln())); long[] t; foreach (i; 0..n) { t ~= to!long(chomp(readln())); } long lcm(long a, long b) { if (a < b) { auto tmp = a; a = b; b = tmp; ...
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); writeln(n*800-(...
D
void main() { long n, m, q; rdVals(n, m, q); long[] a = new long[q], b = new long[q], c = new long[q], d = new long[q]; foreach (i; 0 .. q) { rdVals(a[i], b[i], c[i], d[i]); --a[i], --b[i]; } long result; void dfs(long[] arr) { if (arr.length == n) ...
D
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random,std.concurrency; const dx = [1,0,-1,0], dy = [0,1,0,-1]; const readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(a...
D
import std.algorithm; import std.array; import std.bigint; import std.bitmanip; import std.conv; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } T[] readToArray(T)() { return readln.split.to!(...
D
import std.algorithm, std.string, std.range, std.stdio, std.conv; void main() { int N = readln.chomp.to!int; string S = readln.chomp; char l = '(', r = ')'; int ls, rs; int als; foreach (c; S) { if (c == l) { ls++; } else { rs++; } if (ls - rs...
D
void main(){ import std.stdio; auto x = readln.dup; x[3] = '8'; writeln(x); }
D
import std.stdio; import std.string, std.conv, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons; import core.bitop, std.datetime, std.range; void main(){ auto rd = readln.split.to!(int[]); auto n = rd[0], q = rd[1]; auto ds = new int[][](n, 1); auto n2s = iota(n).array; ...
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[]); char[] S; for (size_t i; i < s.length; ++i) { if (i < s.length-1 && s[i] == 'B' && s[i+1] == 'C') { S ~= 'X'; ++i; ...
D
void main() { string s = readln.chomp; char[] acgt = ['A', 'C', 'G', 'T']; int cnt, ans; foreach (x; s) { if (acgt.canFind(x)) { ++cnt; ans = max(ans, cnt); } else { ans = max(ans, cnt); cnt = 0; } } ans.writeln; } import s...
D
void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], k = tmp[1]; writeln((n + 1) / 2 >= k ? "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 std.t...
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 a, b, c; long k; scan(a, b, c, k); writeln(k & 1 ? b - a : a - b); } void scan(T......
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, a, b, c; scan(n, a, b, c); auto x =...
D
import std.stdio; import std.array; import std.conv; import std.string; import std.algorithm; void main() { string s; while( (s=readln.strip) != "0 0") { auto n = map!(to!int)(s.strip.split); int h = n[0], w = n[1]; foreach(i;0..h) { foreach(j;0..w) { write((i...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { auto n = readln.chomp.to!int; int[][] ab = new int[][](10,10); for(int i=1; i<=n; i++) { int a = i; while(a>=10) a/=10; int b = i%10; ab[a][b]++; } long result = 0; ...
D
import std.stdio; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.ascii; import std.concurrency; void times(alias fun)(int n) { // n.iota...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto args=readln.split.to!(int[]); if((args[2]-args[1])&1){ writeln("Borys"); }else{ writeln("Alice"); } } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); for...
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 std; 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); } void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); } string unsplit(T)(...
D
import std.algorithm; import std.conv; import std.numeric; import std.range; import std.stdio; import std.string; void main () { auto tests = readln.strip.to !(int); foreach (test; 0..tests) { auto s = readln.strip; auto t = readln.strip; auto m = s.length; auto n = t.length; auto g = gcd (m, n); auto x...
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 r = 0; ...
D
import std.stdio; import std.string; void main() { int a; scanf("%d\n", &a); auto s = readln.chomp; if (a >= 3200) s.write; else "red".write; }
D
import std.algorithm; import std.array; import std.ascii; import std.bigint; import std.complex; import std.container; import std.conv; import std.functional; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; auto readInts() { return array(map!(to!int)(readln().strip().split...
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); if (b%a ...
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 n = readln.chomp.to!int; auto s = readln.chomp; long rc, gc, bc; foreach (i; 0..n) { if (s...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; long P = 10^^9+7; long[10^^5+50] F, RF; void init() { F[0] = F[1] = 1; foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P; { RF[$-1] = 1; auto x = F[$-1]; auto k...
D
import std.algorithm; import std.conv; import std.stdio; import std.string; import std.typecons; alias Tuple!(int, "x", int, "y") Point; auto move = [[-1, 0], [0, 1], [1, 0], [0, -1]]; void main(){ string input; Point[200] points; points[0] = Point(0, 0); while((input = readln.chomp) != "0"){ ...
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
/+ dub.sdl: name "C" dependency "dcomp" version=">=0.6.0" +/ import std.stdio; // import dcomp.scanner; int main() { auto sc = new Scanner(stdin); long x; sc.read(x); long sm; foreach (i; 1..1000000) { sm += i; if (sm >= x) { writeln(i); break; ...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return r...
D
import std.stdio, std.string, std.conv, std.array, std.algorithm; void main() { auto S = readln.chomp.to!int; writeln(S/3600, ":", S % 3600 / 60, ":", S % 60); }
D
void main() { bool[string] dict; foreach(i; 0..ri) { auto ip = readln.split, command = ip[0], str = ip[1]; switch(command) { case "insert": dict[str] = true; break; case "find": if(str in dict && dict[str]) "yes".writeln; else "no".writeln; break; default: break; } } } // ====...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(T = long)() ...
D
import std.stdio; import std.string; import std.conv; int main() { while (true) { string[] s1 = readln.chomp.split; int n = s1[0].to!int; int m = s1[1].to!int; int a = s1[2].to!int; if (n == 0 && m == 0 && a == 0) break; int max = -1; int[1001][1001] N; ...
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; auto S = readln.chomp.to!(char[]); foreach (ref c; S) { auto x = c - 'A'; x = (x + N) % 26; c = ('A' + x).to!char; } writeln(S);...
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 w, h, a, b; void main() { scan(h, w, a, b); auto c = ModCombo(w + h); long ans; foreach (i ; 0 .. h -...
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, std.format; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } /* 誰の子にもなっていない頂点は、根 1人の子にな...
D
// Cheese-Cracker: cheese-cracker.github.io void solve(){ auto n = scan; auto arr = scanArray; long gcd1 = arr[0]; for(int i = 2; i < n; i += 2){ gcd1 = gcd(gcd1, arr[i]); } long gcd2 = arr[1]; for(int i = 3; i < n; i += 2){ gcd2 = gcd(gcd2, arr[i]); } show(gcd1, gcd...
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 X = to!ulong(tokens[0]); if (X == 7 || X == 5 || X == 3) writeln("YES");...
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() { readln; readln.chomp.split.map!(a=>a.to!int - 1).sum.writeln; }...
D
void main() { long a, b, k; rdVals(a, b, k); foreach (i; 0 .. k) { if (i & 1) { b >>= 1; a += b; } else { a >>= 1; b += a; } } writeln(a, " ", b); } enum long mod = 10^^9 + 7; enum long inf = 1L <<...
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!(long[]); writeln(iota(tmp[1] - tmp[0]).sum - tmp[0]); }
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 N = readln.chomp; writeln(to!char(N[0] + 1)); }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { char a, b; scan(a, b); writeln(a == b ? "H" : "D"); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primit...
D
import std.stdio,std.conv,std.string,std.algorithm,std.array; void main(){ auto a=readln(); auto b=readln(); auto c=readln(); char A,B,C; A=a[0]; B=b[1]; C=c[2]; write(A); write(B); write(C); writeln(); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import 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, 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 N; scan(N); auto x = new int[](N); a...
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; void main () { string s; while ((s = readln.strip) != "") { auto t = readln.split; bool ok = t.any !(r => r[0] == s[0] || r[1] == s[1]); writeln (ok ? "YES" : "NO"); } }
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 X = readln.chomp.to!long; auto K = readln.chomp.to!int + 2; auto RR = 0 ~ readln.split.map!(to!long).array ~...
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 T = readln.chomp.to!int; auto A = new int[](26); auto B = new int[](26); bool ok() { ...
D
import std.stdio; void main() { foreach (i; 0 .. 1000) writeln("Hello World"); }
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 std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto X = readln.chomp.to!long; long x = 100; foreach (t; 1..10000) { x = (x.to!double * 1.01).to!long; if (x >= X) { writeln(t); return; } ...
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 n = read(); auto hs = reads(); int ans = 1...
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.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.traits; import std.typecons; struct Word { string s; int last; } void main() { int[char] v = [ 'a' : 0, 'e' : 1, 'i' : 2, 'o' : 3, 'u' : 4 ]; int vo...
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); int [] [] board; foreach (row; 0..n * 2) { board ~= readln.splitter.map !(to !(int)).array; } a...
D
void main() { (ri < 1200 ? "ABC" : "ARC").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.typeco...
D
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math; void main() { auto nw = readln.split.to!(int[]); auto N = nw[0]; auto W = nw[1]; int[] vs, ws; foreach (_; 0..N) { auto vw = readln.split.to!(int[]); vs ~= vw[0]; ws ~= vw[...
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 c =...
D
import std.stdio; import std.typecons; import std.algorithm; void main() { long n, m; scanf("%ld %ld", &n, &m); Tuple!(long, long)[] ss; foreach(i;0..n) { long a, b; scanf("%ld %ld", &a, &b); ss ~= tuple(a, b); } ss.sort!((a, b) => a[0] < b[0]); long p; foreach(s; ss) { if (m <= 0) break; p += s[0] *...
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; enum MAX = 1_000_100; ulong MOD = 1_000_000_007...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container; void main() { int[32] a = [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]; a[readln.chomp.to!int-1].writeln; }
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex; void main() { auto N = readln.chomp.to!int; auto A = readln.chomp; foreach (i; 0..N-1) { if (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; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; void main() { int N; scan(N); auto a = readln.split.to!(int[]); a[] ...
D
void main(){ int p, q, r; scanf("%d %d %d", &p, &q, &r); min(p+q, p+r, q+r).writeln(); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] _scanln(T = int)(){ T[] ln; foreach(string elm; readln()....
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 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; void main() { int n = 0; int m = 0; scanf("%d %d", &n, &m); printf("%d %d\n", n*m, 2*(n+m)); }
D
// Cheese-Cracker: cheese-cracker.github.io void theCode(){ ll n = scan; auto arr = scanArray; ll odd = 0; for(int i = 0; i < 2*n; ++i){ if(arr[i] % 2 == 1){ ++odd; } } if(odd == n){ writeln("Yes"); }else{ writeln("No"); } } void main(){ ...
D
import std.stdio; import std.range; import std.array; import std.algorithm; import std.string; import std.conv; void main(){ auto n = readln().chomp().to!int(); auto s = readln(); solve(n, s).writeln(); } int solve(int n, string s){ int[] kindNums; foreach(cutPlace; 1..n) { auto right = s[...
D