code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];
auto g = new bool[][](n, n);
foreach (_; 0..m) {
auto rd2 = readln.split.to!(size_t[]), a = rd2[0]-1, b = rd2[1]-1;
g[a][b] = g[b][a] = true;
}
auto isValid(... | 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 N = readln.chomp.to!int;
long[] rs, cs;
foreach (_; 0..N) {
auto rc = readln.split.to!(long[]);
rs ~= rc[0];
cs ~= rc[1];
}
auto DP = new long[][](N, N)... | D |
/+ dub.sdl:
name "E"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
/*
int l;
long mod;
long calc(int n, int a, int b, int c, int d) {
assert(c >= 0 && d >= 0);
assert(c == 0 || d == 0);
if (n == 0) return 1;... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto n = readln.strip.to !(int);
auto k = readln.splitter.map !(to !(long)).array;
auto h = readln.splitter.map !(to !(long)).array;
f... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1], t = tmp[2];
writeln(t / a * b);
}
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 |
/+ dub.sdl:
name "F"
dependency "dcomp" version=">=0.7.4"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int k;
// sc.read(k);
k = 38;
int n = k*(k-1)+1;
bool[][] g = new bool[][](n, n);
... | D |
import std.stdio, std.string, std.conv, std.algorithm;
void main() {
int[] tmp = readln.chomp.split.to!(int[]);
int n = tmp[0], k = tmp[1];
string s = readln.chomp;
int cnt;
foreach (i; 1 .. n) {
if (s[i] == s[i-1]) ++cnt;
}
min(n-1, cnt+2*k).writeln;
} | D |
void main()
{
long k = rdElem - 1;
long[] a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
a[k].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;
}
alias rdSt... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
stri... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto rd = readln.chomp.splitter;
auto ai = new int[](n);
foreach (i; n.iota) {
ai[i] = rd.front.to!int;
rd.popFront;
}
auto k = ai.reduce!(max);
auto bi = countingSort(ai, k);
for... | 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 = 10^^5 + 1;
void main() {
int N, W;
sca... | 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(){
int n = readNum!int;
writeln(180 * (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;
import std.string; // chomp????????????????????????(?????????????????????)
import std.conv; // to????????????????????????
import std.array; // split?????????????????????
void main() {
auto input = readln.split;
auto a = input[0].to!int;
auto b = input[1].to!int;
writeln(a * b, " ", 2... | D |
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;
enum INF = long.... | D |
import std.stdio, std.string, std.conv;
import std.algorithm;
void main() {
auto input = getStdin!(string[]);
string needle = input[0].toLower;
string[] haystack = input[1..$-1].join(" ").replace(".", "").replace(",", "").toLower.split(" ");
auto count = haystack.count(needle);
count.writeln;
}
T getStdin(T)() ... | D |
void main() {
auto S = rs;
string str = "keyence";
if(S == str) { writeln("YES"); return; }
foreach(i; 0..str.length) {
auto l = str[0..i];
auto r = str[i..$];
if(S.startsWith(l) && S.endsWith(r)) {
writeln("YES");
return;
}
}
writeln("NO");
}
// ===================================
import std.stdi... | D |
import std.stdio, std.range, std.conv, std.string, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
void main() {
long N = readln().strip.to!long;
long minCount=long.max;
for (long i = 0; i < 5;... | 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 |
void main()
{
string s = rdStr;
string t;
foreach (x; s)
{
if (x == 'B')
{
if (t.length) t = t[0..$-1];
}
else
{
t ~= x;
}
}
t.writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(... | 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 A = scanElem;
auto B = scanElem;
writeln(A-B+1);
}
long gcd(long a, long b)
{
if(b ... | 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]);
long[] h;
foreach (token; spli... | 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() {
long r, d, x;
scan(r, d, x);
foreach (i ... | 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 |
/+ dub.sdl:
name "D"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.numeric.prime;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
long n;
sc.read(n);
auto dlist =... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import 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 |
import std.stdio, std.conv, std.string, std.array, std.algorithm, std.range;
void main() {
auto N = readln.split[0].to!int;
auto H = readln.split.to!(int[]);
H ~= int.max;
auto maxNum = 0;
auto num = 0;
size_t i = 0;
while(i < H.length - 1) {
if(H[i+1]<=H[i]) {
num++;
} else {
maxNu... | D |
void main() {
("A" ~ rs[8] ~ "C").writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
impo... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int x = tmp[0], y = tmp[1] / 2;
writeln(x + y);
}
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,std.conv,std.string,std.algorithm;
void main(){
auto nab = readln.chomp.split.map!(to!int);
int n=nab[0],a=nab[1],b=nab[2];
if(n*a<b) writeln(n*a);
else writeln(b);
} | 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 d, t, s;
scan(d, t, s);
double tmp = double(d) / double... | 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;
import std.range, std.algorithm, std.array, std.math, std.typecons;
void main() {
int n, t;
scan(n, t);
auto imos = new int[](t + 2);
foreach (i ; 0 .. n) {
int li, ri; scan(li, ri);
imos[li]++;
imos[ri]--;
}
foreach (i ; 0 .. ... | 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.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.map!(to!int);
auto w = rd[0], h = rd[1], x = rd[2], y = rd[3], r = rd[4];
writeln(x >= r && x <= w - r && y >= r && y <= h - r ? "Yes" : "No");
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nx = readln.split.to!(int[]);
auto N = nx[0];
auto X = nx[1];
auto xs = readln.split.to!(int[]);
auto d = xs[0];
X = abs(X - d);
foreach (x; xs[1..$]) {
X = gcd... | 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.algorithm, std.conv, std.array, std.string;
void main()
{
readln.chomp.split(" ").sort().uniq.count.writeln;
} | 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.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
auto N = readln.chomp.to!int;
auto X = new long[](N);
auto Y = new long[](N);
auto A = new long[](N);
a... | D |
import core.stdc.stdio;
import std.algorithm;
void main(){
int n,k;
scanf("%d%d",&n,&k);
for(int i=0;i<k;i++){
int a,b;
scanf("%d%d",&a,&b);
int m = min(a,n+1-a,b,n+1-b);
printf("%d\n",(m-1)%3+1);
}
} | D |
import std.stdio, std.range, std.conv, std.string, std.array, std.functional;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;
void main()
{
auto N = readln().strip.to!(long);
... | 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 |
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;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
import std.math;
import std.range;
void main() {
auto S = readln.chomp.dup;
auto T = readln.chomp.dup;
auto findResult = iota(S.length-T.length+1).retro
.find!(i =>... | D |
import std.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv,
std.format,
std.math;
void main()
{
auto r = readln.chomp.to!int;
... | 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 |
module app;
import core.bitop;
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;
import std.traits;
struct Input
{
int n, k;
int[] d;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
auto ar = readln().strip().split().map... | D |
import std.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.conv;
void main(string[] argv)
{
long x = readln.chomp.to!long;
long a = readln.chomp.to!long;
long b = readln.chomp.to!long;
x -= a;
writeln(x%b);
}
| D |
import std.stdio;
import std.string;
import std.range;
import std.conv;
void main()
{
auto N = readln.chomp.to!int;
auto K = readln.chomp.to!int;
auto X = readln.chomp.to!int;
auto Y = readln.chomp.to!int;
if(N>K){
writeln((K*X)+((N-K)*Y));
}else{
writeln(N*X);
}
} | 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;
}
cons... | D |
import std.stdio,std.ascii,std.conv,std.string,std.algorithm,std.range,std.functional,std.math,core.bitop;
void main()
{
auto a=readln.chomp.to!int;
auto b=readln.chomp.to!int;
writeln((a*a)-b);
} | 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;
import std.conv;
import std.array;
import std.string;
void main()
{
while (1) {
string[] input = split(readln());
int m = to!(int)(input[0]);
int f = to!(int)(input[1]);
int r = to!(int)(input[2]);
if ( m == -1 && f == -1 && r == -1) break;
if (r == -1) r = 0;
char g;
... | D |
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;
void main() {
auto s = readln.chomp;
auto c = s.count!(x => x == 'R');
if (c == 2 && s[1] != 'R') {
writeln(1);
} else {
writeln(c);
}
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto hw = readln.split.to!(int[]);
auto H = hw[0];
auto W = hw[1];
char[][] MAP;
MAP.length = H;
int s;
foreach (i; 0..H) {
MAP[i] = readln.chomp.to!(char[]);
... | D |
void main()
{
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1];
if (a + b == 15)
{
"+".writeln;
}
else if (a * b == 15)
{
"*".writeln;
}
else
{
"x".writeln;
}
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
im... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
auto ... | D |
import std.stdio, 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 N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
int odd, two, four;
foreach (a; A) {
... | D |
void main(){
int x = _scan();
( (x/500)*1000 + (x%500)/5*5).writeln();
}
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()){... | 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 |
void main() {
auto N = ri;
auto S = rs;
int res = 0;
int tmp = 0;
foreach(i; S) {
i == 'I' ? tmp++ : tmp--;
res = max(res, tmp);
}
res.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import st... | 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 l = new long[](n+1);
l[0] = 2;
l[1] = 1;
... | D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
int [] get (string s)
{
auto f = new int [10];
foreach (c; s)
{
f[c - '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() {
int n,m;
scan(n);
scan(m);
int ans;
if (n > 30) {
ans = m;
}
else {
ans = m % 2^^n;
}
writeln(ans);
}
... | 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.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
stri... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
//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;
int test () {
auto s = readln.strip;
auto t = readln.strip;
immutable l = s.length.to!int;
auto next = new int[26]... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
stri... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, m, q; rd(n, m, q);
auto s=readln.chomp.to!(char[]);
auto t=readln.chomp.to!(char[]);
auto ok=new bool[](s.length+1);
for(int i=0; i+t.length<=s.length; i++){
if(s[i..(i+t.length)]==t) ok[i]=true;
}
while(q--){
int l, r;... | 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)
{
readln.strip.length.writeln;
}
}
| 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);
int n = s.length.to!int;
long ans;
foreach (i ; 0 .. n) {
foreach (j ; i + 1 .. n) {
foreach (k ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
void main()
{
auto a = readln.split.to!(long[]);
auto N = a[0];
auto A = a[1];
auto B = a[2];
auto C = a[3];
auto D = a[4];
foreach (i; 0..N-1) {
auto l = A + C * i... | D |
void main() {
auto r = ri;
writeln(r*r);
}
// ===================================
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.conv;
import std.typecons;... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
class Node {
Node[] to;
Node[] from;
int n;
}
void main() {
int m = to!int(readln().strip());
int n = to!... | 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];
writeln(max(A+B, A-B, 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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
void main()
{
auto S = readln.chomp;
auto DP = new long[][](S.length+1, 4);
DP[S.length][3] = 1;
foreach_reverse (i; 0..S.length) {
auto c = S[i];
foreach (j; 0..4)... | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;
alias sread = () => readln.chomp();
ulong bignu... | D |
// 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 |
void main() {
problem();
}
void problem() {
auto X = scan!int(5);
int solve() {
foreach(i; 0..5) {
if (X[i] == 0) return i+1;
}
return 0;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.contain... | D |
import std.stdio;
import std.string;
void main()
{
auto S = readln().chomp();
if ((S == "AAA") || (S == "BBB"))
{
writeln("No");
return;
}
writeln("Yes");
}
| D |
void main() {
int n = readln.chomp.to!int;
string[] w = new string[n];
int ok = true;
foreach (i; 0 .. n) {
string s = readln.chomp;
if (i > 0) {
if (s[0] != w[i-1][$-1] || w.canFind(s)) {
ok = false;
break;
}
}
w[i]... | 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;
alias Edge = Tuple!(int, "u", int, "v");
void main() {
int n, k;... | 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;
immutable long MOD = 10^^9 + 7;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto K = s[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;
import std.typecons;
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", ... | 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 Point... | D |
void main()
{
long n = readln.chomp.to!long;
long[] op = [1];
foreach (i; 0 .. n)
{
if (6 ^^ (i + 1) <= n)
{
op ~= 6 ^^ (i + 1);
}
if (9 ^^ (i + 1) <= n)
{
op ~= 9 ^^ (i + 1);
}
if (6 ^^ (i + 1) > n)
{
... | 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 |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1], c = tmp[2];
writeln(min(c, b/a));
}
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.string;
import std.algorithm;
import std.conv;
import std.array;
import std.math;
import std.range;
import std.typecons;
void main()
{
for(string[] inputs; (inputs = readln.split)[0] != "0";)
writeln( solve( inputs[0].to!int, inputs[1].to!int ) );
}
int[][] G, D;
bool[][][] M;
int so... | 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;
void main()
{
auto x = readln.chomp.split.to!(int[]);
auto a = new int[](3);
a[0] = x[0] * x[1]... | 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.typecons;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.