code
stringlengths
4
1.01M
language
stringclasses
2 values
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; // dfmt off T lread(T=long)(){return readln.chomp.to!T;} T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;} T[] aryread(T=long)(){return readln.split.to!(T[]);} void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;} void scan(TList...)(ref TList Args){auto line =...
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 n, m; scan(n, m); long max_x = long.min; long min_x...
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.string,std.conv,std.array,std.algorithm; void main(){ readln(); auto arr = readln().chomp().split(); reverse(arr); arr.join(" ").writeln(); }
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.algorithm; import std.conv; import std.numeric; import std.math; import std.string; void main() { auto tokens = split(chomp(readln())); auto n = to!int(tokens[0]); auto m = to!int(tokens[1]); int[][] nodes; nodes.length = n; foreach (i; 0..m) { auto tokens2 = split(chomp(readln())...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; long n; rd(n); for(long a=1; a<=3500; a++)for(long b=1; b<=3500; b++){ auto x=4*a*b-n*a-n*b; if(x<=0) continue; auto y=n*a*b; if(y%x==0){ writeln(a, " ", b, " ", y/x); return; } } } void rd(T...)(ref T x){ imp...
D
import std.stdio; import std.array; import std.conv; void main() { auto input = split(readln()); int a = to!(int)(input[0]); int b = to!(int)(input[1]); if (a < b) writeln("a < b"); else if (a > b) writeln("a > b"); else writeln("a == b"); }
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 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.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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto n=readln.chomp.to!(char[]); int sum1=0; foreach(c; n) sum1+=(c-'0'); if(n.length>1){ int tmp=(n[0]-'0')-1; tmp+=(n.length.to!(int)-1)*9; sum1=max(sum1, tmp); } writeln(sum1); } void rd(T...)(ref T x){ import std.st...
D
void main() { long n = rdElem; long[] a = rdRow; long[long] cnt; foreach (x; a) { ++cnt[x]; } long total; long[long] list; foreach (key, val; cnt) { list[key] = val * (val - 1) / 2 - (val - 1) * (val - 2) / 2; total += val * (val - 1) / 2; } for...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[][10^^5] G; bool[3][10^^5] F; alias S = Tuple!(int, "p", int, "c"); void main() { auto nm = readln.split.to!(int[]); auto N = nm[0]; auto M = nm[1]; foreach (_; 0..M) { auto uv = readln....
D
import std.stdio, std.conv, std.string, std.array; bool f(int[] nList, int i, int m) { if(m == 0) return true; if(m < 0) return false; if(i == nList.length) return false; return f(nList, i+1, m) || f(nList, i+1, m-nList[i]); } void main() { readln(); int[] nList = readl...
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, k, q; scan(n, k, q); auto a = iota(...
D
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(){ auto nm = readNums!int; auto ks = new int[][](nm[1]); foreach(i; ...
D
void main(){ int n=_scan(); int d, ans; int[int] dic; foreach(i; 0..n){ d = _scan(); if(dic.get(d, 0)==0){ ans++; } dic[d]++; } ans.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行に同一...
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.string, std.conv; import std.range, std.algorithm, std.array; void main() { int a, b, c; scan(a, b, c); writeln(b - a == c - b ? "YES" : "NO"); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import ...
D
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv; void main() { string s = readln.chomp; auto cur = s.length / 2; char pi = s[cur]; if (s.length % 2 == 0) { while (cur < s.length && pi == s[$ - cur - 1] && pi == s[cur]) { ++cur; } } else { ++cur; while (cur < ...
D
import std.stdio, std.string, std.conv, std.math, std.algorithm; void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], d = tmp[1]; int[][] x = new int[][](n); foreach (i; 0 .. n) { x[i] = readln.split.to!(int[]); } int[] square; for (int i = 1; i * i <= 16000; ++i) { ...
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 s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1]; auto A = readln.split.map!(to!int).array; ...
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); auto cnt = new int[](3); foreach (ch ; s) { cnt[ch - 'a']++; } cnt.sort(); writeln(cnt[2] - cnt[0...
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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto tmp = readln.split.to!(long[]); auto N = tmp[0], K = tmp[1]; auto xs = readln.split.to!(long[]); long minTime = long.max; foreach (i; 0..N-K+1) { auto j = i + K - 1; ...
D
import std.stdio; import std.algorithm; import std.conv; import std.array; import std.string; import std.math; import std.functional; import std.range; import std.typecons; import std.format; import std.bigint; void main(string[] args) { readln.solve.writeln; } auto solve(string line1) { auto _ = line1.chomp.spli...
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
// Vicfred // https://atcoder.jp/contests/dp/tasks/dp_a // dynamic programming import std.algorithm; import std.array; import std.conv; import std.math; import std.stdio; import std.string; void main() { const long n = readln.chomp.to!long; const long[] h = 0~readln.split.map!(to!long).array; long[] dp = ...
D
import std.stdio; import std.conv; import std.string; void main() { char[] buf; int a; stdin.readln(buf); a = to!(int)(chomp(buf)); a = a * a * a; writeln(a); }
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 edges = new int[][](N); foreach (i; 0..N-1) { auto s = readln.split.map...
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.algorithm, std.array, std.conv, std.range, std.stdio, std.string; void main() { auto x = readln.chomp.to!int; while (x.notPrime) x += 1; x.writeln; } bool notPrime(int x) { if (x < 4) return x < 2; int d = 2; while (d*d <= x) { if (!(x % d)) return true; ...
D
import std; long calc(long[] a) { if (a.any!(e => e == 0)) return 0; long x = 1; long m = 10L ^^ 18; foreach (e; a) { long y = x * e; if (y < x) return -1; if (y > m) return -1; x = y; } return x; } void main() { int n; scan(n); auto a = reads!long; ...
D
import std.stdio; import std.string; import std.array; // split import std.conv; // to import std.math; void main() { string[] input = split(readln()); int x = to!int(input[0]); int a = to!int(input[1]); int b = to!int(input[2]); if(abs(x - a) < abs(x - b)){ writeln("A"); } else { ...
D
//dlang template---{{{ import std.stdio; import std.conv; import std.string; import std.array; import std.algorithm; // MIT-License https://github.com/kurokoji/nephele class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; import std.string; import std.traits : isSome...
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; void main() { foreach(s;stdin.byLine()) { int[10] c; foreach(n;s) ++c[n-'0']; bool dfs(int n, bool d) { if(n>9) return d; if(c[n]==0) return dfs(n+1,d); if(c[n]>=3) ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.math; void main() { int n, q; scan(n, q); auto sd = SqrtDecomp(n); foreach (_ ; 0 .. q) { auto line = readln.split.to!(int[]); if (line[0] == 0) { sd.update(line[1], line[2]); ...
D
/+ dub.sdl: name "D" 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, m; sc.read(n, m); int[] perm; sc.read(pe...
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, std.algorithm, std.array, std.range, std.string, std.conv, std.uni; void main() { auto s = readln.strip; auto yy = s[0..2].to!int; auto mm = s[2..$].to!int; if (1 <= mm && mm <= 12) { if (1 <= yy && yy <= 12) { writeln("AMBIGUOUS"); } else { w...
D
import std.stdio, std.string, std.conv; int main(string[] argv) { auto s = split(readln()); int x = to!int(s[0]), y = to!int(s[1]); writeln(x * y, ' ', (x + y) * 2); return 0; }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.math; void main() { auto s = readln.chomp; auto hi = new int[](s.length + 1); foreach (i, c; s) hi[i + 1] = hi[i] + c.predSwitch('\\', -1, '_', 0, '/', 1); auto maxH = hi.reduce!(max); auto fs1 = hi.findSplitBefore([maxH]), hi...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nl = readln.split.to!(int[]); auto N = nl[0]; long L = nl[1]; auto as = readln.split.to!(long[]); foreach (i, a; as) { if (i == 0) continue; if (as[i-1] + 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.container; void main() { int sum; foreach (line; stdin.byLine) { sum += line.chomp.to!int; } writeln(sum/60); writeln(sum%60); }
D
import std.functional, std.algorithm, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; class UnionFind { long[] data; this (size_t size) { data.length = size; foreach (ref e; data) { e = -1; } } void unite...
D
import std.stdio, std.string, std.conv; void main() { auto n = readln.chomp; if((n[0] == n[1] && n[1] == n[2])||(n[1] == n[2] && n[2] == n[3])){ writeln("Yes"); } else { writeln("No"); } }
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 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 bignu...
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; int a, z; foreach (i, e; s) { if (e == 'A') { a ...
D
import std; void main() { long a; string b; scan(a, b); int x = b[0] - '0'; int y = b[2] - '0'; int z = b[3] - '0'; long ans = a * 100 * x; ans += a * 10 * y; ans += a * z; writeln(ans / 100); } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = s...
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); foreach (i ; 0 .. n) { int yi, mi, di; scan(yi, mi, di); writeln(mill(yi, mi, di)); } } int mill(i...
D
import std.stdio; import std.range; import std.string; import std.algorithm; import std.conv; void main() { ulong x = readln.chomp.to!ulong; (x/11*2 + (x%11 <= 6 ? 1 : 2) + (x%11 == 0 ? -1 : 0)).writeln; }
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.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto q = readln.chomp.to!size_t; foreach (_; q.iota) { auto x = readln.chomp, xl = x.length; auto y = readln.chomp, yl = y.length; auto memo = new int[][](xl + 1, yl + 1); foreach (i; 1..xl+1) foreach (j; 1..yl+...
D
// import chie template :) {{{ static if (__VERSION__ < 2090) { import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip, std.numeric; } else { import std; } // }}} // nep.scanner {{{ class Scanner { ...
D
import std.algorithm, std.string, std.range, std.stdio, std.conv; bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else { return false; } } void chChar(ref string base, size_t idx, char c) { char[] tmp = base.to!(char[]); tmp[idx] = c; base = cast(st...
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); int cnt; foreach (i ; 0 .. n) { string s = readln.chomp; if (s == "A") cnt++; else { i...
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; alias Key = Tuple!(int, "cost", int, "mask"); long calc(int num, Key[] keys) { int n = cast(int)keys.length; // dp[i ...
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 = readln.chomp; writeln(s.startsWith("YAKI") ? "Yes" : "No"); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg;...
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
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; int f(int n) { if (...
D
void main(){ int[] input; foreach(i; 0..3)input ~= _scan(); ( (input[0]-input[1])%input[2] ).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(stri...
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 d = readln.chomp.split.to!(int[]); immutable m...
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; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { return readln.split.to...
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.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range; T[] Reads(T)() { return readln.split.to!(T[]); } alias reads = Reads!int; void scan(Args...)(ref Args args) { string[] ss = readln.split; foreach (i, ref arg ; args) arg = ss[i].parse!int; } enum MOD ...
D
import std.conv, std.stdio; import std.algorithm, std.array, std.range, std.string; void main() { auto buf = readln.chomp.split.to!(ulong[]); buf[0].solve(buf[1]).writeln; } ulong solve(in ulong a, in ulong b) { assert (a <= b); if (a == b) return a; if (a.even && b.odd) return (~(b...
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; void main() { auto ab = readln.chomp.split().to!(long[]); long a = ab[0]; long b = ab[1]; writeln(a * b - (a + b - 1)); }
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() { while (1) { int n; scan(n); if (!n) return; auto ans = cntp(n); writeln(ans); } } int cntp(int n) { 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; import std.bigint; import std.ascii; void main() { auto x = readln.chomp.split; auto a = x[0].to!int; auto b = x[2...
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 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.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.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 long MOD = 10^^9 + 7; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; auto cnt = ne...
D
import std.stdio; import std.uni; import std.conv; import std.container; import std.functional; import std.algorithm; import std.array; import std.typecons; import std.range; import std.numeric; import std.traits; void main(string[] args) { auto t = next!int; foreach(tc; 0 .. t) { auto a = next!long; ...
D
// Cheese-Cracker: cheese-cracker.github.io void solve(){ long n = scan; for(int i = 2; i < 2 + n; ++i){ write(i, " "); } writeln; } void main(){ long tests = scan; // Toggle! while(tests--) solve; } /************** ***** That's All Folks! ***** **************/ impo...
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
//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]; auto psteps = (n - 11) >> 1; auto t = s...
D
import std.stdio; import std.ascii; import std.algorithm; import core.stdc.stdio; int main() { int t = readInt!int; while (t--) { int n = readInt!int; auto a = new int[](2 * n); foreach(ref ai; a) ai = readInt!int; sort(a); debug writeln(a); auto ...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; 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 readC(T...)(size_t n,ref T t){foreach(ref v;t)...
D
import std.array; import std.conv; import std.stdio; import std.math; void main() { readln.split[0].to!int.pow(2).writeln; }
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto s=readln.chomp.to!(char[]); if(s.count("AC")) writeln("Yes"); else writeln("No"); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } }
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, std.string, std.conv; import std.range, std.algorithm; import std.math :abs; void main() { int n; scan(n); int x, y, t; foreach (i ; 0 .. n) { int ti, xi, yi; scan(ti, xi, yi); int d = abs(xi - x) + abs(yi - y); int e = ((x + y) % 2) ^ ((xi + yi) % ...
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.string, std.conv; void main() { writeln(3 * readln.chomp.to!int ^^ 2); }
D
import std.stdio, std.algorithm, std.string, std.range, std.array,std.conv; void main() { const tmp = readln.split.map!(to!int).array; writeln(tmp[0] < tmp[1] ? 0:10); }
D
import std.stdio; import std.conv; import std.string; import std.range; void main(){ // input int[] input; input.length = 4; foreach(ref i; input) { i = to!int(readln().chomp()); } immutable int five_hund = input[0]; immutable int hund = input[1]; immutable int fifty = input[2]; immutable int sum_num = in...
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[]); const N = tmp[0], M = tmp[1]; auto as = readln.split.to!(long[]); as = 0 ~ as; foreach (i; 0..N) as[i+1] += as[i]; long[long] cnt; foreac...
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.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto s = readln.split; auto N = s[0].to!int; auto S = s[1].to!(dchar[]); bool f(dchar[] T) {...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto abc = readln.split.to!(int[]); auto A = abc[0]; auto B = abc[1]; auto C = abc[2]; writeln(max(0, C - A + B)); }
D
import std.stdio, std.string, std.conv; void main() { while(1){ auto n = readln.chomp.to!int; int cnt; if(n==0) break; while(n!=1){ if(n%2==0) n/=2; else n = n*3+1; cnt++; } cnt.writeln; } }
D
import std.stdio; import std.string; import std.conv; int main() { int i = 0; string str; while ((str = readln().chomp()) != "0") { i++; writeln("Case ", i, ": ", str); } return 0; }
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.numeric; import std.stdio; import std.string; void main() { int n = to!int(readln().chomp()); int[] a = readln().split().map!(a => to!int(a)).array; int m = int.min; for (int l = 0; l < a.length; ++l) { for...
D
import std; void main(){ long a = readln.chomp.to!long - 1; char[] ans; while(a >= 0){ ans ~= 'a' + (a % 26); a /= 26, a -= 1; } ans.reverse.writeln; }
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[]); [tmp[0]+tmp[1], tmp[0]-tmp[1], tmp[0]*tmp[1]].reduce!max.writeln; }
D