code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio; import std.string; import std.conv; import std.range; import std.array; import std.algorithm; void main(){ auto ab = readln().chomp().split().map!(to!int).array(); ab.solve().writeln(); } int solve(int[] input){ auto a = input[0]; auto b = input[1]; if (b >= a){ return a;...
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; } /* ------------------------...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto s = readln.chomp; auto t = ""; foreach (c; s) switch (c) { case '0': case '1': t ~= c; break; case 'B': t = t.empty ? t : t[0..$-1]; break; default: assert(0); } writeln(...
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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.functional; void main() { auto N = readln.chomp.to!int; int cx = 0, cy = 0; int ct = 0; bool ok = true; foreach (i; 0..N) { auto tmp = readln.split.to!(int[]); if (!ok) continue; auto t = tmp[0]; au...
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() { immutable N = readln.chomp.to!long; long res; foreach (i; 1..N.to!real.sqrt.to!l...
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, A, B; scan(N, A, B); string s = readln.chomp; ...
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() { long x, a, b; scan(x, a, b); long A = abs(x - a); long B...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main(){ auto a=readln.split.to!(int[]),x=a[0],y=a[1]; writeln(x+y/2); }
D
import std; void main() { auto K = readln.split[0].to!int; auto AB = readln.split.to!(int[]); auto A = AB[0], B = AB[1]; foreach (i; A .. B+1) { if (i % K == 0) { writeln("OK"); return; } } writeln("NG"); }
D
void main() { string s = readln.chomp; string s1 = s[0..2], s2 = s[2..$]; bool yymm, mmyy; if ("01" <= s1 && s1 <= "12") mmyy = true; if ("01" <= s2 && s2 <= "12") yymm = true; if (yymm && mmyy) { writeln("AMBIGUOUS"); } else if (yymm && !mmyy) { writeln("YYMM"); } else i...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.format; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 =...
D
import std.stdio; import std.string; import std.array; // split import std.conv; // to void main() { string n = chomp(readln()); int a = to!int(n); if(a/100%10 == a/10%10 && (a/100%10 == a/1000 || a/100%10 == a%10)){ writeln("Yes"); } else { writeln("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, std.bitmanip; void main() { auto N = readln.chomp.to!int; auto S = N.iota.map!(_ => readln.chomp).array; long ans = 0; fore...
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
// 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; void main() { while (true) { scan(n); if (n == 0) break; writeln(solve(n)); } } in...
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() { long x; readV(x); auto ans = x/...
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 r = readln.chomp.to!int; auto g = readln.chomp.to!int; wr...
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; const long INF = 1L << 59; const long MOD = 10 ^^ 9 + 7; void main() { auto N = readln.chomp.to!int; auto edges = new Tuple!(int, ...
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 N = readln.split[0].to!int; auto S = readln.split[0].to!(dchar[]); auto K = readln.split[0].to!int; string ans = ""; auto c = S[K-1]; foreach (d; S) { if...
D
import std.stdio; import std.string; import std.conv; int main() { string[] str; while (true) { str = readln().split(); int num1 = str[0].to!int(); char op = str[1].to!char(); int num2 = str[2].to!int(); switch (op) { case '+': writeln(num1 + num2); break; ...
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 scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primiti...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto s = readln.chomp.to!ulong; bool[1000000] memo; foreach (i; 0..1000000) { memo[s] = true; auto a = s & 1 ? (3*s+1) : (s/2); if (memo[a]) { writeln(i+2);...
D
import std.stdio; import std.string; import std.conv; void main() { double[] weight = [48, 51, 54, 57, 60, 64, 69, 75, 81, 91]; string[] names = ["light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"]; while(true) { string ...
D
import std.stdio; import std.regex; void main(){ auto io = new IO(); auto N = io.line()[0]; auto K = io.line()[0]; auto X = io.line()[0]; auto Y = io.line()[0]; size_t fee = 0; if( N>K ){ fee += K*X; fee += (N-K)*Y; }else{ fee += N*X; } writeln(fee); return; } import std.stdio,std.conv,std.stri...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!int; auto a = readln.chomp.to!int; writeln(n * n - a); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { auto S = readln.chomp.to!(wchar[]); auto T = readln.chomp.to!(wchar[]); foreach (_; 0..101) { if (S == T) { writeln("Yes"); return; } S = [S[$-1]] ~ S[0.....
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.ascii; import std.algorithm; import core.stdc.stdio; int main() { auto t = readInt!int; foreach(ti; 0 .. t) { int[4] s; s[0] = readInt!int; s[1] = readInt!int; s[2] = readInt!int; s[3] = readInt!int; if (min(s[2], s[3]) > max(s[0]...
D
import std.stdio, std.range, std.conv, std.string; import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting; struct Strut{ long A; long B; } void main() { long[] input = readln().split.to!(long[]); long A = i...
D
// Vicfred // https://atcoder.jp/contests/abc052/tasks/abc052_b // simulation import std.algorithm; import std.conv; import std.stdio; import std.string; void main() { int n = readln.chomp.to!int; string s = readln.chomp; int maxima = 0; int x = 0; foreach(ch; s) { if(ch == 'I') ...
D
void main(){ long n = _scan!long(); for(int i;; i++){ if(i*i>n){ ( (i-1)*(i-1) ).writeln(); break; } } } 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; for...
D
/+ dub.sdl: name "B" dependency "dunkelheit" version="1.0.1" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; int main() { Scanner sc = new Scanner(stdin); scope(exit) assert(!sc.hasNext); int a, b, c, d; sc.read(a, b, c, d); int ans = 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; string[] operators = ["=","(", ")", "+", "-", "*", "/"]; bool isOperator(string s) { return operators.canFind(s); } int priority(string op) { int i =...
D
import std.stdio; import std.algorithm; int[] readArray(int n) { int[] a = new int[n - 1]; int start = -1; for (int i = 0, j = 0; i < n; i++) { int x; scanf("%d", &x); if (x == 1) { start = j; } if (x != 0) { a[j++] = x; } } int[] res = new int[n - 1]; for (int i = 0, j = star...
D
import std.algorithm; import std.conv; import std.math; import std.range; import std.stdio; import std.string; bool isSquare (int n) { auto p = cast (int) (sqrt (n * 1.0) + 0.5); return p * p == n; } void main () { auto tests = readln.strip.to !(int); foreach (test; 0..tests) { auto n = readln.strip.to !(int);...
D
import std.stdio, std.algorithm, std.array, std.string, std.conv; void main() { int t; scanf("%d", &t); foreach(_; 0..t) { long n; scanf("%lld", &n); getchar(); writeln(-1 * (n - 1), ' ', n); } }
D
import core.bitop; import std.algorithm; import std.array; import std.container; import std.conv; import std.exception; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void main () { string s; while ((s = readln.strip) != "") { ...
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; class InputReader { private: ubyte[] p; ubyte[] buffer; size_t cur; public: this () { buffer = uninitializ...
D
module main; import std.stdio; import std.string; int main(string[] argv) { int n, j = 0; scanf("%d", &n); int [] a = new int[n]; for(int i = 0; i < n; i++) { scanf("%d", &a[j]); while(j > 0 && a[j] == a[j - 1]) { a[j - 1]++; a[j] = 0; j--; } ...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a = new char[][](n); foreach (i; 0 .. n) { a[i] = readln.chomp.to!(char[]); } if (a[0][0] == '.' || a[0][n - 1] == '.' || a[n - 1][0] == '.' || a[n - 1][n - 1] == '.') { writeln("NO"); return; } for (i...
D
void main() { int[] tmp = readln.split.to!(int[]); int h = tmp[0], w = tmp[1]; string[] s = new string[h]; foreach (i; 0 .. h) { s[i] = readln.chomp; } foreach (i; 0 .. 2*h) { s[i/2].writeln; } } import std.stdio; import std.string; import std.array; import std.conv; import ...
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); long ans; foreach (i ; 1 .. N + 1) { ...
D
import std.stdio, std.string, std.conv, std.algorithm; void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1]; max(a+b, a-b, a*b).writeln; }
D
void main(){ string[] str = readln().chomp().split(); if( str[0] > str[1] )writeln(">"); else if( str[0] < str[1] )writeln("<"); else 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...
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 h, w; scan(h, w); int a, b; scan(a,...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nr = readln.split.to!(int[]); auto N = nr[0]; auto R = nr[1]; if (N >= 10) { writeln(R); } else { writeln(R + 100 * (10-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() { int n; readV(n); auto dp1 = new...
D
void main() { long h = rdElem; long cnt = 1; long result; while (h) { h >>= 1; result += cnt; cnt <<= 1; } result.writeln; } T rdElem(T = long)() if (!is(T == struct)) { return readln.chomp.to!T; } alias rdStr = rdElem!string; alias rdDchar = rdElem!(dchar[]);...
D
import std.stdio; import std.string; import std.conv; void main() { for (int i = 1; ; i++) { int a = to!(int)(chomp(readln())); if (a != 0) { writeln("Case ", i, ": ", a); } else { break; } } }
D
import std; void main() { int n; string s; scan(n); scan(s); auto w = new int[](n + 1); auto b = new int[](n + 1); foreach (i; 1 .. n + 1) { b[i] = b[i-1] + (s[i-1]=='#'); } foreach_reverse (i; 0 .. n) { w[i] = w[i+1] + (s[i]=='.'); } auto ans = 1_000_000_000; foreach (i; 0 .. n + 1) { ...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { int n; scanf("%d\n", &n); int[][] g = new int[][n]; int[] degree = new int[n]; foreach (i; 0..n-1) { int x, y; scanf("%d %d\n", &x, &y); --x; ...
D
void main() { problem(); } void problem() { auto a = scan!long; long solve() { return a == 0 ? 1 : 0; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.type...
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
//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.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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ...
D
import std.stdio, std.string, std.array, std.conv; void main() { int n = readln.chomp.to!int; int[] h = readln.split.to!(int[]); bool ok = true; int cnt = 1; foreach (i; 1 .. n) { if (h[i] > h[i-1]) { ++cnt; } else if (h[i] < h[i-1]) { if (h[i-1] - h[i] > cnt...
D
import std.stdio, std.string, std.algorithm, std.range, std.conv; void main() { auto N = readln.chomp.to!int; if(N%2==1) { writeln(N*2); } else { writeln(N); } }
D
import std.stdio, std.string, std.conv; void main() { writeln(readln.chomp.to!int ^^ 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; import std.ascii; void main() { auto a = readln.chomp.split.to!(int[]); if (a[0] <= a[2] && a[1]...
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.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.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 (a < ...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; import std.numeric; void main() { int k = readln.chomp.to!int; long sum = 0; for(int i=0; i<k; i++) for(int j=0; j<k; j++) for(int l=0; l<k; l++) { sum += gcd(i+1, gcd(j+1, l+1)); ...
D
import std.stdio; import std.algorithm; import std.math; import std.string; import std.conv; import std.range; void main() { while (true) { int n = readln.chomp.to!int; if (n == 0) break; int[] ice = new int[10]; foreach (i; 0..n) { ice[readln.chomp.to!int]++; }...
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() { long h, w; scan(h, w); auto a = new string[](h); 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, std.datetime; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; auto W = new int[](N+1); aut...
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, 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 a, b, c, d; scan(a, b, c, d); foreach (i; 0 .. 1000) {...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { string s = readln.chomp; if(s[0]=='7' || s[1]=='7' || s[2]=='7') writeln("Yes"); else writeln("No"); }
D
import std.stdio, std.conv, std.string; void main() { int N, K; N = readln().chomp().to!(int); K = readln().chomp().to!(int); int res = 1; foreach(int i; 0..N) { if(res + K < res*2) { res += K; } else { res *= 2; } } writeln(res); }
D
import std.stdio; import std.string; import std.conv; void main() { auto X = readln.split.to!(int[]),A = X[0],B = X[1]; if((A + B) % 2 == 0) { writeln((A + B) / 2); } else { writeln((A + B) / 2 + 1); }}
D
// Vicfred // https://atcoder.jp/contests/abc047/tasks/arc063_a // greedy import std.stdio; import std.string; void main() { string s = readln.strip; long n = s.length; long count = 0; for(long i = 0; i < s.length-1; i++) { if(s[i] != s[i + 1]) count += 1; } count.writeln; }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; scan(n); int ans; int ls, rs; ans = query(0); if (ans == 2) return; ls = ans; ans = query(n-1); if (ans == 2) return; rs = ans; int left = 0, right = n - 1; whil...
D
import std.conv; import std.stdio; import std.string; void main() { auto ab = readln.split.to!( int[] ); writeln( solve( ab[ 0 ], ab[ 1 ] ) ); } auto solve( in int a, in int b ) { return ( a <= 8 && b <= 8 ) ? "Yay!" : ":(" ; } unittest { assert( solve( 5, 4 ) == "Yay!" ); assert( solve( 8, 8 ) == "Yay!" ); a...
D
void main(){ int a, b, x; scanf("%d %d %d", &a, &b, &x); writeln(a+b>=x&&a<=x?"YES":"NO"); } 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行に同一型の複数入力 T[] inl...
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[]); writeln(ab[0] < 10 && ab[1] < 10 ? ab[0] * ab[1] : -1); }
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; ulong MOD = 1_000_000_007; ulong INF = 1_000_00...
D
void main() { // ((A, B) => A > B ? "GREATER" : A < B ? "LESS" : "EQUAL")(BigInt(rs), BigInt(rs)).writeln; auto A = rs, B = rs; if(A.length == B.length) { if(A[0] > B[0]) writeln("GREATER"); else if(A[0] == B[0]) writeln("EQUAL"); else writeln("LESS"); } else { if(A.length > B.length) writeln("GREATER"); ...
D
void main() { import std.stdio; (readln>"2019/05"?"TBD":"Heisei").writeln; }
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 N = readln.split[0].to!int; if (N == 1) { writeln("Hello World"); } else if (N == 2) { auto A = readln.split[0].to!int; auto B = readln.split[0].to!int; w...
D
void main() { string n = readln.chomp; int total; foreach (d; n) { total += d - '0'; } if (total == 1) total *= 10; total.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;...
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() { int n...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto N = readln.chomp.to!int; auto T = new int[][N]; foreach (_; 1..N) { auto ab = readln.split.to!(int[]); auto a = ab[0]-1; auto b = ab[1]-1; ...
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; static import std.ascii; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return r...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.container; import std.array; import std.math; import std.range; import std.typecons; import std.ascii; import std.format; void main() { int[101] imos; auto d = readln.chomp.split.map!(to!int); imos[d[0]]++; imos[d[1]]--; i...
D
import std.stdio, std.ascii; void main() { auto d = stdin.readln.dup; foreach (c; d) { if (c.isLower) c -= 32; else if (c.isUpper) c+= 32; c.write; } }
D
import std.stdio; import std.string, std.conv, std.array, std.algorithm; import std.uni, std.math, std.container; import core.bitop, std.datetime; void main(){ auto s = readln.chomp; auto n = s.length.to!int; if(n == 2){ if(s[0] == s[1]){ writeln(1, " ", 2); return; ...
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() { int n; scan(n); writeln(24 + 24 - n); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { a...
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.string, std.range, std.array, std.algorithm; import std.bigint; bool[1000001] p; void main() { int[10002] sum; p[2 .. 1000001] = true; for (int i = 2; i <= 1000000; i++){ if (p[i]){ for (int j = i * 2; j <= 1000000; j += i){ p[j] = false; } } } fo...
D
import std.stdio; import std.array; import std.conv; import std.algorithm; void main() { while ( true ) { string[] line = split( readln() ); int n = to!int( line[ 0 ] ); int q = to!int( line[ 1 ] ); if ( n == 0 && q == 0 ) break; int[ 101 ] date; foreach ( i; 0 .. n ) { line = split( readln() ); int m = ...
D
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons; const dx = [1,0,-1,0]; const dy = [0,1,0,-1]; void read(T...)(auto ref T args){ auto line = readln().split(); foreach(i,ref arg; args) arg = line[i].to!(typeof(arg)); } int sum(int n){return n * (n + 1)/ 2;} void ma...
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
void main() { long n = readln.chomp.to!int; long mod = 10 ^^ 9 + 7; long power = 1; foreach (i; 1 .. n+1) { power = power * i % mod; } power.writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import...
D
import std.stdio; import std.array; import std.conv; import std.math; import std.algorithm; void main() { string[] input = split(readln()); int w = to!int(input[0]), h = to!int(input[1]), n = to!int(input[2]), ans = 0; input = split(readln()); int x = to!int(input[0]), y = to!int(input[1]); for(auto i = 0...
D
/+ dub.sdl: name "F" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; // import dcomp.array; immutable long MD = 10^^9 + 7; int main() { auto sc = new Scanner(stdin); int q; sc.read(q); long[2][] base = [...
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 int inf = mod; void main(){ int N, W; readVars(N, W); auto v = new int[](N); au...
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; foreach (i; 1..8) { auto p = 2 ^^ i; if (p > ...
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 = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = (...
D