code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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 |
void main() {
problem();
}
void problem() {
const A = scan!long;
const B = scan!long;
const N = scan!long;
long calc(long x) {
return (A*x / B) - A*(x/B);
}
long solve() {
if (B > N) {
return calc(N);
}
const k = N / B;
return calc(B * k - 1);
}
solve().writeln;
}
// --... | D |
import std.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
string s = readln.chomp;
int K = readln.chomp.to!int;
int[str... | D |
import std.algorithm;
import std.range;
import std.stdio;
import std.typecons;
import std.traits;
import std.array;
struct Input
{
T next(T)()
{
import std.conv;
return to!T(nextWord);
}
string nextWord()
{
if (_nextWords.empty)
_nextWords.insertFront(readln().split);
string word = _nextWords... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;
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 ... | 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 = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () ... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n;
rd(n);
auto a = readln.split.to!(int[]);
auto g = new int[][](n);
foreach (_; 1 .. n) {
int u, v;
rd(u, v);
g[u - 1] ~= v - 1;
g[v - 1] ~= u - 1;
}
auto num_r = new int[](n), num_b = new int[](n);
void f(int i... | 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;
alias P = Tuple!(long, "x", long, "y");
const MOD = 10^^9 + 7;
long calc(P[] ps, int zeros) {
long[P] m;
foreach (p; ps) m[p]++;
bool[P] used;
long[] group;
foreach (p; ps) {
if (used.get(p, false)) continue;
// p に属するグループ数
auto a1 = p;
auto a2 = P(-p.... | D |
void main() {
int n = readln.chomp.to!int;
int[] tmp = readln.split.to!(int[]);
int d = tmp[0], x = tmp[1];
foreach (i; 0 .. n) {
int a = readln.chomp.to!int;
int day = 1;
while (day <= d) {
++x;
day += a;
}
}
x.writeln;
}
import std.stdio... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
readln;
writeln(sort(readln.split).group.walkLength == 3 ? "Three" : "Four");
} | 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 X = readln.split[0].to!long;
long money = 100;
foreach (i; 1 .. 4000) {
money = cast(long) floor(money * 1.01);
if (money >= X) { writeln(i); break; }... | 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 gcd(int a, int b) {
if (b == 0)
retu... | 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() {
string s;
scan(s);
writeln(s.count!"a == '1'");
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (ref arg; args)... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
writeln("ABC" ~ readln.chomp);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primitives;
auto line = readln... | 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.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;
void main() {
while (true) {
int sum = readln.chomp.to!int;
if (sum == 0) break;
foreach (i; 0..9) {
sum -= readln.chomp.to!int;
}
sum.writeln;
}
... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];
auto r = new int[](n);
foreach (_; 0..m) {
auto rd2 = readln.split.to!(size_t[]), a = rd2[0]-1, b = rd2[1]-1;
++r[a];
++r[b];
}
foreach (ri; r) writeln(r... | D |
module app;
import core.bitop;
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;
import std.traits;
struct Input
{
int n;
int[] a;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
n = readln().strip().to!int;
a = readln... | D |
import std.stdio, std.algorithm, std.string;
int main(string[] argv)
{
string[] s = readln().chomp().split();
s.sort;
writeln(join(s, " "));
return 0;
} | 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 int inf = mod;
void main(){
auto s = readln.split;
auto stack = new SList!int;
int ... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.conv;
void main(){
readln.split.map!(to!int).unaryFun!(a => a[0] < a[1] ? "a < b" : a[0] > a[1] ? "a > b" : "a == b").writeln;
} | D |
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;
enum INF = long.... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.ascii;
void main()
{
foreach(_; 0 .. readln.chomp.to!int)
{
auto line = readln;
auto keys = line.split.filter!(str => str.length == 4);
loop:foreach(a; [0, 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25])
{
foreac... | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
int[] input = readln.split.to!(int[]);
int sx = input[0];
int sy = input[1];
int tx = input[2];
int ty = input[3];
char[] ans;
foreach (i; 0..(ty - sy))
ans ~= 'U';
foreach (i; 0..(tx - sx))
ans ~= '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 |
module app;
import core.bitop;
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;
void main()
{
Input input = void;
parseInput(input, stdin);
main2(&input);
// writeln(result);
}
auto main2(Input* input)
{
uint[100000] seikaisuu;
foreach... | 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(int[] xs) {
... | D |
import std.stdio;
import std.range;
import std.conv;
import std.algorithm;
import std.string;
import std.array;
import std.conv;
void main()
{
readln();
writeln(readln().strip.split(" ").reverse.join(" "));
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main(){
uint[] arr=new uint[10];
for(uint i;i<10;++i){
arr[i]=readln().chomp().to!int();
}
arr.sort().reverse();
for(uint i;i<3;++i){
writeln(arr[i]);
}
} | D |
import std.stdio;
import std.conv;
import std.string;
int main() {
string[] str = chomp(readln).split(" ");
int a = to!(int)(str[0]);
int b = to!(int)(str[1]);
writeln(a*b, " ", a*2+b*2);
return 0;
} | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.math;
void main() {
int n = readln.chomp.to!int;
int[] arr = readln.chomp.split.map!(to!int).array;
long ans = 1000000000000007;
for (int i = 0; i < 2; ++i) {
auto a = arr.dup;
long tmp;
long[]... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto S = readln.chomp.to!(char[]);
int r;
foreach (i; 1..N-1) {
int[char] CNT;
foreach (c; S[0..i]) {
CNT[c] = 1;
}
... | 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.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!long).array;
long[] B = new long[](N);
long cnt =... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] 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;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
void main() {
string s;
scan(s);
int N = s.length.to!int;
foreach... | 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!long;
long n = long.max;
foreach (_; 0..5) n = min(n, readln.chomp.to!long);
writeln((N + n - 1) / n + 4);
} | D |
import std.algorithm,
std.string,
std.array,
std.stdio,
std.range,
std.conv;
long abs(long x) {
return x * (x < 0 ? -1 : 1);
}
void main() {
long N = readln.chomp.to!long;
long[] a = readln.chomp.split.to!(long[]);
long ans = long.max;
long[] dp1,
dp2;
dp1.le... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1], c = rd[2], d = rd[3];
writeln(max(a*b, c*d));
}
| 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.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;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;
string my_readln() { return chomp(readln()); }
void main()
{
auto tokens = my_readln().split();
auto N = tokens[0].to!uint;
uint[] h;
foreach (token; my_readln().... | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
(readln.chomp.to!int ^^ 3).writeln;
} | 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.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 S = readln.chomp;
int b, n;
foreach (c; S) {
switch (c) {
case... | D |
import std.stdio, std.string, std.conv, std.array;
string inv( string v ) {
return to!string(2 - to!int(v));
}
string mult( string x, string y ) {
if ( x == "0" || y == "0" ) return "0";
else if ( x == "1" || y == "1" ) return "1";
else return "2";
}
string add( string x, string y ) {
if ( x == "2" || y ==... | 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 h = readln.chomp.split.to!(i... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
import std.math;
void main(){
auto a=readln.chomp;
writeln("A",a[8],"C");
} | D |
void main(){
int x, y;
scanf("%d %d", &x, &y);
(x + y/2).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行に同一型の複数入力
T[] _scanln(T = int)(){
T[] ln;
foreach(string elm; readln().chomp().split()){
... | 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 int INF = 1 << 29;
void main() {
auto T = readln.chomp.to!int;
while (T--) {
auto s = readln.sp... | 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.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | 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;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1];
if(A==B)writeln("Draw");
else if(A==1&&A<B)writeln("Alice");
else if(B==1&&A>B)writeln("Bob");
else if(A<B)writeln("Bob");
else if(A>B)writeln... | 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, m;
int[] a;
void main() {
scan(n, m);
a = readln.split.to!(int[]);
auto imos = new int[](m + 2);
aut... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1];
writeln((a + b) % 24);
}
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.... | 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;
alias Edge = Tuple!(int, "to", int, "idx");
void main() {... | 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.algorithm, std.conv;
void main()
{
int[101] count;
int max_;
foreach(n; stdin.byLine().map!(to!int))
{
++count[n];
max_ = max(max_, count[n]);
}
foreach(i; 1..101)
{
if(count[i] == max_) i.writeln;
}
} | D |
void main(){
int[int] dic;
int ans;
int[] colors = inln();
foreach(elm; colors){
dic[elm]++;
if(dic.get(elm,0)==1)ans++;
}
ans.writeln();
}
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!(... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
int N, M;
int[] a, b;
bool[] data;
int[][] e;
int[] memo;
int ans;
void Func(int n, int b){
memo ~= n;
foreach(i ; e[n]){
bool check = false;
if(i == b) continue;
foreach(j ; memo){
... | 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.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;
void main()
{
int[] m;
while((m=map!(to!int)(readln.strip.split).array)!=[0,0]) {
int n=m[0],x=m[1],sum = 0;
for(int i=1;i<n;i++)
{
for(int j=i+1;j<x-i;j++)
{
int k = x-i-j;
... | 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 readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pic... | 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.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.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;
writeln(((n-1)/111+1)*111);
}
| 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;
void main(){
auto col = new int[](8);
int n = readln.chomp.to!int;
auto a = readln.split.to!(... | 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 p = readln.chomp.split.to!(int[]);
int cnt;
... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;
void main()
{
auto pat = ['z', '.', '?', '!', ' '];
foreach (line; stdin.byLine) {
auto str = line.chomp;
if (str.... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void solve()
{
auto abcd = readln.split.to!(long[]);
auto A = abcd[0];
auto B = abcd[1];
auto C = abcd[2];
auto D = abcd[3];
if (A < B || D < B) {
writeln("No");
return;
}... | D |
import std.algorithm;
import std.array;
import std.stdio;
import std.conv;
import std.string;
import std.range;
void main(){
int[] ary;
int[] temp1, temp2;
while(true){
auto input = readln.split;
int n = input[0].to!int;
int r = input[1].to!int;
if(n == 0 && r == 0){
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto Q = readln.chomp.to!int;
foreach (_; 0..Q) {
auto X = readln.chomp;
auto Y = readln.chomp;
auto DP = new int[][](X.length, Y.length);
foreach_reverse (i; 0.... | D |
void main(){
auto NK = readLine!long();
long[] list = new long[](cast(size_t)NK[0]);
long K = NK[1];
foreach( i ; 0..K ){
auto type = readLine!int()[0];
auto toList = readLine!int();
foreach( to ; toList ){
list[to-1] += type;
}
}
list.count(0).writeln();
}
import std;
string alphabet = "... | D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto input1=readln.chomp,input2=readln.chomp;
writeln((2*input2.to!int)-input1.to!int);
} | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
auto X = readln.split.to!(int[]);
if(X.count(5) == 2 && X.count(7) == 1) {
writeln("YES");
} else {
writeln("NO");
}
} | 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;
scanf("%d", &n);
long[] d = new long[n];
foreach (i; 0..n) {
scanf("%lld", &d[i]);
}
alias Tuple!(long,int) P;
P[] raw_p = ... | 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(true) {
if (STONES[right] != 'R') right--;
if (STONES[left] != 'W') left++;
if (right <= left) break;
... | D |
import std.stdio;
long fact(int N) {
if (N == 0) return 1L;
return N * fact(N - 1);
}
void main() {
int N; scanf("%d\n", &N);
writeln(fact(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 |
import std.stdio;
import std.conv;
import std.string;
import std.range;
import std.algorithm;
void main(){
while(true){
int n = readln().chomp().to!int();
if(n == 0){
break;
}
string str = readln().chomp();
foreach(i; 0..n){
string res;
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() {
int x... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
import std.typecons : Tuple;
ulong safeMod(long x, long m) @safe pure nothrow @nogc
{
x %= m;
if (x < 0)
x += m;
return x;
}
long ctPowMod(long x, long n, int m) @safe p... | 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 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 N = tmp[0], M = tmp[1];
iota(1,M/N+1).retro.filter!(x => M % x == 0).front.writeln;
}
| 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 s; readV(s);
string t; re... | 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<<30;
enum full = (1<<26) - 1;
void main() {
string s;
scan(s);
int n = s.length.to!int;
long ans;
void dfs(int i, long val, lon... | D |
import std.stdio, std.conv, std.string, std.random, std.range, std.typecons, std.math;
import std.algorithm.comparison, std.algorithm.iteration;
import std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting;
void main()
{
auto input = readln().strip.split.to!(int[]);
auto A = input[0];
auto... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long solve(long N)
{
if (N == -1) return 0;
if (N%2 == 0) {
return N ^ ((N/2)%2 == 0 ? 0 : 1);
} else {
return (N/2)%2 == 1 ? 0 : 1;
}
}
void main()
{
auto ab = readln.split.to!(l... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto ab = readln.split.to!(int[]);
auto A = ab[0];
auto B = ab[1];
writeln(A * B - A - B + 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;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long a = tmp[0], b = tmp[1];
if (a == 0 || b == 0)
{
if (a < b) writeln(abs(b.abs-a.abs));
else writeln(abs(b.abs-a.abs) + 1);
}
else if (a / a.abs == b / b.abs)
{
if (a <= b) writeln(b - a);
else writeln(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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, m; rd(n, m);
auto as=readln.split.to!(long[]);
auto bs=readln.split.to!(long[]);
auto dub=new long[](n+1);
foreach(i; 0..n) dub[i+1]=dub[i]+as[i];
dub~=1_000_000_000_000_000_000;
int x=0;
foreach(b; bs){
while(dub[x+1]<b)... | D |
// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio, std.string, std.array, std.algorithm, std.conv;
void main() {
auto nm = to!(int[])(split(chomp(readln())));
int n = nm[0], m = nm[1];
auto xss = appender!(string[])();
for (int i = 0; i < n; i++) {
xss.put(chomp(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;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;
import std.range;
import std.numeric;
import std.traits;
import std.math;
void main(string[] args)
{
long[100][100] mat;
auto t = next!int;
foreach(tc; 0 ..... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.