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.regex : regex; import std.container; import std.bigint; void main() { auto x = readln.chomp.split.to!(int[]); if (x[0]+x[1]<x[2] || x[0] > x[2]) { wr...
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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional; alias FactorizeResult = ulong[101]; void main() { const N = readln.chomp.to!int; FactorizeResult table; foreach (i; 1..N+1) { table[] += primeFactorize(i)[]; } ulong func(...
D
void main() { long x = rdElem; bool[] lists = new bool[x+1]; lists[1] = true; for (long i = 2; i * i <= x; ++i) { for (long j = i * i; j <= x; j *= i) { lists[j] = true; } } foreach_reverse (i, y; lists) { if (y) { i.write...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, 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_rd[0]; s_rd....
D
import std.stdio, std.conv, std.array, std.string; import std.algorithm; import std.container; void main() { auto N = readln.chomp.to!ulong; ulong sum = 0; for(ulong i=0; i<N; i++) { sum += i; } writeln(sum); }
D
import std.stdio; import std.conv; import std.algorithm; import std.math; void main() { long n; scanf("%ld", &n); long m = long.max; foreach(i; 1..n.to!double.sqrt.ceil.to!size_t+2) { if (n % i == 0) { m = min(i + n/i-2, m); } } m.write; }
D
import std.stdio; import std.conv; import std.string; void main() { while(true) { string [] s = split(readln()); int H = to!int(s[0]); int W = to!int(s[1]); if(H==0 && W==0) break; for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { if(i==0 || ...
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() { int n; scanf("%d", &n); int[] p = new int[n]; foreach(i; 0..n) { scanf("%d", &p[i]); p[i]--; } int[] a; bool prev = true; int s...
D
import std.stdio; import std.string; import std.conv; ulong debt(ulong x, int n) { if(n > 0) { ulong m = x * 105 / 100; if(m % 1000 > 0) m = (m / 1000 + 1) * 1000; return debt(m, n - 1); } else return x; } void main() { int n = to!int(chomp(readln())); writeln(debt(100000, n)); }
D
void main() { string s = readln.chomp; writeln(s[0], s.length - 2, s[$-1]); } 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 std.typecons; import std.ascii; import std.uni;
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.typecons; import std.numeric, std.math; 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_rd[0]; s_rd.popFront; re...
D
import std.stdio; import std.string; import std.conv; struct BloodData { int number; string bloodGroup; } void main() { string[] input = new string[](2); BloodData[] list; int[] count = [0, 0, 0, 0]; while ((input = readln.chomp.split(",")).length != 0) { BloodData temp = {number:in...
D
import std.stdio, std.string, std.conv; import std.algorithm, std.array; auto solve(string s_) { auto NAB = s_.split.map!(to!long)(); immutable N=NAB[0], A=NAB[1], B=NAB[2]; if(A>B || (A<B && N<2)) return 0; return (B-A)*(N-2)+1; } void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s))...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; import std.range; void main(){ auto N = readln.chomp.to!int; if(N/10==9 || N%10==9) writeln("Yes"); else writeln ("No"); }
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; long n, k; rd(n, k); long tot = 0; for (long a = 1; a <= n; a++) { if ((a * 2) % k == 0) { auto x = (a + n) / k - (a + 1 + k - 1) / k + 1; tot += x * x; } } writeln(tot); } void rd(T...)(ref T x) { import std.std...
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; 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(); long[] tmp = [1, 2, 4, 8, 16, 32, 64]; lon...
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; void main() { auto n = readln.chomp.to!int; foreach (i; 0..n) { readln.replace("Hoshino", "Hoshina").write; } }
D
import std.algorithm, std.conv, std.range, 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 readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}} void readM(T...)(size_...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n, m; rd(n, m); int[] a; for (int i = 2; i * i <= m; i++) { if (m % i == 0) { int cnt = 0; while (m % i == 0) { cnt++; m /= i; } a ~= cnt; } } if (m > 1) { a ~= 1; } const lo...
D
import std; void main() { int t; scanf("%d", &t); getchar(); foreach(_; 0..t) { int n; scanf("%d", &n); getchar(); auto d = n % 7; if (d == 0) writeln(n); else { int m = n % 10; if (m >= d) writeln(n...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { const xs = 5.iota.map!(_ => readln.chomp.to!int).array; const k = readln.chomp.to!int; foreach (i; 0..5) { foreach (j; i+1..5) { if (xs[j] - xs[i] > k) { wr...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.container; import std.array; import std.math; import std.range; import std.typecons; import std.ascii; void main() { readln; int right; int left; auto s = readln.chomp; foreach(c; s) { if (c == '(') { ++right; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { auto abc = readln.split.to!(int[]); writeln(abc[0] == abc[1] ? abc[2] : abc[0] == abc[2] ? abc[1] : abc[0]); }
D
import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range; void main() { auto a = readln.strip.to!int; auto b = readln.strip.to!int; auto c = readln.strip.to!int; auto d = readln.strip.to!int; auto e = readln.strip.to!int; min(a*e, max(b,b+(...
D
import std.algorithm; import std.container; import std.exception; import std.format; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; immutable int MED_L = 1 << 17; immutable int MAX_L = MED_L << 1; void main () { int n, m; while (scanf (" %d %d", &n, &m) > 0) { auto a...
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, k; readV(n, k); --k; dcha...
D
import std.algorithm; import std.conv; import std.math; 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); auto s = readln.strip; if (s.all !(q{a != '>'}) || s.all !(q{a != '<'})) { writeln...
D
void main() { dchar[] s = readln.chomp.to!(dchar[]); if (s.length == 3) reverse(s); s.writeln; } 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 std.typecons; import std.ascii;...
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() { string s; scan(s); int n = s.length.to!int + 1; s = ">...
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; import std.string; import std.conv; import std.array; import std.algorithm; import std.range; void main(){ auto A=readln.chomp.to!(char[]); writeln(A.replace(","," ")); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; void main() { auto ip = readln.split.to!(int[]), A=ip[0],B=ip[1],C=ip[2],D=ip[3]; if(A+B>C+D) { writeln("Left"); } else if(A+B==C+D){ writeln("Balanced"); } else { writeln("Right"); } }
D
import std.stdio; import std.string; import std.algorithm; import std.conv; void main() { auto l = readln.chomp.split.map!(to!int); ((l[0] * l[1]) % 2 ? "Odd" : "Even").writeln; }
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.conv, std.string, std.array, std.algorithm, std.math; void main() { auto ns = readln.chomp; auto ret = ns.count; auto n = ns.to!ulong; for (ulong a = 2; a^^2 <= n; ++a) { if (n%a) continue; auto b = n/a; int i = 1; for (; b > 9; ++i) b /= 10; ...
D
/+ dub.sdl: name "C" 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); string s; sc.read(s); int n = s.length.to!int; int ans = 0; int l = 0, r = n-1; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; int[][52] SS; dchar[52] CS; long N = 1000000007; void main() { auto n = readln.chomp.to!int; auto s1 = readln.chomp.to!(dchar[]); auto s2 = readln.chomp.to!(dchar[]); auto j = 0; for (auto i = 0; i < n; ++i) { 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 = "%.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 N; scan(N); auto lb = (100 ...
D
import std.stdio, std.string, std.conv, std.algorithm; void main(){ auto a = readln.split.map!(to!int); if(a[0]>a[1]) writeln("a > b"); else if(a[0]<a[1]) writeln("a < b"); else writeln("a == b"); }
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; void main() { while(true) { int n = readln.chomp.to!int; if (n==0...
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(); alias Point...
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.stdlib; immutable int INF = 1 << 29; void main() { auto X = readln.chomp.to!long; long[] F; for (long i = 1; i * i <...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!size_t; auto co = 0, c2 = 0, c4 = 0; auto rd = readln.splitter; foreach (_; 0..n) { auto a = rd.front.to!int; rd.popFront(); if (a % 2 != 0) ++co; else if (a % 4 != 0) ++c2; else ++c4; } ...
D
import std.stdio; import std.string; import std.format; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.concurrency; import std.traits; import std.uni; import s...
D
import std.stdio; import std.string; import std.conv; import std.array; import std.algorithm; void main() { auto input = readln.split.map!(to!int); int K = input[0], S = input[1]; int ans = 0; foreach (x; 0 .. K + 1) { foreach (y; 0 .. K + 1) { int z = S - (x + y); if...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 = Tuple!(long, "y", ...
D
import std.stdio, std.conv, std.string, std.math, std.algorithm; void main(){ auto ip = readln.chomp; if(ip[0] == 'H'){ if(ip[2] == 'H') 'H'.writeln; else if(ip[2] == 'D') 'D'.writeln; } else if(ip[0] == 'D') { if(ip[2] == 'H') 'D'.writeln; else if(ip[2] == 'D') 'H'.writeln; } }
D
import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.conv, std.stdio, std.typecons; void main() { while (true) { auto rd = readln.split; auto a = rd[0].to!int, op = rd[1], b = rd[2].to!int; if (o...
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; void main(){ string s = readln.chomp; int f = 0; foreach(c; s){ if(f == 0 && c == 'C') f = 1; if(f == 1 && c == 'F') f = 2; } string ans; if(f == 2) ans = "Ye...
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); auto a = readln.splitter.map !(to !(int)).array; int [] levels; levels ~= 1; int cur = 0; int prev...
D
import std.stdio; import std.range; import std.array; import std.algorithm; import std.string; import std.conv; void main(){ readln; string[] inputs = readln.chomp.split; writeln(solve(inputs)); } string solve(in string[] inputs){ foreach(color; inputs) { if(color == "Y"){ return "...
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.to!long; long money = 100; long cnt; while (x > money) { ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { writeln("ABC"~readln.chomp); }
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { long n, m; scan(n, m); // writeln(n, m); auto 正解したか = new bool[](n + 1); auto WAの回数 = new long[](n + 1); foreach (_; 0 .. m) { ...
D
void main() { problem(); } void problem() { auto N = scan!ulong; ulong solve() { auto primes = primeFactoring(N); int[ulong] primeCounts; foreach(p; primes) { primeCounts[p]++; } ulong answer; foreach(p; primeCounts.keys) { const count = primeCounts[p]; int sumCount;...
D
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.typecons, std.math; void main(){ auto x = readln.chomp.to!int; writeln(x < 1200 ? "ABC" : "ARC"); }
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
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; long check(long n) { long i=1; while(n>0) { n-=i; i++; } return n==0?i:-1; } void main() { auto N = scanElem; ...
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; } /* ナップサック問題(価値の上限が小さい) xs[...
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 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.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
void main() { problem(); } void problem() { auto L = scan!long; auto R = scan!long; auto d = scan!long; long solve() { long ans; foreach(i; L..R+1) { if (i % d == 0) ans++; } return ans; } solve().writeln; } // ---------------------------------------------- import std.stdio, 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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto xy = readln.split.to!(long[]); auto X = xy[0]; auto Y = xy[1]; auto a = X; long r; while (a <= Y && a ) { ++r; a *= 2; } writeln(r); }
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex; void main() { immutable long MOD = 10^^9 + 7; auto N = readln.chomp.to!int; auto A = N.iota.map!(_ => ...
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[]); writeln(nk[0] - nk[1] + 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.conv,std.string; void main(){ int sum; auto N = readln().chomp().to!int(); auto list = readArray!int(); foreach( elm ; list ){ while( elm%2 == 0 ){ elm /= 2; sum++; } } writeln(sum); } T[] readArray(T)(){ T[] ret; foreach( elm ; readln().split() ){ ret ~= elm.to!T(); } re...
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; foreach (x; 1..N) { if (x^^2 > N) break; if (N%x == 0) { auto m = N/x - 1; if (x*m + x == N && N/m == N%m) 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, std.format; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return readln.split.to!(T[])();} ...
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; bool calc(int k, int a, int b) { return a <= b / k * k; } void main() { int k; scan(k); int a, b; scan(a, b); writeln(calc(k, a, b) ? "OK" : "NG"); } 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!...
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; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { return readln.split.to!(T[])(); } void sca...
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; void main(){ string s = readln.chomp; int[] ans = [-1, -1]; // search for "aa" for(int i = 0; i < s.length - 1; i ++){ if(s[i] == s[i + 1]) ans = [i + 1, i + 2]; ...
D
import std.stdio; // readln import std.array; // split import std.conv; // to import std.typecons; bool[][] g; void main(){ string[] s = split(readln()); int N = to!int(s[0]); int M = to!int(s[1]); g = new bool[][](N,N); alias Tuple!(int,int) pair; pair[] p = new pair[](M); for(int i = 0; i < M; i++){ s = s...
D
void main(){ string n = readln().chomp(); int cnt, ans; foreach(i; 0..n.length){ if(cnt==0)cnt++; else if(n[i-1]==n[i])cnt++; else cnt=1; ans = max(cnt, ans); } ( ans>=3?"Yes":"No" ).writeln(); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range; const long mod ...
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; foreach (x; N..1000) { if (x/100 == (x/10)%10 && (x/10)%10 == x%10) { writeln(x); return; } } }
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() { string s = readln.chomp; writeln(s[0 .. 4], " ", s[4 .. $]); } void scan(T...)(ref T args) { str...
D
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.typecons, std.math; void main(){ auto S = readln.chomp; ulong min = 0, max = 0; foreach (i,c; S) { if (c == 'A') { min = i; break; } } foreach_reverse (i,c; S) { if (c == 'Z') { ...
D
import std.stdio; import std.conv; import std.array; void main() { int N = readln.split[0].to!int; auto reader = readln.split; int[] a = new int[N]; for(uint i = 0; i < N; i++){ a[i] = reader[i].to!int; } int cnt = 0; for(uint i = 0; i < N; i++){ if (a[i] != i + 1) cnt++; ...
D
import std.stdio; void main() { auto s = readln(); if(s[2]==s[3] && s[4]==s[5]) writeln("Yes"); else writeln("No"); }
D
void main() { long a = rdElem, b = rdElem, c = rdElem; long s = 3 * c; long[][] x = new long[][](3, 3); x[0][0] = a, x[0][1] = b, x[0][2] = s - a - b; x[1][0] = 4 * c - 2 * a - b, x[1][1] = c, x[1][2] = 2 * a + b - 2 * c; x[2][0] = a + b - c, x[2][1] = s - b - c, x[2][2] = s - a - c; x.wrM...
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; void main() { auto N = readln.chomp.to!int; auto X = new long[](N); auto S = new long[](N); foreach (i; 0....
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 S = readln.chomp; char last; int cnt; foreach (c; S) { if (c != last) ++cnt; last = c; } writeln(cnt); }
D
import std.stdio; import std.conv; import std.string; void main() { int times; while((times = readln.chomp.to!(int)) != 0){ char[] str = cast(char[])readln.chomp; for(int i = 0; i < times; i++) { char[] next_str; char prev; uint n = 1; prev = str[0]; foreach(s; str[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; void main() { auto n = readln.chomp.to!int; foreach (_; 0..n) { auto str = readln.chomp; char[] res; res ~= str[0...
D
import std.stdio, std.math, std.conv, std.array, std.string, std.algorithm; void main() { string str; while((str = readln()).length != 0) { double v = to!double(str.chomp); double t = (v/9.8)^^2 * 4.9; int nt = to!int(floor(to!real(t))); int h = nt + (5 - nt%5); writeln(...
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 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.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int n; scan(n); int ans; foreach (i ; 0 .. n + 1) { if (i*i <= n) { ans = i*i; } else { br...
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; auto N = s[0].to!int; auto L = s[1].to!long;...
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; import std.typecons; immutable int dirs = 4; immutable int [dirs] dRow = [ -1, 0, +1, 0]; immutable int [dirs] dCol = [ 0, -1, 0, +1]; immutable char [dirs] dName = ['N', 'W', 'S', 'E']; void main () { auto te...
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.ascii; import std.algorithm; import std.array; import core.stdc.stdio; int main() { int t = readInt!int; while(t--) { string astr = readString; auto a = new int[](astr.length); auto count = new int[](4); foreach(i, ref ai; a) { ...
D
module main; import std.stdio : writeln, stdin; import core.stdc.stdio; int main(string[] argv) { int n, l, r; scanf("%d %d %d", &n, &l, &r); l = l - 1; r = r - 1; int [] arr = new int[n]; int [] b = new int[n]; for(int i = 0; i<n; i++) scanf("%d", &arr[i]); for (int i = 0; i < n; i++) scanf("%d", &b[i...
D