code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ap = readln.split.to!(int[]);
auto A = ap[0];
auto P = ap[1];
writeln((P + A*3)/2);
} | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;
int[100001] dp;
int solve(int n) {
if (n == 0)
return 0;
if (dp[n] != -1)
return dp[n];
int ret = solve(n - 1) + 1;
for (int d = ... | 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 A = abc[0];
auto B = abc[1];
auto C = abc[2];
writeln(min(B / A, C));
} | 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;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
buffer = uninitializ... | 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, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
int n = readln.chomp.to!int;
string s = readln.chomp;
ulong mod = 1_000_000_007;
ulong[][] dp; // dp[j][i] := # of ways to make (any) string of length 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.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
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;
in... | D |
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto md = readln.split.to!(int[]);
auto M = md[0];
auto D = md[1];
int r;
foreach (m; 0..M) {
++m;
foreach (d; 21..D) {
++d;
if (d%10 >= 2 &&... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(dchar[]);
auto Q = readln.chomp.to!int;
dchar[] as, bs;
int f;
foreach (_; 0..Q) {
auto q = readln;
if (q[0] == '1') {
++f;
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto c=readln.chomp.to!char;
if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')writeln("vowel");
else writeln("consonant");
} | 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;
long[Tuple!(long, long)] mem;
immutable long MOD = 10^^9 + 7;
long dp(long s, long x) {
Tuple!(long, long) t = tuple(s... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1],C=Q[2];
if(C>=A&&C<=B)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.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;
void main()
{
writeln((readln.chomp.to!int+1)/2);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
void main() {
auto tmp = readln.split.to!(int[]);
auto N = tmp[0];
auto M = tmp[1];
writeln((M * 1900 + (N-M) * 100) * 2^^M);
}
| D |
import std.stdio, std.string, std.conv;
void main(){
string str;
string[] s;
int q1, b, c1, c2, q2, a1, a2, t;
while ((str = readln()) != "0\n") {
s = split(str);
q1 = s[0].to!int;
b = s[1].to!int;
c1 = s[2].to!int;
c2 = s[3].to!int;
q2 = s[4].to!int;
foreach (i; 0..q2+1) {
a1 = q2 - i;
t = b -... | 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);
writeln(n... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto n = readln.chomp.to!int;
auto s = readln.chomp;
int m;
foreach (i; 1..n) {... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(char[]);
foreach (ref c; S) c = 'x';
writeln(S);
} | 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;
void main() {
auto N = readln.chomp.to!int;
long ans = 0;
foreach (i; 1..N+1) foreach (j; 1..N+1) foreach(k; 1... | D |
import std.stdio,
std.string,
std.conv,
std.algorithm,
std.range,
std.math;
void main()
{
while(true){
auto ip = readln.split.to!(int[]), h = ip[0], w = ip[1];
if(h == 0 && w == 0) break;
else{
string W;
foreach(j; 0..w){
W ~= "#";
}
foreach(i; 0..h){
W.writeln;
}
... | D |
import std.algorithm,
std.string,
std.range,
std.stdio,
std.conv;
void chmax(T)(ref T a, ref T b) {
if (a < b) {
a = b;
}
}
void main() {
int N = readln.chomp.to!int;
int[] s = N.iota.map!(_ => readln.chomp.to!int).array;
bool[10010][110] dp;
dp[0][0] = true;
dp[0][s[0]... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
writeln(reduce!"a + b"(0, readln.split.to!(int[])) >= 22 ? "bust" : "win");
} | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, 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 s1, s2;
s1 = readln().chomp().dup().reverse();
s2 = readln().chomp();
if(s1 == s2)writeln("YES");
else writeln("NO");
}
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[] _scanl... | 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.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
auto a = ["dream", "dreamer", "erase", "eraser"];
loop: while (!s.empty) {
foreach (ai; a) {
if (s.length >= ai.length && s[$-ai.length..$] == ai) {
s = s[0..$-ai.length];
continue loo... | 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 |
/+ 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);
int n;
sc.read(n);
int[][] g = new int[][n];
foreach (i; 0..n-1) {
int a, b;
... | D |
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;
// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : ... | 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.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.format;
import std.array;
import std.math;
import std.string;
import std.container;
void main() {
int N; readlnTo(N);
if (N == 1) "Hello World".writeln;
else {
int A, B;
readlnTo(A);
readlnTo(B);
(A + B).writeln... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n, m;
scan(n, m);
auto uf = WeightedUnionFind!(int)(n + 1);
bool ok = 1;
foreach (i ; 0 .. m) {
int l, r, d;
scan(l, r, d);
if (uf.same(l, r)) {
if (uf.diff(l... | 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.stdio;
import std.string;
import std.range;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
auto xs = readints();
int a = xs[0], b = xs[1], c =... | D |
import std.stdio, std.conv, std.string, std.algorithm, std.range;
void main() {
auto N = readln.split[0].to!int;
(N ^^ 3).writeln;
} | 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;
import std.string;
import std.conv;
import std.algorithm;
void main() {
string[] inputs = split(readln());
int a = to!int(inputs[0]);
int b = to!int(inputs[1]);
int c = to!int(inputs[2]);
min(a + b, b + c, c + a).writeln;
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto R = readln.chomp.to!int;
if (R < 1200) {
writeln("ABC");
} else if (R < 2800) {
writeln("ARC");
} else {
writeln("AGC");
}
} | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln(48 - readln.chomp.to!int);
}
| 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;
void main() {
int k;
scan(k);
auto ans = (k /... | D |
import std.stdio,std.string;
import std.conv,std.math;
void main(){
int [] n = readln.chomp.split.to!(int[]);
if((abs(n[0]-n[1])<=n[3] &&abs(n[1]-n[2])<=n[3])
||abs(n[0]-n[2])<=n[3]){
writeln("Yes");
}
else{
writeln("No");
}
} | 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.algorithm, std.conv, std.array, std.string;
int[10^^5] BS;
bool[10^^5] HS;
void main()
{
auto n = readln.chomp.to!int;
foreach (i; 0..n) {
BS[i] = readln.chomp.to!int - 1;
}
int p, cnt;
for (;;) {
++cnt;
HS[p] = true;
p = BS[p];
if (p ... | D |
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;
immutable long mod = 10^^9 + 7;
immutable long inf = mod;
void main(){
long m, n;
readVars(m, n);
long ans = modpow(m, n, mod... | 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 a, b, c, x, y;
scan(a, b, c, x,... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
int N = to!int(chomp(readln()));
int x = N * 800;
int y = (N / 15) * 200;
(x - y).writeln;
}
| D |
void main() {
"square1001".writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
impor... | 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 |
/+ dub.sdl:
name "E"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.range, std.algorithm, std.conv;
// import dcomp.scanner;
// import dcomp.algorithm;
int n;
long[] d, v;
bool check(long fi) {
v[] = d[];
foreach_reverse(i; 1..n) {
long x = v[i];
if (fi < x) return fals... | 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.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 |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.7.3"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int a, b, c;
sc.read(a, b, c);
if (a == b) writeln(c);
else if (b == c) writeln(a);
... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
enum S { E = 0, A = 1, B = 2 };
void main() {
string s = readln.strip;
immutable n = s.length;
auto z = new dchar[n];
s.copy(z);
debug stderr.writeln(z);
long res;
int i;
int cnt;
S t = S... | 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;
auto input()
{
return readln().chomp();
}
alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long x;
scan(x);
long k = 1;
while ((x * k) % 360 != 0)
{
k++;
}
writeln(k);
}
void scan(L...)(ref L A)
{
auto ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto N = S.length;
long min_n;
auto ns = new long[](N+1);
long x;
foreach (i; 1..N+1) {
if (S[i-1] == '<') {
ns[i] = ++x;
} els... | D |
void main() {
problem();
}
void problem() {
auto a = scan!long;
long solve() {
auto mod = a % 1000;
return mod == 0 ? 0 : 1000 - mod;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto A=readln.chomp;
writeln(A.replace(","," "));
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n, h, w;
scan(n);
scan(h);
scan(w);
... | D |
import std.stdio, std.conv, std.array,std.string;
void main()
{
string[] input=readln.split;
int a=input[0].to!int,b=input[1].to!int;
if((a*b)%2==0){
writeln("Even");
}else{
writeln("Odd");
}
} | 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.math,std.string,std.conv,std.typecons,std.format;
import std.algorithm,std.range,std.array;
T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
//END OF TEMPLATE
void main(){
ulong k;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto s = readln.chomp;
size_t i, j = s.length-1;
int c;
while (j > i) {
if (s[i] == s[j]) {
++i; --j;
} else if (s[i] == 'x') {
++i; ++c;
... | 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 |
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() {
long n, p;
scan(n, p);
long ans = 1;
for (long i = 2; i*i <= p; i++) {
int cnt;
while (p % i == 0) {
p... | D |
void main()
{
string s = rdStr;
string t = "AKIHABARA";
string u;
foreach (i, x; s)
{
if (i == 0 && x != 'A') u ~= 'A';
if ((x == 'B' || x == 'R') && u.back != 'A') u ~= 'A';
u ~= x;
if (i == s.length - 1 && x == 'R') u ~= 'A';
}
writeln(t == u ? "YES" : "NO... | D |
import core.stdc.stdio;
import std.typecons;
import std.algorithm;
struct Seg{
Seg* l,r;
int c;
}
int Count(Seg* x){
return x is null?0:x.c;
}
Seg* Left(Seg* x){
return x is null?null:x.l;
}
Seg* Right(Seg* x){
return x is null?null:x.r;
}
Seg[] buf;
Seg* newSeg(Seg* l,Seg* r){
static int i;
buf[i]=Seg(l,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 inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n;
scan(n);
int ma;
int ans;
... | D |
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
int main() {
int[] hs;
string l;
while((l = readln()).length >= 2) printf("%d\n", to!string(to!int(l.split()[0]) + to!int(l.split()[1])).length);
return 0;
} | D |
import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
void main()
{
int[] input = readln().split.to!(int[]);
int N = input[0];
int M = input[1];
int C = i... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, m;
rd(n, m);
auto a=readln.split.to!(int[]);
auto b=readln.split.to!(int[]);
int mx=0;
foreach(i; 0..m){
int j=i;
foreach(e; a){
if(j>=m) break;
if(e==b[j]) j++;
}
mx=max(mx, j-i);
}
writeln(mx... | 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, b; readV(a, b);
writel... | D |
import std;
void main() {
int n;
scanf("%d\n", &n);
auto as = readln.chomp.split.to!(int[]);
long count = 0;
int[long] memj;
foreach(i;0..as.length) {
++memj[i-as[i]];
}
foreach(i;0..as.length) {
if (i+as[i] in memj) {
count += memj[i+as[i]];
}
}
write(count);
}
| 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 a = readln.chomp[0];
auto b = readln.chomp[1];
auto c = re... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;
void main() {
auto S = readln.chomp;
auto N = S.length.to!int;
int[] cnt = new int[](26);
foreach (s; S) cnt[... | 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 N = to!string(tokens[0]);
ulong ans;
foreach (e; N)
{
if (e == '2') +... | 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;
}
void main() {
while (true) {
auto ab = r... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
auto s=readln.chomp.to!(char[]);
int w; rd(w);
auto t="".to!(char[]);
int i=0;
while(i<s.length){
t~=s[i];
i+=w;
}
writeln(t);
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
ass... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;
void main() {
int sum = 0;
foreach (i; 0..10) {
sum += readln.chomp.to!int;
}
sum.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 std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
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;
}
void main() {
string s;
... | 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 |
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.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 s = readln.split.map!(to!int);
auto N = s[0];
auto L = s[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.stdlib;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto K = s[1];
auto C = s[2];
auto S ... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
writeln(readln.chomp.to!int < 1200 ? "ABC" : "ARC");
}
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.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.algorithm, std.conv, std.array, std.string;
void main()
{
auto stxy = readln.split.to!(int[]);
auto xd = stxy[2] - stxy[0];
auto yd = stxy[3] - stxy[1];
string ret;
foreach (_; 0..yd) ret ~= "U";
foreach (_; 0..xd) ret ~= "R";
foreach (_; 0..yd) ret ~= "D";
foreac... | 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.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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp;
int l = N.length.to!int;
int r, p;
foreach (int i, c; N) {
auto n = c-48;
if (n) {
r = max(r, p + n-1 + (l-i-1)*9);
p += n;... | 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() {
string s;
scan(s);
bool fir... | 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) {
string str = readln.chomp;
if (str ==... | D |
import std.stdio;
import std.string;
import std.algorithm.mutation;
void main()
{
readln;
string[] s = readln.split;
s.reverse();
writeln(s.join(" "));
} | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
do{
auto m = iota(8).map!(_=>countUntil(readln().chomp(),'1')).array().filter!"a>=0"().array();
char c='Z';
switch(m.length)
{
case 1:
c = 'C';
break;
... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.