code
stringlengths
4
1.01M
language
stringclasses
2 values
void main() { dchar[] s = rdDchar; s.sort!"a < b"; writeln(s.uniq.array.length == 2 ? "Yes" : "No"); } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdElem(T = long)() if (!is(T == struct)) { return readln.chomp.to!T; } alias rdStr = rdElem!string; alias rdDchar = rdElem!(dchar[]); T rdEl...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void readA(T)(size_t n,ref T[]t){t=new T[](n);auto ...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; import std.numeric; void main() { int n, m; scan(n, m); auto adj = new int[][](n + m, 0); foreach (i ; 0 .. n) { auto line = readln.split.to!(int[]); ...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.conv; import std.stdio; import std.string; import std.traits; struct Input { int n, r; } void parseInput(T)(out Input input, T file) { with (file) with (input) { auto ar = readln().strip().split().map!(to!int)....
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 MOD = 10^^9 + 7; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).ar...
D
import std.functional, std.algorithm, std.container, std.typetuple, std.typecons, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; bool chmin(t)(ref t a, t b) { if (b < a) { a = b; return true; } else...
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.algorithm; import std.conv; import std.stdio; import std.string; void main() { auto n = readln.strip.to!( int ); auto as = readln.split.to!( int[] ); writeln( solve( as ) ); } auto solve( in int[] as ) { auto mi = as.reduce!( min ); auto ma = as.reduce!( max ); return ma - mi; }
D
void main() { auto N = rl; dchar[] res; while(N != 0) { N--; res ~= ('a' + N % 26); N /= 26; } res.reverse.writeln; } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; import std.con...
D
import std.stdio; import std.range; import std.array; import std.algorithm; import std.string; import std.conv; void main(){ auto ab = readln().chomp().split().map!(to!int); auto a = ab[0]; auto b = ab[1]; solve(a, b).writeln(); } int solve(int a, int b){ return max(a+b, a-b, a*b); }
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 calc(string s) { ...
D
void main() { int[] xy = readln.split.to!(int[]); int money; foreach (i; 0 .. 2) { if (xy[i] == 1) { money += 300000; } else if (xy[i] == 2) { money += 200000; } else if (xy[i] == 3) { money += 100000; } } if (xy.all!"a == 1") mone...
D
import std.algorithm; import std.array; import std.container; import std.conv; import std.math; 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 readln.chomp.to!T; } T[]...
D
void main() { auto N = ri; auto P = iota(N).map!(a => ri).array; auto dp = new int[](N+1); int res = int.max; foreach(i; 0..N) { debug writeln(dp); dp[P[i]] = dp[P[i] - 1] + 1; res = min(res, N - dp[P[i]]); } res.writeln; } // =================================== import std.stdio; import std.string; impor...
D
import std; void main() { string s = read!string; writeln(s == "ABC" ? "ARC" : "ABC"); } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; al...
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 dg = readln.chomp.split.map!(to!long); long d = dg[0], g = dg[1]; long[] p = new long[](d), c = new long[](d); fo...
D
import std.stdio; import std.algorithm; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() {//try{ auto tokens = split(my_readln()); auto D = to!ulong(tokens[0]); if (D == 25) writeln("Christmas"); else if (D ...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.random; struct ImplicitKeyTreapNode(Value, Extra=void) { enum has_extra = !(is (Extra == void)); ImplicitKeyTreapNode!(Value, Extra)* left, right; Value value; static if (...
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 main() { string a; readV(a); auto p = ne...
D
/+ dub.sdl: name "A" 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); string s; sc.read(s); if (s.length != 26) { ...
D
void main() { long[] tmp = readln.split.to!(long[]); long h = tmp[0], w = tmp[1]; long[][] c = new long[][](10); foreach (i; 0 .. 10) { c[i] = readln.split.to!(long[]); } foreach (i; 0 .. 10) { foreach (j; 0 .. 10) { foreach (k; 0 .. 10) {...
D
import std.stdio; import std.string; void main() { auto l = readln().chomp(); size_t c; size_t t; for (size_t i; i < l.length; ++i) { if (l[i] == 'W') { t += i - c; ++c; } } t.write; }
D
import std; import core.bitop; ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = () => readln.chomp.to!(T); alias aryread(T = long) = () => readln.split.to!(T[]); alias Pair = Tuple!(long, "index", long, "num"); alias PQueue(T, alias less = "...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto sw = readln.split.to!(int[]); writeln(sw[1] >= sw[0] ? "unsafe" : "safe"); }
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; enum P = 10L^^9+7; long[][10^^5] T; long[10^^5] D; bool[10^^5] M; void main() { auto nk = readln.split.to!(long[]); auto N = nk[0]; auto K = nk[1]; foreach (_; 0..N-1) { auto ab = readln.spl...
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.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.array; auto k = readln.chomp.to!long; if...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.container.rbtree; import std.conv; import std.stdio; import std.string; import std.traits; struct Input { string s; string t; } void parseInput(T)(out Input input, T adapter) { with (input) { s = adapter.readl...
D
import std.stdio; import std.conv; import std.array; void main() { auto reader = readln.split; int A = reader[0].to!int; int B = reader[1].to!int; if (A == B){ writeln(A * 2); } else { int max = A; if (B > A) max = B; writeln(max + (max - 1)); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum P = 10L^^9+7; 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; } long inv(long x) { return pow(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; long calc(int K, int[] ...
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(int n, int y)...
D
unittest { assert( [ "atcoder" ].parse.expand.solve == "acdr" ); assert( [ "aaaa" ].parse.expand.solve == "aa" ); assert( [ "z" ].parse.expand.solve == "z" ); assert( [ "fukuokayamaguchi" ].parse.expand.solve == "fkoaaauh" ); } import std.conv; import std.range; import std.stdio; import std.string; import std.ty...
D
void main() { long n = rdElem; long[] a = rdRow; if (n == 0) { writeln(a[0] == 1 ? 1 : -1); return; } if (a[0]) { writeln(-1); return; } long[] v = new long[n+1]; v[n] = a[n]; foreach_reverse (i; 0 .. n) { v[i] = v[i+1] + a[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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto T = readln.chomp.to!int; foreach (_; 0..T) { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; auto as = readln.split.to!(int[]); a...
D
import std.stdio; import std.range; import std.array; import std.algorithm; import std.string; import std.conv; void main(){ int input = readln.chomp.to!int; writeln(input / 3); }
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; } void main(){ long n = read....
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
/+ dub.sdl: name "D" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; long[2][] aDiv(long a, long dist, long cnt) { if (a == cnt) return [[1, cnt]]; long[2][] al; long af = (a-cnt) / (dist-1); al ~= [dist,...
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.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; enum mod = 1_000_000_007L; void main() { int W, H, N; scan(W, H, N); ...
D
import std.stdio; import std.conv; import std.algorithm; import std.array; import std.string; import std.uni; import std.math; void main() { foreach(_; stdin.byLineCopy()) { writeln("NO"); stdout.flush(); } }
D
import std.stdio; import std.algorithm; import std.range; import std.conv; import std.string; int f(int a, int k) { if (a < k) return 0; if (a%k == 0) return a/k; int c = a/k+1; int l = a/k*k; a -= ((a-l-1)/c+1)*c; return f(a, k); } void main() { int n = to!int(chomp(readln())); //int ...
D
import std.stdio, std.conv, std.algorithm, std.array; void main(){ while(true){ auto line = readln(); if(line == null){ break; } auto strs = line.split(); if(strs.length < 8){ break; } auto input = strs.map!(to!real)(); auto p1 = input[0] + input[1] * 1....
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; immutable limitList = 100000; void main() { int input; bool[] listNumbers = new bool[](limitList); int[] listPrimeNumbers; //List of prime numbers. listNumbers.fill(true); listNumbers[0..1] = false; ...
D
import std.algorithm; import std.conv; import std.stdio; import std.string; void main() { auto abcxy = readln.split.map!( to!int ); writeln( solve( abcxy[ 0 ], abcxy[ 1 ], abcxy[ 2 ], abcxy[ 3 ], abcxy[ 4 ] ) ); } int solve( in int a, in int b, in int c, in int x, in int y ) { auto cc = c * 2; if( a + b < cc ) ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nab = readln.split.to!(long[]); auto N = nab[0]; auto A = nab[1]; auto B = nab[2]; if (N <= A) { writeln(N); } else { auto c = N / (A+B); writeln(A ...
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
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
/+ dub.sdl: name "A" dependency "dunkelheit" version=">=0.7.4" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; Scanner sc; static this() { sc = new Scanner(stdin); } int query(int i) { writeln(i); stdout.flush(); string s; sc.read(s); if...
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 a, b; scan(a, b); if (a >= 9 || b >= 9) { writeln(":("); } else { writeln("Yay!"); } } ...
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);} const e = ["dream", "dreamer", "erase", "eraser"];...
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; } void main(){ long n = read....
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[2][] v = new int[2][n]; ...
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; void main () { string s; while ((s = readln.strip) != "") { auto n = s.length.to !(int); int res = 0; foreach (i; 0..n) { foreach (j; i + 1..n + 1) { auto t = s[i..j]; if (!equal (t, t.retro)) { ...
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; struct List { List* next; List* prev; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; enum MP = [ [0,0], [9,10], [9,11], [3,4], [9,13], [9,14], [3,5], [9,16], [9,17], [0,0] ]; void main() { auto M = readln.chomp.to!int; long[] ...
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; } void main(){ int n = read.t...
D
import std.algorithm; import std.bigint; import std.concurrency; import std.container; import std.conv; import std.functional; import std.format; import std.math; import std.meta; import std.numeric; import std.random; import std.range; import std.stdio; import std.string; import std.traits; import std.typecons; auto...
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.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.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, 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
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; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ int n = read.to!int; long[] as = ...
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; void main(){ auto cin = new Cin(); auto N = cin.line()[0]; ((N+N*N)/2).writeln(); } auto solve(){ } unittest{ } import std.stdio,std.conv,std.string; import std.algorithm,std.array; class Cin { T[] line( T = size_t , string token = " " )( size_t m = 1 ){ T[] arr = []; foreach( i ; 0..m...
D
void main() { auto X = ri; int now; if(X % 105 == 0) { writeln(1); return; } auto tmp = X % 10; if(tmp % 5 == tmp || tmp == 5) now += 100 + tmp; else now += 200 + tmp; debug now.writeln; tmp = X % 100 / 10 * 10; now += tmp / 5 * 100; debug now.writeln; if(now > X) { writeln(0); } else writeln(1)...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.typecons; int n, m; rd(n, m); auto l=new int[](m), r=new int[](m), d=new int[](m); foreach(i; 0..m){ rd(l[i], r[i], d[i]); l[i]--; r[i]--; } alias T=Tuple!(int, "to", long, "d"); auto g=new T[][](n), rev=new T[][](n...
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; long calc(int[] a, int[...
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; void main() { int a, b, c, d; scan(a, b, c, d); auto on = new int[](200); foreach (i ; a .. b) { on...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void main() { long n, m; readV(n, m); auto x ...
D
import std.stdio; import std.conv; import std.string; import std.algorithm; import std.range; import std.functional; import std.math; import core.bitop; void main() { auto i = readln.chomp.to!long(); if (i < 1200) { "ABC".writeln; } else if (i < 2800) { "ARC".writeln; } ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto x = readln.chomp.to!long; struct T { long t, y; } auto t = iota(0, x+1) .map!(t => T(t, t*(t+1)/2)) .assumeSorted!"a.y < b.y" .lowerBound(T(0, x)).back.t; writeln(t+1); }
D
import std.stdio; import std.string; import std.range; import std.conv; void main() { auto S = readln.chomp; switch(S) { case "abc", "acb", "bac", "bca", "cab", "cba": "Yes".writeln; break; default: "No".writeln; break; } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; auto rsp = readln.split.to!(long[]); auto r = rsp[0]; auto s = rsp[1]; auto p = rsp[2]; auto T = readln...
D
#!/usr/bin/rdmd import std.stdio: stdin, lines, writeln; import std.ascii: newline; import std.conv: to; import std.array: split; void main() { int[2] a; foreach (string line; lines(stdin)) { if(line == newline) break; else { a = to!(int[])(split(line)); writel...
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.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; long calc(int t, int[] ...
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; enum MAX = 1_000_100; ulong MOD = 1_000_000_007...
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 a, b, c, d; scan(a, b, c, d); writeln(abs(a-c) <= d || max(abs(a-b), abs(b-c)) <= d ? "Yes" : "No"); } ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { writeln(readln.chomp.canFind('9') ? "Yes" : "No"); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; 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; } ret...
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.string, std.conv, std.range; void main() { auto N = readln.chomp.to!int; ulong power = 1; foreach (i; iota(1, N + 1)) { power *= i; power %= 1000000007; } power.writeln; }
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.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.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void solve() { auto nx = readln.split.to!(int[]); auto N = nx[0]; auto X = nx[1]; int sum_a, infected; bool all_same = true; foreach (a; readln.split.to!(int[])) { ...
D
import std.conv, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons; import core.bitop, core.thread; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) thr...
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.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.math, std.regex, std.range, std.ascii; import std.typecons, std.functional; import std.algorithm, std.container; void main() { long N = scanElem; long[] list = scanArray; long count; long res; foreach(i; 0..list.length) { if(list[i]...
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, 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 K, N; scan(K, N); auto a = readln.split.to!(int[]); ...
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[]...
D
import std.stdio, std.string, std.array, std.conv; long solve(long x, long y) { import std.numeric; long d = gcd(x, y); long[] factors = [1]; while (d % 2 == 0) { d /= 2; if (factors[$-1] != 2) factors ~= 2; } for (long i = 3; i * i <= d; i += 2) { while (d % i == 0) { ...
D