code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
void main() {
problem();
}
void problem() {
auto N = scan!long, M = scan!long;
long solve() {
long answer;
if (N > 0) answer += N*(N-1)/2;
if (M > 0) answer += M*(M-1)/2;
return answer;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto S = readln.chomp;
int x = 0;
int cnt = 0;
while (x+1 < S.length) {
if (S[x] == S[x+1]) {
x++;
} else {
S = S[0..x] ~ S[x+2..$];
cn... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric;
void main(){
auto nt=readln.split.map!(to!long).array;
auto ts=readln.split.map!(to!long).array;
auto T=nt[1];
long l... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln("Christmas", " Eve".repeat(25 - readln.chomp.to!int).join);
}
| D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
immutable int steps = 10;
int solve (string s, int team)
{
int [2] goals;
foreach (step; 0..steps)
{
auto cur = (s[step] == '0') ? 0 :
(s[step] == '1') ? 1 : (step % 2 == team);
goals[step % 2] += cur;
if (goa... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;
void main()
{
auto n = readln.chomp.to!int;
auto h = readln.chomp.split.to!(i... | D |
import std.conv;
import std.stdio;
import std.string;
void main() {
auto n = readln.chomp.to!int;
(n%2==0 ? n : 2*n).writeln;
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.math;
void main() {
auto num = readln().chomp().to!int();
writeln(pow(num, 3));
} | D |
import std.stdio,
std.conv,
std.string;
void main()
{
int a,b,c;
scanf("%d %d %d", &a, &b, &c);
if (a <= c && c <= b) {
writeln("Yes");
}
else {
writeln("No");
}
} | 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.string;
import std.conv;
int count(int n) {
int ans = 0;
for(int a = 0; a < 10; a++)
for(int b = 0; b < 10; b++)
for(int c = 0; c < 10; c++)
for(int d = 0; d < 10; d++)
if(a + b + c + d == n) ans++;
return ans;
}
void main() {
int[] data;
while(true) ... | D |
import std.stdio,std.string,std.conv;
void main(){
for(;;){
auto rc = readln().chomp();
if( rc == "0" ){ break; }
int sum=0;
foreach( c ; rc ){
sum += c-'0';
}
writeln(sum);
}
} | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
bool solve (int n, int [] a)
{
n = min (n, 30);
a = a[0..n];
remove_loop:
while (!a.empty)
{
foreach_reverse (i; 0..n)
{
if (a[i] % (i + 2) != 0)
{
a = a[0..i] ~ a[i + 1..$];
n -= 1;
continue remove_... | D |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
const int MOD = 1_000_000_007;
int n;
scanf("%d", &n);
int[] cb = new int[n+1];
cb[0] = 1;
foreach (i; 2..n+1) {
if (i&1) continue... | D |
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;
// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : ... | D |
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outb... | 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;
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 m = n;
int cnt;
foreach_reverse(i; 0..10) {
... | 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] cnt;
foreach (e; s) {
cnt[... | 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, 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;
bool check(string s) {
if (s.length % 2) {
return false;
}
while... | 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;
bool calc(int n) {
... | 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;
struct S{
long x=long.min;
long[] pair;
long[] cost;
}
S[] sList;
bool resolve(S s){
if(s.x==long.min)
{
s.x=0;
}
... | 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;
void times(alias fun)(int n) {
foreach(i... | D |
void main() {
writeln(readln.chomp.to!int / 3);
}
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;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long n, m;
scan(n, m);
auto ab = new long[][](n, 2);
auto cd = new long[][](m, 2);
// writeln(ab);
// writeln(cd);
auto ans = new... | 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.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
immutable mod = 10^^9 + 7;
immutable inf = 2 * 10^^9;
void main() {
int n, k;
scan(n, k);
auto x = new int[](n), y = new int[](n);
foreach (i ; 0 .. n) {scan(x[i], y... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto F=readln.split.to!(int[]),a=F[0],b=F[1];
if((a+b)%2==0)writeln((a+b)/2);
else writeln((a+b)/2+1);
} | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
char calc(string s, lon... | 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() {
string s;
scan(s);
writeln(s.count('+').to!int - s.count('-').to!int);
}
void scan(T...)(ref T a... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int x, y, z;
rd(x, y, z);
writeln((x - z) / (y + z));
}
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 == x.length);
foreach (i, ref e;... | 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.to!(int[]),a=z[0],b=z[1];
if(a<=8&&b<=8)writeln("Yay!");
else 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, core.bitop;
void main(){
auto S = scanString;
writeln((15-S.length)+S.count('o')>=8?"YES":"NO");
}
long g... | D |
void main() {
string n = readln.chomp;
string m;
foreach (x; n) {
m ~= x == '1' ? '9' : '1';
}
m.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons; | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto s = readln.chomp;
auto dp = new int[](s.length+1);
dp[0] =... | 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: writeln, readln;
import std.string: strip;
void main() {
string a = readln.strip;
string b = readln.strip;
if (a == b)
writeln("EQUAL");
else if (a.length > b.length)
writeln("GREATER");
else if (b.length > a.length)
writeln("LESS");
else if (a > b)
writeln("GREATER");
else
writeln(... | 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 n; readV(n);
writeln(n*(n+1)... | 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 t = readln.chomp;
int o, z;
foreach (c; t) {
if (c == '0') ++z;
if (c == '1') ++o;
... | 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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, k; rd(n, k);
long tot=0;
for(int a=1; a<=n; a++){
if(a%k==0){
auto y=(n/k).to!(long);
tot+=y*y;
}else{
auto x=k-a%k;
if((x*2)%k==0){
if(n>=x){
auto y=((n-x)/k+1).to!(long);
tot... | 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 a, b, c;
scan(a, b, c);
writeln(min(a + b, a + c, b + c... | D |
#!/usr/bin/env rdmd
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
void main()
{
for(string S; (S=readln().chomp()).length; )
{
auto n = S.to!int();
string w = "<3";
foreach(i;0..n)
w ~= readln().chomp() ~ "<3";
immutable string t = readln()... | D |
import std.stdio,
std.array,
std.conv,
std.string;
void main(){
string s;
for(;;){
s=readln();
if(stdin.eof()) break;
for(int i = cast(int)s.length; i > 1; --i ){
write(s[i-2]);
}
if(s.length > 0) write("\n");
}
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ab = readln.split.to!(int[]);
auto a = ab[0];
auto b = ab[1];
if (a > 0) {
writeln("Positive");
} else if (a <= 0 && b >= 0) {
writeln("Zero");
} else {
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
void main() {
int input;
immutable limitList = 200000;
bool[] listNumbers = new bool[](limitList);
int[] listPrimeNumbers;
listNumbers.fill(true);
foreach (i; 2..limitList.to!double.sqrt.to!int) {
... | 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;
}
long calc(long n, long a, long b) {
if (n == 1) ... | D |
import std.stdio;
import std.array;
import std.conv;
void main()
{
while (1) {
string[] str = split(readln());
int a = to!(int)(str[0]);
int b = to!(int)(str[1]);
if (a == 0 && b == 0) {
break;
} else if (a > b) {
writeln(b, " ", a);
} else {
writeln(a, " ", b);
}
}
} | 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 n;
int[] a;
void main() {
scan(n);
a = iota(n).map!(i => readln.chomp.to!int - 1).array;
auto d = new int[]... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long a = tmp[0], b = tmp[1], c = tmp[2];
long x = tmp[3], y = tmp[4];
if (a + b < 2 * c)
{
writeln(a * x + b * y);
}
else
{
long z = min(x, y);
long u = a * (x - z) + b * (y - z);
long v = 2 * c * (max(... | D |
import std.algorithm,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
N gcd(N)(N a, N b) if (isNumeric!N || is (N == BigInt)) { return a ? gcd(b % a, a) : b; }
N lcm(N)(N a, N b) if (isNumeric!N || is (N == BigInt)) { return a / gcd(a, b) * b; }
void main()... | D |
import std.functional,
std.algorithm,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
int n = readln.chomp.to!int;
int k = n / 15;
writeln(n * 800 - k * 200);
}
| D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
std.random, std.typecons, std.container;
ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = (... | D |
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.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric;
void main(){
readln.split.map!(to!int).map!"a-1".reduce!"a*b".writeln;
}
| D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
int a; rd(a);
if(n%500<=a) writeln("Yes");
else writeln("No");
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.length);
foreach(i, ref e; x){
e=l[i].to!(... | 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[]);}
//END OF TEMPLATE
void main(){
auto s=scan!st... | 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);
int h, w;
scan(h... | 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.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;
enum lim = 80 * 80 * 2;
void main() {
int m1, d1;
... | 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() {
auto w = ["Sunny", "Cloudy", "Rainy"];
string s... | D |
void main() {
problem();
}
void problem() {
auto K = scan!int;
auto S = scan;
string solve() {
if (S.length > K) return S[0..K] ~ "...";
return S;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.contain... | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.math;
long calc(long x) {
return x * (x + 1) / 2;
}
void main() {
string s = readln.chomp;
if (s[0] == '>') s = '<' ~ s;
if (s[$-1] == '<') s ~= '>';
auto g = s.group.array;
long[] a = new long[g.length];
foreach (i, x; ... | 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 |
import std.stdio, std.conv, std.string, std.math, std.regex, std.array;
void main(){
auto ip = readln.chomp.to!(char[]);
replace(ip, ",", " ").writeln;
} | D |
import std.stdio;
import std.string;
import std.conv;
void main()
{
int N = readln.chomp.to!int;
int H = readln.chomp.to!int;
int W = readln.chomp.to!int;
int result = (N - H + 1) * (N - W + 1);
writeln(result);
}
| 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] % 2) {
writeln("Odd");
... | D |
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
void main()
{
auto N = readln.chomp.to!long;
long result;
foreach (n; 1 .. N + 1)
{
long cnt;
if (n % 2 == 0)
... | D |
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
// 差の絶対値
@nogc @safe pure T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
// 切り上げ除算
@nogc @safe pur... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.math;
void main(){
auto input = readln().chomp.split.map!(to!int);
if(input[1] % input[0] == 0){
writeln(input[0] + input[1]);
}else{
writeln(input[1] - input[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, 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.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; }
void main(){
long[] as;
fo... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, q; rd(n, q);
int s=0;
while(q--){
int t, k; rd(t, k);
if(t){
(s+=k)%=n;
}else{
writeln(((k-1)+s)%n+1);
}
}
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
asser... | 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;
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 sum = readln.chomp.split.map!(to!i... | 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[]);
int[] N;
N.length = S.length;
int x;
foreach (i, c; S) {
if (c == 'R') {
++x;
} else {
N[i-1] += (x+1)/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 std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;
void main()
{
auto n = readln.chomp.to!int;
//auto s = new string[](n);
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;
enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n, m;
scan(n, m);
auto adj = new int[... | 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() {
int n... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main(){
stdin.readln.chomp.filter!(a => a != ',' && a != '.').array.split.filter!(a => a.length > 2 && a.length < 7).reduce!((a, b) => a ~ " " ~ b).writeln;
} | D |
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outb... | 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() {
long N;
scan(N);
if (N % 2) {
... | 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;
void main()
{
auto r1 = readln();
auto r2 = readln();
auto r3 = readln();
write(r1[0], r2[1], r3[2]);
} | 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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int a, b; rd(a, b);
for(int c=1; c<=3; c++){
if((a*b*c)&1){
writeln("Yes");
return;
}
}
writeln("No");
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.leng... | D |
void main()
{
string n = readln.chomp;
n.count('2').writeln;
}
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.string;
import std.conv;
import std.algorithm;
import std.stdio;
void main() {
int hp = readln.chomp.split(" ")[0].to!int;
foreach (e;readln.chomp.split(" ").map!(to!int)) {
hp -= e;
if (hp <= 0) {
writeln("Yes");
return;
}
}
writeln("No");
}
| D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
string s = readln.chomp;
int w = readln.chomp.to!int;
for (int i = 0; i < s.length; i++) {
if (!(i % w)) write(s[i]);
}
} | D |
import std.stdio;
void main() {
for (int i = 0; i < 1000; i++) {
writeln("Hello World");
}
} | D |
import std;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i]... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
import std.math;
void main() {
int n;
scan(n);
auto s = readln.split;
foreach (ch ; s) {
if (ch == "Y") {
writeln("Four");
return;
}
}
writeln("Three");
}
void scan(T... | D |
import std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
long mod = 1000000007;
long modinv(long a) {
long b=mod, u=1, v=0;
while(b>0) {
long t=a/b;
a -= t*b; swap(a,b);
u -= t*v; swap(u,v);
}
u %= mod;
if(u<0) u+=mod;
return u;
}
void ma... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
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() {
string s;... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
void main(string[] args) {
readln.chomp.solve.writeln;
}
auto solve(string input) {
return input.count("1");
}
unittest {
assert(solve("101") == 2);
assert(solve("000") == 0);
assert(solve("0001")... | 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 N = readln.chomp.to!int;
int c;
bool ok;
foreach (_; 0..N) {
auto ab = readln.split;
if (ab[0] == ab[1]) {
++c;
if ... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.bitmanip; // BitArray
void main()
{
auto n = readln.chomp.to!size_t;
auto s = new int[](n);
foreach (i; 0..n) s[i] = readln.chomp.to!int;
auto t = s.sum;
auto dp = BitArray();
dp.length = t+1;
dp[0] = true;
foreach (i; 0..n... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.