code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container, std.typecons; import std.numeric, std.math; import core.bitop; T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; } string RDR()() { return readln.c...
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; import std.conv; import std.algorithm; import std.range; import std.string; void main() { foreach (char[] line; stdin.lines) { if (line == "-\n") break; char[] s = line.chomp; int i = readln.chomp.to!int; for (int x = 0; x < i; x++) { int n = readln.chomp.to!int; s = s...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; import std.regex; void main() { auto s = readln.chomp; (s.lastIndexOf('Z') - s.indexOf('A') + 1).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.stdio, std.string, std.conv; void main() { auto x = readln.chomp.to!ulong; auto ans = x / 11; x -= ans * 11; ans *= 2; if (0 < x && x <= 6) ans += 1; else if (x > 6) ans += 2; writeln(ans); }
D
import std.stdio; import std.string; import std.algorithm; import std.range; import std.array; import std.conv; ubyte toNum(dchar e) { if('a' <= e && e <= 'z') return cast(ubyte)(e - 'a'); else return cast(ubyte)(e - 'A' + 26); } char toChar(ubyte u) { if(u < 26) return cast(char)...
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 ss = new bool[](N); foreach (_; 0..K) { readln; foreach (i; readln.split.to!(int[])) ss[i-1] =...
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; } string calc(string s, string t) { bool match(in...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);} void main() { int[] s; readA...
D
import std.stdio; import std.string; import std.conv; void main() { int n; scanf("%d\n", &n); auto s = readln.chomp; auto cache = '\n'; size_t cnt; foreach(c; s) { if (c != cache) { cache = c; ++cnt; } } cnt.write; }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; void main(){ auto X=readln.chomp.to!int; auto A=readln.chomp.to!int; auto B=readln.chomp.to!int; writeln((X-A)%B); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import 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, 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 t; scan(t); while (t--) { int a, b, c; ...
D
/* imports all std modules {{{*/ import std.algorithm, std.array, std.ascii, std.base64, std.bigint, std.bitmanip, std.compiler, std.complex, std.concurrency, std.container, std.conv, std.csv, std.datetime, std.demangle, std.encoding, std.exception, std.file, std.format, std.functi...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp.to!int; auto AS = readln.split.to!(ulong[]); ulong x; size_t i, j; long r; while (j < N) { if (j < N && !(x&AS[j])) { x |= AS[j]; ...
D
void main() { problem(); } void problem() { auto a = scan; long solve() { long ans; long count; foreach(c; a) { if (c == 'R') { count++; if (ans < count) ans = count; } else { count = 0; } } return ans; } solve().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
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; import std.typecons; import std.bigint; // import dcomp.foundation, dcomp.scanner; // import dcomp.container.deque; int main() { auto sc = new Scanner(stdin); int n, m, k; sc....
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.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.algorithm, std.conv, std.array, std.string, std.math; void main() { auto ab = readln.split.to!(int[]); writeln(ab[0] + ab[1] == 15 ? "+" : ab[0] * ab[1] == 15 ? "*" : "x"); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto X = readln.chomp.to!long; long r; r += X/500 * 1000; X -= X/500 * 500; r += X/5 * 5; writeln(r); }
D
//aoj10018 import std.stdio; import std.ascii; void main() { char c; dchar c1; while(1) { scanf("%c", &c); if(c == '\n') break; if(isLower(c) != 0) c1 = toUpper(c); else if(isUpper(c) != 0) c1 = toLower(c); else c1 = c; write(c1); } writeln()...
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!(long[]); auto N = nk[0]; auto K = nk[1]; auto AS = readln.split.to!(long[]); int[60] bs; foreach (a; AS) { foreach (i; 0..60) if (a & (1L<<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; long powmod(long a, long x, long m) { long ret = 1; while (x) { if (x % 2) ret = ret * a % m; a = a * a % m; ...
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.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
// Try Codeforces // author: Leonardone @ NEETSDKASU import std.algorithm : sort, sum; import std.array : split; import std.conv : to; import std.stdio : readln, writeln; import std.string : chomp; auto gets() { return readln.chomp; } auto getV(T)() { return readln.chomp.to!T; } void main() { ...
D
import std.algorithm, std.range, std.stdio, std.numeric, std.array, std.exception, std.container, std.typecons, std.conv, std.random, std.bigint, std.string; void read(S...)(ref S args) { auto input = readln.split; assert(input.length == args.length); foreach (i, ref arg; args) { arg = input[i].to!(S[...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(T = long)() ...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.container, std.math; immutable int mod = 10^^9 + 7; int x1, y1, x2, y2; int x, y; void main() { readVariables(x1, y1, x2, y2); readVariables(x, y); if ((x2 - x1) % x || (y2 - y1) % y) { writeln("NO"); ...
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.4.0" +/ import std.stdio, std.algorithm, std.conv, std.range; import std.typecons; // import dcomp.scanner, dcomp.container.deque; int main() { auto sc = new Scanner(stdin); alias E = Tuple!(int, "to"); int n; sc.read(n); E[][] g = new ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { writeln(readln.chomp.to!int^^2); }
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; import std.concurrency; import core.bitop : popcnt; alias Generator ...
D
import std.stdio; import std.algorithm; import std.math; import std.conv; import std.string; import std.bigint; T readNum(T)(){ return readStr.to!T; } T[] readNums(T)(){ return readStr.split.to!(T[]); } string readStr(){ return readln.chomp; } void main(){ auto nk = readNums!long; auto a = readNums!int; ...
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 a = readNums!int; max(a[0]+a[1], a[0]-a[1], a[0]*a[1]).writeln;...
D
unittest { assert( [ "?ABC" ].parse.expand.solve == 4 ); // 追加ケース assert( [ "ABC?" ].parse.expand.solve == 4 ); // 追加ケース assert( [ "A??C" ].parse.expand.solve == 8 ); assert( [ "ABCBC" ].parse.expand.solve == 3 ); assert( [ "????C?????B??????A???????" ].parse.expand.solve == 979596887 ); } import std.conv; im...
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 N; scan(N); auto a = readln.split.to!(int[]); auto...
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.stdio, std.conv, std.string, std.algorithm, std.math, std.array; void main() { string s = readln.chomp; if(s[0]==s[1] && s[1]==s[2]) writeln("No"); else writeln("Yes"); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; string[100] WS; bool[string] MEMO; void main() { auto N = readln.chomp.to!int; foreach (i; 0..N) { WS[i] = readln.chomp; } char c = WS[0][0]; foreach (w; WS[0..N]) { if (c != w[0] || w in MEMO...
D
import std.stdio; // readln import std.array; // split import std.conv; // to import std.typecons; import std.range; import std.algorithm; void main(){ string s = readln(); int cnt = 0; foreach (elem; s) { if(elem == '1') cnt++; } writeln(cnt); }
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, std.container, std.range; void main() { auto N = readln.chomp.to!int; auto R = new int[](N-1); foreach (d; 1..N) { auto end = true; auto s = true; foreach (ref x; R) { ...
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() { while (1) { auto x = readln.chomp.to!int; if (!x) break; int cnt; while (x != 1) { if (x % 2) x = x * 3 + 1; else x /=...
D
import std.stdio; import std.string; import std.conv; void main(){ int i = 1; while(1){ int a = readln().chomp().to!int(); if(a == 0) break; writeln("Case ", i, ": ", a); i++; } }
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 nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; auto AS = readln.split.to!(long[]); long r = 1; foreach (i, a; AS) { if (i <...
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[]); writeln(max(ab[0] + ab[1], ab[0] - ab[1], ab[0] * ab[1])); }
D
import std.stdio, std.math; void main(){ int n, m; immutable mod = cast(long)(1e9 + 7); scanf("%d%d", &n, &m); auto Cs = new int[][](m,2), idxToC = new int[][](n+1, 2); auto appear = new int[](n+1); foreach(i; 0..m){ scanf("%d%d", &Cs[i][0], &Cs[i][1]); foreach(j; 0..2){ int x = abs(Cs[i][j]); idxToC[...
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.typecons; class InputReader { private: ubyte[] p; ubyte[] buffer; size_t cur; public: this () { ...
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; import std.algorithm; import std.range; import std.conv; import std.string; void main() { auto nd = readln.split.map!(to!int).array; int max_ans1, max_ans2; foreach (idx; 0 .. nd[1]) { bool d_idx = readln.strip.map!(to!char).array.any!(d => d == '0'); if (d_idx) { ...
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.array, std.conv, std.stdio, std.string; void main() { auto buf = readln.chomp.split.to!(int[]); ((buf[0] * 500 >= buf[1]) ? "Yes" : "No").writeln; }
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; void main() { auto ab = readln.chomp.split.to!(int[]); auto s = readln.chomp.split("-"); auto f...
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.chomp; auto N = S.length.to!int; auto next = new int[][](26, N); foreach (i; 0..26) fill(next...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto hw = readln.split.to!(int[]); auto H = hw[0]; auto CS = new long[][](10, 10); foreach (i; 0..10) { foreach (j, c; readln.split.to!(long[])) CS[i][j] = c; } foreach ...
D
import std; auto input() { return readln().chomp(); } alias sread = () => readln.chomp(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { long n; scan(n); if (n % 2 == 0) { writeln(n / 2); } else { writeln(n / 2 + 1); } } void scan(L...)(ref ...
D
import std.stdio; import std.algorithm; import std.conv; import std.string; void main() { int N = readln.chomp.to!int; auto cards = readln.chomp.split; auto cards2 = cards.dup; string b = cards.bubbleSort.join(" "); b.writeln; "Stable".writeln; string s = cards2.selectionSort.join(" "); ...
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; immutable int mod = 998_244_353; void main () { auto tests = readln.strip.to !(int); foreach (test; 0..tests) { auto n = readln.strip.to !(int); auto a = readln.splitter.map !(to !(int)).array; auto f = new long [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 = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = () ...
D
void main() { string s = readln.chomp; int n = s.to!int; int m; foreach (x; s) { m += x -'0'; } writeln(n % m == 0 ? "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; impo...
D
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; import core.bitop; string RD() { 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 % mod)) % m...
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
void main() { string s = rdStr; long len = s.length; foreach (i; 0 .. len) { 'x'.write; } writeln; } 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!(...
D
import std.string; import std.stdio; import std.algorithm; void main() { auto s = readln.chomp.dup; auto t = readln.chomp.dup; if (t.length < s.length) { swap(s, t); } auto dp0 = new char[][s.length + 1]; auto dp1 = new char[][s.length + 1]; foreach (ref e;dp0) { e = new char[0]; } dp1[0] = new char[0];...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nq = readln.split.to!(int[]); auto N = nq[0]; auto Q = nq[1]; auto S = readln.chomp; char[] ts, ds; foreach (_; 0..Q) { auto td = readln; ts ~= td[0]; ...
D
void main() { auto S = rs; string s; foreach(i; 1..6) { s ~= "hi"; if(S == s) { writeln("Yes"); return; } } writeln("No"); } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; i...
D
import std.stdio, std.string, std.conv, std.algorithm; void main(string[] args) { auto x = readln().chomp; foreach(int i, char c; x){ if(i%2==0){c.write;} } writeln; }
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.algorithm, std.conv, std.range, std.stdio, std.string; const days = [0,31,28,31,30,31,30,31,31,30,31,30,31]; void main() { auto rd = readln.split.to!(int[]), x = rd[0], y = rd[1]; writeln(days[x] == days[y] ? "Yes" : "No"); }
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; import std.datetime; void main() { while (1) { auto x = readln.chomp.split.map!(to!int); if (x[0] == 0 && x[1] == 0) break; foreac...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; void main() { (readln.chomp.to!int / 3).writeln; }
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 a, stri...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.math; // math functions alias point = Point!int; void main() { auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1]; auto a = new point[](n), c = new point[](m); foreach (i; 0..n) { auto rd2 = readln.split.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.stdio; void main() { immutable long MAX = 2*10^^6+1; immutable long MOD = 10^^9+7; auto modinv = new long[](MAX); ...
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[] factors(int n) { ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!size_t; auto si = readln.split.to!(int[]); auto q = readln.chomp.to!size_t; auto ti = readln.split.to!(int[]); writeln(ti.count!(t => si.canFind(t))); }
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, k; rd(n, k); auto x=new long[](n), y=new long[](n); foreach(i; 0..n) rd(x[i], y[i]); long mn=5_000_000_000_000_000_000; foreach(i1; 0..n)foreach(i2; (i1+1)..n){ foreach(j1; 0..n)foreach(j2; (j1+1)..n){ auto x1=x[i1], x2=x...
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.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 t = readln.split; auto N = t[0].to!int; auto L = t[1].to!long; auto S = N.iota.map!(_ => re...
D
import std.stdio,std.array,std.conv,std.string; void main(){ int n=readln().chomp().to!int; string k=to!string(n); int m=0; for(int i=0;i<k.length;i++){ m+=to!int(k[i])-48; } if(n%m==0) writeln("Yes"); else writeln("No"); }
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.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.to!(int[]); } void calc(int n) { string get() { return readln.chomp; } wri...
D
import std.stdio; import std.string; import std.conv; void main() { int[] a = readln.chomp.split.to!(int[]); if (a[0] <= 8 && a[1] <= 8) { writeln("Yay!"); } else { writeln(":("); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; enum DREAM = "dream"; enum DREAM_CNT = DREAM.length; enum DREAMER = "dreamer"; enum DREAMER_CNT = DREAMER.length; enum ERASE = "erase"; enum ERASE_CNT = ERASE.length; enum ERASER = "eraser"; enum ERASER_CNT = ERASER.length; void main() { auto 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; import std.array; import std.string; import std.conv; import std.algorithm; import std.typecons; import std.range; import std.random; import std.math; import std.container; void main() { auto input = readln.split.map!(to!int); int N = input[0]; int T = input[1]; auto A = readln.split.map!(to!...
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 d = abc[0] + abc[1] + abc[2]; writeln(d + max(abc[0], abc[1], abc[2]) * 9); }
D
import std.stdio; import std.conv; import std.string; void main() { auto n = readln.chomp.to!(int); auto ans = 0; if (n / 100 == 9) ans += 100; else ans += 900; if (n % 100 >= 90) ans += 10; else ans += 90; if (n % 10 == 9) ans += 1; else ...
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[] lreads(T = long)(long n){return generate(()=>readln.c...
D
void main() { string b = readln.chomp; b == "A" && "T".writeln; b == "T" && "A".writeln; b == "C" && "G".writeln; b == "G" && "C".writeln; } 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 ...
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.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 N = readln.chomp.to!int; auto S = readln.chomp; auto dp = new bool[][][][](N+1, 11, 11, 11)...
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.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, std.conv, std.range, std.stdio, std.string; void main() { auto a = readln.chomp; auto b = readln.chomp; auto s = max(a.length, b.length); auto a2 = a.rightJustify(s, '0'); auto b2 = b.rightJustify(s, '0'); if (a2 == b2) writeln("EQUAL"); else if (a2 < b2) writeln("LESS"); ...
D