code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
void main() {
auto D = ri;
switch(D) {
case 25: writeln("Christmas"); break;
case 24: writeln("Christmas Eve"); break;
case 23: writeln("Christmas Eve Eve"); break;
case 22: writeln("Christmas Eve Eve Eve"); break;
default: break;
}
}
// ===================================
import std.stdio;
import std.st... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1];
string s = readln.chomp;
bool ok = true;
foreach (i, x; s) {
if (i == a) {
if (x != '-') {
ok = false;
}
} else {
if (!x.isNumber) {
ok =... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.range;
void main()
{
auto N = readln.split[0].to!int;
auto H = readln.split.to!(int[]);
for(int i = N - 1; i > 0; i--) {
if(H[i-1] > H[i]) H[i-1]--;
}
for (int i = 1; i < N; i++)
{
if (H[i - 1] > H[i])
{
writeln("No")... | D |
import std.stdio;
import std.string; // chomp????????????????????????(?????????????????????)
import std.conv; // to????????????????????????
void main() {
int x = to!int(chomp(readln()));
writeln(x ^^ 3);
} | D |
void main()
{
string s = rdStr;
bool[] alpha = new bool[26];
if (s.length == 26)
{
alpha[s[$-1]-'a'] = true;
foreach_reverse (i; 0 .. 25)
{
if (s[i] < s[i+1])
{
s[0..i].write;
long idx;
foreach (j; s[i]-'a'+... | D |
import std.stdio, std.string, std.conv;
import std.math;
auto solve(string s_)
{
immutable n = s_.to!long();
immutable s = readln.chomp.to!long();
if(s==n) return s+1;
immutable m = sqrt(n.to!real()).to!long+1;
foreach(i;2..m)
{
long v=n, c=0;
while(v) c+=v%i, v/=i;
if(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.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.array;
import std.algorithm;
import std.conv;
int gcd (int x, int y) {
if(x < y) swap(x, y);
if(y == 0) return x;
return gcd(y, x % y);
}
void main () {
int a, b;
while(true) {
string[] input = split(readln());
if(input.length == 0) break;
a = t... | 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 Q = readln.chomp.to!int;
long ans;
while (Q--) {
auto n = readln.chomp.to!long;
if (n % 4 == ... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
void main()
{
readln.replace("peach", "~").replace("apple", "peach").replace("~", "apple").write;
} | 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;
writeln(a/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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto T = readln.chomp.to!int;
foreach (_t; 0..T) {
auto N = readln.chomp.to!long;
if (N == 1) {
writeln("FastestFinger");
continue;
}
if (... | 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;
static import std.ascii;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){ret... | 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 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.stdio,std.string,std.conv;
int main(){
auto input=readln.chomp.split;
auto a=input[0].to!int;
auto b=input[1].to!int;
auto at=(a*13).to!int;
auto bt=(b*10).to!int;
foreach(y;bt..at+1){
if((y*0.08).to!int==a&&(y*0.1).to!int==b){
y.writeln;
return 0;
... | 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;
void main() {
auto N = readln.chomp.to!int;
auto edges = new int[][](N);
foreach (_; 0..N-1) {
auto s ... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
long ... | D |
void main()
{
writeln(readln.chomp.count('x') < 8 ? "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.typecons;
import std.ascii;
import std.uni; | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto X = readln.chomp.to!(long);
long res = 0;
foreach (b; 1..X+1) {
foreach (p; 2..10) {
if (b^^p <= X) {
res = max(res, b^^p);
}
}
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto b = readln.chomp.to!(char);
switch (b) {
case 'A':
writeln("T");
return;
case 'T':
writeln("A");
return;
case 'C':
... | D |
import std.stdio, std.string, std.conv;
void main() {
long n = readln.chomp.to!long;
writeln((n - 1) * n / 2);
} | 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!(long[]);
auto a = abc[0];
auto b = abc[1];
auto c = abc[2];
if (c-a-b > 0 && 4*a*b < (c-a-b)^^2L) {
writeln("Yes");
} else {
writeln(... | D |
void main(){
int n = inelm();
( n*(1+n)/2 ).writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
// 1要素のみの入力
T inelm(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] inln(T = int)(){
T[] ln;
foreach(strin... | D |
void main()
{
long h = rdElem;
long w = rdElem;
long n = rdElem;
long a = max(h, w);
writeln((n + a - 1) / a);
}
T rdElem(T = long)()
{
//import std.stdio : readln;
//import std.string : chomp;
//import std.conv : to;
return readln.chomp.to!T;
}
alias rdStr = rdElem!string;
dcha... | 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.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
writeln(s[0], s.length-2, s[$-1]);
}
| D |
import std.stdio,std.array,std.string,std.algorithm,std.conv;
immutable STR_LENGTH = 20;
int main(string[] argv)
{
char[] buf;
stdin.readln(buf);
char[] c;
for(int i = 0;i < STR_LENGTH;i++){
if(buf.length > i){
c ~= buf[i];
}
}
reverse(c);
writeln(c);
return 0;
} | 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(){
long[] tmp = readln.chomp.split.map!(to!long).array;
long a = tmp[0], b = tmp[1];
string ans;
if(b < 0){
if((a - b) % 2) ans = "Positive"; // eg -4 .. -... | 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.format;
void main()
{
auto ip = readln.chomp.to!int;
w... | 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() {
string s;
scan(s);
auto ok = new string[](0);
void dfs(int i, string t) {
if (i == 4) {
ok ~= t;
return;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto K = readln.chomp.to!int;
writeln(K/2 * ((K+1)/2));
} | 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 readS(T)(size_t n,ref T t){t=new T(n);foreach(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto nab = readln.split.to!(long[]);
auto N = nab[0];
auto A = nab[1];
auto B = nab[2];
writeln(max(0, B*(N-1)+A - (A*(N-1)+B) + 1));
} | D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;
T binarySearch(T)(T[] haystack, T needle) {
auto min = 0UL;
auto max = haystack.length - 1;
while (min <= max) {
auto mid = (min + max) / 2;
if (haystack[mid] == needle) ... | D |
import std.stdio,std.string,std.conv,std.array,std.algorithm;
void main(){
foreach(i;1..int.max){
string[] a = readln().chomp().split();
if( a[0]=="0" && a[1]=="0" ){ break; }
if( to!int(a[0]) < to!int(a[1]) ){
writeln( a[0]," ",a[1] );
}else{
writeln( a[1]," ",a[0] );
}
}
} | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto N = readln.chomp.to!long;
auto a = N.iota.map!(_ => readln.chomp.to!long-1).array;
long c = 0;
foreach (i; 0..N) {
c = a[c];
if (c == 1) {
writeln(i+1);
... | D |
import std.stdio, std.string,std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.container, std.datetime;
void main() {
auto a = readln.chomp.to!int;
auto b = readln.chomp.to!int;
auto h = readln.chomp.to!int;
writeln((a+b)*h/2);
}
| 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.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
alias sread = () => readln.chomp();
alias Point2 =... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.numeric;
ulong[100] TS;
T lcm(T)(T a, T b)
{
return a / gcd(a, b) * b;
}
void main()
{
auto N = readln.chomp.to!int;
foreach (i; 0..N) {
TS[i] = readln.chomp.to!ulong;
}
auto res = TS[0];
foreach (t; TS[1..N]) {
... | 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;
// 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 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.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;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
void main()
{
while (1) {
auto n = readln.chomp.to!int;
if (!n) break;
auto bmi = double.max;
auto id = in... | D |
import std.stdio : readln, writeln, writefln;
import std.array : array, split;
import std.conv : to;
import std.range.primitives;
import std.range : enumerate, iota, repeat, retro, assumeSorted;
import std.algorithm.searching : all, any, canFind, count, countUntil;
import std.algorithm.comparison : max, min, clamp;
i... | 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 K = readln.chomp.to!long;
auto k = K;
int r;
while (k) {
++r;
foreach (long i; 0..10) {
if ((k+K*i)%10 == 7) {
... | 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;
import core.bitop;
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "money", long, "stack");
alias PQueue(T, alias less =... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int t;
rd(t);
while (t--) {
int l, r;
rd(l, r);
writeln(l, " ", l * 2);
}
}
void rd(T...)(ref T x) {
import std.stdio : readln;
import std.string : split;
import std.conv : to;
auto l = readln.split;
assert(l.length... | 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;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
auto st = aryread!string();
// writeln(st);
long a, b;
scan(a, b);
auto u = sread();
// writeln(u);
if (u == s... | D |
void main(){
int n = _scan();
writeln(n%1000==0? 0: 1000-n%1000);
}
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 = int)(){
T[] ln;
foreach(string elm; readln().chomp().split()){
ln... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto x = readln.chomp.split.to!(int[]);
if (x[0]+x[1]==x[2]||x[0]+x[2]==x[1]||x[1]+... | D |
import std.stdio,std.string,std.conv,std.array,std.algorithm;
void main(){
for(;;write("\n")){
auto a = readln().chomp().split();
if( a[0]=="0" && a[1]=="0" ){ break; }
int h=to!int(a[0]) , w=to!int(a[1]);
foreach(y;0..h){
foreach(x;0..w){
if( (x+y)%2==1 ){
write(".");
}else{
write("#");
... | 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()
{
readln.chomp.replace(",", " ").writeln;
}
| 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() {
long[] ans = new long[31];
ans[0] = 1;
fo... | 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.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.to!int;
auto s = readln.chomp;
if (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;
void scan(T...)(ref T args) {
auto line = readln.split;
foreach (ref arg; args) {
arg = line.front.to!(typeof(arg));
line.popFro... | D |
import std.stdio, std.string, std.range;
void main(){
string s = readln.chomp;
foreach(i; 0..3){
if(s[i] == s[i+1]){
writeln("Bad");
return;
}
}
writeln("Good");
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
bool eq(char a, char b) {
return a == '?' || b == '?' || a == b;
}
void main()
{
auto a = readln.chomp.to!(char[]);
auto b = readln.chomp.to!(char[]);
auto c = readln.chomp.to!(char[]);
auto A = ... | D |
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional, std.traits;
import std.algorithm, std.container;
void main()
{
auto S = scanElem!string;
long s,res;
foreach(c; S)
{
if(c=='S')s++;
if(c=='T'&&s!=0)
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nabcd = readln.split.to!(int[]);
auto N = nabcd[0];
auto A = nabcd[1]-1;
auto B = nabcd[2]-1;
auto C = nabcd[3]-1;
auto D = nabcd[4]-1;
auto S = readln.chomp.to!(char[])... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto T = readln.chomp.to!int;
foreach (_; 0..T) {
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
if (N > M) swap(N, M);
writeln(N == 1... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long x = tmp[0], y = tmp[1];
writeln(x % y != 0 ? x : -1);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
... | 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 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 h, w;
scan(h, w);
long ans = min(solv... | 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 readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_... | D |
void main()
{
import std.stdio, std.string, std.array, std.algorithm, std.conv;
auto b = readln.chomp.split.map!(to!int);
b[0].solve(b[1]).writeln;
}
int solve(in int nTestCase, in int mTLE)
{
immutable
base = 100 * nTestCase + 1800 * mTLE,
pInv = 1 << mTLE;
/*
S := 1 p + 2 pq +... | 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() {
bool[] alp = new bool[](26);
string s = readln.chomp;
foreach (ch ; s) {
alp[ch - 'a'] = 1;
}
foreach (i ; 0 .. 26) {
if (!alp[i]) {... | D |
import std.stdio;
import std.string;
import std.conv;
int main()
{
string s = readln();
write(toUpper(s));
return 0;
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
class Tree
{
Tree[26] children;
long[26] counts;
char c;
this(char c) {
this.c = c;
}
void add(string s) {
assert(this.c == '\n');
auto las... | D |
import std.conv;
import std.stdio;
import std.string;
void main()
{
auto s = readln.strip;
writeln( solve( s ) );
}
auto solve( in string s )
{
auto checkA = false;
auto checkC = false;
auto checklower = true;
foreach( i, c; s )
{
if( i == 0 && c == 'A' )
{
checkA = true;
continue;
}
if( 2 <... | D |
import std.algorithm;
import std.array;
import std.ascii;
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 log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }
void main() ... | D |
void main(){
int[] vals = inln();
( ((vals[2]+0.5)/vals[0]).to!int()*vals[1] ).writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
// 1要素のみの入力
T inelm(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] inln(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
int N, M;
int[][int] RS;
int[200000] IS;
void main()
{
auto nm = readln.split.to!(int[]);
N = nm[0];
M = nm[1];
foreach (_; 0..M) {
auto ab = readln.split.to!(int[]);
auto a = ab[0] - 1;
... | 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.array, std.range, std.algorithm;
void main(){
auto s = readln.strip;
long a = 0;
long b = 0;
foreach (i, c; s) {
if ((i % 2 == 0) == (c == '1')) {
a++;
} else {
b++;
}
}
writeln(min(a, b));
}
| 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.array, std.container, std.range;
import std.numeric, std.math, std.bigint, std.random;
import std.string, std.uni, std.regex, std.conv;
import std.bitmanip, core.bitop;
import std.stdio, std.typecons;
void main()
{
auto w = readln.chomp;
auto r = 0;
for (;;) {
auto t = readln.chomp... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!long;
foreach (h; 1L..3501L)
foreach (m; h..3501L) {
auto a = 4*h*m-n*(h+m);
auto b = n*h*m;
if (a > 0 && b % a == 0) {
writeln(h, " ", m, " ", b/a);
return;
}
}
... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto n = readln.chomp.to!int;
auto s = readln.chomp;
int m;
foreach (i; 1..n-1)... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto x = readln.chomp.split.to!(int[]);
writeln(x[0]-1+(x[0]<=x[1]));
}
| D |
void main(){
auto ABCK = readLine!long();
auto A = ABCK[0];
auto B = ABCK[1];
auto C = ABCK[2];
auto K = ABCK[3];
if( K <= A ){
K.writeln();
} else if( K <= A+B ) {
A.writeln();
} else {
(A - (K-(A+B))).writeln();
}
return;
}
import std;
string readStr(){
return readln().chomp();
}
T[] r... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main() {
auto l = readln.chomp.split.map!(to!int).array;
int n = l[0], c = l[1];
long[][] cc = new long[][](31, 200010);
long[] imos = new long[](200010);
for (int i = 0; i < n; ++i) {
auto m = readln.c... | D |
void main(){
string input;
input = readln().chomp().dup;
string ans;
foreach(elm; input){
if(elm == 'B'){
if( ans.length==0 )continue;
ans.popBack();
}else{
ans ~= elm;
}
}
writeln(ans.length==2? ans[$-2..$]: ans[0..$] );
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.ma... | 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, std.algorithm;
void main()
{
while(true)
{
auto input=readln.split.map!(to!int);
if(input[0]==0&&input[1]==0) break;
int m=input[1]-input[0];
int th, fiv, han;
for(; m>=1000; ++th) m-=1000;
for(; m>=500; ++fiv) m-=500;
... | 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 N = readln.chomp.to!int;
auto a = readln.split... | 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;
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[]);
writeln(ip[0] + i... | 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;
auto r = ['R', 'U', 'D'];
auto l = ['L', 'U', 'D'];
boo... | 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() {
auto nab = readints;
int n = nab[0], a ... | D |
import std.stdio : writeln;
void main() {
int n,a,b;
scan(n,a,b);
long ans;
foreach (i ; 1 .. n + 1) {
int d = digitSum(i);
if (a <= d && d <= b) {
ans += i;
}
}
writeln(ans);
}
int digitSum(int x) {
return x > 0 ? digitSum(x / 10) + x % 10 :... | D |
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
void main(){
auto S = readln.chomp;
auto F = S[0..2].to!int;
auto R = S[2..$].to!int;
if((1<=F&&F<=12) && (1<=R&&R<=12)) writeln("AMBIGUOUS");
else if(1<=F&&F<=12) writeln("MMYY");
else if(1<=R&&R<=12) writeln("YYM... | D |
import std.stdio, std.conv, std.string, std.algorithm.searching, std.algorithm.iteration;
void main()
{
auto N = readln().strip.to!int;
int[] pList = [];
foreach(i; 0..N)
{
pList ~= readln().strip.to!int;
}
writeln(pList.sum - pList.reduce!"a<b?b:a" / 2);
}
| D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.