code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.algorithm,
std.string,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
int n = readln.chomp.to!int;
int[] a = readln.chomp.split.to!(int[]);
int m1,
m2,
m4;
bool flag;
foreach (ai; a) {
if (ai % 4 == 0) {
m4++;
} else if (ai % ... | 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, std.bitmanip;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
auto C = readln.split.map!(to!... | 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;
import std.string;
import std.range;
import std.conv;
void main()
{
auto ip = readln.split.to!(int[]), a = ip[0], b = ip[1];
writeln(((b-a)*(1+(b-a))/2)-b);
} | D |
void main()
{
dchar c = rdElem!dchar;
writeln((c + 1).to!dchar);
}
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;
dchar[] rdDchar()
{
//import std.conv : to;
return rd... | 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 main() {
string str = readln.chomp... | 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;
bool f1, f2;
foreach (e; s) {
if (!f1) {
if (e =... | D |
#!/usr/bin/rdmd
import std.stdio;
immutable hW = "Hello World";
void main()
{
foreach(i;0..1000)
{
writeln(hW);
}
} | 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;
import std.string;
import std.conv;
void main()
{
auto input = split( readln() );
int sup = to!int(input[1]), inf = to!int(input[0]);
int i = inf;
int cnt = 0;
while (i <= sup) {
int n1 = i % 10;
int n2 = (i % 100 - n1) / 10;
int n3 = (i % 1000 - 10 * n2 - n1) / 100;
int n4 = (i % 1000... | D |
import std.stdio, std.conv, std.string;
void main()
{
auto N = readln.chomp;
writeln("ABC", N);
} | D |
void main() {
problem();
}
void problem() {
auto N = scan!int;
auto D = N.iota.map!(x => [scan!int, scan!int]);
string solve() {
int continuasLevel;
foreach(d; D) {
if (d[0] == d[1]) continuasLevel++;
if (d[0] != d[1]) continuasLevel = 0;
if (continuasLevel == 3) {
return "Y... | 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.split.to!(int[]);
auto f = fa... | 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 a, b, c, d;
scan(a, b, c, d);
auto a... | 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.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; }
foreach(y;0..to!int(a[0])){
foreach(x;0..to!int(a[1])){ write("#"); }
write("\n");
}
}
} | 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;
void main() {
int N, K;
scan(N, K);
auto ans = K;
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()
{
writeln(700 + readln.chomp.to!(char[]).count!(x=>x=='o') * 100);
}
| 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 |
// Vicfred
// https://atcoder.jp/contests/abc159/tasks/abc159_a
// math
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
long gauss(long n) {
return n*(n-1)/2;
}
void main() {
long n = readln.chomp.to!long;
long[] a = readln.split.map!(to!long).array;
long... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
void main() {
int n = readln.chomp.to!int, ans;
bool[int] mp;
foreach(i; 0..n) {
int d = readln.chomp.to!int;
// keyが連想配列に登録されているかどうか
if ((d in mp) == null) {
ans++;
mp[d] = true;
}
}
... | D |
import std.stdio,std.conv,std.string;
void main(){
auto args = readln().chomp().split();
writeln( to!int(args[0]) * to!int(args[1])," ",(to!int(args[0]) + to!int(args[1])) * 2 );
} | D |
import std.stdio;
import std.string;
import std.range;
import std.conv;
void main()
{
auto ip = readln.split.to!(int[]), a = ip[0], b = ip[1], c = ip[2];
if(b-a==c-b){
writeln("YES");
}else{
writeln("NO");
}
} | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void main()
{
string s; readV(s);
auto n = s.length.to!int, k = (n+1)/2+1;
for (; k <= n; ++k)
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;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
while(true){
auto s = readln();
if(stdin.eof()) break;
s = chomp(s);
if(s=="")break;
string s1,s2;
s1 = s;
s2 = s;
while(s1.length > 1){
s2 = "";
for(int i=0;i<s1.length-1;i++){
s2 ~= to!ch... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
string s; readV(s);
auto t = ""... | 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;
enum MAX = 1_000_100;
ulong MOD = 1_000_000_007... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
immutable long MOD = 998244353;
void main() {
auto S = readln.chomp;
auto N = S.length.to!int;
long ans = 1;... | 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, k;
scan(n, k);
int ans = n - k + 1... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(long[]), a = rd[0], b = rd[1], x = rd[2];
if (a > 0)
writeln(b/x - (a-1)/x);
else
writeln(b/x + 1);
}
| D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.math;
void main() {
int N;
N = readln.chomp.to!int;
auto s = [0, 0, 0];
bool is_reach = true;
for (int i = 0; i < N; ++i) {
auto g = readln.chomp.split.map!(to!int).array;
int t = g[0] - s[0], 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 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;
void main()
{
writeln("A" ~ readln.split[1][0] ~ "C");
} | D |
import std.stdio, std.conv, std.string, std.algorithm.comparison, std.algorithm.searching, std.algorithm.sorting;
void main()
{
int[] input = readln().split.to!(int[]);
int X = input[0];
int Y = input[1];
writeln(X + Y / 2);
} | D |
import std.stdio, std.string, std.algorithm;
void main() {
string s = readln.chomp;
s ~= s;
string p = readln.chomp;
writeln(s.canFind(p) ? "Yes" : "No");
}
| D |
import std.stdio, std.string, std.conv;
void main()
{
auto x = readln.split.to!(int[]), n = x[0], a = x[1], b = x[2];
if(a*n < b){
writeln(a*n);
} else {
writeln(b);
}
} | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
void main() {
int n, a, b;
auto l = readln.chomp.split.map!(to!int);
n = l[0], a = l[1], b = l[2];
long ans; // longである必要はない
foreach(i; 1..(n + 1)) {
int sum, num = i;
while (num > 0) {
sum += (num %... | 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, std.bitmanip;
void main() {
auto S = readln.chomp;
auto N = S.length.to!int;
if (S.map!(s => s == S[0]).all) {
writeln(... | D |
import std.stdio, std.conv, std.string, std.math;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[0] == ip[1]){
"Draw".writeln;
} else if(ip[0] == 1){
"Alice".writeln;
} else if(ip[1] == 1){
"Bob".writeln;
} else if (ip[0] > ip[1]){
"Alice".writeln;
} else {
"Bob".writeln;
}
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1];
if(A+B>=24)writeln((A+B)-24);
else writeln(A+B);
} | 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.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;
long digit_sum(long b, long n) {
if (n < b)
return n;
else
return digit_sum(b, n/b) + n % b;
}
voi... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto N = readln.chomp.to!(wchar[]);
writeln(N[1] != N[2] ? "No" : N[0] == N[1] || N[2] == N[3] ? "Yes" : "No");
} | 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 x, y;
scan(x, y);
long[] tmp;
tmp ~= x;
while (... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int y, b, r;
rd(y, b, r);
int mx = 0;
for (int i = 1; i <= y; i++) {
for (int j = 1; j <= b; j++) {
for (int k = 1; k <= r; k++) {
if (i + 1 == j && j + 1 == k) {
mx = max(mx, i + j + k);
}
}
}... | D |
import std.stdio;
import std.conv;
import std.string;
void main() {
auto n = readln.chomp.to!(int);
((n / 111 + (n % 111 != 0)) * 111).writeln;
}
| D |
import std.stdio,std.conv,std.algorithm,std.array;
int[] raia() { return readln().split().map!(to!int).array; } //read stdin as int[]
void main(){
auto it = raia();
int count;
for(auto i=it[0];i<=it[1];i++)
if(it[2]%i == 0) count++;
writeln(count);
} | D |
// unihernandez22
// https://atcoder.jp/contests/abc157/tasks/abc157_b
// implementation
import std.stdio: writeln, writefln, readln;
import std.array: array, split;
import std.algorithm: map;
import std.string: chomp;
import std.conv: to;
void main() {
int[3][3] bingo;
foreach(byte i; 0..3) {
int[3] input = 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(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | 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, std.bitmanip;
long X;
int cnt = 0;
void ans(long x) {
debug {
writeln((x == X) ? "OK ": "NG");
writeln(cnt);
re... | 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;
import std.random;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof) ... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.array;
void main() {
string S, T;
S = readln().chomp();
T = readln().chomp();
string res = S.replace("?","z");
const string ng = "UNRESTORABLE";
bool flg = false;
foreach(int i; 0..(to!(int)(S.length)-to!(int)(T.length)+1)) {
bool f = true;
foreach(... | D |
import std.stdio, std.string, std.conv;
void main()
{
auto r = readln.split.to!(int[]), R = r[0];
auto g = readln.split.to!(int[]), G = g[0];
writeln(2*G-R);
} | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
while(true){
auto s = readln();
if(stdin.eof()) break;
real w = to!real(chomp(s));
if(w <= 48.0) writeln("light fly");
else if(w <= 51.0) writeln("fly");
else if(w <= 54.0) writeln("bantam");
else if(w <= 57.0) writeln("feather");
else if(... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
int N = to!int(chomp(readln()));
int K = to!int(chomp(readln()));
int X = to!int(chomp(readln()));
int Y = to!int(chomp(readln()));
int fee;
if(N < K) {
fee = N*X;
fee.writeln;
return;
}
fee += K*X;
if(!N-K < 1) ... | 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, std.bitmanip;
immutable int MAX = 10^^3+1;
immutable long MOD = 10^^9+7;
auto modinv = new long[](MAX);
auto f_mod = new lo... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto n = lread();
long cnt;
foreach (i; 1 .. n + 1)
{
string s;
s = i.to!string();
if (s.length % 2 != 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.container;
import std.datetime;
void main()
{
auto n = readln.chomp.to!double;
int cnt;
while (n > 1) {
n /= 3;
cnt++;
}
cnt.writeln;
} | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format, std.datetime;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generat... | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
int[] input = readln.split.to!(int[]);
int a = input[0];
int b = input[1];
if (a + b == 15){
writeln("+");
} else if (a * b == 15){
writeln("*");
} else {
writeln("x");
}
} | D |
import std.stdio;
import std.string;
string toSwapCase(string s) {
if (s == s.toLower) {
return s.toUpper;
}
if (s == s.toUpper) {
return s.toLower;
}
return s;
}
void main() {
auto str = readln;
foreach (ch; str) {
write(toSwapCase(ch ~ ""));
}
} | 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(int n) {
if (n == 1) return 1;
long a = 2;... | D |
import std.stdio;
import std.algorithm;
int main() {
int t;
scanf("%d", &t);
while (t --> 0) {
int n;
scanf("%d", &n);
int[] a = new int[n];
int[] cnt = new int [42];
long result = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
int bit_id = 0;
while (... | 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 |
module main;
import core.stdc.stdio;
char[9][6] a;
char[9][6] ud;
void print() {
for (int i = 0; i < 6; i++) {
printf("%s\n", &a[i]);
}
}
int main(string[] argv) {
ud[0] = "334433";
ud[1] = "334433";
ud[2] = "223322";
ud[3] = "223322";
ud[4] = "112211";
ud[5] = "112211";
//for (int i = 0; ... | D |
import std.stdio :write, writeln;
import std.array;
import std.range;
import std.typecons;
import std.algorithm : max, min;
string[] list = [
"",
"Washington",
"Adams",
"Jefferson",
"Madison",
"Monroe",
"Adams",
"Jackson",
"Van Buren",
"Harrison",
"Tyler",
"Polk",
"Taylor",
"Fillmore",
"Pierce",
"Buchanan",
"Lincoln",... | 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;
long a, b, c, d;
void main() {
scan(n, a, b, c, d);
b = b - a;
a = 0;
n--;
foreach (i ; 0 .. n ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto ab = readln.split.join("").to!int;
writeln(ab == ab.to!float.sqrt.to!int^^2 ? "Yes" : "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 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 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, std.format;
// }}}
// nep.scanner {{{
class Scanner {
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
impor... | 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(string[] ss) ... | 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);
int res = 0;
for (int a = 3; ; a += 2)
{
int d = a * a;
int b = d / 2;
int c = d - b;
if (... | D |
import std.stdio, std.string,std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto S = [readln.chomp, readln.chomp, readln.chomp];
auto current = 0;
int[3] count;
while (true) {
if (count[current] == S[current].length) {
writeln(current == 0 ? "A" : current == 1 ?... | 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;
T lread(T = long)()
{
return readln.chomp.to!T();
}
T[] aryread(T = long)()
{
ret... | 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;
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,a,b;
scan(n, a, b);
auto ans = min... | 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 = 10L^^15;
void main() {
int n, m;
scan(n, m);
auto adj = new int[][](n, 0);
foreach (i ; 0 .. m) {
int xi, yi;
scan(xi,... | 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;
immutable long mod = 10^^9 + 7;
void main() {
int n;
scan(n);
auto s = iota(n + 1).array;
long ans = 1;
foreach (p ; 2 .. n + 1) {
if (s[p] ... | 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.to!(char[]);
auto q = readln.chomp.to!int;
auto r = 1;
st... | 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%2 == ... | 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;
import std.datetime, std.bigint;
int n, k;
string s;
void main() {
scan(n, k);
s = readln.chomp;
auto t = new i... | D |
/+ dub.sdl:
name "B"
dependency "dcomp" version=">=0.7.3"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n; int[] a;
sc.read(n, a);
long all = 1, err = 1;
foreach (d; a) {
all *=... | 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; readV(a, b, c);
wri... | D |
/+ dub.sdl:
name "J"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
import std.typecons;
int main() {
auto sc = new Scanner(stdin);
alias Edge = Tuple!(int, "to", int, "dist");
int n;
sc.read(n);
Edge... | 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.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop, std.typetuple, std.typecons;
immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;
alias triplet = Tuple!(int, int, int);
void main(){
int a, b, c;
readVa... | 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 |
void main() {
string s = readln.chomp;
long k = readln.chomp.to!int;
auto g = s.group.array;
long ans;
if (g.length == 1) {
ans = k * g[0][1].to!long / 2;
} else {
foreach (x; g) {
ans += x[1] / 2;
}
ans *= k;
if (s[0] == s[$-1]) {
... | D |
void main() {
problem();
}
void problem() {
auto S = scan;
auto T = scan;
auto SL = S.length;
auto TL = T.length;
long solve() {
int max_contained;
foreach(i; 0..SL - TL + 1) {
int contained;
foreach(j; 0..TL) {
if (T[j] == S[i + j]) contained++;
}
if (max_con... | 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[]);
writeln( max(data[0] * 2 - 1, data[0] + data[1], data[1] * 2 - 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.string, std.algorithm, std.array;
void bracket (int count)
{
for (int i = count; i >= 1; i--)
{
string s = "";
s ~= replicate("(", i);
s ~= replicate(")", i);
s ~= replicate("(", count - i);
s ~= replicate(")", count - i);
writeln(s);
}
}
void main()
{
int t;
scanf("%d", &... | D |
import std.stdio, std.conv, std.string;
void main(){
auto ip = readln.split.to!(int[]), x = ip[0], y = ip[1];
const gr = [0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1];
if(gr[x] == gr[y]){
writeln("Yes");
} else {
writeln("No");
}
} | 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 string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
void main() {
if(rs.count('7')) writeln("Yes");
else writeln("No");
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std... | 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.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
int n; long c;
scanf("%d%ld", &n, &c);
struct P { long x; int v;}
P[] p = new P[n];
foreach (i; 0..n) {
long x; int v;
scanf("%ld%d", &x, &v);
p[i] = P(x,v);... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.