code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
module main;
import std.stdio : readln, writeln, write, writefln, writef;
import std.conv : to;
import std.array : split, replace;
import std.string : strip;
import std.algorithm : max, min, map, reduce, sort, reverse;
import std.functional : memoize;
version = B;
version (A)
{
void main()
{
auto seq... | 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;
import std.typecons;
import std.datetime.systime : Clock;
class InputReader {
private:
ubyte[] p;
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
import std.typecons;
alias Point=Tuple!(int, "x", int, "y");
auto u=new Point[](n), v=new Point[](n);
foreach(i; 0..n) rd(u[i].x, u[i].y);
foreach(i; 0..n) rd(v[i].x, v[i].y);
auto mf=new maxFlow(n*n+2), s=n*n, t=s+1;
... | 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() {
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], k = tmp[1];
writeln(n % k != 0 ? 1 : 0);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons; | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto s = readln.chomp;
int res;
switch (s) {
case "SUN":
... | 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;
void main()
{
auto n = readln;
auto s = readln.strip;
writeln( solve( s ) );
}
int solve( in string s )
{
auto lc = new int[ s.length ];
lc[ 0 ] = 0;
foreach( i; 1 .. s.length )
{
lc[ i ] = lc[ i - 1 ] + ( s[ i - 1 ] == 'E' ? 0 : 1 );
}
auto rc = new int[ s.length ... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
long solve (int [] a, int n)
{
if (a[1..$ - 1].all !(q{a == 0}))
{
return 0;
}
if (a[1..$ - 1].all !(q{a <= 1}))
{
return -1;
}
if (n == 3 && a[1] % 2 == 1)
{
return -1;
}
long res = 0;
foreach (i; 1..n - 1)
... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;
void main(){
int n = readln().chomp().to!int;
for(int i=0;i<n;i++){
int[] s = split(readln()).to!(int[]);
int res = s... | 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.string,
std.range,
std.stdio,
std.conv;
void main() {
int N = readln.chomp.to!(int);
int[] ns = readln.chomp.split.to!(int[]);
int x = ns[$-1];
ulong[21][101] dp;
dp[0][ns[0]]++;
foreach (i; 1..(N-1)) {
foreach (j; 21.iota) {
int a = j... | 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;
long calc(long n, long k) {
long d = k / (n-1);
return k + d + (k % (n-1) == 0 ? -1 : 0);
}
void main() {
int t; s... | D |
import std.stdio, std.array, std.conv, std.string;
void main() {
while (true) {
string[] input = split(readln());
int h = to!int(input[0]);
int w = to!int(input[1]);
if (h == 0 && w == 0) return;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
write("#");
}
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
auto nxt = readln.split.to!(int[]);
auto N = nxt[0];
auto X = nxt[1];
auto T = nxt[2];
writeln((N + X - 1) / X * T);
} | D |
import std.stdio, std.conv, std.string;
void main() {
int N = to!(int)(readln().chomp());
writeln(N/3);
}
| D |
import std.stdio;
import std.algorithm;
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]);
ulong[] A;
foreach (i; 0..N)
{
auto tokens2 ... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
static import std.ascii;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return r... | D |
import 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 : 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;
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;
auto a = readln.chomp.split.to!(int... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp, a = s.map!(c => cast(int)(c-'0')).sum, n = s.to!int;
writeln(n%a == 0 ? "Yes" : "No");
}
| 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 |
void main()
{
string s = readln.chomp;
auto g = s.group.array;
writeln(g.length - 1);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import ... | 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 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.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) {
auto line = readln.split;
foreach (ref arg; args) {
arg = line.front.to!(typeof(arg));
line.popFro... | 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 mod = 10L^^9 + 7;
void main() {
int n;
scan(n);
auto a = readln.split.to!(long[]);
auto r = new long[](n + 1);
foreach (i ; 1 .. n + 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;
import std.container;
alias sread = () => readln.chomp();
ulong bignu... | 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 x = lread();
long ans;
foreach (p; 2 .. 11)
{
... | 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 b = readln.split[0];
if (b == "A") "T".writeln;
if (b == "T") "A".writeln;
if (b == "G") "C".writeln;
if (b == "C") "G".writeln;
}
| 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 n, k;
scan(n, k);
auto a = aryread();
// writeln(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.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() {
long N;
scan(N);
auto ans = N * (N - 1) / 2;
writeln(... | D |
import std.stdio, std.string, std.conv, std.math;
void main(){
real x = 0, y = 0, rad = 90;
while(true){
auto line = readln.chomp.split(",");
auto speed = line[0].to!int;
if(speed == 0) break;
x += cos(rad / 180 * PI) * speed;
y += sin(rad / 180 * PI) * speed;
ra... | 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.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
int n... | D |
import std.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()
{
long n = rdElem;
long[] a = rdRow;
long[] l = new long[n+1];
foreach (i; 0 .. n)
{
l[i+1] = gcd(l[i], a[i]);
}
long[] r = new long[n+1];
foreach_reverse (i; 0 .. n)
{
r[i] = gcd(r[i+1], a[i]);
}
long result;
foreach (i; 0 .. n)
{
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.math;
void main ()
{
double a = 100000;
int n = to!int(chomp(readln()));
foreach (i; 0 .. n)
{
a = a * 1.05;
if(a % 1000)
a = a - (a % 1000) + 1000;
}
writeln(to!int(a));
} | 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;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;
void main()
{
readln;
auto x = readln.chomp.split.map!(to!long).array;
writeln(x.reduce!(min), " ", x.reduce!(max), " ", x.reduce!("a+b"));
} | D |
void main() {
dchar[] s = readln.chomp.to!(dchar[]);
s.sort!"a < b";
writeln(s == "abc" ? "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.container;
import std.typecons;
import s... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
void main()
{
int n;
n = readln.chomp.to!int;
while (n) {
auto a = new int[9][9];
auto b = new int[9][9];
auto c... | 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; readV(k);
writeln((k/2) *... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
int[4] bty;
while(true){
auto s = readln();
if(stdin.eof()) break;
auto s1 = split(chomp(s),',');
if(s1[1]=="AB") s1[1] = "C";
if(s1[1]=="O") s1[1] = "D";
bty[to!int (to!char(s1[1]) - 'A')]++;
}... | 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 |
void main() {
auto S = rs.to!(dchar[]);
auto N = S.length;
bool isParin(dchar[] s) {
debug writefln(s);
return s == s.retro.array;
}
bool f1 = isParin(S);
bool f2 = isParin(S[0..(N-1)/2]);
bool f3 = isParin(S[(N+3)/2 - 1..$]);
if(f1 && f2 && f3) writeln("Yes");
else writeln("No");
}
// ===================... | 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.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;
void main(){
auto a=readln.chomp.to!int;
auto b=readln.chomp.to!int;
auto h=readln.chomp.to!int;
writeln((a+b)*h/2);
}
| D |
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;
immutable long mod = 10^^9 + 7;
immutable long inf = mod;
void main(){
long n, m;
readVars(n, m);
auto ans = modpow(n, m, mod... | 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 |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
long gcd(long a, long b) {
if (b == 0)
return a;
return g... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int N, K;
scan(N, K);
auto 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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, m; rd(n, m);
auto a=readln.split.to!(int[]);
auto b=new int[](n);
foreach(e; a) b[e-1]=1;
int c=0;
bool f(){
return reduce!((r, e)=>(r && e==1))(true, b[0..m]);
}
foreach_reverse(i; 0..n){
if(f()) break;
if(b[i]){... | 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 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.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;
void main() {
auto a = readln.split[0].to!int;
auto b = readln.split[0].to!int;
auto c = readln.split[0].to!int;
auto d = readln.split[0].to!int;
auto e = readln.split[0].to!int... | D |
void main() {
auto S = rs.to!(dchar[]);
S[3] = '8';
S.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
impo... | D |
import std.stdio; // readln
import std.array; // split
import std.conv; // to
void main(){
string[] s = split(readln());
int a = to!int(s[0]);
int b = to!int(s[1]);
int c = to!int(s[2]);
if(a == b) writeln(c);
else if(a == c) writeln(b);
else writeln(a);
}
| 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;
}
void main() {
auto nq = readints();
int 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(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | 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;
bool solve() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
auto d = A.reduce!max - ... | D |
import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm, std.typecons;
void main(){
auto buf = readln().strip().split().map!(to!int)();
immutable N = buf[0];
immutable K = buf[1];
if((N-1)/2 + 1 >= K) {
writeln("YES");
} else {
writeln("NO");
}
}
| D |
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math;
void main()
{
for (;;) {
auto H = readln.chomp.to!int;
if (H == 0) return;
int[][] MAP;
MAP.length = H;
foreach (i; 0..H) MAP[i] = readln.split.to!(int[]);
auto c... | D |
/+ dub.sdl:
name "B"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv, std.string;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
string s;
sc.read(s);
auto li = s.group.a... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;
T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.cho... | D |
import std.algorithm;
import std.conv;
import std.math;
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 a = readln.splitter.map !(to !(int)).array;
long res = 0;
foreach (i; 0..n)
{
... | 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 A = readln.split.map!(to!long).array;
... | 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;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof) {
return fals... | 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 |
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]);
if(a + b == c || b + c == a || c + a == b) "Yes".writeln;
else "No".writeln;
}
| 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.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
auto n = read.... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
void main()
{
readln;
auto a = readln.chomp.split.map!(to!int);
writeln = a.reduce!max - a.reduce!min;
}
| D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto a = lread();
auto s = sread();
if (a >= 3200)
writeln(s);
else if (a < 3200)
writeln("red");
}
//https://rclone.org/
v... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto K = readln.chomp.to!int;
long[] rnrn;
void make(int i, long n, long l) {
rnrn ~= n;
if (i == 10) return;
foreach (m; max(0, l-1)..min(10, l+2)) {
mak... | 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() {
auto s = new bool[](10^^5 + 1);
s[] = 1;
s[0] = s[1] = 0;
for (int p = 2; p*p <= 10^^5; p++) {
if (s[p]) {
for (int 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.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;
}
lon... | D |
import std;
void main()
{
const N = readln().chomp().to!uint();
const S = readln().chomp();
size_t ans = count(S, 'R') * count(S, 'G') * count(S, 'B');
foreach (uint i; 0 .. N)
foreach (uint j; i + 1 .. N)
{
if (S[i] == S[j]) continue;
const k = 2 * j - i;
if (k >= N) ... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
int[101] team;
int count = 0;
while(true){
auto s = split(chomp(readln()),',');
int n1 = to!int(s[0])-1;
int n2 = to!int(s[1]);
if(n1==-1&&n2==0) break;
team[n1] = n2;
count++;
}
int[101... | 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;
alias Pair = Tuple!(int, "x", int, "y");
void main() {
while (1) {
int n;
scan(n);
if (!n) return;
auto a = new Pair[](n);
... | 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 |
/+ dub.sdl:
name "B"
dependency "dcomp" version=">=0.3.2"
lflags "-stack_size" "100000000"
+/
import std.algorithm, std.conv, std.range, std.stdio;
// import dcomp.scanner;
// import dcomp.algorithm;
int main(string[] argv) {
auto sc = new Scanner();
int n, k;
sc.read(n, k);
int[26] co;
... | 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, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;
void main()
{
auto rd = readln.split.map!(to!int);
auto a = rd[0], b = rd[1];
writeln(a == b ? "a == b" : (a < b ? "a < ... | D |
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
int n = readln.chomp.to!int;
bool[int] set;
foreach (i; 0..n) {
int... | D |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
int n, k;
scanf("%d%d", &n, &k);
int[] x = new int[n];
foreach (i; 0..n) scanf("%d", &x[i]);
int c = x.assumeSorted.lowerBound(0).leng... | D |
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
import std.typecons;
void main() {
auto N = readln.chomp.to!int;
char[] S = cast(char[])readln.chomp;
foreach(i; 0..S.length) {
S[i] = 'A' + (S[i] - 'A... | 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;
int a, b, ab, r;
foreach (_; 0..N) {
auto s = readln.chomp;
if (s[0] == 'B' && s[$-1] == 'A') {
++ab;
} else if (s[0] == 'B'... | 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.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() {
readi... | 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();
auto a = aryread();
long ans;
foreach (i; 0 .. n)
{
ans += a[i] - 1;
}
writeln(ans);
}
void scan(L..... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.