code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std;
void main() {
auto S = readln.split[0];
if (S == "ABC") writeln("ARC");
else writeln("ABC");
}
| 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[] aryread(T = long)(){return 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;
import std.array;
import std.string;
import std.conv;
void main() {
int x = to!int(chomp(readln()));
writeln(x * x * x);
} | 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;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
long a = read.to!long;
long b = 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.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;
void main()
{
long A = scanElem;
long B = scanElem;
long cost;
for(int i =0 ;i < 2;i++)
{
if(A<B){
cost += B;
B... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
auto s = readln().chomp();
string t;
for(int i=0; i<s.length; )
{
if(startsWith(s[i..$],"apple")) t~="peach", i+=5;
else if(startsWith(s[i..$],"peach")) t~="apple", i+=5;
else t~=s[... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
long n, x, t;
scan(n, x, t);
// writeln(n, x, t);
long 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 n = readln.chomp.to!int;
auto a = readln.chomp;
auto b = readln.chomp;
aut... | 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() {
readint();
auto ss = readints(... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, k; rd(n, k);
auto x=new long[](n), y=new long[](n);
foreach(i; 0..n) rd(x[i], y[i]);
long mn=5_000_000_000_000_000_000;
foreach(i1; 0..n)foreach(i2; (i1+1)..n){
foreach(j1; 0..n)foreach(j2; (j1+1)..n){
auto x1=x[i1], x2=x... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;
void main() {
int a, b, c, x, y;
scan(a, b, c, x, y);
int ans = min(x, y) * min(2*c, a + b);
if (x > y) {
ans += (x - y) * min(2*c, a);
}
else {
ans += (y - x) * min(2*c, b);
}
... | D |
import std.stdio, std.string, std.conv, std.range, std.algorithm, std.functional;
void main() {
auto N = readln.chomp.to!long;
auto n = N;
auto f = 0;
while (n > 0) {
f += n % 10;
n /= 10;
}
writeln(N % f == 0 ? "Yes" : "No");
}
| D |
import std.functional,
std.algorithm,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
string s = readln.chomp;
int c;
foreach (i; 0..s.length-1) {
if (s[i] != s[i + 1]) {
c++;
}
}
writeln(c);
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
import std.stdio;
void main(){
string c1=readln();
string c2=readln();
if(c1[0]==c2[2]&&c1[1]==c2[1]&&c1[2]==c2[0])
writeln("YES");
else
writeln("NO");
} | D |
import std.stdio,std.string,std.conv;
int main()
{
int n;
while((n = readln.chomp.to!int) != 0)
{
int ans = 0;
while((n /= 5) != 0)
{
ans += n;
}
ans.writeln;
}
return 0;
} | 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;
int r = 1;
foreach (i; 1..X+1) {
foreach (j; 2..X+1) {
if (i^^j <= X) r = max(r, i^^j);
}
}
writeln(r);
} | D |
import std.stdio, std.string, std.array;
import std.algorithm, std.regex;
void main(){
"ATA CGC".find(readln[0])[1].writeln;
} | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
long ... | D |
import std.stdio, std.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() {
long N;
scan(N);
auto ans = N * (N - 1) / 2... | D |
void main()
{
long a, b, c;
rdVals(a, b, c);
if (a + b >= c)
{
"No".writeln;
return;
}
long x = a * b;
long y = c - a - b;
writeln(4 * x < y * y ? "Yes" : "No");
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T == struct))
{
re... | D |
void main()
{
long n = rdElem;
long result = inf;
for (long i = 1; i * i <= n; ++i)
{
if (n % i == 0)
{
result = min(result, i+n/i-2);
}
}
result.writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T == struct))
{
... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n;
rd(n);
if (n == 1) {
writeln("Hello World");
} else {
int a, b;
rd(a);
rd(b);
writeln(a + b);
}
}
void rd(T...)(ref T x) {
import std.stdio : readln;
import std.string : split;
import std.conv : to;
au... | D |
void main(){
import std.stdio, std.conv, std.string, std.algorithm;
int n; rd(n);
int f(int x){
int ret=0;
while(x>0){
ret+=x%10;
x/=10;
}
return ret;
}
int mn=1_000_000_000;
for(int a=1; a<n; a++){
int b=n-a;
mn=min(mn, f(a)+f(b));
}
writeln(mn);
}
void rd(T...... | 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 n = readln.chomp.to!int;
writeln(n*(n+1)/2);
}
| D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
auto n = lread();
// writeln(n);
long 余り = n % 100;
// w... | D |
/+ dub.sdl:
name "D"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) sc.read!true;
import std.typecons;
alias E = Tuple!(int, "to", long, "dist")... | D |
import std.stdio, std.string, std.conv, std.math;
void main() {
int n = readln.chomp.to!int;
long debt = 100000;
foreach(i;0..n) debt = ((((debt + (debt*0.05)) / 1000.0).ceil) * 1000).to!long;
debt.writeln;
} | 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;
import core.stdc.stdlib;
void main()
{
auto N = scanElem;
auto M = scanElem;
long[] list;
list.length = N;
foreach(i; 0... | 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;
int[char] k;
foreach (e; s) {
k[e]++... | D |
import std.stdio, std.string, std.conv;
import std.algorithm;
void main()
{
for(string s_; (s_=readln().chomp()).length;)
{
auto ab = s_.split.map!(to!int)();
immutable a=ab[0], b=ab[1];
if(0<a) writeln("Positive");
else if(a<=0 && 0<=b) writeln("Zero");
else if(b<0 && (... | 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);
foreach (cmb ; 0 .. 16) {
string t;
t ~= (cmb & 1) ? "AKIH" : "KIH";
t ~= (cmb & 2) ? "AB" : "B";
... | 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 k = readln.chomp.to!int;
auto h = k / 2;
if (k % 2) {
... | 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 n;
scan(n);
while (n > 0) {
if (n % 10 == 9) {
writeln("Yes");
return;
}
n /= 10;
}
writeln("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 rs = S.dup;
rs.reverse();
if (S != rs) {
writeln("No");
return;
}
auto N = S.length;
auto s = S[0..(N-1)/2];
rs = s.dup;
r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void get(Args...)(ref Args args)
{
import std.traits, std.meta, std.typecons;
static if (Args.length == 1) {
alias Arg = Args[0];
static if (isArray!Arg) {
... | D |
void main(){
int n = inelm();
( 800*n - (n/15).to!int()*200).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[] l... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ha = readln.split.to!(int[]);
auto H = ha[0];
auto A = ha[1];
writeln((H+A-1)/A);
} | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, m; rd(n, m);
auto g=new int[][](n, 0);
foreach(_; 0..m){
int a, b; rd(a, b);
a--; b--;
g[a]~=b; g[b]~=a;
}
auto c=new int[](n);
fill(c, -1);
bool dfs(int i, int w, int p=-1){
c[i]=w;
bool ret=true;
for... | D |
import std.stdio, std.string, std.conv, std.math, std.regex;
void main()
{
auto n = readln.split.to!(int[]);
writeln((n[0] - 1) * (n[1] - 1));
} | 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 readC(T...)(size_t n,ref T t){foreach(ref v;t)... | 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 N = readln.chomp.to!long;
writeln(N);
}
} | D |
void main() {
int n = readln.chomp.to!int;
string s = readln.chomp;
auto g = s.group.array;
string bra, ket;
foreach (i; 0 .. n) {
bra ~= '(';
ket ~= ')';
}
int l, r;
foreach (x; g) {
if (x[0] == '(') {
r += x[1].to!int;
} else {
in... | D |
import std.stdio,std.conv,std.string,std.algorithm;
void main(){
auto s=readln();
writeln("2018",s[4..10],);
} | D |
// Cheese-Cracker: cheese-cracker.github.io
const ll PRIME = 10^^9 + 7;
void play(){
ll n, x, pos;
n = rd; x = rd; pos = rd;
ll clo = x-1, chi = n - x;
ll res = 1;
int lo = 0, hi = n.to!int;
while(lo < hi){
int midd = (lo + hi)/2;
show(midd, pos, clo, chi);
if(midd <= p... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.to!(dchar[]);
auto T = readln.to!(dchar[]);
dchar[dchar] smemo, tmemo;
foreach (i, s; S) {
auto t = T[i];
if (s in smemo && t in tmemo) {
if ... | 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.algorithm,
std.string,
std.range,
std.array,
std.stdio,
std.conv;
bool check(string s) {
if (s.length % 2) { return false; }
string a = s[0..$/2],
b = s[$/2..$];
return a == b;
}
void main() {
string s = readln.chomp;
size_t del = 1;
while (del < s... | D |
import std;
import core.bitop;
// dfmt off
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[]);
void aryWrite(T = long)(T[] ary){ ary.map!(x => x.text()).join(' ')... | D |
// Vicfred
// https://atcoder.jp/contests/abc168/tasks/abc168_a
import std.stdio;
import std.conv;
import std.string;
void main() {
int n = readln.chomp.to!int;
n = n%10;
switch(n) {
case 0, 1, 6, 8:
writeln("pon");
break;
case 3:
writeln("bon");
bre... | 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;
auto S = readln.chomp;
if (S.length <= K) {
writeln(S);
} else {
writeln(S[0..K], "...");
}
} | 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 abc = readln.split.to!(int[]);
auto A = abc[0];
auto B = abc[1];
auto C = abc[2];
writeln((A < C && C < B) || (B < C && C < A) ? "Yes" : "No");
} | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto s=new char[][](n);
foreach(i; 0..n) s[i]=readln.chomp.to!(char[]);
long[char] cnt;
cnt['M']=cnt['A']=cnt['R']=cnt['C']=cnt['H']=0L;
foreach(i; 0..n){
auto c=s[i][0];
if(c in cnt) cnt[c]++;
}
char[int] p;
... | 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 data = readln.split.to!(int[]);
auto A = data[0], B = data[1], C = data[2];
if (A+B >= C-1) writeln(B+C);
else writeln( B + A+B+1 );
} | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;
import std.typecons;
import std.format;
void main(string[] args) {
readln.solve.writeln;
}
auto solve(string line1) {
auto _ = line1.chomp.split.map!(to!int).arra... | D |
void main() {
auto O = rs, E = rs;
foreach(i, v; E) {
write(O[i]);
write(v);
}
if(O.length - E.length == 1) writeln(O[$-1]);
else writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.t... | 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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
int idx(char c) {
switch (c) {
case 'R': return 0;
case 'G': return 1;
default: return 2;
}
return -1;
}
void main()
{
auto N = readln.chomp.to!int;
auto S = readln.chomp;... | 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.functional;
int n;
int[][] g;
int[] gsm;
int main() {
auto sc = new Scanner(stdin);
int m;
sc.read(n, m);
calc.init([[0... | D |
import std.stdio,std.conv,std.string,std.algorithm,std.array,std.math;
void main(){
auto sa=readln().split();
auto sb=readln().split();
auto sc=readln().split();
auto sd=readln().split();
int a,b,c,d,ans=0;
a=to!int(sa[0]);
b=to!int(sb[0]);
c=to!int(sc[0]);
d=to!int(sd[0]);
... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
T readNum(T)(){
return readStr.to!T;
}
T[] readNums(T)(){
return readStr.split.to!(T[]);
}
string readStr(){
return readln.chomp;
}
void main(){
auto s = readStr;
bool dif;
foreach(i; 0 .. 3){
if(s[i] == s[... | 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;
int c;
foreach (i; 0..N-2) {
if (S[i..i+3] == "ABC") ++c;
}
writeln(c);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum A = "AKIHABARA";
void main()
{
auto S = readln.chomp;
size_t i, j;
while (i < S.length && j < A.length) {
if (S[i] == A[j]) {
++i; ++j;
} else if (A[j] == 'A') {
... | D |
import std.stdio;
import std.conv;
import std.string;
int main() {
string str = chomp(readln);
int val = to!(int)(str);
int h = val/3600; val %= 3600;
int m = val/60; val %= 60;
int s = val;
writeln(h, ":", m, ":", s);
return 0;
} | 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() {
string s;
scan(s);
int n = s.length.to!int;
auto a = new int[](n + 1);
foreach (i ; 0 .. n) {
a[i + 1] = a[i] ^ (1<<(s[i] - 'a'));
}
... | D |
import std.stdio;
import std.array;
import std.math;
import std.conv;
void main(){
string str;
while((str = readln()).length != 0){
string[] input = split(str);
int a = to!int(input[0]);
int b = to!int(input[1]);
writeln(digit(a + b));
}
}
uint digit(in int num){
if(num <= 0) return 0;
else
return cast... | D |
import std.stdio;
import std.algorithm;
import std.array;
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[] a, b, c;
foreach (i; 0... | D |
import std.stdio, std.string, std.ascii;
void main() {
string s = readln.chomp;
writeln( (s.length >= 6 && s.count!(isDigit) >= 1 && s.count!(isUpper) >= 1 && s.count!(isLower) >= 1) ? "VALID" : "INVALID" );
} | 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.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.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
long n, m;
scan(n, m);
if (n > m) swap(n, m);
if (n == 1 && m == 1) {
writeln(1);
}
else if (n == 1) {
writeln(m - 2);
}
else {
writeln((n-2)*(m-2));
}
}
vo... | D |
import std.stdio;
import std.conv;
import std.array;
import std.string;
import std.algorithm;
void main() {
int n;
n = to!int(chomp(readln()));
int res = 0;
for(int i = 0; i < n; i++) {
string [] t;
int l, r;
t = chomp(readln()).split();
l = to!int(t[0]);
r = to!int(t[1]);
res += r-l+1;
}
writeln(r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
int N, M;
string[100] NS, MS;
void main()
{
N = readln.chomp.to!int;
foreach (i; 0..N) NS[i] = readln.chomp;
M = readln.chomp.to!int;
foreach (i; 0..M) MS[i] = readln.chomp;
auto ns = NS[0..N];
auto ms =... | 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 |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int calc(char[] s, char mas) {
int n = s.length.to!int;
if (s.count(mas) == n) return 0;
char[] t = new char[n-1];
foreach (i; 0..n-1) {... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main() {
string str = readln();
write(toUpper(str));
} | D |
import std.stdio;
void main(){
int n = 1000;
while(n--)
writeln("Hello World");
} | 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.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
int n;
scanf("%d", &n);
int[] a = new int[n];
int[] b = new int[n];
bool same = true;
foreach (i; 0..n) {
scanf("%d%d", &a[i], &b[i]);
if (a[i] != b[i]) same... | D |
import std.stdio;
import std.string;
void main() {
string ans = "WA";
char[] s = readln.strip.dup;
if (s[0] == 'A') {
ulong c = 0;
foreach(i, e; s[0..$ - 1]) {
if (e == 'C' && i > 1) {
c = i;
break;
}
}
if (c > 1) {
... | D |
import std.stdio,std.conv,std.string,std.array;
void main(){
auto x=readln.chomp.split;
int a = to!int(x[0]), b = to!int(x[1]);
if(a<b){writeln("a < b");}
if(a>b){writeln("a > b");}
if(a==b){writeln("a == b");}
} | D |
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.math;
void main() {
auto NK = readln.chomp.split.map!(to!int);
auto N = NK[0];
auto K = NK[1];
(K * pow(K - 1, N - 1)).writeln;
}
| D |
import std.stdio;
import std.string;
import std.range;
//standard input/output
void main()
{
auto S = readln.chomp;
int res = 700;
if(S[0] == 'o') res += 100;
if(S[1] == 'o') res += 100;
if(S[2] == 'o') res += 100;
writeln(res);
/*
int res = 700;
foreach(i; S) if(i == 'o') res += 100;
writeln(res);
*/
/... | D |
import std.string;
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
int n,s;
long[1001][11] dp;
void main(){
dp[0][0] = 1;
for(int i=0;i<=100;i++){
for(int j=9;j>=1;j--){
for(int k=0;k<=1000;k++){
if(0<=i+k&&i+k<=1000)
dp[j][i+k] += dp[j-1][k];
}
}
}
whil... | D |
void main()
{
string n = rdStr;
long len = n.length;
long total;
foreach (x; n)
{
total += x - '0';
}
max(total, (n[0]-'1')+9*(len-1)).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;
}
ali... | D |
void main() {
problem();
}
void problem() {
auto N = scan!ulong;
ulong solve() {
// Sum_{k=1..n} k/2 * floor(n/k) * floor(1 + n/k)
ulong ans;
foreach(k; 1..N+1) {
ulong x = N / k;
ans += x * (2*k + (x - 1) * k) / 2;
}
return ans;
}
solve().writeln;
}
// --------------------... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int x = tmp[0], a = tmp[1], b = tmp[2];
if (a - b >= 0) {
"delicious".writeln;
} else if (a - b + x >= 0) {
"safe".writeln;
} else {
"dangerous".writeln;
}
}
import std.stdio;
import std.string;
import std.array;
import ... | D |
import std.stdio, std.conv, std.string, std.math, std.algorithm;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[1] - ip[0] == ip[2] - ip[1]) "YES".writeln;
else "NO".writeln;
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
int[] buf = readln.chomp.split.to!(int[]);
int a = buf[0], b = buf[1];
int ans = a - 1 + (a <= b ? 1 : 0);
writeln(ans);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
void main() {
string input = "4823108376";
while ((input = readln.chomp).length != 0) {
while (input.length > 1) {
string output;
for (int i = 0; i < input.length-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;
static import std.ascii;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return r... | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
string input = chomp(readln());
int output = to!(int)(input);
output = output*output*output;
writeln(output);
} | D |
/+ dub.sdl:
name "B"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) sc.read!true;
int k;
long[] a;
sc.read(k, a);
long dw = 2, up = 2;
... | 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;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TL... | D |
import std.stdio, std.string, std.conv;
import std.algorithm;
void main() {
auto input = getStdin!(string[]);
string s = input[0] ~ input[0];
string p = input[1];
if (s.count(p) > 0) {
"Yes".writeln;
}
else {
"No".writeln;
}
}
T getStdin(T)() {
string[] cmd;
string line;
while ((line = chomp(st... | 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 MOD =... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.