code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.container; import std.datetime; void main() { auto n = readln.chomp.to!double; int cnt; while (n > 1) { n /= 3; cnt++; } cnt.writeln; }
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex; immutable long INF = 1L << 59; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long P = 10^^9+7; long[10^^5+50] F, RF; long pow(long x, long n) { long y = 1; while (n) { if (n%2 == 1) y = (y * x) % P; x = x^^2 % P; n /= 2; } return y; } void init() { ...
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, std.datetime; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generat...
D
import std.stdio; import std.conv; import std.string; void main() { int[] input = readln.split.to!(int[]); int a = input[0]; int b = input[1]; if (a + b == 15){ writeln("+"); } else if (a * b == 15){ writeln("*"); } else { writeln("x"); } }
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; import std.string; string toSwapCase(string s) { if (s == s.toLower) { return s.toUpper; } if (s == s.toUpper) { return s.toLower; } return s; } void main() { auto str = readln; foreach (ch; str) { write(toSwapCase(ch ~ "")); } }
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; } long calc(int n) { if (n == 1) return 1; long a = 2;...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; ulong[10^^5] AS; int[40] BS; bool[40] KS; void main() { auto nk = readln.split.to!(ulong[]); auto N = nk[0]; auto K = nk[1]; ulong o = 1; foreach (i, a; readln.split.to!(ulong[])) { AS[i...
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; int main() { int t; scanf("%d", &t); while (t --> 0) { int n; scanf("%d", &n); int[] a = new int[n]; int[] cnt = new int [42]; long result = 0; for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); int bit_id = 0; while (...
D
import std.stdio, std.conv, std.string; import std.array, std.range, std.algorithm, std.container; import std.math, std.random, std.bigint, std.datetime, std.format; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } int DEBUG_LEVEL = 0; void pr...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.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.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
module main; import core.stdc.stdio; char[9][6] a; char[9][6] ud; void print() { for (int i = 0; i < 6; i++) { printf("%s\n", &a[i]); } } int main(string[] argv) { ud[0] = "334433"; ud[1] = "334433"; ud[2] = "223322"; ud[3] = "223322"; ud[4] = "112211"; ud[5] = "112211"; //for (int i = 0; ...
D
import std.stdio :write, writeln; import std.array; import std.range; import std.typecons; import std.algorithm : max, min; string[] list = [ "", "Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson", "Van Buren", "Harrison", "Tyler", "Polk", "Taylor", "Fillmore", "Pierce", "Buchanan", "Lincoln",...
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; long a, b, c, d; void main() { scan(n, a, b, c, d); b = b - a; a = 0; n--; foreach (i ; 0 .. n ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto ab = readln.split.join("").to!int; writeln(ab == ab.to!float.sqrt.to!int^^2 ? "Yes" : "No"); }
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() { auto n = lread(); auto a = aryread(); auto q = lread(); ...
D
import std.algorithm; import std.array; import std.ascii; import std.bigint; import std.complex; import std.container; import std.conv; import std.functional; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; auto readInts() { return array(map!(to!int)(readln().strip().split...
D
import std.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 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; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return readln.split.to!(T[])();} void scan(TL...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=readln.split.to!(int[]); auto c=new int[](100009); foreach(ref e; a) e+=2; foreach(e; a) c[e]+=1; int mx=0; foreach(i; 2..c.length-2){ mx=max(mx, c[i-1]+c[i]+c[i+1]); } writeln(mx); } void rd(T...)(r...
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
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; long calc(long h, long w) { if (h == 1 || w == 1) return 1; return (h * w + 1) / 2; } void main() { long h, w; sca...
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 calc(string[] ss) ...
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; void main () { auto tests = readln.strip.to !(int); foreach (test; 0..tests) { auto n = readln.strip.to !(int); int res = 0; for (int a = 3; ; a += 2) { int d = a * a; int b = d / 2; int c = d - b; if (...
D
import std.stdio, std.string,std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto S = [readln.chomp, readln.chomp, readln.chomp]; auto current = 0; int[3] count; while (true) { if (count[current] == S[current].length) { writeln(current == 0 ? "A" : current == 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; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { ret...
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; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum inf3 = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int n,a,b; scan(n, a, b); auto ans = min...
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 = 10L^^15; void main() { int n, m; scan(n, m); auto adj = new int[][](n, 0); foreach (i ; 0 .. m) { int xi, yi; scan(xi,...
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, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; immutable long mod = 10^^9 + 7; void main() { int n; scan(n); auto s = iota(n + 1).array; long ans = 1; foreach (p ; 2 .. n + 1) { if (s[p] ...
D
import std.stdio, std.array, std.conv; void main() { int[] integers; int x; int y; int z; integers = readln.split.to!(int[]); x = integers[0]; y = integers[1]; z = integers[2]; writeln(z, ' ', x, ' ', y); }
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto np = readln.split.to!(int[]); auto N = np[0]; auto P = np[1]; int even, odd; foreach (a; readln.split.to!(int[])) { if (a%2 == 0) { ++even; } else {...
D
import std; void main() { int t; scanf("%d", &t); getchar(); foreach(_; 0..t) { int n; scanf("%d", &n); getchar(); int[] a = readln.strip.split(" ").to!(int[]); int res = 0; while (a.uniq.array.length != 1) { // writeln(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; void main() { auto s = readln.chomp.to!(char[]); auto q = readln.chomp.to!int; auto r = 1; 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 n; readV(n); writeln(n%2 == ...
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
// 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; import std.datetime, std.bigint; int n, k; string s; void main() { scan(n, k); s = readln.chomp; auto t = new i...
D
/+ dub.sdl: name "B" dependency "dcomp" version=">=0.7.3" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; int main() { Scanner sc = new Scanner(stdin); int n; int[] a; sc.read(n, a); long all = 1, err = 1; foreach (d; a) { all *=...
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; readV(a, b, c); wri...
D
import std.algorithm; import std.conv; import std.stdio; import std.string; void main() { auto abc = readln.split.map!( to!int ); auto k = readln.strip.to!int; writeln( solve( abc[ 0 ], abc[ 1 ], abc[ 2 ], k ) ); } int solve( in int a, in int b, in int c, in int k ) { auto m = max( a, b, c ); int md = m; for...
D
/+ dub.sdl: name "J" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; import std.typecons; int main() { auto sc = new Scanner(stdin); alias Edge = Tuple!(int, "to", int, "dist"); int n; sc.read(n); Edge...
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, std.array, std.algorithm; import std.uni, std.range, std.math, std.container, std.datetime; import core.bitop, std.typetuple, std.typecons; immutable long MOD = 1_000_000_007; alias tie = TypeTuple; alias triplet = Tuple!(int, int, int); void main(){ int a, b, c; readVa...
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 scan(TList...)(ref TList Args){auto line = readln.split(); foreach (i, T; TList){T val = line[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, std.bitmanip; immutable long INF = 1L << 50; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1]; ...
D
void main() { string s = readln.chomp; long k = readln.chomp.to!int; auto g = s.group.array; long ans; if (g.length == 1) { ans = k * g[0][1].to!long / 2; } else { foreach (x; g) { ans += x[1] / 2; } ans *= k; if (s[0] == s[$-1]) { ...
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 = sort(readln.chomp.split).array; if (s == ["1", "4", "7",...
D
void main() { problem(); } void problem() { auto S = scan; auto T = scan; auto SL = S.length; auto TL = T.length; long solve() { int max_contained; foreach(i; 0..SL - TL + 1) { int contained; foreach(j; 0..TL) { if (T[j] == S[i + j]) contained++; } if (max_con...
D
import std.stdio, std.string, std.conv; import std.typecons; import std.algorithm, std.array, std.range, std.container; import std.math; void main() { auto data = readln.split.to!(int[]); writeln( max(data[0] * 2 - 1, data[0] + data[1], data[1] * 2 - 1) ); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint; void main() { auto N = readln.chomp.to!int; auto ds = readln.split.to!(int[]); int l, r; foreach (d; ds) { if (d) { ++r; } else { ++l; } ...
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; import std.array; import std.conv; import std.string; void main() { int N, Y; auto l = readln.chomp.split.map!(to!int).array; N = l[0], Y = l[1]; for (int i = 0; i <= N; ++i) { for (int j = 0; j <= N - i; ++j) { int k = N - i - j; int sum = 10000 * i + ...
D
import std.stdio, std.string, std.algorithm, std.array; void bracket (int count) { for (int i = count; i >= 1; i--) { string s = ""; s ~= replicate("(", i); s ~= replicate(")", i); s ~= replicate("(", count - i); s ~= replicate(")", count - i); writeln(s); } } void main() { int t; scanf("%d", &...
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; void main(){ auto ip = readln.split.to!(int[]), x = ip[0], y = ip[1]; const gr = [0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1]; if(gr[x] == gr[y]){ writeln("Yes"); } else { writeln("No"); } }
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(); } bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); } voi...
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; 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; const MOD = 10^^9 + 7; long calc(int h, int w, int a, int b) { initFactTable(h + w); // (a, b) -> (c, d) long f(i...
D
void main() { if(rs.count('7')) writeln("Yes"); else writeln("No"); } // =================================== 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...
D
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons; T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); } ...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { int n; long c; scanf("%d%ld", &n, &c); struct P { long x; int v;} P[] p = new P[n]; foreach (i; 0..n) { long x; int v; scanf("%ld%d", &x, &v); p[i] = P(x,v);...
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.container; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.traits; class UnionFind { private: uint[] rank; uint[] par; uint size; public: this(uint size) { rank = repeat(0u).take(size).array; par = iota(size).array; ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto S = readln.chomp.map!(c => c.to!(int) - '0'); auto K = readln.chomp.to!long; long pos = 1; foreach(x; S) { if (x == 1 && pos < K) { pos++; } else { ...
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 cord = readln.split.to!(long[]); auto x1 = cord[0]; auto y1 = cord[1]; auto x2 = cord[2]; ...
D
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math; int read() { return readln.chomp.to!int; } int[] reads() { return readln.split.to!(int[]); } void solve() { string s = readln; writeln(s.count('+').to!int - s.count('-').to!int); } void main() { solve(); readln; }
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 x, y, z; readV(x, y, z); writeln((x-z)/(y+z)); }
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.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); writeln(a...
D
import std.stdio; import std.string; import std.range; import std.algorithm; void main() { auto s = readln.chomp.retro.array; auto cands = ["dream", "dreamer", "erase", "eraser"].map!(s => s.retro.array).array; int idx = 0; while(true) { bool succ; if (idx >= s.length-1) break; foreach(cand; cands) { if (...
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 s = readln.split; auto N = s[0].to!int; auto H = s[1].to!long; auto A = N.iota.map!(_ => re...
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[]); auto D = tmp[0], N = tmp[1]; auto res = 100^^D; if (N < 100) res *= N; else res *= N+1; writeln(res); }
D
import std.stdio, std.range, std.conv, std.string, std.array, std.functional; import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting; import std.container.binaryheap; void main() { char input; scanf("%c", &input); ...
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 c = readMatrix!int(3, 3); (check(c) ? "Yes" : "No").writeln; } bool check(int[][] a) { return a[0][0] == a[0][1] + a[1][0] - a[1][1] && a[1][0] == ...
D
import std.stdio; void main() { long n; scanf("%ld", &n); write((n*(n-1))/2); }
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
void main() { int[] s = readln.chomp.split("/").to!(int[]); writeln(s[1] <= 4 ? "Heisei" : "TBD"); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import std.container; import std.typecons;
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; long r = long.max; for (long i = 1; i^^2 <= N; ++i) { if (N%i != 0) continue; r = min(r, i-1 + N/i-1); } writeln(r); }
D
import std.stdio, std.string, std.conv, std.algorithm; void main(){ while(true){ auto input = readln.split.map!(to!int); int h = input[0], n = input[1]; if(n == 0 && h == 0) break; int[int] cube; foreach(i; 0..n){ auto line = readln.split; int a = lin...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; int[int][2000] MEMO; int N, Z, W; void main() { auto nzw = readln.split.to!(int[]); N = nzw[0]; Z = nzw[1]; W = nzw[2]; auto AS = readln.split.to!(int[]); int solve(int i, int t, int z, int 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, std.bitmanip, std.regex; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; auto B = new lo...
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 h, w, n; //scan(h, w, n); scan(h); scan(w); sc...
D
import std.stdio; // readln import std.array; // split import std.conv; // to int[] dx = [1,1,1,0,-1,-1,-1,0]; int[] dy = [1,0,-1,-1,-1,0,1,1]; void main(){ string[] s = split(readln()); int h = to!int(s[0]); int w = to!int(s[1]); char[][] m = new char[][](h + 2,w + 2); for(int i = 1; i < m.length - 1; i++){ ...
D
import std.stdio,std.string,std.conv; void main(){ auto debt = 10_0000; auto week = to!int( readln().chomp() ) ; for( ; 0<week ; week-- ){ debt *= 1.05; debt += (debt%1000)?1000-debt%1000:0; } writeln(debt); }
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; // }}} // nep.scanner {{{ class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; import ...
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,std.string; void main(){ char[] str2="".dup; auto str = readln().chomp() ; foreach( c ; str ){ str2 = c~str2; } writeln(str2); }
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 s = readln.split.map!(to!long); auto N = s[0]; auto M = s[1]; ...
D
import std.stdio; import std.algorithm; import core.stdc.stdio; static immutable maxM = 5000; struct t{ int idx; int len; } class State{ int[] sizes; t[][] data; this(){ sizes = new int[3]; data = new t[][3]; t[] buf = new t[3*(maxM*2+1)]; for(int i=0;i<3;i++){ data[i] = buf[i*(maxM*2+1)..(i+1)*(maxM...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { dchar[] s; scan(s); s.sort(); if (s == "abc") { writeln("Yes"); } else { writeln("No"); } } void scan(T...)(ref T args) { import std.stdio : readln; import std.alg...
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; alias Card = Tuple!(int, "x", bool, "h"); void main() { int N; scan(N); ...
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[]); if (abs(x[0] - x[2]) <= x[3] || (a...
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[](n+1); int cnt=0; foreach(e; a){ if(e>n) cnt++; else freq[e]++; } for(int i=1; i<=n; i++){ if(i<freq[i]) cnt+=(freq[i]-i); else if(i>freq[i]) cnt+=freq[i...
D
void main() { string[] tmp = rdRow!string; string s = tmp[0], t = tmp[1]; writeln(t, s); } T rdElem(T = long)() { //import std.stdio : readln; //import std.string : chomp; //import std.conv : to; return readln.chomp.to!T; } alias rdStr = rdElem!string; dchar[] rdDchar() { //import s...
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, std.datetime; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generat...
D