code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.string;
import std.conv;
void main(){
string[] input = split(readln());
int x = to!int(input[0]);
int y = to!int(input[1]);
writeln(x * y, ' ', 2 * (x + y));
} | 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);
int t, a;
scan(t, a);
t *= 1000;
a *= 1000;
auto h = readln.split.to!(int[]);
int ans = -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 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;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TL... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
immutable mod = 10^^9 + 7;
void main() {
int n, m;
scan(n, m);
auto adj = new bool[][](n, n);
foreach (i ; 0 .. m) {
int ai, bi;
scan(ai, bi);
... | 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, x;
scan(n, x);
auto l = aryread();
long sum_x;
... | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
auto a = readln.chomp.to!int;
auto b = a % 10;
auto c = a / 10 % 10;
auto d = a / 100 % 10;
auto e = a /1000 % 10;
writeln(b==c&&c==d||c==d&&d==e ? "Yes":"No");
} | 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 |
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
void main()
{
auto hwk = readln.split.to!(int[]);
auto H = hwk[0];
auto W = hwk[1];
auto K = hwk[2];
long[] A, B;
A.length = W;
B.length = W;
A[0] = 1;
foreach... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
void main()
{
foreach (s; stdin.byLine) {
if (s == "-") break;
int m = readln.chomp.to!int;
foreach (i; 0..m) {
int h = readln.chomp.to!int;
s = s[h..$] ~ s[0..h];
}
s.writeln();... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto n = readln.chomp.to!int;
auto a = readln.chomp.split.to!(int[]);
int[9] res... | D |
import std.stdio, std.conv, std.string;
void main() {
uint n = readln.strip.to!int;
writeln(n & 1 ? n / 2 + 1 : n / 2);
} | D |
//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
... | D |
import std.string;
import std.stdio;
import std.conv;
import std.algorithm;
import std.typecons;
void main() {
int n, q;
int[][int] map;
scanf("%d %d\n", &n, &q);
int[] cnts, checks;
cnts = new int[n+1];
checks = new int[n+1];
foreach(i;0..n-1) {
int a, b;
scanf("%d %d\n", &a, &b);
map[a] ~= b;
}
foreac... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;
void main()
{
long[] a = readln.chomp.split(" ").to!(long[]);
long m = long.max;
foreach (job; [[0, 1, 2], [1, 2, 0], [2, 1, 0], [1, 0, 2], [2, 0, 1]])
{
long cost;... | D |
void main()
{
dchar[] s = rdDchar;
dchar[] t = rdDchar;
long pos = t.length - 1;
bool ok;
foreach_reverse (long i, x; s)
{
if (x == t[pos] || x == '?')
{
bool check;
if (i - pos >= 0)
{
check = true;
foreach (j;... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
void main() {
foreach (i; 0..7) {
auto a = readln.split.map!(to!int);
writeln(a[0] - a[1]);
}
} | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n;
rd(n);
struct E {
int to;
long cost;
}
auto g = new E[][](n);
foreach (_; 0 .. n - 1) {
int a, b;
long c;
rd(a, b, c);
g[a - 1] ~= E(b - 1, c);
g[b - 1] ~= E(a - 1, c);
}
int q, k;
rd(q, k);
a... | D |
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
void main()
{
int[] t = map!(to!int)(split(readln())).array;
int[] checker = [0,0];
for(int i=0;i < 3;i ++)
{
if(t[i] == 5)
{
checker[0] ++;
}
else
{
checker[1] ++;
}
}
if(checker[0] == 2 && checker[... | 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.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, core.stdc.stdlib;
void main() {
auto N = readln.chomp.to!int;
auto S = readln.chomp.map!(c => c.to!int).array;
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
void main() {
auto input = map!(to!int)(readln.split);
int N = input[0], T = input[1], H = input[2], L = input[3];
Tuple!(int, int)[] data;
foreach (i; 0..N) {
input = map!(to!int)(readln.split);
auto t = input[0],... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
void main(){
auto a=readln.chomp.to!int;
auto b=readln.chomp.to!int;
auto c=readln.chomp.to!int;
writeln((a-b)%c);
} | D |
void main()
{
long a, b;
rdVals(a, b);
max(0, a-2*b).writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T == struct))
{
return readln.chomp.to!T;
}
alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);
T rdElem(T)()
if (is(T == struct))
{
T res... | 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 main() {
int n;
scan(n);
auto a = readln.split.to!(long[]);
auto ans = min(solve(n, a, 1), solve(n, a, -1));
writeln(ans);
}
i... | 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 std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const tmp = readln.split.to!(long[]);
const A = tmp[0], B = tmp[1];
// f(A,B) = AからBまでのすべての整数のxor
// 各bitでもとめる
// 1bit目はAからBまでのうち1のbitが奇数個なら1、偶数個なら0を返す
// これは交互に来るから、結局(B-A+1)が奇数個... | D |
import std.stdio;
void main(){
for(int i = 1; i < 10; ++i){
for(int j = 1; j < 10; ++j){
writeln(i,"x",j,"=",i*j);
}
}
} | D |
import std.stdio;
void main(){
foreach(i; 1..10)
foreach(j; 1..10)
writeln(i,"x",j,"=",i*j);
} | 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 |
// 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 n;
int[] a;
void main() {
scan(n);
a = readln.split.to!(int[]);
int b1, b2, b3;
foreach (ai ; a) {
... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
T readNum(T)(){
return readStr.to!T;
}
T[] readNums(T)(){
return readStr.split.to!(T[]);
}
string readStr(){
return readln.chomp;
}
void main(){
auto n = readNum!int;
auto b = readNums!int;
int ret;
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, 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, core.stdc.string;
void main() {
auto s = readln.split.map!(to!long);
auto N = s[0].to!int;
auto K = s[1];
auto A = readln.sp... | 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 ps = readln.split.to!(int[]);
int r, min_p = ps[0];
foreach (p; ps) {
min_p = min(min_p, p);
if (p == min_p) ++r;
}
writeln(r);... | 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;
import std.typecons;
immutable int infinity = int.max / 2;
immutable int NA = -1;
void main ()
{
string s;
while ((s = readln.strip) != "")
{
auto t = readln.strip;
auto k = s.length.to !(int);
auto n = t.length.to ... | 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;
immutable long MOD = 10^^6 + 3;
long powmod(long a, long x, long m) {
long ret = 1;
while (x) {
if (x % 2) ret = ret * a % ... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.array;
int n; rd(n);
auto a=readln.split.to!(int[]);
if(a.length%2==0){writeln("No"); return;}
if(a.front%2==1 && a.back%2==1){
writeln("Yes");
}else{
writeln("No");
}
}
void rd(T...)(ref T x){
import std.stdio,... | 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 = 998244353;
void main() {
auto N = readln.chomp.to!int;
auto S = readln.chomp;
if (N == 1) {... | D |
import std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
import std.numeric;
void main() {
int n = readln.chomp.to!int;
long sum = 0;
for(int i=1; i<=n; i++) {
if(!(i%3==0 || i%5==0)) sum += i;
}
writeln(sum);
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.algorithm;
import std.math;
import std.regex;
void main() {
auto n = readln.chomp.filter!"a != ' '".array;
(sqrt(n.to!float) % 1 == 0 ? "Yes" : "No").writeln;
}
| D |
void main(){
long n = _scan!long();
long[] a = _scanln!long();
long q = _scan!long();
long[long] dic;
long ans;
// 合計値と参照辞書の作成
foreach(elm; a){
ans += elm;
dic[elm]++;
}
// replace 操作
foreach(i; 0..q){
long[] bc = _scanln!long();
ans += bc[1]*dic.get(bc[0], 0) - bc[0]*dic.get(bc[0], 0);
dic[bc[1]] ... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
void main()
{
auto S = readln.chomp;
auto DP = new long[][](S.length, 4);
foreach (ref dp; DP) dp[] = -1;
long solve(int i, int s) {
if (i == S.length) return s == 3 ? 1 : ... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.math;
void main(string[] args)
{
auto n = to!int(strip(readln));
int[1001] a;
auto x = split(strip(readln));
foreach (j; 0 .. n)
{
a[to!int(x[j])]++;
}
int count;
int ze = s(a);
while(ze >= 1)
{
count += ze - 1;
... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
char x, y;
scan(x, y);
if (x < y) {
writeln("<");
}
else if (x > y) {
writeln(">");
}
else {
writeln("=");
}
}
void scan(T...)(ref T args) {
import std.stdi... | D |
/+ dub.sdl:
name "E"
dependency "dcomp" version=">=0.7.4"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n, k;
sc.read(k, n);
int[] ans = new int[n];
if (k % 2 == 0) {
ans[0] = k/... | 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, m;
scan(n, m);
auto c = ... | 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;
long INF = 1L << 59;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
auto G =... | 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 |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n, m, x, y;
rd(n, m, x, y);
auto a = readln.split.to!(int[]);
auto b = readln.split.to!(int[]);
for (int z = x + 1; z <= y; z++) {
auto ok = reduce!((r, e) => (r && e < z))(true, a) && reduce!((r, e) => (r && e >= z))(true, b);
... | D |
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
import std.math;
import std.algorithm;
void main()
{
string n = chomp(readln());
int N = to!int(n); // 第0要素を整数に変換
string[] input = split(readln());
int a = to!int(input[0]);
int min = a,max = a;
for(int i =1;i... | D |
import std.stdio;
import std.string;
import std.algorithm;
import std.range;
import std.array;
import std.conv;
void main()
{
while(1){
auto N = readln().chomp().to!uint;
if(N == 0)
break;
auto seq = readln().chomp().split();
uint state;
uint cnt;
uint... | 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.regex, std.conv, std.stdio, std.typecons;
void main()
{
for (;;) {
auto rd = readln.split.map!(to!int);
auto m = rd[0], f = rd[1], r = rd[2];
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;
int calc(int n, int m) {
int f(int k) {
return k * (k - 1) / 2;
}
int ans = 0;
if (n >= 2) ans += f(n)... | 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() {
string s;
scan(s);
auto n = s.length.to!in... | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
int qty = readInt();
int[] value = readInts();
int[] cost = readInts();
int profit;
foreach(i; 0 .. qty){
if(value[i] > cost[i]){
profit += value[i] - cost[i];
}
}
writeln(profit);
}
int readInt(){
return readln.ch... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm;
void main() {
int d = readln.chomp.to!int;
("Christmas " ~ repeat("Eve", 25 - d).join(" ")).writeln;
} | 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!(long[]);
auto cs = new long[](N);
foreach (i; 0..N) {
if (i != 0) cs[i] = cs[i-1];
cs[i] += as[i];
}
aut... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
alias Path = Tuple!(int, "to", int, "w");
alias SS = Tuple!(int, "cur", int, "c");
Path[][10^^5] PS;
int[10^^5] TS;
void main()
{
auto N = readln.chomp.to!int;
foreach (_; 0..N-1) {
auto uvw = readl... | 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 ds = readln.split.to!(long[]);
long s;
foreach (i; 0..N) {
foreach (j; i+1..N) {
s += ds[i] * ds[j];
}
}
writeln(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, core.stdc.string, core.stdc.stdlib;
void main() {
immutable long INF = 1L << 59;
auto s = readln.split.map!(to!int);
auto N = s[... | D |
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
string[] ss = readln.split;
foreach (i, ref arg ; args) ar... | 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, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop, std.typetuple, std.typecons;
immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;
alias triplet = Tuple!(int, int, int);
void main(){
int A, B, C;
readVa... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], m = tmp[1];
string[] a = new string[n], b = new string[m];
foreach (i; 0 .. n) {
a[i] = readln.chomp;
}
foreach (i; 0 .. m) {
b[i] = readln.chomp;
}
bool ok;
foreach (i; 0 .. n-m+1) {
foreach (... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto q=readln.split.to!(int[]);
const int m=1_000_000+5;
auto isPrime=new bool[](m);
fill(isPrime, true);
isPrime[1]=false;
for(int i=2; i*i<=m; i++)if(isPrime[i]){
for(int j=2; i*j<m; j++) isPrime[i*j]=false;
}
... | D |
import std;
void calc(int[] a, int[][] adj) {
auto dp = new int[a.length].assumeSorted;
foreach (i; 0..a.length) dp[i] = int.max;
auto ans = new ulong[a.length];
void dfs(int node, int prev) {
auto x = dp.lowerBound(a[node]);
auto old = dp[x.length];
dp[x.length] = a[node];
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(char[]);
auto K = readln.chomp.to!long;
if (S.length == 1) {
writeln(K/2);
return;
}
long[] ns;
long cnt;
char last;
foreach (... | 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;
enum inf = 10^^9;
void main() {
int n, m;
scan(n, m);
auto c = new int[][](n, n);
foreach (i ; 0 .. n) {
foreach (j... | D |
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
bool test (string s) {
if (s.length % 2) return false;
foreach (i; 0 .. s.length) {
if (i % 2) {
if (s[i] != 'i') return false;
} else {
if (s[i] != 'h') return fa... | 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;
void main(){
int h, w;
{
int[] tmp = readln.chomp.split.map!(to!int).array;
h = tmp[0], w = tmp[1];
}
char[][] css;
for(int i = 0; i < h; i ++){
css ~= readln.ch... | 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 |
/+ dub.sdl:
name "A"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n;
string s;
sc.read(n, s);
int ans = 10^^9;
int wc, ec = s.count('E').to!in... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
void main() {
int B = readln.chomp.to!int;
foreach(i; 1..10) {
foreach(k; 1..10) {
if(B == i*k) {
"Yes".writeln;
return;
}
}
}
"No".writeln;
}
| 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.split;
if (s[0][$-1] == s[1][0] && s[1][$-1... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln(readln.chomp.to!int / 3);
}
| 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;
T lread(T = long)()
{
return readln.chomp.to!T();
}
T[] aryread(T = long)()
{
ret... | 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;
void times(alias pred)(int n) {
foreach(i; 0..n) pred();
}
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;
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", ... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.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;
scan(n);
auto t = readln.split.to!(... | 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() {
int N;
scan(N);
auto w = new int[](N + 1);
auto b = n... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto hw = readln.split.to!(int[]);
auto H = hw[0];
auto W = hw[1];
char[][] MAP;
MAP.length = H;
foreach (ref line; MAP) {
line = readln.chomp.to!(char[]);
}
in... | D |
void main()
{
string s = readln.chomp;
long k = readln.chomp.to!long;
long n = s.countUntil!(x => x != '1');
if (n == -1 || n >= k)
{
s[0].writeln;
}
else
{
s[n].writeln;
}
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorith... | D |
void main() {
string s = readln.chomp;
int cnt;
foreach (x; s) {
if (x == '+') ++cnt;
else --cnt;
}
cnt.writeln;
}
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.containe... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main() {
auto n = readln.chomp.to!int;
int[][][] f = new int[][][](n, 5, 2);
int[][] p = new int[][](n, 11);
for (int i = 0; i < n; ++i) {
auto l = readln.chomp.split.map!(to!int).array;
for (int j = 0; ... | 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 s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1... | 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.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
string f = readln.chomp;
string s = readln.chomp;
au... | 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;
void main()
{
auto ip = readln.split.to!(int[]);
if(ip[0] <= 8 &&... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
long[][] mmul(long[][] x, long[][] y)
{
auto r = new long[][](x.length, y.length);
foreach (i; 0..x.length) {
foreach (j; 0..y[0].length) {
foreach (k; 0..y.length) {
... | 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, m;
scanf("%d%d", &n, &m);
bool[][] g = new bool[][](n,n);
foreach (i; 0..n) foreach (j; 0..n) {
if (i != j) g[i][j] = true;
}... | 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 n) {
/... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nab = readln.split.to!(int[]);
auto N = nab[0];
auto A = nab[1];
auto B = nab[2];
auto ts = new int[](N);
foreach (i; 0..N) ts[i] = readln.chomp.to!int;
int r;
forea... | D |
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.array;
void main() {
readln();
auto inp = readln().chomp.split;
string[] b1, b2;
for(int i; i<inp.length; i++){
auto a = inp[i];
if(i%2==0){b1 ~= a;}
else{b2 ~= a;}
}
if(inp.length%2==0){b2.reverse(); (b2 ~ b1).join(" ").writ... | D |
void main() {
int x = readln.chomp.to!int;
bool[] ok = new bool[x+1];
ok[1] = true;
for (int i = 2; i * i <= x; ++i) {
for (int j = 2; i ^^ j <= x; ++j) {
ok[i^^j] = true;
}
}
foreach_reverse (i, y; ok) {
if (y) {
i.writeln;
break;
... | 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 d, n; readV(d, n);
writeln((... | 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() {
auto d = ['A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'];... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.