code
stringlengths
4
1.01M
language
stringclasses
2 values
void main(){ int[] n = _scanln(); foreach(i; 0..n[0]+1 ){ if(n[1] == 2*i + 4*(n[0]-i)){ writeln("Yes"); return; } } writeln("No"); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] _scanln(T = in...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { string s; s = readln().chomp; int n = s.length.to!int; if (s[n-1] == '1') { writeln(-1); return; } if (s[0] == '0') { writeln(-...
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.random; import std.datetime.systime : Clock; class InputReader { private: ubyte[] p; ubyte[] buffer; si...
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!(int[]); auto A = nab[1]; auto B = nab[2]; writeln(A%2 == B%2 ? "Alice" : "Borys"); }
D
import std.algorithm, std.string, std.array, std.range, std.stdio, std.conv; void main() { string[] n = readln.chomp.split(""); if (n[0] == n[2]) { writeln("Yes"); } else { writeln("No"); } }
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, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii; import std.typecons, std.functional, std.traits; import std.algorithm, std.container; void main() { long A = scanElem; long B = scanElem; long C = scanElem; if(A>B)swap(A,B); if(A<C&&C<B){ writeln(...
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 a = read....
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; 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 o = sread(); auto e = sread(); auto s = (o.length) + (e...
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; enum lim = 2 * 10^^5; void main() { auto s = eratos(lim); au...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.container; import std.bigint; import std.math; void main() { auto n = readln.chomp.to!int; foreach (i; 1..n+1) { auto x = i; if (x % 3 == 0) { write(" ", i); continue; } while (x) { ...
D
import std.stdio,std.string,std.conv,std.array; void main(){ int[4][] data; for(int i=0;;i++){ auto rd = readln().chomp(); if(rd){ data.length = i+1; auto abcd = split(rd); data[i][0] = to!int(abcd[0]); data[i][1] = to!int(abcd[1]); data[i][2] = to!int(abcd[2]); data[i][3] = to!int(abcd[3]); }...
D
void main(){ string s = readln().chomp(); char tmpc; foreach(ch; s){ if(tmpc == ch){ writeln("Bad"); return; } tmpc = ch; } writeln("Good"); } 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.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!long; long a = 0; long b = 0; foreach (i; 0..10^^6) { b += 1...
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.algorithm, core.bitop; void main(){ int A, B, K, ans; scanf("%d%d%d", &A, &B, &K); foreach(bit; 0..1<<10)if(popcnt(bit) <= K){ ans = max(ans, test(A, B, bit)); } writeln(ans); } int test(int A, int B, int bit){ int carry = 0, ten = 1, C = 0; for(;A;A/=10, B/=10, ten*=10, bit>>=1){ int...
D
// dfmt off T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;} T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;} void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
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 k, s; readV(k, s); auto ans...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 = Tuple!(long, "y", ...
D
void main() { string s1 = readln.chomp; string s2 = readln.chomp; string s3 = readln.chomp; writeln(s1[0], s2[1], s3[2]); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import std.numeric; import std.container; import s...
D
import std.algorithm; import std.array; import std.range; import std.conv; import std.stdio; import std.string; import std.typecons; alias FairyPos = Tuple!(int,int); void main(){ auto blue_num = readln.chomp.to!int; string[] blues; foreach(i; iota(0, blue_num)) { blues ~= readln.chomp; } ...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, core.bitop; int r, c; int[] sb; void main() { string s = readln.chomp; int n = s.length.to!int; bool[] e = new bool[](26); foreach (ch ; s) { e[ch - 'a'] = 1; } if (e.count(1)...
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(D...
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() { string s; readV(s); auto b = new bool[](26); foreach (c; s) b[c-'a'] = true; foreach...
D
void main() { string s = readln.chomp; long n = s.countUntil('C'); long m = -1; if (n != -1) { m = s[n+1..$].countUntil('F'); } writeln(m != -1 ? "Yes" : "No"); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import...
D
void main() { problem(); } void problem() { const S = scan; auto N = S.length; long solve() { if (N < 4) return 0; const P = 2019; long ans; auto cs = new long[](P); cs[0] = 1; long x, t = 1; foreach_reverse (c; S) { x = ((c-'0').to!long * t + x) % P; t = (t ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; void main() { int n; scan(n); auto a = iota(n).map!(i => readln.chomp.to!int).array; foreach (s ; 0 .. 1<<n) { int deg; foreach ...
D
/+ dub.sdl: name "D" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; int main() { Scanner sc = new Scanner(stdin); int n; long k; sc.read(n, k); long[] a = new long[n]; long[] b = new long[n]; fore...
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.numeric; void main() { auto n = readln.chomp.to!int; bool[string] cnt; foreach (_; 0...
D
import std.stdio; import std.string; import std.conv; int main() { int[string] hash; int n = to!int(readln.chomp); string[] s = readln.chomp.split; foreach (ref c; s) { hash[c]++; } writeln(hash.length == 3 ? "Three" : "Four"); return (0); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; import core.bitop; alias H = Tuple!(int, "r", string, "s"); void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; long[H] ls, rs; foreach (b; 0..(1<<N)) { ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { writeln(readln.to!(wchar[]).count!(c => c == '1')); }
D
import std.stdio, std.array, std.conv, std.typecons, std.algorithm; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } void main() { immutable ip = readln.split.to!(ulong[]); immutable n = ip[0], m = ip[1]; auto ls = new ulong[m]; auto rs = new ulong[m]; for(ulong i = 0; i...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 = Tuple!(long, "y", ...
D
void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1], t = tmp[2]; writeln(t / a * b); } 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
/+ dub.sdl: name "F" dependency "dcomp" version=">=0.7.4" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; int main() { Scanner sc = new Scanner(stdin); int k; // sc.read(k); k = 38; int n = k*(k-1)+1; bool[][] g = new bool[][](n, n); ...
D
void main() { long k = rdElem - 1; long[] a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]; a[k].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 rdSt...
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, 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; enum lim = 10^^5 + 1; void main() { int N, W; sca...
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(){ int n = readNum!int; writeln(180 * (n - 2)); }
D
import std.stdio; import std.string; // chomp????????????????????????(?????????????????????) import std.conv; // to???????????????????????? import std.array; // split????????????????????? void main() { auto input = readln.split; auto a = input[0].to!int; auto b = input[1].to!int; writeln(a * b, " ", 2...
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.algorithm; void main() { auto input = getStdin!(string[]); string needle = input[0].toLower; string[] haystack = input[1..$-1].join(" ").replace(".", "").replace(",", "").toLower.split(" "); auto count = haystack.count(needle); count.writeln; } T getStdin(T)() ...
D
void main() { auto S = rs; string str = "keyence"; if(S == str) { writeln("YES"); return; } foreach(i; 0..str.length) { auto l = str[0..i]; auto r = str[i..$]; if(S.startsWith(l) && S.endsWith(r)) { writeln("YES"); return; } } writeln("NO"); } // =================================== import std.stdi...
D
import std.stdio, std.range, std.conv, std.string, std.math; import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting; void main() { long N = readln().strip.to!long; long minCount=long.max; for (long i = 0; i < 5;...
D
void main() { string s = rdStr; string t; foreach (x; s) { if (x == 'B') { if (t.length) t = t[0..$-1]; } else { t ~= x; } } t.writeln; } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdElem(T = long)() if (!is(...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii; import std.typecons, std.functional, std.traits; import std.algorithm, std.container; import core.stdc.stdlib; void main() { auto A = scanElem; auto B = scanElem; writeln(A-B+1); } long gcd(long a, long b) { if(b ...
D
import std.stdio; import std.algorithm; import std.array; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() {//try{ auto tokens = split(my_readln()); auto N = to!ulong(tokens[0]); long[] h; foreach (token; spli...
D
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container; 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.chomp; } long ...
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.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.algorithm, std.range; void main() { auto N = readln.split[0].to!int; auto H = readln.split.to!(int[]); H ~= int.max; auto maxNum = 0; auto num = 0; size_t i = 0; while(i < H.length - 1) { if(H[i+1]<=H[i]) { num++; } else { maxNu...
D
void main() { ("A" ~ rs[8] ~ "C").writeln; } // =================================== import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.container; import std.bigint; import std.numeric; import std.conv; import std.typecons; impo...
D
void main() { int[] tmp = readln.split.to!(int[]); int x = tmp[0], y = tmp[1] / 2; writeln(x + y); } 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.conv,std.string,std.algorithm; void main(){ auto nab = readln.chomp.split.map!(to!int); int n=nab[0],a=nab[1],b=nab[2]; if(n*a<b) writeln(n*a); else writeln(b); }
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 d, t, s; scan(d, t, s); double tmp = double(d) / double...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 = Tuple!(long, "y", ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.math, std.typecons; void main() { int n, t; scan(n, t); auto imos = new int[](t + 2); foreach (i ; 0 .. n) { int li, ri; scan(li, ri); imos[li]++; imos[ri]--; } foreach (i ; 0 .. ...
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.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.map!(to!int); auto w = rd[0], h = rd[1], x = rd[2], y = rd[3], r = rd[4]; writeln(x >= r && x <= w - r && y >= r && y <= h - r ? "Yes" : "No"); }
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 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 core.stdc.stdio; import std.algorithm; void main(){ int n,k; scanf("%d%d",&n,&k); for(int i=0;i<k;i++){ int a,b; scanf("%d%d",&a,&b); int m = min(a,n+1-a,b,n+1-b); printf("%d\n",(m-1)%3+1); } }
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() { auto N = readln().strip.to!(long); ...
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; void times(alias fun)(int n) { foreach(i...
D
import std.stdio; import std.string; import std.conv; import std.bigint; import std.typecons; import std.algorithm; import std.array; import std.math; import std.range; void main() { auto S = readln.chomp.dup; auto T = readln.chomp.dup; auto findResult = iota(S.length-T.length+1).retro .find!(i =>...
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, std.format, std.math; void main() { auto r = readln.chomp.to!int; ...
D
import std.stdio; import std.array; import std.algorithm; import std.string; import std.conv; void main(string[] argv) { long x = readln.chomp.to!long; long a = readln.chomp.to!long; long b = readln.chomp.to!long; x -= a; writeln(x%b); }
D
import std.stdio; import std.string; import std.range; import std.conv; void main() { auto N = readln.chomp.to!int; auto K = readln.chomp.to!int; auto X = readln.chomp.to!int; auto Y = readln.chomp.to!int; if(N>K){ writeln((K*X)+((N-K)*Y)); }else{ writeln(N*X); } }
D
import std.algorithm; import std.array; import std.ascii; 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 log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } cons...
D
import std.stdio,std.ascii,std.conv,std.string,std.algorithm,std.range,std.functional,std.math,core.bitop; void main() { auto a=readln.chomp.to!int; auto b=readln.chomp.to!int; writeln((a*a)-b); }
D
import std.stdio; import std.conv; import std.array; import std.string; void main() { while (1) { string[] input = split(readln()); int m = to!(int)(input[0]); int f = to!(int)(input[1]); int r = to!(int)(input[2]); if ( m == -1 && f == -1 && r == -1) break; if (r == -1) r = 0; char g; ...
D
import std.container; import std.range; import std.algorithm; import std.array; import std.string; import std.conv; import std.stdio; import std.container; void main() { auto s = readln.chomp; auto c = s.count!(x => x == 'R'); if (c == 2 && s[1] != 'R') { writeln(1); } else { writeln(c); } }
D
void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1]; if (a + b == 15) { "+".writeln; } else if (a * b == 15) { "*".writeln; } else { "x".writeln; } } import std.stdio; import std.string; import std.array; import std.conv; im...
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; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; int odd, two, four; foreach (a; A) { ...
D
void main(){ int x = _scan(); ( (x/500)*1000 + (x%500)/5*5).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(string elm; readln().chomp().split()){...
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.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 l = new long[](n+1); l[0] = 2; l[1] = 1; ...
D
import std.algorithm; import std.array; import std.container; import std.conv; import std.exception; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; int [] get (string s) { auto f = new int [10]; foreach (c; s) { f[c - '0']++;...
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,m; scan(n); scan(m); int ans; if (n > 30) { ans = m; } else { ans = m % 2^^n; } writeln(ans); } ...
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.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
//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; int test () { auto s = readln.strip; auto t = readln.strip; immutable l = s.length.to!int; auto next = new int[26]...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, m, q; rd(n, m, q); auto s=readln.chomp.to!(char[]); auto t=readln.chomp.to!(char[]); auto ok=new bool[](s.length+1); for(int i=0; i+t.length<=s.length; i++){ if(s[i..(i+t.length)]==t) ok[i]=true; } while(q--){ int l, r;...
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) { readln.strip.length.writeln; } }
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); int n = s.length.to!int; long ans; foreach (i ; 0 .. n) { foreach (j ; i + 1 .. n) { foreach (k ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto a = readln.split.to!(long[]); auto N = a[0]; auto A = a[1]; auto B = a[2]; auto C = a[3]; auto D = a[4]; foreach (i; 0..N-1) { auto l = A + C * 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[]); auto A = ab[0]; auto B = ab[1]; writeln(max(A+B, A-B, 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.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; enum P = 10L^^9+7; void main() { auto S = readln.chomp; auto DP = new long[][](S.length+1, 4); DP[S.length][3] = 1; foreach_reverse (i; 0..S.length) { auto c = S[i]; foreach (j; 0..4)...
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
// 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.string; void main() { auto S = readln().chomp(); if ((S == "AAA") || (S == "BBB")) { writeln("No"); return; } writeln("Yes"); }
D
void main() { int n = readln.chomp.to!int; string[] w = new string[n]; int ok = true; foreach (i; 0 .. n) { string s = readln.chomp; if (i > 0) { if (s[0] != w[i-1][$-1] || w.canFind(s)) { ok = false; break; } } w[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 MOD = 10^^9 + 7; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[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; import std.typecons; alias sread = () => readln.chomp(); alias Point2 = Tuple!(long, "y", ...
D