code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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 S = readln.split[0], T = readln.split[0];
int[26] s_data, t_data;
int[26] s_ord, t_ord;
int ord = 1;
foreach ( c; S ) {
if (s_ord[c-'a'] == 0) {
s_ord[... | D |
/+ dub.sdl:
name "F"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
// import dcomp.numeric.prime;
// import dcomp.numeric.primitive;
import std.numeric;
long powmod(long x, long n, long md) {
long r = 1;
while (... | 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.container;
import std.datetime;
void main()
{
auto res = iota(0, 1000001).array;
foreach_reverse (i; 0..1000001) {
foreach (y; 2..1001) {
auto py = y ... | D |
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.array;
void main() {
auto inp = readln().chomp;
int max;
for(int i; i<=(inp.length-1)/2; i++){
if(inp[0..i]==inp[i..i*2]){max=i*2;}
}
max.writeln;
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto md1 = readln.split.to!(int[]);
auto md2 = readln.split.to!(int[]);
writeln(md1[0] == md2[0] ? 0 : 1);
} | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;
void main() {
auto S = readln.chomp;
if(S == "Sunny") {
"Cloudy".writeln;
} else if (S=="Cloudy") {
"Rainy".writeln;
} else if(S=="Rainy") {
"Sunny".writeln;
}
}
| D |
void main() {
auto n = ri;
n %= 10;
switch(n) {
case 2, 4, 5, 7, 9:
writeln("hon");
break;
case 0, 1, 6, 8:
writeln("pon");
break;
case 3:
writeln("bon");
break;
default: assert(0);
}
}
// ===================================
import std.stdio;
import std.stri... | 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.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, 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 |
void solve(){
}
void main(){
string s = instr();
writeln( s==s.dup.reverse.to!string?"Yes":"No" );
}
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[... | 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.container;
import std.datetime;
void main()
{
foreach (line; stdin.byLine) {
auto str = line.chomp;
if (str == "#") break;
int s, cnt;
foreach (e; s... | D |
import std.stdio, std.string;
void main() {
readln.chomp.replace(",", " ").writeln;
} | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
... | D |
import std.stdio, std.string, std.conv;
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("Right");
} else {
writeln("Balanced");
}
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm;
void main() {
int a,b;
scan(a,b);
writeln(a*b % 2 ? "Odd" : "Even");
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (ref arg; args) {
arg = line.front.to!(typeof(arg));
line.popFront(... | 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 core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;
alias sread = () => readln.chomp();
ulong bignu... | D |
import std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
int solve() {
auto s = readln.chomp;
int i=0, j=(s.length-1).to!int;
char x = 'x';
int res = 0;
while(i<j) {
if(s[i]==x&&s[j]==x) { i++; j--; continue; }
if(s[i]==x&&s[j]!=x) { i++; res++; ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import 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;
if(a>=b&&c>=d)writeln(b+d);
else if(a>=b&&c<=d)writeln(b+c);
else if... | D |
// Vicfred
// https://atcoder.jp/contests/abc176/tasks/abc176_c
// greedy
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main() {
long n = readln.chomp.to!long;
long[] a = readln.split.map!(to!long).array;
long last = a[0];
long ans = 0;
for(int... | 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 |
module aoj;
import std.conv;
import std.stdio;
import std.string;
int getInt() { return to!int(chomp(readln())); }
void main() {
int n;
while ((n = getInt()) != 0) {
int sum = 0;
foreach (i; 0 .. n/4) {
sum += getInt();
}
writeln(sum);
}
} | 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; }
/*
a[i]: i番目を踏むときの最善
漸化式は
a... | 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 S = readln... | 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;
alias T = Tuple!(int, int);
void main() {
immutable n = readln.strip.to!int;
long res;
int[4] c;
foreach (qid; 0 .. n) {
auto s = readln.strip;
int t1 =... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
void main() {
int x;
scan(x);
if (x == 3 || x == 5 || x == 7) {
writeln("YES");
}
else {
writeln("NO");
}
}
... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
void main()
{
string input;
int div;
while ((input = readln().chomp()).length != 0) {
div = input.to!int();
int[] position = iota(600).filter!(a => a % div == 0).array();
... | 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 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;
// }}}
// tbh.scanner {{{
class Scanner {
import std.stdio;
import std.conv ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
int calc(int x,int r){
return x * (r+100) / 100;
}
void main() {
while(true) {
string[] cin;
cin=split(readln());
int a=to!int(cin[0]),b=to!int(cin[1]),x=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, core.bitop;
void main() {
readln.chomp.count!"a == '2'".writeln;
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.... | 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(){
ulong ai, ao, at, aj, al, as, az;
{
ulong[] tmp = readln.chomp.split.map!(to!ulong).array;
ai = tmp[0], ao = tmp[1], at = tmp[2], aj = tmp[3],
al = tmp[... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto H = readln.split.to!(int[])[0];
foreach (A; readln.split.to!(int[])) H -= A;
writeln(H <= 0 ? "Yes" : "No");
} | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;
void main()
{
string s = readln().chomp;
long w = readln().chomp.to!long;
for (int i = 0; i < s.length; i += w)
{
write(s[i]);
}
writeln();
}
| 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 s = readln.strip;
int cur = 1;
foreach (i; 1..n)
{
cur += (s[i - 1] == s[i]);
}
writeln ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main()
{
auto N = to!int(split(readln())[0]);
auto input = split(readln());
auto D = to!int(input[0]), X = to!int(input[1]);
int[] A;
int n = X;
foreach (i; 0..N) {
n += (D-1) / ( to!int(split(readln())[0]) ) + 1;
}
writ... | D |
import std.stdio,
std.string,
std.conv;
void main() {
writeln((readln.chomp.split.join.to!int % 4) == 0? "YES" : "NO");
} | 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 K = readln.chomp.to!int;
foreach (ref c; s) {
if (c == 'a') continue;
int i = c-'a';
if (K < 26-i) continue;
c = 'a';
... | 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 abc = readln.split.to!(int[]);
auto A = abc[0];
auto B = abc[1];
auto C = abc[2];
auto K = readln.chomp.to!int;
int k;
while (B <= A) {
... | 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;
import std.ascii;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
bool ... | D |
import std.stdio;
import std.conv;
import std.numeric;
long f(long n, long c, long d) {
return n - (n / c) - (n / d) + (n / (c * d / gcd(c, d)));
}
void main() {
long a, b, c, d;
scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
write(f(b, c, d) - f(a-1, c, d));
}
| 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() {
long N;
scan(N);
foreach(h ; 1 .. 3501) {
foreach (n ; 1 .. 3501) {
long x = 4L * h * n;
long hn = 1L * h * n;
/... | D |
import std.stdio, std.string, std.algorithm, std.array, std.conv;
void main() {
auto input = readln.chomp.split.map!(to!int).array;
auto a = input[0];
auto b = input[1];
if (a < b) {
"a < b".writeln;
} else if (a > b) {
"a > b".writeln;
} else {
"a == b".writeln;
}
} | D |
import std.algorithm,
std.string,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
ulong[] NK = readln.chomp.split.to!(ulong[]);
ulong N = NK[0],
K = NK[1];
writeln(K * (K-1)^^(N-1));
}
| D |
void main() {
(700 + rs.count!(a => a == 'o') * 100).writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import ... | D |
import std;
void main() {
int N, M;
scan(N, M);
auto to1 = new bool[](N);
auto toN = new bool[](N);
foreach (i; 0 .. M) {
int ai, bi;
scan(ai, bi);
ai--, bi--;
if (ai == 0) {
to1[bi] = true;
}
if (bi == N - 1) {
toN[ai] = true;
}
}
bool ok;
foreach (i; 0 .. 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.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()
{
auto n = readln.chomp.to!size_t;
auto ai = readln.split;
ai.reverse();
writeln(ai.join(" "));
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto xab = readln.split.to!(long[]);
writeln( xab[1] - xab[2] >= 0 ? "delicious" : xab[1] + xab[0] >= xab[2] ? "safe" : "dangerous" );
} | 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, 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 m, k; readV(m, k);
if (m ==... | 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, c, d; readV(a, b, c, d);... | 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 ,std.conv , std.string;
void main(){
auto input = readLine!size_t();
solve(input[0],input[1]).writeln();
}
auto solve( size_t x, size_t y ) {
if( x < y ){
return 0;
} else {
return x-y;
}
}
unittest{
assert(1);
}
T[] readLine( T )(){
T[] ret;
foreach( val ; readln().chomp().split() ){
... | D |
import std.stdio,
std.string,
std.conv;
void main() {
int[] a = readln.chomp.split.to!(int[]);
writeln((a[0] + a[1] >= a[2]) ? "Yes" : "No");
}
| 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;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
void main() {
string[] inputs = split(readln());
int x = to!int(inputs[0]);
int a = to!int(inputs[1]);
int b = to!int(inputs[2]);
if(abs(x - a) < abs(x - b)) 'A'.writeln;
else 'B'.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.container;
import std.conv;
import std.math;
import std.numeric;
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 read... | 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;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
string RD() { return chomp(readln()); }
long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % m... | 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!ulong(tokens[0]);
ulong big, result;
foreach (i; 0..N)
{
auto p... | D |
import std.stdio;
int main(){
int n;
long c1 , c2;
scanf("%d %lld %lld" , &n , &c1 , &c2);
char arr;
int zeroes = 0;
int ones = 0;
for(int i = 0 ; i < n ; ++i){
scanf(" %c" , &arr);
if(arr == '0'){
++zeroes;
}
else{
++ones;
}
}
long ans = 800000000000000000L... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
bool ask (long value)
{
writeln ("? ", value);
stdout.flush ();
return readln.strip == "Y";
}
void answer (long value)
{
writeln ("! ", value);
stdout.flush ();
}
void main ()
{
... | D |
import std.stdio, std.string, std.conv;
void main() {
const tmp = readln.split.to!(int[]);
const N = tmp[0];
const X = tmp[1];
const Ls = readln.split.to!(int[]);
int p = 0;
int cnt;
foreach (i; 0..N+1) {
if (p > X) break;
p += Ls[i];
cnt++;
}
writeln(cnt);
}
| 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, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto len = S.length;
int c;
foreach (i; 0..len/2) {
if (S[i] != S[len-i-1]) ++c;
}
writeln(c);
} | D |
void main()
{
string s = rdStr;
writeln(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}
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 rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);
T rdElem(T)()
if (is(T == ... | 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;
void main() {
char[] s, t;
scan(s);
scan(t);
int n = s.length.to!int;
int m = t.length.to!int;
if (n < m) {
writeln("UNRESTORABLE");
return;
}
char[] ans = new char[](n);
bool exist;
foreach_reverse (i; 0 .. n - m + 1) {
if (match(s[i .. i + m], t)) {
foreach (j; 0 .. ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
long solve(int i, long n, long s) {
if (i == S.length) {
return n + s;
} else {
return solve(i+1, S[i]-'0', n+s) + solve(i+1, n*10+... | 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);
auto x = new long[](n + 1);
auto s = new int[](n + 1);
foreach (i ; 1 .. n + 1) {
scan(x[i], s[i]);
}
... | D |
void main() {
problem();
}
void problem() {
auto N = scan!int;
auto STONES = scan!string.to!(char[]);
long solve() {
long left = 0;
long right = N-1;
long ans;
while(left <= right) {
if (STONES[right] != 'R') {
right--;
continue;
}
if (STONES[left] != 'W') {
... | 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 c... | 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 |
void main() {
auto X = ri;
ulong res;
while(X >= 500) {
res += 1000;
X -= 500;
}
res += (X / 5) * 5;
res.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.contai... | 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;
int[string] t;
int sum;
foreach... | 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 |
/+ dub.sdl:
name "C"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.algorithm;
immutable L = 19;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
int n, q;
sc.read(n, q)... | 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.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.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;
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;
long sum;
foreach (int i; 1..n+1) {
if (i % 3 &&... | D |
import std.conv;
import std.stdio;
import std.string;
void main()
{
auto n = readln.strip.to!int;
writeln( solve( n ) );
}
auto solve( in int n )
{
if( n < 1000 ) return "ABC";
else return "ABD";
}
unittest
{
assert( solve( 999 ) == "ABC" );
assert( solve( 1000 ) == "ABD" );
assert( solve( 1481 ) =... | 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; }
string calc(Vec2 a, Vec2 b, Vec2 c) {
auto ab = b - a;
... | 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;
void main()
{
int m = readln.chomp.split.back.to!int;
string s = readln.chomp;
int l = 0, r = 1;
// bool[string] set;
bool[ulong[2]] set;
auto hasher = new ... | 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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const tmp = readln.split.to!(long[]);
writeln(max(0, tmp[2] - tmp[0] + tmp[1]));
}
| 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 |
// Code By H~$~C
import std.stdio;
import std.math, std.uni, std.format, std.bigint;
import std.array, std.string, std.container, std.range, std.typecons;
import std.algorithm, std.conv, std.functional, std.random;
immutable Maxn = 200005;
int n;
int[Maxn] c;
int[][Maxn] g;
long[Maxn] ans;
int[Maxn] sz, num;
void d... | 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 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;
int[(10^^5)*2+1] PS;
void main()
{
auto N = readln.chomp.to!int;
foreach (_; 0..N) {
auto p = readln.chomp.to!int;
PS[p] = PS[p-1] + 1;
}
int max = 0;
foreach (p; PS[0..N+1]) if (p > max) max = p;
writeln(N - ma... | 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 k, x;
scan(k, x);
writeln(500*k >= x ?... | D |
void main() {
char c = readln.chomp.to!char;
char[] vowels = ['a', 'e', 'i', 'o', 'u'];
writeln(vowels.canFind(c) ? "vowel" : "consonant");
}
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.conta... | D |
import std.stdio, std.string, std.conv;
void main() {
int x = readln.chomp.to!int;
writeln(x ^^ 3);
}
| D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.