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 nk = readln.split.to!(int[]);
auto K = nk[1]-1;
auto S = readln.chomp.to!(char[]);
if (S[K] == 'A') {
S[K] = 'a';
} else if (S[K] == 'B') {
S[K] = 'b';
} els... | 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;
void main() {
auto s = readln.chomp;
int ans;
foreach (... | 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;
void main() {
int n, k;
scan(n, k);
bool ok = (n + 1) / ... | D |
void main(){
string[] weather = ["Sunny", "Cloudy", "Rainy", "Sunny"];
string now = readln().chomp();
weather = weather.find(now);
weather[1].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行に同一型の複... | D |
import std.stdio, std.string, std.array, std.conv;
void main() {
string[] board = ["#", "."];
while (true) {
int[] tmp = readln.chomp.split.to!(int[]);
int h = tmp[0], w = tmp[1];
if (h == 0 && w == 0) break;
foreach (i; 0 .. h) {
foreach (j; 0 .. w) {
... | D |
void main()
{
auto S = rs;
auto ltarr = new int[](S.length); // <
auto gtarr = new int[](S.length); // >
ltarr[0] = S[0] == '<' ? 1 : 0;
foreach (i; 1 .. S.length)
{
if (S[i] == '<')
ltarr[i] = ltarr[i - 1] + 1;
else
ltarr[i] = 0;
}
gtarr[$ - 1] ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
long P = 10^^9+7;
long[1001] F, RF;
long pow(long x, long n) {
long y = 1;
while (n) {
if (n%2 == 1) y = (y * x) % P;
x = x^^2 % P;
n /= 2;
}
return y;
}
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;
void main() {
int n;
scan(n);
auto ans = (n + 999) / 1000 * 1000 - n;
writeln(ans);
}
void scan(T...)(ref T args) {
auto line = rea... | 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;
long m, a, r, c, h;
foreach (_; 0..N) {
switch (readln[0]) {
case 'M': ++m; break;
case 'A': ++a; break;
case 'R': +... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
writeln(readln.chomp.replace(",", " "));
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primitives;
auto lin... | 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;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[0] * ip[1... | D |
import std.array : split;
import std.conv : to;
import std.stdio;
import std.string : strip;
private {
string[] temp;
}
void main() {
read();
int n = get!int(0);
int[] h = new int[n];
int[] a = new int[n];
foreach (i; 0 .. n) {
read();
h[i] = get!int(0);
a[i] = get!int(1);
}
int count = 0;
foreach... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto a = readln.chomp.to!int;
auto s = readln.chomp;
writeln(a >= 3200 ? s : "red");
} | 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.algorithm;
import std.array;
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[] reads(T)() { return r... | D |
import std;
long calc(string s) {
int n = cast(int)s.length;
auto acc = new int[][](3, n);
foreach (i; 0..n) {
acc[0][i] = (s[i] == 'R') + (i > 0 ? acc[0][i-1] : 0);
acc[1][i] = (s[i] == 'G') + (i > 0 ? acc[1][i-1] : 0);
acc[2][i] = (s[i] == 'B') + (i > 0 ? acc[2][i-1] : 0);
}... | 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, std.datetime;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generat... | D |
import std.conv;
import std.stdio;
import std.array;
import std.range;
import std.string;
import std.algorithm;
void main()
{
while(true)
{
auto n = readln.chomp.to!int;
if(n == 0) break;
auto hs = readln.split.map!(a => a.to!int()).array;
foreach(i; 0..(n+1)) {
if(isCommonDiff(hs[0..i] ~ hs[(i+1)..(n... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
void main ()
{
foreach (test; 0..readln.strip.to !(int))
{
auto n = readln.strip.to !(int);
auto a = readln.splitter.map !(to !(int)).array;
auto num = new int [] [] (n, n + 1);
foreach (i; 0..n)
{
foreach (j; ... | 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 |
// 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;
void main() {
int h1, m1, h2, m2, k; scan(h1, m1, h2, m2, k);
int a = h1 * 60 + m1;
int b = h2 * 60 + m2;
writeln(max(0, b - a - k));
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[... | 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;
void main() {
uint n = readln.strip.to!int;
auto s = readln[0 .. n];
auto l = s.count ('L');
auto r = s.count ('R'... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.map!(to!int), a = rd[0], b = rd[1];
if (a == b) writeln("a == b");
else writeln(a > b ? "a > b" : "a < b");
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
bool[int] buf;
foreach (_; 0..n) {
auto a = readln.chomp.to!int;
if (a in buf) {
buf.remove(a);
} else {
buf[a] = true;
}
}
writeln(buf.length);
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
int[10^^5] PXS, MXS;
void main()
{
auto nk = readln.split.to!(int[]);
auto N = nk[0];
auto K = nk[1];
int i, j;
foreach (x; readln.split.to!(int[])) {
if (x > 0) {
PXS[i++] = x;
} else if (x < ... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto w=new int[](n), h=new int[](n);
foreach(i; 0..n) rd(w[i], h[i]);
int cur=1_000_000_000+1;
foreach(i; 0..n){
if(cur<min(w[i], h[i])){
writeln("NO");
return;
}
if(cur>=max(w[i], h[i])) cur=max(w[i]... | 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 = 1L << 50;
void main() {
int n, k;
scan(n, k);
auto h = readln.split.to!(int[]);
auto dp = new long[](n + 1);
foreach (i ; 1 .. n) ... | D |
import std.stdio;
import std.array;
import std.conv;
import std.math;
import std.string;
void main()
{
int[] addinput = new int[200];
int anslength;
string s;
int i = -1;
while( (s=readln()).length > 1 )
{
i ++;
anslength = i;
string[] input = split(s);
int a = to!int(input[0]);
int b = to!int(inpu... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
void main() {
int n = readln.strip.to!int;
auto s = readln.strip;
foreach (c; s) {
auto i = c.to!int - 65;
i = (i + n) % 26;
write((65+i).to!char);
}
writeln;
}
| D |
void main()
{
long n = rdElem;
long k = rdElem;
long[] x = rdRow;
long total;
foreach (y; x)
{
total += 2 * min(y, k-y);
}
total.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... | 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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split, n = rd[0].to!size_t, a = rd[1].to!long, b = rd[2].to!long, c = a-b;
auto h = new long[](n);
foreach (i; 0..n) h[i] = readln.chomp.to!long;
auto calc(long x)
{
auto y = 0;
foreach (hi; h) {
a... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto s = readln.chomp;
auto nc = s.count('N');
auto wc = s.cou... | 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.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 a, b; readV(a, b);
auto c = ... | 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.stdio, std.string, std.algorithm, std.range, std.conv;
void main(){
while(true){
auto input = readln.split;
int n = input[0].to!int, k = input[1].to!int;
if(n == 0 && k == 0) break;
auto G = new int[][](n + 1, n + 1);
foreach(ref g; G){
g[] = int.max;... | 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 |
unittest
{
assert( [ "atcoder beginner contest" ].parse.expand.solve == "ABC" );
assert( [ "resident register number" ].parse.expand.solve == "RRN" );
assert( [ "k nearest neighbor" ].parse.expand.solve == "KNN" );
assert( [ "async layered coding" ].parse.expand.solve == "ALC" );
}
import std.conv;
import std.ra... | 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() {
while (true) {
int n, p;
scan(n, p);
if (n == 0 && p == 0) return;
auto m = new int[](n);
int pos;
int ... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional;
void main() {
auto tmp = readln.split.to!(int[]);
auto A = tmp[0], B = tmp[1];
iota(1,4).any!(C => A * B * C % 2 == 1).pipe!(b => b ? "Yes" : "No").writeln;
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
alias CSF = Tuple!(long, "c", long, "s", long, "f");
void main()
{
auto N = readln.chomp.to!int;
CSF[] ss;
foreach (_; 0..N-1) {
auto csf = readln.split.to!(long[]);
ss ~= CSF(csf[0], csf... | 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 nk = readln.split.to!(int[]);
auto N = nk[0];
long K = nk[1];
auto AS = readln.split.to!(int[]);
long[] xs, ys;
xs.length = N;
ys.length = N;
fo... | D |
module app;
import core.bitop;
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;
struct Input
{
int h;
int n;
int[] a;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
auto array = readln().strip().split();
h = a... | 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(){
string s = readln.chomp;
... | D |
import std.stdio : readln, writeln;
import std.array : split;
import std.conv : to;
import std.typecons;
import std.algorithm : map;
import std.string : chomp;
char[Tuple!(int, int)] field;
int W, H;
void dfs(int x, int y, char f) {
field[tuple(x, y)] = '.';
foreach (dx; [-1, 1]) {
int nx = x + dx;
if (0 ... | 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.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 S = N.iota.map!(_ => readln.chomp).array;
int[string] cnt;
foreach (s; S) ... | 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 chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons;
// }}}
// nep.scanner {{{
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
import ... | D |
import std.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 chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons;
// }}}
// nep.scanner {{{
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
import ... | D |
import std.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;
void main() {
int n, m;
scan(n, m);
auto cnt = new int... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm;
long lcm(long x, long y) {
import std.numeric;
return x * y / gcd(x, y);
}
void main() {
long[] tmp = readln.split.to!(long[]);
long a = tmp[0] - 1, b = tmp[1], c = tmp[2], d = tmp[3];
long l = lcm(c, d);
long n = b - b / c - b ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.algorithm;
import std.math;
import std.regex;
void main() {
auto s = readln.chomp.map!(a => a.to!int).array;
auto t = s.sort().uniq.array;
if(s.length != t.length) "no".writeln;
else "yes".writeln;
} | D |
void main() {
auto S = readln.split;
int[] stack;
foreach(i; S) {
int num;
try {
num = i.to!int;
stack ~= num;
} catch(Exception e) {
auto a = stack.back;
stack.popBack;
auto b = stack.back;
stack.popBack;
stack ~= i.predSwitch("+", b+a, "-", b-a, "*", b*a);
}
}
stack.back.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;
import std.numeric;
void main()
{
auto n = readln.chomp.to!int;
auto s = new int[](n);
foreach ... | 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;
void main(){
int N, M, l, r, x;
readVars(N, M);
auto p = readln.split.to!(int[]);
int cnt;
foreach(i ; 0 .. M){
... | 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 |
void solve(){
}
void main(){
string s = instr();
(700+s.count('o')*100).writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
alias instr = () => readln().chomp();
T inelm(T= int)(){ return to!(T)( readln().chomp() ); }
T[] inary(T = int)... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
import std.range;
void main() {
auto w = readln.chomp.to!(dchar[]);
auto s = w.sort().uniq;
foreach(s_i; s) {
if(w.count(s_i) % 2 == 1) {
"No".writeln;
return;
}
}
"Yes".writeln;
} | D |
import std.stdio;
import std.conv;
import std.string;
void main(){
int[] str = readln.chomp.split.to!(int[]);
int time = str[0];
int qty = str[1];
int duration = str[2];
writeln(duration / time * qty);
} | D |
void main()
{
long n = rdElem;
Graph[] g;
foreach (i; 1 .. n)
{
foreach (j; i+1 ..n+1)
{
if (i + j != (n + !(n & 1))) g ~= Graph(i, j);
}
}
g.length.writeln;
foreach (x; g)
{
writeln(x.a, " ", x.b);
}
}
struct Graph
{
long a, b;
}
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 |
/+ dub.sdl:
name "C"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
long calc(long[] a) {
int n = a.length.to!int;
if (a[0]) return -1;
long sm = 0;
foreach (i; 1..n) {
if (a[i-1]+1 < a[i]) retur... | 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;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return r... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto Z=readln.split.to!(int[]),a=Z[0],b=Z[1];
if(a<=b)writeln(a);
else writeln(a-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;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
/// 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;
auto head = S[0..7];
auto tail = S[$-7..$];
foreach (i; 0..8) {
if (head[0..i] ~ tail[i..7] == "keyence") {
writeln("YES");
return... | 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();
long bignum... | 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 bs = new int[][](K+2, K+2);
auto ws = new int[][](K+2, K+2);
foreach (_; 0..N) ... | 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, core.bitop;
enum P = 998244353;
void main()
{
auto ns = readln.split.to!(long[]);
auto N = ns[0];
auto S = ns[1];
auto as = readln.split.to!(long[]);
auto DP = new long[][](N, S+1);
foreach (... | 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;
void main() {
int n;
scan(n);
auto a = readln.split.to!(... | 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() {
writeln(readln.chomp.to!int^^3);
} | 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;
// }}}
// tbh.scanner {{{
class Scanner {
import std.stdio;
import std.conv : to;
import std.ar... | 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 N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
long ans = 0;
foreach (a... | D |
void main()
{
int n = readln.chomp.to!int;
string s = readln.chomp;
writeln(s.count('R') > s.count('B') ? "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;
import std.container;
import std.t... | D |
import std.stdio;
/* Hello World Program in D Programming */
void main(string[ ] args)
{
int n;
scanf("%d", &n);
int[211111] a;
int a_len = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
for (int i = 0; i < n; ++i) {
a[a_len] = a[i];
++a_len;
while (a... | 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 |
module main;
import core.stdc.stdio;
int max(int a,int b){
if(a>b) return a; else return b;
}
int main(){
int n;
scanf("%d",&n);
if(n==1){
printf("23:59");
return 0;
}
int [] arr=new int[105];
for(int i=0;i<n;i++){
int a,b;
scanf("%d:%d",&a,&b);
... | D |
import std;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i]... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int x, a, b;
scan(x, a, b);
writeln(abs(x - a) < abs(x - b) ? "A" : "B");
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (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.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto a = readln.chomp.split.to!(int[]);
min(a[0]*a[1], a[2]).writ... | 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;
void main() {
auto s = readln.chomp;
auto mae = s[0..2].to!... | D |
import std.array;
import std.conv;
import std.string;
import std.algorithm;
import std.stdio;
void main() {
auto length = readln.chomp.to!uint;
auto a = readln.chomp.split(" ").map!(to!uint).array;
assert(length >= 1);
assert(a.length == length);
auto sieve = new uint[1000008];
foreach (size_t i, e;a) {
if (... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
auto hi = new int[](s.length + 1);
foreach (i, c; s)
hi[i + 1] = hi[i] + c.predSwitch('\\', -1, '_', 0, '/', 1);
auto maxH = hi.reduce!(max);
auto fs1 = hi.findSplitBefore([maxH]), hiL = fs1[0], hiMR ... | 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 |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n, m;
rd(n, m);
struct E {
int u, v;
}
auto edges = new E[](m);
foreach (i; 0 .. m) {
rd(edges[i].u, edges[i].v);
edges[i].u--;
edges[i].v--;
}
int b = 0;
foreach (i; 0 .. m) {
auto g = new int[][](n);
... | D |
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
void main()
{
string n = chomp(readln());
int a = to!int(n);
if(a/100%10 == a/10%10 && (a/100%10 == a/1000 || a/100%10 == a%10)){
writeln("Yes");
} else {
writeln("No");
}
} | D |
void main() {
auto s = rs, t = rs;
size_t[][char] m;
foreach(i, c; s) m[c] ~= i + 1;
long last, loopc;
auto N = s.length;
foreach(c; t) {
if(c !in m) {
writeln(-1);
return;
}
auto k = m[c].assumeSorted.upperBound(last);
debug writefln("%s %s", m[c], k);
if(k.empty) {
loopc++;
last = m[c][0]... | 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()
{
int[31] stu;
foreach (i; 0..28) {
stu[readln.chomp.to!int]++;
}
foreach (i; 1..31) {
if (!stu[i]) i.writeln;
}
} | D |
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto s = readln.chomp;
writeln(s[0..4]~" "~s[4..$]);
} | 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 |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ab = readln.split.to!(real[]);
auto A = ab[0];
auto B = ab[1];
writeln((A * B).to!long);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp.dup, ns = s.length;
auto t = readln.chomp, nt = t.length;
loop: foreach_reverse (i; 0..ns-nt+1) {
foreach (j; 0..nt)
if (s[i+j] != '?' && s[i+j] != t[j]) continue loop;
s[i..i+nt][] = t[];
wri... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto r = readln.chomp.to!int;
auto g = readln.chomp.to!int;
writeln(2*g-r);
}
| D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.