code
stringlengths
4
1.01M
language
stringclasses
2 values
//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; void main() { auto n = readln.strip.to!int; auto s = readln.strip[0 .. n]; foreach (i; 1 .. n) { if (s[i-1] > s[...
D
import std.algorithm; import std.array; import std.bigint; import std.conv; import std.exception; import std.math; import std.numeric; import std.random; import std.range; import std.stdio; import std.string; import std.typecons; import core.bitop; immutable int NA = -1; immutable string A = "ABCDEFGHIJKLMNOPQRSTUVWXY...
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
// cheese-cracker [2022-02-06] void solve(){ long n = scan; long k = scan; if(k == 1 || (n % 2 == 0)){ writeln("YES"); }else{ writeln("NO"); return; } long m = n * k; long x = 1; for(int i = 0; i < n; ++i){ for(int j = 0; j < k; ++j){ write(x...
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.algorithm; void main() { int n; scanf("%d", &n); int a, cnt1, cnt0; for (int i = 0; i < n; ++i) { scanf("%d", &a); if (a & 1) ++cnt1; else ++cnt0; } int ans = min(cnt0, cnt1); cnt1 -= ans; ans += cnt1 / 3; printf("%d", ans); }
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n, m, r; rd(n, m, r); auto a = readln.split.to!(int[]); auto b = readln.split.to!(int[]); auto dp = new int[][](n + 1, r + 1); for (int i = 0; i <= n; i++) { fill(dp[i], -1); } dp[0][0] = 0; foreach (i; 0 .. n) { for ...
D
import std.stdio, std.string, std.algorithm; void main() { immutable s1 = readln.chomp; immutable s2 = readln.chomp; int[][] dp = new int[][](s1.length+1, s2.length+1); for( int i=0; i<=s1.length; ++i ) dp[i][0] = i; for( int i=0; i<=s2.length; ++i ) dp[0][i] = i; for( int i=1; i<=s1.l...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; struct UFTree(T) { struct Node { T parent; T rank = 1; } /// T min_size, max_size; /// this(T n) { nodes.length = n; sizes.l...
D
import std.conv,std.stdio,std.math,std.string;void main(){readln.chomp.to!int.pow(2).writeln;}
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() { string s; scan(s); writeln(s.canFind("AC") ? "Yes" : "No"); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args)...
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
// 提出解 void solve(){ foreach(_; 0 .. scan!int){ long n = scan!long, m = scan!long; long ans; if(n == 1 && m == 1) ans = 0; else if(n == 1 || m == 1) ans = 1; else ans = 2; ans.print; } } // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- // // 愚直解 void jury(){ } // ----- ----- -...
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
/* imports all std modules {{{*/ import std.algorithm, std.array, std.ascii, std.base64, std.bigint, std.bitmanip, std.compiler, std.complex, std.concurrency, std.container, std.conv, std.csv, std.datetime, std.demangle, std.encoding, std.exception, std.file, std.format, std.functi...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); alias route...
D
import std.stdio, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; void main() { immutable x = readln.split.to!(int[]); (x.countUntil!"a == 0" + 1).writeln; } void scan(T...)(ref T args) { auto line = readl...
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; void main() { auto x_y = readln.to!(wchar[]); writeln(x_y[0] > x_y[2] ? ">" : x_y[0] < x_y[2] ? "<" : "="); }
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; } const long mod = 1_000_000_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.string; immutable long BASE = 31; immutable long MOD = 10^^9 + 9; immutable long BASE_INV = powmod(BASE, MOD-2, MOD); void main()...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto H = readln.chomp.to!long; long d, x = 1; while (H) { d += x; x *= 2; H /= 2; } writeln(d); }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; alias Pair = Tuple!(int, "a", int, "b"); void main() { ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { for (;;) { auto rd = readln.split.map!(to!int), m = rd[0], f = rd[1], r = rd[2]; if (m == -1 && f == -1 && r == -1) break; if (m == -1 || f == -1) writeln("F"); else if (m + f >= 80) writeln("A"); else if...
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, 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.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; scan(a, b); auto ans = a * (a - 1) / 2 + b * (b ...
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, 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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.typecons; int n; rd(n); int m; rd(m); auto lose=new int[](n), g=new int[][](n); foreach(i; 0..m){ int a, b; rd(a, b); g[a-1]~=(b-1); lose[b-1]++; } bool multi=false; auto used=new bool[](n); foreach(_; 0..n...
D
import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm; void main() { int n = readln().chomp().to!int; string minS = readln().chomp(); for (int i = 0; i < n - 1; i++){ string dic = readln().chomp(); if (dic < minS){ minS = dic; } } writeln(minS); }
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
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.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 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.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.stdio; import std.conv; import std.string; void main() { string s = readln().chomp; if (s[$ - 1] == '0' || s[$ - 1] == '2' || s[$ - 1] == '4' || s[$ - 1] == '6' || s[$ - 1] == '8' ) { writeln(s); } else { writeln(s.to!(int) * 2); } }
D
import std.stdio, std.string, std.range, std.algorithm, std.math, std.typecons, std.conv; void main() { auto a = readln.split.to!(int[]); ((a[0] <= a[2] && a[2] <= a[1]) ? "Yes" : "No").writeln; }
D
void main() { auto S = rs; ulong[] arr = new ulong[](S.length); arr[0] = S[0] == 'B' ? 1 : 0; foreach(i, v; S[1..$]) arr[i+1] = arr[i] + (v == 'B' ? 1 : 0); ulong res; foreach(i, v; S[1..$]) { if(v == 'W') res += arr[i]; } // arr.writeln; res.writeln; } // =================================== import std.std...
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 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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp.to!int; auto as = readln.split.to!(int[]); int[][] T; T.length = N; foreach (_; 1..N) { auto uv = readln.split.to!(int[]); auto u = uv[0]-1; ...
D
import std.algorithm; import std.array; import std.ascii; 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 log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } void main() ...
D
import std.stdio; import std.conv; import std.array; import std.math; import std.algorithm; import std.string; public int gcd(int m, int n) { if ((m == 0) || (n == 0)) return 0; while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } public int lcm(int m, int n) { if ((m == 0) || (n == 0)) re...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.conv; import std.stdio; import std.string; struct Input { string s; } void parseInput(T)(out Input input, T file) { with (file) with (input) { s = readln().strip(); } } struct Output { } auto main2(Input* 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() { int n, m; readV(n, m); auto g =...
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 s; scan(s); int n = s.length.to!int; if (n % 2)...
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() { string s; scan(s); foreach (i ; 0 .. s.length) { if (i & 1 ^ 1) { write(s[i]); } } writeln(); } void scan...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { long n = readln.chomp.to!long; long[] a = readln.chomp.split.to!(long[]); long[] count = new long[n]; foreach(ai;a) count[ai-1]++; foreach(ci;count) writeln(ci); }
D
void main() { auto a = ri; writeln(a + a*a + a*a*a); } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; import std.container; import std.bigint; import std.numeric; import std.conv; import s...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.stdio, 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 L; scanf("%d", &L); int n = 20, m = (n-2)*2; int l = L; foreach (i; 0..n) { m += l&1; if (i == n-1) m += l&1; l >>= 1; } w...
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 = N.iota.map!(_ => readln.chomp.to!int).array; auto dp = new bool[][](N+1, 1...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.15f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv, std.typecons, std.math, std.container, std.format; void main(string[] args) { if (readln.split.to!(long[]).sum >= 22) { writeln("bust"); } else { writeln("win"); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto ab = readln.split.to!(float[]); writeln(ceil((ab[0] + ab[1]) / 2).to!int); }
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.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; void main() { string s; long k; scan(s); scan(k); k--; int pos = -1; char nm = '1'; foreach (i ; 0 .. s.length) { if (s[...
D
import std.stdio,std.string,std.conv; void main(){ auto input=readln.chomp.split; auto n=input[0].to!ulong; auto a=input[1].to!ulong; auto b=input[2].to!ulong; auto ans=n/(a+b)*a; ans+=n%(a+b)>a?a:n%(a+b); writeln(ans); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { auto xyz = readln.split.to!(int[]); int c; xyz[0] -= xyz[2]; while (xyz[0] >= xyz[1] + xyz[2]) { xyz[0] -= (xyz[1] + xyz[2]); ++c; } writeln(c); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio, 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, 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
//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.array, std.conv; void main() { long n = readln.chomp.to!long; int[] a = new int[32]; int[] b = new int[32]; int[] c = new int[32]; int[] d = new int[32]; long m = n << 1; long l = n >> 1; foreach_reverse (i; 0 .. 32) { a[i] = n & 1; b[i]...
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(){ import std.stdio, std.string, std.conv, std.algorithm; import std.numeric; long a, b, x, y; rd(a, b, x, y); auto g=gcd(x, y); x/=g; y/=g; writeln(min(a/x, b/y)); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split, n = rd[0].to!size_t, a = rd[1].to!long, b = rd[2].to!long; auto x = readln.split.to!(long[]); auto ans = 0L; foreach (i; 0..n-1) ans += min((x[i+1]-x[i])*a, b); writeln(ans); }
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[2][10^^5*2] DP; void main() { auto S = readln.chomp.to!string; foreach_reverse (i; 0..S.length) { if (i == S.length-1) { DP[i][0] = 1; DP[i][1] = int.min; } else ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=readln.split.to!(int[]); auto freq=new int[](105); foreach(e; a) freq[e]++; int nice=0; foreach(e; freq){ if(e==1) nice++; } if(nice&1){ if(n==nice){ writeln("NO"); return; } bool o=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; immutable long INF = 1L << 60; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto X = s[1].to!long; 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() { int n = readln.chomp.to!int; if (n == 1) { "Hello World".writeln; } else { writeln(readln.chomp.to!int + 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.co...
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 a = readln.chomp.split.to!(int[]); int cnt=1, ...
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; int ds(int x) { int ret = 0; while (x > 0) ret += x % 10,...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { int N = to!int(chomp(readln())); int res; for(int i = 0; i <= N; i++) { res += i; } res.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; void main() { auto x = readln.chomp.split.to!(int[]); auto a = max(x[0], x[2]); auto b = min(x[...
D
/+ dub.sdl: name "C" 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); scope(exit) assert(!sc.hasNext); int n; sc.read(n); int[] a, b; sc.read(a, b); ...
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.conv,std.string; void main() { auto num = readln.strip.to!long; if (num < 1200) { writeln("ABC"); } else if (num < 2800) { writeln("ARC"); } else { writeln("AGC"); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void main() { auto nm = readln.split.to!(int[]); auto N = nm[0]; auto M = nm[1]; long x = 1; int c; foreach (a; readln.split.to!(long[])) { auto y = x / gcd(...
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; bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); } void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; import std.numeric; 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...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int m; rd(m); writeln(24+(24-m)); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } } void wr(T...)(T x){ import st...
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, c, d; readV(a, b, c, d);...
D
import std.stdio,std.string,std.conv; int main() { string[char] ID; ID[' '] = "101"; ID['\''] = "000000"; ID[','] = "000011"; ID['-'] = "10010001"; ID['.'] = "010001"; ID['?'] = "000001"; ID['A'] = "100101"; ID['B'] = "10011010"; ID['C'] = "0101"; ID['D'] = "0001"; ID['E'] = "110"; ID['F'] = "01001"; ID[...
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() { string n = readln.chomp; writeln(n.canFind('9') ? "Yes" : "No"); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args...
D
void main() { long n, ma, mb; rdVals(n, ma, mb); Medicine[] m = n.rdCol!Medicine; long limit = 10 * n + 1; long[][][] dp = new long[][][](n+1, limit, limit); foreach (i; 0 .. n+1) { foreach (j; 0 .. 10*n+1) { dp[i][j][] = inf; } } dp[0][0][0] = 0;...
D
// import chie template :) {{{ import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons, std.format; // }}} // nep.scanner {{{ class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; impor...
D
void main() { auto N = ri; fact(N).writeln; } ulong fact(ulong n) { if(n<=1) return 1; else return n*fact(n-1)%(10UL^^9 + 7); } // =================================== import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.bigin...
D
// Try AtCoder // author: Leonardone @ NEETSDKASU import std.algorithm : min; import std.stdio : readln, writeln; import std.string : chomp; import std.array : split; import std.conv : to; auto gets(T)() { return readln.chomp; } auto getVals(T)() { return readln.chomp.split.to!(T[]); } vo...
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 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
const long mod=998244353; const int M=1_000_00*4; void main(){ import std.stdio, std.algorithm; long n, a, b, k; rd(n, a, b, k); auto fact=genFact(M, mod); auto invFact=genInv(fact, mod); long comb(long nn, long rr){ if(nn<rr) return 0; long ret=fact[nn]%mod; (ret*=invFact[rr])%=mod; (re...
D
import std.stdio; import std.string; enum conv = [ 'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000 ]; void main() { foreach (input; stdin.byLine()){ int total = 0; if (input.length == ...
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 AS = readln.split.to!(long[]); long SUM; foreach (a; AS) SUM += a; long x; foreach (a; AS) { if (x + a >= SUM/2) { writeln(...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); long bignum...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!int; writeln(n * 800 - (n/15) * 200); }
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(); } void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE...
D