code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio,std.array,std.conv,std.algorithm; void main(){ auto a=readln().split().map!(to!int); writeln(a[0]-(a[0]>a[1])); }
D
import std.stdio; import std.string; import std.format; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.concurrency; import std.traits; import std.uni; import c...
D
import std.stdio; import std.string; import std.algorithm; import std.array; import std.conv; int solve(int[] list) { while (list.length > 1) { int[] res = new int[](list.length - 1); for(int i = 0; i < list.length - 1; i++) { res[i] = (list[i] + list[i + 1]) % 10; } list = res; } return l...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.conv; void main() { auto s = readln.chomp; string res; foreach(i; s) { switch(i) { case '0', '1': res ~= i; break; case 'B': if(res.length != 0) res.popBac...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; void main() { auto n = readln.strip.to!int; auto s = readln.strip.splitter; auto a = s.front; s.popFront; auto b = s.front; foreach (i; 0 .. n) { write (a[i], b[i]); } writ...
D
import std.stdio, std.string, std.conv, std.algorithm; int abs(int x) { return (x >= 0) ? x : -x; } void main() { int N = readln.chomp.to!(int); int[][] a; for (int i = 0; i < N; i++) { a ~= readln.chomp.split.to!(int[]); } bool f = true; int t = 0, x = 0, y = 0; for (int i =...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; void main() { immutable n = readln.strip.to!long; ulong res; void check (long x) { --x; if (n / x == n % x) res += x; } for (int i = 2; i.to!long * i <= n; ++i) { check...
D
import std.stdio; import std.algorithm; import std.string; import std.array; import std.functional; import std.conv; import std.math; void main(){ while(true){ auto s = readln(); if(stdin.eof()) break; int n = to!int(s.chomp()); int[4001] arr; for(int i=0;i<=1000;i++){ for(int j=0;j<=1000;j++){ arr[i+j...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void main() { auto xt = readints; int x = xt...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; void main() { ((ushort[] ip) => ip[0] + ip[1] >= ip[2] ? "Yes" : "No")(readln.split.to!(ushort[])).writeln; }
D
void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1]; writeln(a >= 13 ? b : a >= 6 ? b / 2 : 0); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.typecons;
D
import std; enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;} T scan(T=long)(){return readln.chomp.to!T;} void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;} T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);} alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q...
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.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; bool f(int n) { ret...
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; long N, cnt; bool ask(long n) { writeln("? ", n); stdout.flush; cnt += 1; debug { string sn = n.to!string; ...
D
import std.algorithm, std.conv, std.range, 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 readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}} void readM(T...)(size_...
D
import std.algorithm, std.string, std.range, std.stdio, std.conv, std.math; long f(long b, long n) { return (n < b) ? n : f(b, n/b) + n % b; } long solve(long N, long S) { if (N < S) { return -1; } if (N == S) { return N + 1; } foreach (i; 2...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; size_t[][26] D; void main() { auto s = readln.chomp.to!(char[]); auto t = readln.chomp.to!(char[]); foreach (i, c; s) { D[c - 'a'] ~= i; } ulong cnt; size_t p; bool first = true...
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 x, y; scan(x, y); int ans = 1; while (2*x <= y) { x *= 2; ans++; } writeln(ans); } void scan(T...)(ref T ar...
D
import core.bitop, std.bitmanip; import core.checkedint; import std.algorithm, std.functional, std.meta; import std.array, std.container; import std.bigint; import std.conv; import std.math, std.numeric; import std.range, std.range.interfaces; import std.stdio, std.string; import std.typecons; void main() { auto s...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; import std.ascii; void main() { auto s = readln.chomp; if (s[2] == s[3] && s[4] == s[5]) { wr...
D
// unihernandez22 // https://atcoder.jp/contests/abc076/tasks/abc076_c // string manipulation import std.stdio; import std.string; void main() { string s = readln.chomp; string t = readln.chomp; long idx = -1; bool matched; for(long i = (s.count-t.count); i >= 0; i--) { if (s[i] == '?' || s[i] == t[0]) { mat...
D
import std.stdio; import std.ascii; void main() { int sum = 0; foreach (string input; stdin.lines) { auto num = 0; foreach (c; input) { if (c.isDigit) { num = (num * 10) + (c - '0'); } else { sum += num; num = 0; ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { string[] inputs = split(readln()); int a, b; foreach(v; inputs) { switch(v) { case "5": a++; break; case "7": b++; break; default: break; } } if(a == 2 && b == 1) "YES".writeln; else "NO".wr...
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 N = readln.chomp.to!int; auto cs = readln.chomp.to!(char[]); int c; int i, j = N-1; while (i < j) { while (i < N && cs[i] != 'W') ++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; long n, m; rd(n, m); long ans = 1; for (long k = 1; k * k <= m; k++) { if (m % k == 0) { if (n * k <= m) { ans = max(ans, k); } if (n * (m / k) <= m) { ans = max(ans, m / k); } } } writeln...
D
import std.stdio; import std.string; void main() { char[] s = readln.chomp.dup; char[] t = readln.chomp.dup; string ans = "No"; foreach (i; 0..s.length){ s = s[$ - 1] ~ s[0..$ - 1]; if (s == t){ ans = "Yes"; break; } } writeln(ans); }
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(){ writeln(totalSum(readln.chomp)); } long totalSum(string str){ long total=0; foreach(i,s;str){ auto num=[s].to!lo...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto abk = readln.split.to!(int[]); auto A = abk[0]; auto B = abk[1]; auto K = abk[2]; foreach_reverse (k; 1..101) { if (A % k == 0 && B % k == 0 && --K == 0) { ...
D
import std.stdio; int main() { for(int i=1; i<=9; i++) { for(int j=1; j<=9; j++) { writeln(i, "x", j, "=", i*j); } } return 0; }
D
import std.stdio, std.algorithm, std.range, std.conv; void main(){ iota(1, 10).map!(a => iota(1, 10).map!(b => text(a, "x", b, "=", a*b)).join("\n")).join("\n").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, 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.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; void main(){ int x, y; { int[] tmp = readln.chomp.split.map!(to!int).array; x = tmp[0], y = tmp[1]; } int ans1, ans2, ans3, ans4; if(y >= x) ans1 = y - x; else a...
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
// xxxxx import std.random; import std.stdio; void main () { rndGen.seed (unpredictableSeed); writeln (uniform (0, 2) ? "Even" : "Odd"); }
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
/+ dub.sdl: name "B" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; // import dcomp.modint; int main() { auto sc = new Scanner(stdin); int n; long a, b, c, d; sc.read(n, a, b, c, d); n--; foreach (i; 0..n...
D
// Vicfred // https://atcoder.jp/contests/abc162/tasks/abc162_b // simulation import std.conv; import std.stdio; import std.string; void main() { int n = readln.chomp.to!int; long sum = 0; foreach(i; 1..n+1) { if(i%3 != 0 && i%5 != 0) sum += i; } sum.writeln; }
D
void main() { long n, m, k; rdVals(n, m, k); foreach (i; 0 .. n+1) { foreach (j; 0 .. m+1) { long black = i * m + j * n -2 * i * j; if (black == k) { "Yes".writeln; return; } } } "No".writel...
D
import std.stdio; import std.string; import std.format; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.concurrency; import std.traits; import std.uni; import c...
D
import std.stdio; int[][int] graph; bool[int] used; void dependent(int n) { if (!used[n]) { foreach(i; graph[n]) { dependent(i); } writeln(n); used[n] = true; } } void main() { int m, n; scanf("%d\n%d\n", &m, &n); foreach(i; 1..(m + 1)) {graph[i] = []; used[i] = false;} foreach(i; ...
D
import std.stdio, std.string, std.conv; void main() { int[] tmp = readln.split.to!(int[]); int x = tmp[0], a = tmp[1]; writeln(x < a ? 0 : 10); }
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; void main(){ auto s=readln(); char x=s[0]; char y=s[2]; if(x<y) writeln("<"); else if(x>y) writeln(">"); else writeln("="); }
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; void main() { int m = readln.chomp.split.back.to!int; string s = readln.chomp; int l = 0, r = 1; // bool[string] set; bool[ulong[2]] set; auto hasher = new ...
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.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.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 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.array, std.algorithm, std.range; void main() { int[string] c; string mw; c[mw]=0; string ml; foreach(w;readln().split()) { if(w in c){ if(++c[w]>c[mw]) mw=w; } else c[w]=1; if(ml.length < w.length) ml=w; } writeln(mw...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio; import std.string; import std.algorithm; import std.conv; void main() { int N = readln.chomp.to!int; auto A = readln.chomp.split.map!(to!int); int ans = (1e9).to!int; foreach(a; A) { int tmp; while (a % 2 == 0 && a > 0) { tmp++; a /= 2; } ans = min(ans, tmp); ...
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 n; scan(n); writeln(n & 1 ? n * 2 : n); } void scan(T...)(ref T args) { import std....
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() { long n; long s; scan(n); scan(s); ...
D
import std.stdio; import std.conv; import std.algorithm; import std.range; import std.string; import std.math; import std.format; void main() { foreach (string line; stdin.lines) { int n = line.chomp.to!int; int cnt = 0; for (int a = 0; a <= 9; a++) { for (int b = 0; b <= 9; b++) { for (in...
D
void main() { string s = readln.chomp; long cnt; long times; foreach (i, c; s) { if (c == 'W') { times += i - cnt; ++cnt; } } times.writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; impo...
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 core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math, std.functional, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container, std.format; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return readln.split.to!(T[])();} ...
D
import std.stdio; import std.string; import std.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; char[] str; void main() { int N = readln.chomp.to!int; str = readln.chomp.to!...
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 k = "CODEFESTIVAL2016"; int cnt; foreach (i; 0..s.l...
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; import std.numeric; class InputReader { private: ubyte[] p; ubyte[] buffer; size_t cur; public: this () { ...
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]; int r; foreach (_; 0..2) { if (A > B) { r += A; --A; } else { r...
D
void main() { string s = rdStr; bool ok = true; foreach (i, x; s) { if (i & 1) { if (x != 'i') ok = false; } else { if (x != 'h') ok = false; } } if (s.length & 1) ok = false; writeln(ok ? "Yes" : "No"); } enum long ...
D
import std.conv, std.stdio, std.algorithm, std.string, std.range; void main() { const N = readln.chomp.to!int; foreach (x; 1..10) foreach (y; x..10) { if (x*y == N) { "Yes".writeln; return; } } "No".writeln; }
D
import std.algorithm, std.conv, std.range, 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 readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}} void readM(T...)(size_...
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 A = readln.chomp.to!(wchar[]); auto B = readln.chomp.to!(wchar[]); auto C = readln.chomp.to!(wchar[]); int r; foreach (i; 0..N) { auto...
D
void main(){ int n = _scan(); // 操作を行う回数 int k = _scan(); // 足す値 int ans = 1; foreach(elm; 0..n){ if(ans*2 < ans+k)ans *=2; else ans +=k; } writeln(ans); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 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 times(alias pred)(int n) { foreach(i; 0..n) pred(); } auto ...
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.7.4" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; // import dcomp.geo.primitive; bool solve() { alias P = Point2D!double; P[] pol = new P[3]; P p; foreach (i; 0..3) { double x, ...
D
import std.stdio; import std.range; import std.array; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.container; import std.typecons; import std.random; import std.csv; import std.regex; import std.math; import core.time; import std.ascii; import std.digest.sha; import std.outb...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; void main() { auto n = readln.chomp; int sum; for (int i = 0; i < n.length; ++i) { sum += (n[i] - '0'); } if (n.to!int % sum == 0) { "Yes".writeln; } else { "No".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 main() { int n, m, nq; readV(n, m, nq); ...
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; import std.range, std.algorithm, std.array; void main() { auto c = new string[](2); c[0] = readln.chomp; c[1] = readln.chomp; writeln(equal(c[0], c[1].retro) ? "YES" : "NO"); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algori...
D
void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1]; writeln(a < 9 && b < 9 ? "Yay!" : ":("); } 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.typ...
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 a, b, x; readV(a, b, x); writeln(a <= x && x <= a+b ? "YES" : "NO"); }
D
import core.stdc.stdio; import std.container; import std.algorithm; import std.typecons; import std.stdio; void main(){ int n,m,k; scanf("%d%d%d",&n,&m,&k); alias Tuple!(int,"cost",int,"to") ct; ct[][] graph = new ct[][n]; alias Tuple!(int,"a",int,"b",int,"l") edge; edge[] es = new edge[m]; foreach(ref e;es){ ...
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; immutable int INF = 1 << 29; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; ...
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
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm; void main(){ auto ip = readln.chomp; switch(ip){ case "A": writeln("T"); break; case "T": writeln("A"); break; case "C": writeln("G"); break; case "G": writeln("C"); break; default: }...
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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp.to!long; writeln(N * (N-1) / 2); }
D
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; import core.bitop; string my_readln() { return chomp(readln()); } long mod = pow(10, 9) + 7; long moda(long x, long y) { return (x + y) % mod; } long mods(long x, long y) { return ((x + mod) - (y % mo...
D
import std.stdio; import std.algorithm; import std.array; import std.conv; void main(){ string[] input = readln().split(); int a = input[0].to!int(), b = input[1].to!int(); while(b != 0){ a = a % b; swap(a, b); } a.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, core.stdc.string; void solve() { auto s = readln.split.map!(to!long); auto K = s[0]; auto X = s[1]; long ans; if (X == ...
D
import std.stdio; import std.algorithm; import std.array; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() { auto tokens = my_readln().split(); auto H = tokens[0].to!ulong; auto W = tokens[1].to!ulong; string[]...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.container; import std.array; import std.math; import std.range; import std.typecons; import std.ascii; import std.format; void main() { auto a = readln.chomp.split.map!(to!int); auto h = a[0]; auto w = a[1]; char[][] map = n...
D
import std.stdio, std.string, std.conv, std.math; void main() { int n = readln.chomp.to!int; long debt = 100000; foreach(i;0..n) { debt += debt * 0.05; debt = (((debt / 1000.0).ceil) * 1000).to!long; } debt.writeln; }
D
import std.stdio; import std.ascii; import std.conv; import std.string; import std.algorithm; import std.range; import std.functional; import std.math; import core.bitop; import std.numeric; void main() { auto k = readln.chomp.to!long; writeln((k/2) * (k - (k/2))); }
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[] lreads(T = long)(long n){ret...
D
void main() { writeln(readln.chomp.count('9') ? "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.typecons; import std.ascii; import std.uni;
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 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
import std.stdio, std.array, std.algorithm, std.string, std.conv, std.math; void main() { int n = readln.chomp.to!int; int[int] chie; auto b = map!(x => x.to!int)(readln.chomp.split); int res = 0; foreach (x; b) { ++chie[x]; } foreach (x, cnt; chie) { if (cnt >= x) { res += min(cnt - x, cnt...
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
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