code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
void main()
{
dchar[] s = readln.chomp.to!(dchar[]);
dchar[] t = s.dup;
reverse(t);
long cnt;
foreach (i; 0 .. s.length/2)
{
if (s[i] != t[i]) ++cnt;
}
cnt.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range... | D |
import std.stdio, std.string, std.conv;
void main()
{
while(true)
{
int n=readln.chomp.to!int;
if(!n)break;
int num;
for(int i=1; i<n; ++i)
{
int sum;
for(int j=i; j<n; ++j)
{
sum+=j;
if(sum == n) ++num... | 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() {
int sum = 0;
foreach(int i; 0..5) {
sum += max(40, read... | D |
import std;
void main(){
int n, k;
int[] as;
scanf("%d %d\n", &n, &k);
auto mem = new bool[n];
foreach(_i; 0..k) {
int d;
scanf("%d", &d);
foreach (_j; 0..d) {
int a;
scanf("%d", &a);
mem[a-1] |= true;
}
}
mem.count!"!a".writeln;
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto S_ = readln.chomp.to!(wchar[]);
auto T = readln.chomp.to!(wchar[]);
wchar[] S;
foreach_reverse (i; 0..S_.length - T.length + 1) {
auto s = S_.dup;
foreach_reverse (j; 0..T.lengt... | 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;
if (N%2 == 1) {
writeln("No");
return;
}
foreach (i; 0..N/2) {
if (S[i] != S[N/2+i]) {
writel... | 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;
import std.string;
import std.conv;
void main(){
while(true){
auto s = readln();
if(stdin.eof()) break;
real w = to!real(chomp(s));
if(w <= 48.0) writeln("light fly");
else if(w <= 51.0) writeln("fly");
else if(w <= 54.0) writeln("bantam");
else if(w <= 57.0) writeln("feather");
else if(... | 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()
{
int n; readV(n);
int a; readV(a);
writeln(n*n-a);
}
| D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const N = readln.chomp.to!long;
iota(1,N+1).filter!(x => x < 10 || (100 <= x && x < 1000) || (10000 <= x && x < 100000)).walkLength.writeln;
}
| 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 K = s[1... | 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[]);
auto T = readln.chomp.to!(char[]);
int r;
foreach (i; 0..3) if (S[i] == T[i]) ++r;
writeln(r);
} | 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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.array;
int n; rd(n);
long[int] freq;
auto y=new int[](n);
auto ng=new bool[](n);
foreach(i; 0..n){
auto s=readln.chomp.to!(char[]);
char[] st;
foreach(c; s){
if(c=='('){
st~='(';
}else{
... | D |
import std.stdio;
import std.algorithm;
void main()
{
int n;
scanf("%d", &n);
bool[] used = new bool[n];
char[] gender = new char[n];
int[] from = new int[n];
int[] to = new int[n];
for (int i = 0; i < n; i++) {
char[10] s;
scanf("%s%d%d", s.ptr, &from[i], &to[i]);
gender[i] = s[0];
}
int res = ... | 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 |
module _;
void main() {
import std.stdio;
import std.string, std.conv;
int n = readln.strip.to!int;
auto s = readln.strip;
bool check(int limit, ref string co, bool doco) {
int r = 0, b = 0;
foreach(ch; s) {
if (ch == '(') {
if (r < limit) {
r++;
if (doco) co ~= '0';
} else if (b < limit)... | 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 |
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.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()
{
string s = rdStr;
long len = s.length;
long[][] dp = new long[][](len+1, 4);
dp[0][0] = 1;
foreach (i, x; s)
{
long c = (x == '?' ? 3 : 1);
foreach (j; 0 .. 4)
{
dp[i+1][j] = (dp[i+1][j] + c * dp[i][j]) % mod;
if (j == 3) continue;
... | 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.algorithm;
import std.algorithm:rev=reverse;
int main(){
auto s=readln.chomp.dup;
foreach(t;s[1..3]){
if(t!=s[0]){
writeln("Yes");
return 0;
}
}
writeln("No");
return 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;
// 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;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
while(true){
auto s = readln();
if(stdin.eof()) break;
int n = to!int(chomp(s));
int ans = 1;
for(int i=1;i<=n;i++)
ans += i;
writeln(ans);
}
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
import std.math;
void main(){
auto z=readln.split.map!(to!int);
auto A=z[0]+z[1];
auto B=z[0]-z[1];
auto C=z[0]*z[1];
writeln(max(A,B,C));
} | D |
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
bool solve (string s, string t)
{
if ((s.length % 2) != (t.length % 2))
{
s = s[1..$];
}
int pos = 0;
bool skip = false;
foreach (ref c; s)
{
if (skip)
{
skip = false;
continue;
}
if (t[pos] == c)
{
... | D |
import std.stdio, std.string, std.conv;
import std.math;
void main() {
auto input = getStdin!(int[])()[0];
auto result = pow(input, 3);
result.writeln;
}
T getStdin(T)() {
string[] cmd;
string line;
while ((line = chomp(stdin.readln())) != "") cmd ~= line;
return to!(T)(cmd);
} | 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;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof) {
return fals... | D |
import std.stdio;
import std.conv;
import std.string;
void main(){
string str;
while((str = readln()).length != 0){
int n = to!int(chomp(str));
int cv;
foreach(a; 0 .. 10){
foreach(b; 0 .. 10){
foreach(c; 0 .. 10){
int d = n - a - b - c;
if(0 <= d && d <= 9){
cv++;
}
}
}
... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const N = readln.chomp.to!long;
const S = readln.chomp;
auto leftList = new long[N+1];
foreach (i; 0..N) leftList[i+1] = S[i] == 'E' ? 1 : 0;
foreach (i; 0..N) leftList[i+1] += leftLis... | 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;
foreach (i;0..s.length) {
write('x');
}
writeln();
}
| 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 int inf = 1<<20;
void main(){
int N, M, a, b, c;
readVars(N, M);
auto cost = new int[][](N, N);
foreach(i ; 0 ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;
void main()
{
auto N = readln.chomp.to!(char[]);
if (N.length == 1) {
writeln(N);
return;
}
long ret, r;
foreach (i, d; N) {
if (!i) {
long s = d-49... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; long y; rd(n, y);
for(int i=0; i<=n; i++)for(int j=0; i+j<=n; j++){
auto k=n-(i+j);
if(10000*i+5000*j+1000*k == y){
writeln(i, " ", j, " ", k); return;
}
}
writeln(-1, " ", -1, " ", -1);
}
void rd(T...)(ref T x)... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto s = readln.chomp.to!(dchar[]);
foreach (i, c; s) if (i % 2 == 0) write(c);
writeln("");
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
auto p = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1];
int x, y;
scan(x, y);
writeln(p[x] == p[y] ? "Yes" : "No");
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : s... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
long[(10^^6)*2+50] 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 inv(lo... | 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(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | 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 n = readln.chomp.to!int;
writeln(n/3);
}
| 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.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 s; readV(s);
writeln(s.co... | D |
import std.functional,
std.algorithm,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
int[] XYZ = readln.chomp.split.to!(int[]);
int X = XYZ[0],
Y = XYZ[1],
Z = XYZ[2];
int n = X - Z;
writeln(n / ... | 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.algorithm;
import std.conv;
import std.array, std.string;
import std.range;
void main(string[] args) {
auto input = readln().chomp.split.map!(to!int);
if(input[0] <= 8 && input[1] <= 8){
"Yay!".writeln;
}else{
":(".writeln;
}
} | 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;
auto input()
{
return readln().chomp();
}
alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long a, b;
scan(a, b);
if ((a <= 9) && (b <= 9))
{
writeln(a * b);
}
else
{
writeln(-1);
}
}
void scan(L... | D |
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;
void main() {
auto n = readln.split[0].to!int;
auto n1 = n/100, n2 = (n - n1*100)/10, n3 = (n - n1*100 - n2*10);
if (n1 == 1) n1 = 9; else if (n1 == 9) n1 = 1;
if (n2 == 1) n2 = ... | 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, w, h;
int s, t;
scan(n);
if (!n) return;
scan(w, h);
auto bd = new int[][](w + 1... | D |
import std.stdio, std.string, std.conv, std.algorithm;
void main()
{
bool[3] cups;
cups[0] = true;
while(true)
{
auto line = readln;
if(!line)break;
auto f = line.chomp.split(",");
swap(cups[f[0][0] - 'A'], cups[f[1][0] - 'A']);
}
foreach(i, cup; cups)
{
... | D |
/* imports all std modules {{{*/
import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.encoding,
std.exception,
std.file,
std.format,
std.functi... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto S = readln.chomp;
auto ls = new bool[][](N, 10);
auto rs = new bool[][](N, 10);
foreach (i; 0..N) {
if (i != 0) {
foreach (j; ... | D |
void main() {
string a = readln.chomp;
string b = readln.chomp;
if (a.length > b.length) {
"GREATER".writeln;
} else if (a.length < b.length) {
"LESS".writeln;
} else {
if (a > b) {
"GREATER".writeln;
} else if (a < b) {
"LESS".writeln;
... | D |
void main(){
int n = _scan();
int a, b;
if(n==2){
a = _scan();
b = _scan();
}
writeln( n==1? "Hello World": ( a+b ).to!string);
}
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 = ... | 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 |
void main(){
int n = _scan();
int ans;
if(n<600)ans=8;
else if(n<800)ans=7;
else if(n<1000)ans=6;
else if(n<1200)ans=5;
else if(n<1400)ans=4;
else if(n<1600)ans=3;
else if(n<1800)ans=2;
else if(n<2000)ans=1;
ans.writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1... | 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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto X = readln.chomp.to!int;
auto n = X / 100;
auto d = X % 100;
int c;
while (d >= 5) {
d -= 5;
++c;
}
if (d >= 4) {
d -= 4;
++c;
}
... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
import std.typecons : Tuple;
alias Edge = Tuple!(int, "to", int, "cost");
void main() {
int n,m;
scan(n,m);
auto adj = new Edge[][](n, 0);
foreach (i ; 0 .. m) {
int a, b, c;
scan(a, b, c);
a-... | D |
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
immutable N = s_.to!int();
auto ab = new long[2][N];
foreach(ref v;ab) v = readln.split.map!(to!long).array();
long c=0;
foreach_reverse(ref v;ab) {
immutable a=v[0], b=v[1];
c+=(b-(a+c)%... | D |
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.math;
void main() {
auto N = readln.chomp.to!ulong;
writeln(pow(N, 3));
}
| 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;
int a, b;
void main() {
int a, b, c;
scan(a, b, c);
writeln(min(min(a + b, b + c), a + c));
}
void scan(T...)(... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
int r = readln.chomp.to!(int);
if (r < 1200) {
writeln("ABC");
}
else if (r < 2800) {
writeln("ARC");
}
else {
writeln("AGC");
}
}
| D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() ... | D |
import std.stdio, std.string;
void main(){
auto s=readln.chomp;
foreach(i;0..s.length-1)if(s[i]==s[i+1]){
writeln(i+1," ",i+2);
return;
}
foreach(i;0..s.length-2)if(s[i]==s[i+2]){
writeln(i+1," ",i+3);
return;
}
writeln("-1 -1");
} | 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)() { 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 mod = pow... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto m = readln.chomp.to!int;
writeln(48 - m);
} | 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, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
void main()
{
auto N = readln.chomp.to!long;
auto s = readln.chomp.to!(char[]);
auto DP = new long[][](N, N);
foreach (i; 0..N) DP[0][i] = 1;
foreach (i; 1..N) {
long c... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1], c = tmp[2], d = tmp[3];
writeln(abs(a-c) <= d || max(abs(a-b), abs(b-c)) <= d ? "Yes" : "No");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
im... | D |
import std.stdio;
import std.math;
import std.conv;
import std.string;
void main() {
const int MAX = 1000000;
int[MAX] p;
p[2] = 1;
for (int i = 3; i < MAX; i++) {
if (i % 2 == 0) {
p[i] = p[i-1];
} else if (isPrime(i)) {
p[i] = p[i-1] + 1;
} else {
... | D |
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.string;
void main() {
int n=to!int(readln().strip());
for(int i=0;i<n;i++){
auto bs=readln().split().map!(to!int)().array();
int s1=-1,s2=-1;
bool flag = true;
... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
string n; rd(n);
if(n[0]=='9' || n[1]=='9') writeln("Yes");
else writeln("No");
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
foreach(i, ref e; x){
e=l[i].to!(typeof(e));
}
} | 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, T; readlnTo(N, T);
int ans = int.max;
foreach(i; 0..N) {
int c, t; readlnTo(c, t);
if (t <= T)
ans = min(c,... | 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 a = readln.chomp.to!int;
auto b = readln.chomp.to!int;
auto h = readln.chomp... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n;
scan(n);
writeln(800*n - (n/15)*200);
}
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.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.stdc.stdio;
import std.typecons;
import std.conv;
import std.container;
import std.algorithm;
void main(){
int n,m,x;
scanf("%d%d%d",&n,&m,&x);
int[] hs = new int[n];
for(int i=0;i<n;i++)
scanf("%d",&hs[i]);
alias Tuple!(long,"cost",int,"idx") ci;
ci[][] graph = new ci[][n];
for(int i=0;i<m;i++){
... | D |
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
void main(){
auto a = readln.chomp.to!int;
auto b = readln.chomp.to!int;
auto c = readln.chomp.to!int;
auto d = readln.chomp.to!int;
auto e = readln.chomp.to!int;
auto k = readln.chomp.to!int;
if((b-a) <= k && (c-... | 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 n = readln.chomp.to!int % 500;
if (readln.chomp.to!int >= n)... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
long[10^^5+50] 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;
}
void init()
{
... | 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 s = readln.chomp;
writeln("2018" ~ s[4..$]);
}
| 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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
bool acgt(char c) {
return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}
void main()
{
auto S = readln.chomp.to!(char[]);
int max_l = 0;
foreach (int i; 0..cast(int)S.length) {
if (!acgt(S... | 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.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto S = readln.chomp.to!(char[]);
if (S.length == 3) S.reverse();
writeln(S);
} | D |
import std.stdio, std.string, std.conv, std.range, std.algorithm, std.array;
import std.numeric, std.math, std.typecons, std.container, core.bitop;
void main() {
int n,a,b;
scan(n,a,b);
writeln((b-a)&1 ? "Borys" : "Alice");
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (... | 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+j) % ... | D |
import std.stdio;
import std.conv;
import std.string;
import std.math;
int f(int x, int y) {
return x - y + 1;
}
void main() {
int n = readln.strip.to!int;
int h = readln.strip.to!int;
int w = readln.strip.to!int;
writeln(f(n, h) * f(n, w));
}
| 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 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, 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, a, b;
scan(n, a, b);
au... | D |
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);
void main() {
string s = readln.chomp;
foreach (i;0..3) if (s[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 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 route... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main ()
{
string a;
while ((a = readln.strip) != "")
{
auto n = a.length.to !(int);
int [char] w;
foreach (c; a)
{
w[c] += 1;
}
auto res = 1 + (n * (n - 1L)) / 2;
foreach (k, v; w)
{
res -= (v * ... | D |
import std.functional,
std.algorithm,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
long N = readln.chomp.to!long;
bool[long] A;
foreach (_; 0..N) {
long a = readln.chomp.to!long;
if (a in A) {
... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.