code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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.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;
auto Q = readln.chomp.to!int;
auto ks = readln.split.to!(int[]);
auto ms = new long[](N);
auto cs = new long[](N);
size_... | D |
void main()
{
long n = rdElem;
long[] a = rdRow;
bool ok = true;
foreach (x; a)
{
if (!(x & 1))
{
if (x % 3 != 0 && x % 5 != 0) ok = false;
}
}
writeln(ok ? "APPROVED" : "DENIED");
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = lon... | 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 |
import std.stdio, std.algorithm, std.array, std.ascii;
int main() {
char a = scanChar();
if('a'<=a && a<='z') {
writeln("a");
} else {
writeln("A");
}
return 0;
}
char scanChar() {
import std.ascii;
int c = ' ';
while(isWhite(c) && c != -1) {
c = getchar;
}
return cast(char)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 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.range, std.algorithm;
void main() {
auto w = readln.chomp;
int[char] char_count;
foreach (c; w) {
char_count[c]++;
}
if (char_count.values.all!"a % 2 == 0") {
"Yes".writeln;
} else {
"No".writeln;
}
} | D |
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
void main(){
auto ip = readln.split.to!(int[]), A=ip[0], B=ip[1], T=ip[2];
writeln(T/A*B);
} | D |
// import chie template :) {{{
static if (__VERSION__ < 2090) {
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons, std.format,
std.bitmanip, std.numeric;
} else {
import std;
}
// }}}
// nep.scanner {{{
class Scanner {
... | D |
import 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 = sread();
// writeln(n);
long sum_n;
foreach (i;... | D |
import std.stdio;
import std.conv;
import std.string;
void main(string[] args){
while(1){
int n = to!int(readln.chomp);
if(n == 0) break;
int S = 0;
int Smin = 0;
int Smax = int.min;
int dmax = int.min;
for(int i = 0; i < n; i ++){
S += to!int(readln.chomp);
if(S > Smax) Smax = S;
if(Smax - Smi... | 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() {
int n;
scan(n);
auto a = iota(n).map!(i => readln.chomp.to!int).array;
long ans;
foreach_reverse (i ; 0 .. n) {
if (a[i... | 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;
import std.range;
import std.conv;
void main()
{
auto ip = readln.split.to!(int[]), X = ip[0], A = ip[1], B = ip[2];
if(A >= B) {
writeln("delicious");
} else {
if(B-A > X) {
writeln("dangerous");
} else {
writeln("safe");
}
}
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm: canFind;
void main() {
string[] inputs = split(readln());
int a = to!int(inputs[0]);
int b = to!int(inputs[1]);
int c = to!int(inputs[2]);
if(b - a == c - b) "YES".writeln;
else "NO".writeln;
}
| D |
import std.stdio,std.string,std.conv;
void main(){
auto n = to!int(readln().chomp());
for( int i=0; i<n ; i++ ){
auto arr = readln().chomp().split();
double[] arr2;
arr2.length = arr.length;
for( int j=0; j<arr.length ; j++ ){
arr2[j] = to!double( arr[j] );
}
if( (arr2[3]-arr2[1])/(arr2[2]-arr2[0]) == ... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.algorithm,
std.string,
std.array,
std.stdio,
std.range,
std.conv;
long abs(long x) {
return x * (x < 0 ? -1 : 1);
}
void main() {
long N = readln.chomp.to!long;
long[] a = readln.chomp.split.to!(long[]);
long ans = long.max;
long x, y;
for (size_t i = 0; i... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
string[] inputs = split(readln());
int A = to!int(inputs[0]);
int B = to!int(inputs[1]);
int C = to!int(inputs[2]);
int D = to!int(inputs[3]);
max(A*B, C*D).writeln;
}
| D |
import std.stdio;
import std.conv;
import std.string;
import std.math;
import std.random;
import std.range;
import std.algorithm;
import std.functional;
import core.bitop;
import std.bigint;
import std.typecons;
import std.container;
void main()
{
auto input = readln.split.to!(ulong[]);
auto X = input[0], Y =... | D |
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math;
struct SegTree(alias _fun, alias def, T)
if (is(typeof(def) : T))
{
import std.functional : binaryFun;
alias fun = binaryFun!_fun;
///
this(size_t n, T[] ts) {
this.n = 1;
while (this... | D |
import std.array;
import std.conv;
import std.math;
import std.algorithm;
import std.string;
import std.stdio;
void main() {
int n = readln.chomp.to!int;
auto steps = readln.chomp.split(' ').map!(to!int).array;
auto dp = new int[n];
dp[1] = abs(steps[0] - steps[1]);
foreach (i;2..n) {
dp[i] = min(
dp[i - 2... | D |
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
void main() {
immutable input = readln.split.to!(ulong[]);
immutable r = input[0], d = input[1], x2k = input[2];
ulong x = x2k;
for(ulong i = 0; i < 10; i++) {... | D |
import std.stdio;
import std.string;
import std.conv;
int main()
{
int a = readln().chomp().to!int();
a = a * a * a;
writeln(a);
return 0;
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nk = readln.split.to!(int[]);
auto N = nk[0];
auto K = nk[1];
auto HS = readln.split.to!(long[]);
HS ~= 0;
long[] hc;
auto DP = new long[][](N, K+1);
long solve(in... | 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()
{
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], a = tmp[1], b = tmp[2];
string s = readln.chomp;
int pass, oversea;
foreach (c; s)
{
if (c == 'a' && pass < a + b)
{
"Yes".writeln;
++pass;
}
else if (c == 'b' && pass < a ... | 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 xt = readln.chomp.split.map!(to!int);
writeln(max(xt[0]-xt[1],0));
}
| D |
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
int DEBUG_LEVEL = 0;
void pr... | D |
/+ dub.sdl:
name "D"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv, std.math;
// import dcomp.foundation, dcomp.scanner;
int main() {
auto sc = new Scanner(stdin);
int n;
sc.read(n);
int[][] g = new int[][](n);
foreach (i; 0..n-1) {
in... | 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.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.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;
void main() {
for(;;) {
// input
int R, C;
{
auto temp = readln.split;
R = to!int(temp[0]);
C = to!int(temp[1]);
}
if(R == 0 && C == 0) {
break;
... | D |
import std.stdio;
import std.array;
import std.math;
import std.conv;
import std.string;
void main() {
string[] input = split(chomp(readln));
int x = to!int(input[0]);
int y = to!int(input[1]);
writeln((x*y)," ",(x*2 + y*2));
} | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
int[101] counter;
string rc;
int max;
while( 1 ){
rc = readln().chomp();
if( !rc ){ break; }
counter[ to!int( rc ) ]++;
if( max < counter[ to!int( rc ) ] ){
max = counter[ to!int( rc ) ];
}
}
foreach( i,c ; counter ){
if( c == max ... | D |
/+ dub.sdl:
name "C"
dependency "dcomp" version=">=0.7.3"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
// import dcomp.graph.bridge;
int main() {
Scanner sc = new Scanner(stdin);
int n, m;
sc.read(n, m);
struct E {int to;}
E[][] g = n... | 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[]);
int cnt;
foreach (i; 0..x[0]) {
auto... | D |
import std.stdio;
import std.conv;
import std.array;
import std.algorithm;
struct Item {
int w;
int v;
}
void main()
{
auto buf = readln.split;
int N = buf[0].to!int;
int W = buf[1].to!int;
Item[] items = new Item[N];
foreach (i; 0..N){
buf = readln.split;
items[i].w = buf[... | D |
import std.string,
std.stdio,
std.conv;
void main(){
while(true){
string s = readln.chomp;
if (s == "-") break;
int n = readln.chomp.to!int;
ulong sx=0;
foreach(i;0..n){
sx+=readln.chomp.to!int;
}
sx = sx % s.length;
writeln(s[sx..$] ~ s[0..sx]);
}
} | 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, m;
scan(n, m);
auto adj = new Edge[][](n, 0);
foreach (i ; 0 .. m) {
int ui, vi, ci;
scan(ui, vi, ci);
adj[ui] ~= Edge(v... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
static import std.ascii;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){ret... | D |
module app;
import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.string;
import std.conv;
void main(string[] args) {
// 一行目の入力を捨てる
readln();
int[][] lines = iota(0,2).map!((Unused) => readln.chop.split.map!(to!int).array).array;
auto candies = iota(0,lines[0].length).... | 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;
int cnt;
foreach (i; 0..s.length/2) {
if (s[i] != s[$-... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
void main ()
{
string s;
while ((s = readln.strip) != "")
{
bool have0 = false;
bool have1 = false;
foreach (ref c; s)
{
if (c == '0')
{
writeln (have0 ? 1 : 3, " ", 1);
have0 ^= true;
}
else
... | D |
void main()
{
long n = rdElem;
string s = rdStr;
long result;
foreach (i; 0 .. n)
{
long[] z_arr = s[i..$].z;
foreach (j; 0 .. n-i)
{
if (j >= z_arr[j]) result = max(result, z_arr[j]);
}
}
result.writeln;
}
long[] z(string s)
{
long len = s.... | 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 |
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.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional, std.traits;
import std.algorithm, std.container;
void main()
{
long N = scanElem;
string S = readln.strip;
long K = scanElem;
foreach(c; S)
{
if(S[K-1]==c)write... | 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;
void main() {
long n, k;
scan(n, k);
long x = n / k;
writeln(x & 1 ? "YES"... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
alias Pair = Tuple!(int, "a", int, "b");
void main() {
... | 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 s; readV(s);
auto b = new b... | D |
import std.stdio;
import core.stdc.stdio;
import std.algorithm;
import std.math;
import core.stdc.string;
char[] A;
char[] B;
class Arr{
int as,bs,cs,ds;
void Set(int a,int b,int c,int d){
as = a;
bs = b;
cs = c;
ds = d;
data = new int[a*b*c*d];
}
this(){
Set(500,10,2,3);
}
int[] data;
ref int opIn... | D |
import std.stdio;
import std.string;
import std.conv;
import std.math;
void main() {
int N = to!int(chomp(readln()));
int A = to!int(chomp(readln()));
writeln(pow(N, 2) - A);
}
| D |
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.datetime;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
auto readInts() {
return array(map!(to!int)(readln().strip().split()... | 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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const N = readln.chomp.to!long;
const as = readln.split.to!(long[]);
long cnt;
long ss, xs;
long r;
foreach (l; 0..N) {
while (r < N && ss + as[r] == (xs ^ as[r])) {
... | 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, k; readV(a, b, k);
for... | D |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
import std.typecons;
import std.bigint;
// import dcomp.foundation, dcomp.scanner;
// import dcomp.container.deque;
int main() {
auto sc = new Scanner(stdin);
int n, m, k;
sc.read(n... | 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;
void main()
{
foreach (line; stdin.byLine) {
auto x = line.chomp.array;
auto field = new int[](9);
foreach (i, e; x) {
if (e == 'o') fie... | 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 b = readln.chomp.split.to!(i... | D |
import std.stdio, std.string, std.conv;
void main() {
string s = readln.chomp;
string t = readln.chomp;
int cnt;
foreach (i; 0 .. 3) {
if (s[i] == t[i]) ++cnt;
}
cnt.writeln;
} | 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 |
// 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, a, b;
int[] x, y;
void main() {
scan(n, a, b);
x = new int[](n);
y = ne... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
long n, m, a, b; rd(n, m, a, b);
long x=(((n+m-1)/m)*m-n)*a;
long y=(n-(n/m)*m)*b;
writeln(min(x, y));
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.length);
foreach(i,... | D |
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.typecons;
import std.variant;
void main() {
long tt = readln().chomp.to!long;
foreach (t; 0 .. tt) {
readln();
long[] piles = readln().chomp.split(" ").map!(to!long).array;
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
int solve (int n, bool [] a, bool [] b)
{
auto aOnes = a.sum.to !(int);
auto bOnes = b.sum.to !(int);
auto same = n.iota.count !(i => a[i] == b[i]).to !(int);
auto diff = n - same;
int res = int.max;
if (aOnes == bOnes)... | 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;
void main() {
auto N = readln.chomp.to!int;
auto S = readln.chomp;
auto used = new bool[](N);
for (int i... | D |
module main;
import std.stdio;
import std.algorithm;
import std.array;
ulong pow(ulong a, ulong b){
if (b == 0)
return 1;
ulong ans = a;
for (ulong i = 2; i<=b; ++i)
ans *= a;
return ans;
}
int main(string[] argv)
{
ulong l;
ulong r;
scanf("%d %d", &l, &r);
ulong ans = 0;
for ... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
auto s=readln.chomp.to!(char[]);
auto t="abcdefghijklmnopqrstuvwxyz".to!(char[]);
if(s.length<t.length){writeln(-1); return;}
int cnt=0;
for(int i=0, j=0; i<t.length.to!(int); i++, j++){
if(cnt==t.length.to!(int)) break;
while(j<s... | 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;
bool solve() {
auto L = new int[](4);
auto S = new int[](4);
auto R = new int[](4);
auto P = new int[](4);
foreach (i;... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto s = readln.chomp;
auto f = false;
foreach (i; 0..s.length-1) {
if (s[i] ... | D |
// 提出解
void solve(){
A: foreach(_; 0 .. scan!int){
int n = scan!int;
int[] as = scan!int(n);
int[] xs;
for(int i = 0, j = n - 1; i < j; i ++, j --){
if(as[i] != as[j]){
xs = [as[i], as[j]];
break;
}
}
if(xs.length == 0){
"YES".print;
continue;
}
foreach(x; xs){
bool isOK = 1;
... | D |
import std;
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "cur", long, "prev");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(... | D |
import std.stdio;
import std.algorithm;
import std.typecons : tuple, Tuple;
import std.container.rbtree;
int n;
long s;
int[] l;
int[] r;
bool can(long m) {
int cnt = 0;
int other = n;
long sum = 0;
for(int i = 0; i < n; ++i) {
if (m < l[i]) {
++cnt;
sum += l[i];
--other;
} else if (r[i] < m) {
s... | D |
void main()
{
long a, b, c, d;
rdVals(a, b, c, d);
long x = abs(a-c), y = abs(b-d);
long g = gcd(x, y);
long result = x + y - g;
result.writeln;
}
enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;
T rdElem(T = long)()
if (!is(T == struct))
{
return readln.ch... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.math;
void main(string[] args)
{
auto n = split(strip(readln));
auto a = to!long(n[0]);
auto b = to!long(n[1]);
long count;
if (a == 1 && b == 1)
{
writeln(0);
return;
}
while(a >= 1 && b >= 1)
{
if (a < b)
{
a+... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
import std.range;
void main() {
auto A = readln.chomp.to!int, B = readln.chomp.to!int, C = readln.chomp.to!int, X = readln.chomp.to!int;
int count;
foreach(i; 0..A+1) {
foreach(j; 0..B+1) {
foreach(k;... | 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 k, n; readV(k, n);
auto ans... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
... | D |
import std.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, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
alias Edge = Tuple!(int, "from", int, "to", int, "s");
alias Pair = Tuple!(int, "sgn", int, "val");
enum inf = 2*10^^9 + 3;
void main() {
int n, m;
scan(n,... | D |
import std.stdio, std.string, std.conv;
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], p= tmp[1];
writeln((3 * a + p) / 2);
} | 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 = 10^^9 + 7;
void main() {
auto N = readln.chomp.to!long;
auto S = readln.chomp;
auto cnt... | D |
import std.string;
import std.range;
import std.conv;
import std.stdio;
import std.algorithm;
void main()
{
auto N = readln.chomp.to!int;
auto A = readln.split.to!(int[]);
auto m = A.reduce!max;
auto l = A.reduce!min;
writeln(m-l);
} | D |
/+ dub.sdl:
name "F"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int solve(int[][] g, bool[] s) {
int n = g.length.to!int;
foreach (i; 0..n) {
if (g[i].length % 2) s[i] = !s[i];
}
debug {
... | 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() {
int N, K;
scan(N, K);
K = min(K... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
writeln(readln.chomp == "0" ? 1 : 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, std.datetime;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generat... | D |
void main(){
//auto NM = readLine!long();
if( readStr() == "ABC" ){
writeln("ARC");
} else {
writeln("ABC");
}
}
import std;
string readStr(){
return readln().chomp();
}
T[] readLine( T = long )(){
return readln().split().to!(T[])();
} | D |
import std.stdio,std.string,std.conv,std.array,std.algorithm;
void main(){
string[] arr;
readln();
for(;;){
auto rc = readln().chomp();
if(!rc){ break; }
arr ~= rc;
}
sort( arr );
writeln( arr[0] );
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
void main() {
while(true) {
string[] cin;
cin=split(readln());
int n=to!int(cin[0]),a=to!int(cin[1]),b=to!int(cin[2]),c=to!int(cin[3]),x=to!int(cin[4]);
if(!(n... | 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.exception : enforce;
int n, p;
int[] a;
void main() {
scan(n, p);
a = readln.split.to!(int[]);
auto ... | 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 |
import std.conv;
import std.stdio;
import std.string;
void main()
{
auto n = readln.strip.to!( int );
writeln( solve( n ) );
}
auto solve( in int n )
{
return n + n * ( n % 2 );
}
| D |
import std.stdio;
import std.array;
import std.conv;
void main(){
string[] input = split(readln());
int a = to!int(input[0]);
writeln(a*a*a);
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main()
{
auto S = split(readln())[0];
//if (S == "zyxwvutsrqponmlkjihgfedcba") { writeln("-1"); return; }
if (S.length < 26) { writeln(solve1(S)); }
else { writeln(solve2(S)); }
}
string solve1(string S) {
bool[26] list;
foreac... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.