code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
int main(){
int n;
long c1 , c2;
scanf("%d %lld %lld" , &n , &c1 , &c2);
char arr;
int zeroes = 0;
int ones = 0;
for(int i = 0 ; i < n ; ++i){
scanf(" %c" , &arr);
if(arr == '0'){
++zeroes;
}
else{
++ones;
}
}
long ans = 800000000000000000L... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
bool ask (long value)
{
writeln ("? ", value);
stdout.flush ();
return readln.strip == "Y";
}
void answer (long value)
{
writeln ("! ", value);
stdout.flush ();
}
void main ()
{
... | D |
import std.algorithm;
import std.array;
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 scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
alias Edge = Tuple!(int, "u", int, "v");
void main() {
int N, M;
scan(N, M);
auto es = new Edge[](M);
foreach (i ; 0 .. M) {
int ai, bi;
scan(ai, bi)... | 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 = "%.15f";
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;
void main() {
const tmp = readln.split.to!(int[]);
const N = tmp[0];
const X = tmp[1];
const Ls = readln.split.to!(int[]);
int p = 0;
int cnt;
foreach (i; 0..N+1) {
if (p > X) break;
p += Ls[i];
cnt++;
}
writeln(cnt);
}
| 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 |
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 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.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.to!(int[]); }
int calc(int[][] xs) {
int n = cast(int) xs[0].length;
int a... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto len = S.length;
int c;
foreach (i; 0..len/2) {
if (S[i] != S[len-i-1]) ++c;
}
writeln(c);
} | D |
void main()
{
string s = rdStr;
writeln(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}
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 rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);
T rdElem(T)()
if (is(T == ... | 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;
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;
void main() {
int N;
string S;
scan(N);
s... | 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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
int[] a; readA... | D |
import std;
void main() {
char[] s, t;
scan(s);
scan(t);
int n = s.length.to!int;
int m = t.length.to!int;
if (n < m) {
writeln("UNRESTORABLE");
return;
}
char[] ans = new char[](n);
bool exist;
foreach_reverse (i; 0 .. n - m + 1) {
if (match(s[i .. i + m], t)) {
foreach (j; 0 .. ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
long solve(int i, long n, long s) {
if (i == S.length) {
return n + s;
} else {
return solve(i+1, S[i]-'0', n+s) + solve(i+1, n*10+... | D |
import std.stdio, std.conv, std.string, std.array, std.algorithm, std.math, std.regex;
void main(){
auto ip = readln.split.to!(int[]);
writeln(ip.count(5) == 2 && ip.count(7) == 1 ? "YES" : "NO");
} | 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;
scan(n);
auto x = new long[](n + 1);
auto s = new int[](n + 1);
foreach (i ; 1 .. n + 1) {
scan(x[i], s[i]);
}
... | D |
void main() {
problem();
}
void problem() {
auto N = scan!int;
auto STONES = scan!string.to!(char[]);
long solve() {
long left = 0;
long right = N-1;
long ans;
while(left <= right) {
if (STONES[right] != 'R') {
right--;
continue;
}
if (STONES[left] != 'W') {
... | D |
import std.stdio;
import std.string;
import std.format;
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.concurrency;
import std.traits;
import std.uni;
import c... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.map!(to!size_t), n = rd[0], m = rd[1];
auto aij = n.iota.map!(_ => readln.split.map!(to!int)).array;
auto bi = m.iota.map!(_ => readln.chomp.to!int).array;
auto ci = new int[](n);
foreach (i; 0..n)
ci[... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; re... | D |
/+ 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, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
/*
mod 6で
3 を偶数個(最大5,000個)
2と4を同数(あわせて最... | D |
void main() {
auto X = ri;
ulong res;
while(X >= 500) {
res += 1000;
X -= 500;
}
res += (X / 5) * 5;
res.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.contai... | 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 n = readln.chomp.to!int;
int[string] t;
int sum;
foreach... | D |
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
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 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.format;
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.concurrency;
import std.traits;
import std.uni;
import c... | 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() {
int n;
scan(n);
auto a = readln.split.to!(... | 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 |
// 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;
long[] a;
void main() {
scan(n, k);
a = readln.split.to!(long[]);
au... | 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 |
/+ dub.sdl:
name "C"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.algorithm;
immutable L = 19;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
int n, q;
sc.read(n, q)... | 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 |
// cheese-cracker [2022-02-06]
void solve(){
long n = scan;
long k = scan;
auto s = scan!(dchar[]);
auto rs = s.dup;
rs.reverse;
if(s == rs || k == 0){
writeln(1);
}else{
writeln(2);
}
}
void main(){
long tests = scan; // Toggle!
while(tests--) solve;
}
... | 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.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 N = readln.chomp.to!int;
auto G = new int[][](N);
foreach (_; 0..N-1) {
auto s = readln... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.string, std.array, std.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 |
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;
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;
long sum;
foreach (int i; 1..n+1) {
if (i % 3 &&... | 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.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
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 std.conv;
import std.stdio;
import std.string;
void main()
{
auto n = readln.strip.to!int;
writeln( solve( n ) );
}
auto solve( in int n )
{
if( n < 1000 ) return "ABC";
else return "ABD";
}
unittest
{
assert( solve( 999 ) == "ABC" );
assert( solve( 1000 ) == "ABD" );
assert( solve( 1481 ) =... | D |
void main() {
auto S = rs;
if(S.uniq.array.length == 1) writeln("No");
else writeln("Yes");
}
// ===================================
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;
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;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }
string calc(Vec2 a, Vec2 b, Vec2 c) {
auto ab = b - a;
... | D |
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container;
void main() {
int n = readln.chomp.to!int;
int[] x = readln.chomp.split.to!(int[]);
int minimum = int.max;
for(int p=1; p<=100; p++) {
int cost = 0;
foreach(xi;x) {
cost += (xi-p)*(xi-p);
}
minimum ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
void main()
{
int m = readln.chomp.split.back.to!int;
string s = readln.chomp;
int l = 0, r = 1;
// bool[string] set;
bool[ulong[2]] set;
auto hasher = new ... | 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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const tmp = readln.split.to!(long[]);
writeln(max(0, tmp[2] - tmp[0] + tmp[1]));
}
| D |
/* imports all std modules {{{*/
import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.encoding,
std.exception,
std.file,
std.format,
std.functi... | D |
// Code By H~$~C
import std.stdio;
import std.math, std.uni, std.format, std.bigint;
import std.array, std.string, std.container, std.range, std.typecons;
import std.algorithm, std.conv, std.functional, std.random;
immutable Maxn = 200005;
int n;
int[Maxn] c;
int[][Maxn] g;
long[Maxn] ans;
int[Maxn] sz, num;
void d... | 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 |
void main() {
problem();
}
void problem() {
auto N = scan!int;
auto K = scan!int;
auto A = scan!long(N);
void solve() {
foreach(i, a; A[K..N]) {
writeln(a > A[i] ? "Yes" : "No");
}
}
solve();
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, st... | 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 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();
long bignum... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
int[(10^^5)*2+1] PS;
void main()
{
auto N = readln.chomp.to!int;
foreach (_; 0..N) {
auto p = readln.chomp.to!int;
PS[p] = PS[p-1] + 1;
}
int max = 0;
foreach (p; PS[0..N+1]) if (p > max) max = p;
writeln(N - ma... | 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() {
int k, x;
scan(k, x);
writeln(500*k >= x ?... | 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, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.ascii;
void main() {
int a, b;
scan(a, b);
string s;
scan(s);
bool ok = s[0 .. a].isNumeric && s[a] == '-' && s[a + 1 .. $].isNumeric;
... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.container.dlist;
alias DL = DList!char;
class P {
DL l;
void add (int f, char c) {
if (!f) {
l.insertFront (c);
} else {
l.insertBack (c);
}
}
}
cl... | D |
void main() {
char c = readln.chomp.to!char;
char[] vowels = ['a', 'e', 'i', 'o', 'u'];
writeln(vowels.canFind(c) ? "vowel" : "consonant");
}
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.conta... | D |
/+ dub.sdl:
name "E"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
auto sc = new Scanner(stdin);
string s;
sc.read(s);
int n = s.length.to!int;
int[26][] nx = new int[26][n+1];
nx[n... | D |
import std.stdio, std.string, std.conv;
void main() {
int x = readln.chomp.to!int;
writeln(x ^^ 3);
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
void main()
{
auto hwk = readln.split.to!(int[]);
auto H = hwk[0];
auto W = hwk[1];
auto K = hwk[2];
auto xy = readln.split.to!(int[]);
auto sy = xy[0]-1;
auto sx = xy[1]-1... | 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 |
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.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
sizediff_t minIndex(alias pred = "a < b", Range)(Range range)
if (isForwardRange!Range && !isInfinite!Range &&
is(typeof(bin... | D |
import std.stdio, std.conv, std.algorithm, std.string;
alias L = long;
L M = 998244353;
L[] X, D;
L q(L m, L[] U){
foreach(i, u; U) if(i / m & 1 ^ U[i % m] ^ u) return u;
return 1;
}
L t(L[] U){
L f;
foreach(u; U) f = (f * 2 + u) % M;
return f;
}
void main(){
L n = readln.chomp.to!L, b = n * 2;
foreach(c; readln... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)... | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primiti... | 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 |
void main(){
string s = _scan!string();
switch(s){
case "SUN": writeln(7); break;
case "MON": writeln(6); break;
case "TUE": writeln(5); break;
case "WED": writeln(4); break;
case "THU": writeln(3); break;
case "FRI": writeln(2); break;
case "SAT": writeln(1); break;
default: break;
}
}
import std.s... | 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.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);
string s; readV... | D |
import std.stdio : readln, writeln, writefln;
import std.array : array, split;
import std.conv : to;
import std.range.primitives;
import std.range : enumerate, iota, repeat, retro, assumeSorted;
import std.algorithm.searching : all, any, canFind, count, countUntil;
import std.algorithm.comparison : max, min, clamp;
i... | 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!(x => x.to!int-1).array;
auto B = new int[](N);
forea... | 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.array, std.conv, std.range;
class Dice6 {
int[string] dice6;
int[] _dice6 = new int[6];
this(int[] _dice6) {
dice6["top"] = _dice6[0];
dice6["front"] = _dice6[1];
dice6["right"] = _dice6[2];
dice6["left"] = _dice6[3];
dice6["back"] ... | D |
void main() {
string[] tmp = readln.split;
string a = tmp[0], b = tmp[1], c = tmp[2];
writeln(a[$-1] == b[0] && b[$-1] == c[0] ? "YES" : "NO");
}
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.c... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
import std.math;
void main() {
int n;
scan(n);
writeln(n/3);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primitives;
... | D |
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if... | D |
void main() {
(N => N.iota.map!(i => ri).any!"a & 1" ? "first" : "second")(ri).writeln;
}
// ===================================
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.... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long w, h, n;
scan(w, h, n);
// writeln(w, h, n);
auto tmp = new long[][](w, h);
foreach (i; 0 .. tmp.length)
tmp[i][] = 1;
/... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, k; rd(n, k);
auto x=new long[](n), y=new long[](n);
foreach(i; 0..n) rd(x[i], y[i]);
long mn=5_000_000_000_000_000_000;
foreach(i1; 0..n)foreach(i2; (i1+1)..n){
foreach(j1; 0..n)foreach(j2; (j1+1)..n){
auto x1=x[i1], x2=x... | D |
import std.stdio : readf, readln, writeln;
import std.string;
import std.array;
import std.conv;
void main() {
int[] v;
v = readln.split.to!(int[]);
int H = v[0];
int W = v[1];
string[] s;
for (int i=0; i<H; i++)
s ~= readln.chomp;
int[][] dw;
int[][] dh;
for (int i = 0; i < H; i++) {
int[] c... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int N;
long L;
scan(N, L);
auto s = new string[](N);
iota(N).each!(i => s[i] = readln.chomp);
auto ssum = s.map!(si => si.length.to!int).sum();
auto nex = new int[][](ssum * 2, 2);
fill... | 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;
int sum;
auto tmp = n;
while (tmp != 0) {
aut... | 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.algorithm;
const int BORING = 15;
const int MATCH = 90;
void main()
{
int n;
int last = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
if ((x - 1) - last >= BORING) {
printf("%d\n", last + BORING);
return;
}
last = x;
}
printf(... | D |
import std.algorithm;
import std.array;
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 scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | 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() {
string s;
scan(s);
int ans;
... | 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.algorithm;
import std.algorithm:rev=reverse;
int main(){
auto input=readln.chomp.split;
auto a=input[0].to!int;
auto b=input[1].to!int;
auto at=(a*13).to!int;
auto bt=(b*10).to!int;
foreach(y;bt..at+1){
if((y*0.08).to!int==a&&(y*0.1).to!int==b){
... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
void main() {
string str = readln.chomp;
string[4] ss = ["dream", "erase", "eraser", "dreamer"];
// array.lengthの返り値の型はulongなので
// intに代入しようとすると(dmd64 v2.070.1では)CEになる
int p = str.length.to!int;
while (p > 0) {
... | 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 mx = min(... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.