code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
void main()
{
long k, a, b;
rdVals(k, a, b);
long rate = 1;
if (k <= a)
{
rate.writeln;
return;
}
if (b >= a)
{
writeln(-1);
return;
}
rate += (k - b - 1) / (a - b) * 2;
rate.writeln;
}
enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60... | 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 L, R;
scan(L, R);
auto D = R - L + 1... | 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 a... | D |
import std.algorithm;
import std.array;
import std.bitmanip;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
auto n = readln.chomp;
int[10] cnt;
foreach (i, ref e; cnt) {
... | 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.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 A = readln.split.map!(to!long).array;
auto G = new int[][](N);
... | D |
// unihernandez22
// https://atcoder.jp/contests/abc150/tasks/abc150_b
// implementation
import std.stdio: readln, writeln;
import std.string: chomp;
import std.algorithm: count;
void main() {
readln;
string s = readln.chomp;
s.count("ABC").writeln;
}
| 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 S = readln.chomp;
auto N = S.length.to!int;
auto C = new long[](26);
foreach (i; 0..N) C[S[i] - 'a'] += 1... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
int[int] NS;
void main()
{
auto N = readln.chomp.to!int;
foreach (_; 0..N) {
auto A = readln.chomp.to!int;
if (A in NS)
++NS[A];
else
NS[A] = 1;
}
int ret;
fore... | D |
import std.stdio, std.math, std.conv, std.string;
bool is_prime(int n)
{
auto t = sqrt(n.to!double);
for (int i = 2; i <= t; ++i) {
if (n % i == 0) return false;
}
return true;
}
void main()
{
auto N = readln.chomp.to!int;
int cnt;
foreach (_; 0..N) {
if (is_prime(readln.... | 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() {
string s;
scan(s);
int n = s.length.to!int;
auto a = new int[](n + 1);
foreach (i ; 0 .. n) {
a[i + 1] = a[i] ^ (1 << (s[i] - 'a'));
}
... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.numeric;
void main() {
const tmp = readln.split.to!(long[]);
const N = tmp[0], M = tmp[1], C = tmp[2];
const bs = readln.split.to!(long[]);
N.iota.map!(_ => readln.split.to!(long[]).dotProduct(bs) +... | D |
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range;
void main() {
auto N = readln.chomp.to!int;
auto K = readln.chomp.to!int;
auto xs = readln.split.to!(int[]);
xs.map!(x => 2 * min(x, K-x)).sum.writeln;
}
| D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n;
scan(n);
auto a = readln.split.to!(int[]);
foreach (i ; 0 .. n) {
foreach (j ; i + 1 .. n) {
if ((a[i] - a[j]) % (n - 1) == 0) {
writeln(a[i], " ", a[j]);
... | D |
import std.stdio;
import std.regex;
void main(){
auto io = new IO();
auto S = io.line!string()[0];
if ( S.have("N") ^ S.have("S") || S.have("W") ^ S.have("E") ){
writeln("No");
}else{
writeln("Yes");
}
return;
}
import std.stdio,std.conv,std.string;
import std.algorithm,std.array,std.math;
class IO
{
... | 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;
void main() {
string str = readln.chomp;
int[char] count;
for(int i=0; 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, core.stdc.stdlib;
immutable long MOD = 10^^9 + 7;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!long).a... | 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.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;
void main() {
auto s = readln.split.map!(to!long);
auto N = s[0].to!int;
auto A = s[1];
auto... | D |
void main(){
string[] val = inln!string();
bool a = val[0]=="H";
bool b = val[1]=="H";
writeln( a^b?'D':'H');
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
// 1要素のみの入力
T inelm(T= int)(){
return to!(T)( readln().chomp() );
}
/... | 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;
long calc(long n, long ... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.uni;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
string s1, s2, s3;... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
void main()
{
auto tokens = split(chomp(readln()));
int a = to!int(tokens[0]);
int b = to!int(tokens[1]);
if ((a * b) % 2 == 0)
writeln("No");
else
writeln("Yes");
stdout.flush();
} | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.typecons, std.math;
int h, w, d; rd(h, w, d);
auto c=new int[][](h, w);
foreach(i; 0..h) c[i]=readln.split.to!(int[]);
foreach(i; 0..h)foreach(j; 0..w) c[i][j]--;
alias P=Tuple!(int, "i", int, "j");
auto map=new P[](h*w);
... | D |
import std;
int calc(string s) {
int[int] d = [0: 1];
int x = 0;
int p = 1;
foreach_reverse (c; s) {
x = (x + (c - '0') * p) % 2019;
p = 10 * p % 2019;
d[x]++;
}
return d.values.map!(e => e * (e - 1) / 2).sum;
}
void main() {
string s = read!string;
writeln(calc... | 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;
import std.typecons;
auto readInts() {
return array(map!(to!int)(readln().strip().split()));
}
auto readInt() ... | D |
import std.stdio, std.conv, std.range, std.string, std.array;
void main(){
auto ip = readln.chomp;
writeln(ip.count('1'));
} | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], m = tmp[1];
long[] a = new long[n+2];
foreach (i; 0 .. m) {
tmp = readln.split.to!(int[]);
int l = tmp[0] - 1, r = tmp[1];
++a[l];
--a[r];
}
foreach (i; 0 .. n+1) {
a[i+1] += a[i];
}
... | D |
import std.stdio;
import std.string;
import std.conv;
int main()
{
int N = readln().chomp().to!int();
string[] num = readln().split();
for (int i = N - 1; i > 0; i--)
write(num[i], " ");
writeln(num[0]);
return 0;
} | 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 nm=readln.split.map!(to!int).array;
auto n=nm[0];
auto m=nm[1];
int[][] abs;
foreach(i;0..m)abs~=readln.spli... | D |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv, std.numeric;
// import dcomp.foundation, dcomp.scanner, dcomp.algorithm;
bool solve() {
auto sc = new Scanner(stdin);
int n; long k; long[] a;
sc.read(n, k, a);
long u = 0;
fo... | 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() {
int x = readln.chomp.to!int;
writeln(x < 1200 ? "ABC" : "ARC");
}
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 std.uni; | D |
import std.stdio;
import std.string;
import std.conv;
import std.ascii;
import std.algorithm;
void main()
{
foreach (_; 0..readln.chomp.to!int) {
auto script = readln;
auto keys = script.split.filter!(str => str.length == 4);
loop:
foreach (a; [0, 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 2... | D |
import std.stdio, std.string, std.array, std.conv;
void main() {
int n = readln.chomp.to!int;
int[][] a = new int[][](n, n);
foreach (i; 0 .. n) {
int[] tmp = readln.chomp.split.to!(int[]);
foreach (j; 0 .. tmp[1]) {
a[tmp[0]-1][tmp[j+2]-1] = 1;
}
}
foreach (i; 0... | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto N = S.length;
int r1, r2;
foreach (i; 0..N) {
auto c = i%2 == 0 ? '0' : '1';
if (S[i] == c) ++r1;
if (S[i] != c) ++r2;
}
writ... | 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 p, q, r;
scan(p, q, r);
auto ans = min... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;
void main() {
int n; scan(n);
auto a = readln.split.to!(long[]);
long[long] cnt;
cnt[0] = 1;
long s;
long ans;
foreach (i ; 0 .. n) {
s += a[i];
... | D |
/+ dub.sdl:
name "A"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.algorithm;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
int n;
sc.read(n);
writeln((n - 2) * ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
alias P = Tuple!(int, "to", int, "d");
void main()
{
auto ve = readln.split.to!(int[]);
auto V = ve[0];
auto E = ve[1];
P[][] ps;
ps.length = V;
foreach (_; 0..E) {
auto std = readln... | D |
void main() {
problem();
}
void problem() {
auto N = scan!int;
auto A = scan!int(N);
long solve() {
long ans;
foreach(i, a; A) {
if (i % 2 == 0 && a % 2 == 1) ans++;
}
return ans;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, st... | 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.range;
import std.array;
import std.algorithm;
void main() {
string input;
while ((input = readln.chomp).length != 0) {
auto line = input.map!(a => a.to!int - '0').array;
while (line.length > 1) {
for (int i = 0; i <... | 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() {
strin... | 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.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.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.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 N = readln.chomp.to!int;
auto A = readln.chomp.map!(a => a == '1')... | 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 AS = readln.split.to!(int[]);
int c;
foreach (a; AS) {
while (a && a%2 == 0) {
++c;
a /= 2;
}
}
writeln... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
class Node{
Node[] adjnodes;
Node[] kids;
Nod... | 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 x = readln.chomp.to!int;
immutable m = 200_000 + 1;
auto... | D |
import std.stdio, std.conv, std.string, std.algorithm, std.array, std.range;
void main() {
int t = readln.chomp.to!(int);
long ans = long.min;
long[][] arr;
long[][] dp = new long[][](t, t);
for(long i = 0; i < t; i++)
arr ~= (readln.chomp.split(" ").map!(to!(long)).array);
for(int i = 0; i < t; i++) ... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
string _1, s, _2; readV(_1, s, _2)... | 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 |
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;
int calc(int rows, int ... | 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() {
string S;
scan(S);
auto N = S.length;
... | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.string;
import std.conv;
void main(){
int[] inputs = readln.chomp.split.map!(to!int).array;
auto n = inputs[0];
auto a = inputs[1];
auto b = inputs[2];
auto answer = min(n * a, b);
writeln(answer);
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
string s;
scan(s);
int n = s.length.to!int;
int btm = 1, top = n + 1;
bool check(int k) {
if (2*k <= n) {
return true;
}
bool b = 1;
char ch = s[n-k];
... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional;
void main()
{
auto ip = readln.chomp.split(" ").map!(pipe!((c => c.to!int), (i => i == 1 ? 14 : i))).array;
auto a = ip[0];
auto b = ip[1];
writeln(
a > b ? "Alice"
: a < b ? "Bob"
: "Dr... | 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.conv, std.string, std.array, std.algorithm;
void main()
{
auto ab = readln.chomp.split(" ").map!(to!int);
auto a = ab[0];
auto b = ab[1];
auto ret = a + b;
while (ret > 23) ret -= 24;
writeln(ret);
} | 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;
// import dcomp.functional;
Scanner sc;
static this() {
sc = new Scanner(stdin);
}
long N;
int main() {
long l = 10L^^10 - 1, r = 10L^^11;
... | D |
void main()
{
long[] tmp = rdRow;
long h = tmp[0], w = tmp[1], a = tmp[2], b = tmp[3];
foreach (i; 0 .. h)
{
foreach (j; 0 .. w)
{
((i < b) ^ (j < a)).to!long.write;
}
writeln;
}
}
T rdElem(T = long)()
{
//import std.stdio : readln;
//import std.... | D |
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
int a, b;
void main() {
scan(a, b);
a = min(a, b);
long ans = 1L;
foreach (i ; 1 .. a + 1) {
ans *... | 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;
void main() {
string[] input = readln.split;
int N = input[0].to!int;
int... | 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.format;
void main()
{
auto abbcca = readln.split.to!(in... | 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.stdio, std.string, std.conv, std.array, std.algorithm;
void main()
{
auto a = readln.split.map!(to!int);
if(a[0]+a[1]==2||a[2]==1) writeln("Open");
else writeln("Close");
} | D |
void main(){
long a;
long[2] bb;
scanf("%ld %ld.%ld", &a, &bb[0], &bb[1]);
long b = bb[0]*100.to!long + bb[1];
( a*b/100 ).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行に同一型の複数... | 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;
int N;
int[] ary;
void main() {
while(true) {
N = readl... | D |
import std;
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line =... | D |
import std.stdio, std.string, std.conv, std.array;
string mathed(char[] s, char[] t)
{
for (int i = cast(int)(s.length-t.length); i >= 0; i--) {
if (s[i] == t[0] || s[i] == '?') {
int ii = i;
bool flag = true;
for (int j = 0; j < t.length;) {
if (!(s[i] == t[j] || s[i] == '?')) {
flag = fal... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int r, g;
scan(r);
scan(g);
auto ans = r + (g - r) * 2;
writeln(ans);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
... | 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 abc = aryread();
// writeln(abc);
long cnt5;
long c... | D |
void main(){
string s = readln().chomp();
string t = readln().chomp();
int ans;
foreach(i; 0..s.length){
if(s[i] != t[i])ans++;
}
ans.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行に同一型の複数入力
... | 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 s = readln.chomp;
int res;... | 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 |
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;
int a = readln.chomp.to!int;
writeln = n * n - a;
}
| 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, m; readV(n, m);
auto r =... | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }
void main() {
dchar[] s = readln.chomp.to!(dchar[]);
dchar[] t = readln.chomp.to!(dchar[]);
bool can() {
foreach (_; 0... | D |
import std.stdio;
import std.ascii;
import std.algorithm;
static import core.stdc.stdio;
long[300_000+2] a;
long[300_000+2] c;
int main()
{
int[][] parent = new int[][](300_000+2, 20);
int q = readInt!int;
a[0] = readInt!long;
c[0] = readInt!long;
parent[0][] = -1;
int getNthParent(int v, int ... | D |
/+ dub.sdl:
name "B"
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);
int n, m;
sc.read(n, m);
int[][] g = new int[][n];
int sa, sb;
foreach (i; 0..m) {
... | 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;
void main()
{
foreach(i; 1 .. 10)
{
foreach(j; 1 .. 10)
{
writeln(i, 'x', j, '=', i * j);
}
}
} | D |
import std.stdio;
void main(){for(int i;i<81;i++){
writeln(i/9+1,"x",i%9+1,"=",(i/9+1)*(i%9+1));
}} | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
while(true){
auto s = readln();
if(stdin.eof()) break;
s = chomp(s);
char win = 'd';
for(int i=0;i<3;i++){
if(s[3*i] != 's' && s[3*i] == s[3*i+1] && s[3*i] == s[3*i+2]) win = s[3*i];
}
for(int i=0;... | 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;
}
int calc(int k, int[] ws) {
bool match(int limit... | 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 R = scanElem;
auto G = scanElem;
auto B = scanElem;
auto N = scanElem;
int... | 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;
long k;
scan(n, k);
auto a = re... | 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 p = readln.chomp.split.to!(i... | 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 |
/+ dub.sdl:
name "B"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.algorithm;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
string s;
sc.read(s);
int n = s.lengt... | 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 ans = 0;
foreach (i; 0..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() {
import std.stdio, std.string, std.conv, std.algorithm;
long n, m;
rd(n, m);
auto mn = max(0, n - m * 2);
long mx = 0;
for (auto k = 0L; k <= n; k++) {
if (k * (k - 1) / 2 >= m) {
mx = max(mx, n - k);
}
}
writeln(mn, " ", mx);
}
void rd(T...)(ref T x) {
import std.stdio :... | D |
// This file is a "Hello, world!" in D language by DMD for wandbox.
import std.stdio;
import std.bigint;
import std.conv;
import std.string;
import std.algorithm;
ulong dfs(int[] arr)
{
bool flag = true;
int prev = -1;
foreach (v; arr)
{
flag &= prev <= v;
prev = v;
}
if (flag)
{
return arr.length;
}
el... | 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 |
module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;
struct IO {
string[] tk;
string readString() {
while (tk.empty)
... | D |
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T[]readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
struct Queue(T){T[]e;auto enq(T t){e~=t;}auto enq(T[]ts){e~=ts;}T deq(){T tp=e[0];e=e.length>1?... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.