code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.array;
void main() {
int n = readln.chomp.to!int;
auto s = readln.chomp.split;
bool[string] dict;
int ans;
foreach(ss; s) {
if ((ss in dict) is null) {
dict[ss] = true;
ans++;
... | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio;
int f(int x) {
string s = x.to!string;
int r = 1, n = cast(int) s.length;
foreach(i, c; s) {
r &= s[i] == s[n-1-i];
}
return r;
}
void main() {
int a, b;
scanf("%d %d", &a, &b);
... | D |
import std.stdio;
void main() {
string line=readln();
int ans=0;
for(int i=0;i<3;i++) ans+=line[i]-'0';
writeln(ans);
}
| 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;
writeln("ABC" ~ n);
}
| 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;
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;
string ans = "";
string[] boin =... | 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.array, std.algorithm, std.conv;
void main()
{
immutable nm = readln.chomp.split(" ").map!(to!int).array;
immutable n = nm[0];
immutable m = nm[1];
auto nodes = new int[][n];
foreach(_i; 0..m) {
auto ab = readln.chomp.split(" ").map!(to!int).array;
... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main() {
//stdin.open("input.txt", "r");
//stdout.open("output.txt", "w");
string num = strip(readln());
if (num[0] == '-') {
int a = to!int(num[0..$-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;
long calc(long n) {
if (n == 1) return 0;
int ans = 0;
foreach (p; factor(n)) {
long k = p[1];
for (int i = 1; ; i++) {
if (k >= i) {
k -= i;
ans++;
} else break;
}
}
return ans;
}
void main() {
long ... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
int x = to!int(chomp(readln()));
writeln(x < 1200 ? "ABC": "ARC");
}
| D |
import std.algorithm,
std.string,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
int[] nm = readln.chomp.split.to!(int[]);
int n = nm[0],
m = nm[1];
int[][] routes;
routes.length = n + 1;
foreach (i; m.iota) {
int[] ab = readln.chomp.split.to!(int[]);
... | 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!int);
auto N = s[0];
auto K = s[1];
auto A = readln.split.map!... | 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 |
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;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
auto B = new long[](N+10... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto a = readln.split.to!(int[]), mi = a.reduce!min, ma = a.reduce!max;
auto ans = int.max;
foreach (x; mi..ma+1)
ans = min(ans, a.map!(ai => (ai - x) ^^ 2).sum);
writeln(ans);
}
| D |
import std.stdio, std.string, std.array, std.conv, std.algorithm;
void main() {
int n = readln.chomp.to!int;
int[] a = readln.chomp.split.to!(int[]);
int q = readln.chomp.to!int;
foreach (i; 0 .. q) {
int[] tmp = readln.chomp.split.to!(int[]);
int b = tmp[0], e = tmp[1], k = tmp[2];
... | D |
void main()
{
long n = rdElem;
long[] a = rdRow;
long m = rdElem;
long[] b = rdRow;
foreach (x; b)
{
long idx = a.binSrch!"a <= b"(x);
if (idx == -1 || a[idx] != x)
{
0.writeln;
return;
}
}
1.writeln;
}
long binSrch(alias pred = ... | D |
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.math;
void main(){
while(true){
string[] s = [];
for(int i=0;i<8;i++){
string temp = readln();
if(stdin.eof()) break;
s ~= chomp(temp);
}
if(stdin.eof()) break;
string ans = "none";
for(int i=0;i<7;i++)
... | 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() {
while (true) {
int N;
scan(N);
if (N == 0... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
const size_t n = 10;
void main()
{
auto hi = n.iota.map!(_ => readln.chomp.to!int).array;
hi.sort!("a > b");
hi.take(3).each!(writeln);
} | 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()
{
auto ab = readln.split.map!(to!int);
writeln(ab[0]*ab[1], " ", ab[0]*2+ab[1]*2);
} | 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 a, b, c;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
auto abc = readln().strip().split().map!(to!i... | 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;
int calc(string s) {
... | 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;
void main() {
auto N = readln.chomp.to!ulong;
auto halfN = N / 2;
writeln(halfN - (N%2 == 0 ? 1 : 0));
}
| 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 |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | D |
import 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 |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto mk = readln.split.to!(uint[]);
auto M = mk[0];
auto K = mk[1];
if (K == 0) {
foreach (a; 0..2^^M-1) {
write(a, " ");
write(a, " ");
}
... | D |
import std.stdio, std.conv, std.string, std.math;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[0] * ip[1] < ip[2] * ip[3]){
writeln(ip[2] * ip[3]);
} else if(ip[0] * ip[1] > ip[2] * ip[3]){
writeln(ip[0] * ip[1]);
} else {
writeln(ip[2] * ip[3]);
}
} | 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 |
/+ dub.sdl:
name "F"
dependency "dunkelheit" version=">=0.7.4"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n;
sc.read(n);
int[][] g = new int[][n];
foreach (i; 0..n-1) {
int a, b;
... | 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()
{
auto n = readln.chomp.to!int * 2;
auto cards = iota(1, n+1).array;
auto m = readln.chomp.to!int;
while ... | D |
import std.conv;
import std.stdio;
import std.string;
void main()
{
auto n = readln.strip.to!int;
auto as = readln.split.to!( long[] );
writeln( solve( n, as ) );
}
auto solve( in int n, in long[] as )
{
auto c = 0;
foreach( i, long a; as )
{
while( 0 < a && a % 2 == 0 )
{
a /= 2;
c++;
}
}
re... | 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.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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, core.bitop;
Tuple!(N, N)[] prime_division(N)(N n)
{
auto nn = n;
Tuple!(N, N)[] res;
for (N i = 2; i^^2 <= nn; ++i) {
if (n%i == 0) {
N cnt;
while (n%i == 0)... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.numeric;
void main() {
int n;
scan(n);
foreach (k ; 1 .. n + 1) {
int s = k * (k + 1) / 2;
if (n <= s) {
int x = s - n;
... | 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() {
readln;
auto xs = readints();
... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, 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 main()
{
int x, a, b; readV(x, a, b);
writeln((x-a).abs < (x-b).abs ? "A" : "B");
}
| 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;
auto ab = readln.split.to!(int[]);
auto A = ab[0];
auto B = ab[1];
auto x = k;
while (x <= B) {
if (x >= A) {
writeln("OK");
... | 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, std.regex;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
auto P = readln.spl... | 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;
void main() {
int[] answers;
answers ~= readln.chomp.to!int;
answers ~= readln.chomp.to!int;
answers = answers.sort().array;
if (answers[0] == 1 && answe... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
int readInt(){
return readln.chomp.to!int;
}
int[] readInts(){
return readln.chomp.split.to!(int[]);
}
void main(){
string s = readln.chomp;
int nf = s[0 .. 2].to!int;
int nl = s[2 .. 4].to!int;
bool YYMM = fals... | D |
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{
auto line = readln().split();
if (line.length < args.length) return;
foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
};
void read(T...) (auto re... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
const dx = [0, 1, 0, -1];
const dy = [1, 0, -1, 0];
int H, W;
bool[55][55] memo;
string[] s;
int bfs(int h, int w) {
if (!(0 <= h && h < H && 0 <= w && w < W)) return 0;
if (s[h][w] == '.') return 0;
if (s[h][w] == '#' && memo[h]... | 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 N = readln.chomp.to!int;
auto tanda = readln.sp... | 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()
{
readln.chomp.to!int;
int x, y, z;
long r = 1;
foreach (a; readln.split.to!(int[])) {
long d;
if (a == x) ++d;
if (a == y) ++d;
if (a =... | 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;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
long binarySearch(long min,... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
struct UFTree(T)
{
struct Node
{
T parent;
T rank = 1;
}
///
T min_size, max_size;
///
this(T n)
{
nodes.length = n;
sizes.length = n;
foreach... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.math;
void main(){
auto nums = readln().chomp.split.map!(to!int);
int[] result;
result.length = nums[1];
for(int i; i < nums[0]; i++){
auto input = readln().chomp.split.map!(to!int);
foreach(a; inpu... | D |
void main() {
dchar[] n = readln.chomp.to!(dchar[]);
auto g = n.group.assocArray;
writeln(g.values.any!"a >= 3" ? "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;
impo... | 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 n = rd[0], x = rd[1];
if (n == 0 &... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional;
long[10^^5+1] AS;
void main()
{
readln;
auto as = readln.split.to!(long[]);
foreach (a; as) ++AS[a];
auto cnt = as.length;
size_t i = 1, j = 10^^5+1;
for (; j > i && i < 10^^5+1 && j > 0;) {
... | D |
void main() {
problem();
}
void problem() {
auto A = scan!long;
auto B = scan!long;
long solve() {
return A * B;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.m... | 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[] A;
long[] B;
Tuple!(long, long)[] X;
Tuple!(long, long)[] Y;
void main() {
auto D = readln.chomp.to!long;
A ... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
auto solve(immutable int n)
{
auto a = iota(n).map!(_=>readln().chomp()).array();
auto dp = new int[][](n+1,n+1);
foreach(i;0..n)
foreach(j;0..n)
dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]+(a[i][j]!='.'... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto a=readln.split.to!(int[]);
auto num=new int[](9);
foreach(e; a){
foreach(i; 0..8){
if(i*400<=e && e<(i+1)*400){
num[i]++; break;
}
}
if(e>=3200){
num[$-1]++;
}
}
auto lb=reduc... | 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;
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.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;
void main(){
int q = readln.chomp.to!int;
string x, y;
int ans;
foreach(qi ; 0 .. q){
x = readln.chomp;
y... | 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 NK = readln.split.to!(int[]);
auto N = NK[0], K = NK[1];
bool[] flag;
flag.length = N;
foreach (i; 0 .. K) {
readln;
auto A = readln.split.to!(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, std.bitmanip;
immutable long MOD = 10^^9 + 7;
long[] F;
void solve() {
auto s = readln.split.map!(to!long);
auto N = s[0];
auto... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
iota(1,readln().chomp().to!long()+1).reduce!"a*b"().writeln();
} | D |
void main()
{
import std.algorithm, std.array, std.range, std.stdio, std.string, std.conv;
readln;
auto yum = cast(ubyte[])(readln.chomp);
yum.uniq.walkLength.writeln;
}
| D |
import std.stdio;
import std.string;
import std.conv;
void main(){
int n;
while((n = readln.chomp.to!int) != 0){
string input = readln.chomp;
foreach(Unused; 0..n){
input = input.operate;
}
input.writeln;
}
}
string operate(string input){
string res;
cha... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
auto ... | D |
import std.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv,
std.format,
std.math;
void main()
{
auto s = readln.chomp;
auto t... | 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, std.string, std.conv;
import std.array, std.algorithm, std.range;
int[][] J;
static this()
{
foreach(i;0..3) J~=[i*3,i*3+1,i*3+2];
foreach(i;0..3) J~=[i,i+3,i+6];
foreach(i;0..2) J~=[i*2,4,8-i*2];
}
char solve(char[] s)
{
foreach(c;"ox")
foreach(a;J)
if(a.map!(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.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
void main()
{
int[] input = readln().split.to!(int[]);
int N = input[0];
int K = input[1];
auto w... | D |
void main()
{
int[] tmp = readln.split.to!(int[]);
int r = tmp[0], g = tmp[1], b = tmp[2], n = tmp[3];
int cnt;
int x = n / r;
foreach (i; 0 .. x+1)
{
int y = (n - r * i) / g;
foreach (j; 0 .. y+1)
{
if ((n - r * i - g * j) % b == 0)
{
... | 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; }
/*
けたごとに見る。
A[i]たちについて、そのけた... | 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 p = readNums!int;
int nmin = p[0], ret =... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void get(Args...)(ref Args args)
{
import std.traits, std.meta, std.typecons;
static if (Args.length == 1) {
alias Arg = Args[0];
static if (isArray!Arg) {
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
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.datetime;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!long).array;
auto M = A.reduce!min;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long lcm(long a, long b)
{
return a * b / gcd(a, b);
}
void main()
{
auto N = readln.chomp.to!int;
auto as = readln.split.to!(long[]);
auto ls = new long[](N);
ls[0] = as[0];
foreach (i; 1..N... | D |
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm;
bool isPrefixOf(string x, string y){
if (x.length > y.length) return false;
bool res = true;
for(int i;i<x.length;i++){
res = res && x[i] == y[i];
}
return res;
}
void main(){
string x = readln.chomp;
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;
void main()
{
readln;
auto os = readln.chomp;
int n;
foreach (o; os) {
if (o == '+') {
++n;
} else if (o == '-' && n > 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() {
auto N = ri;
long res;
foreach(i; 0..N+1) {
if(i % 5 != 0 && i % 3 != 0) res += i;
}
res.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;... | D |
void main()
{
string s = readln.chomp;
writeln(s.canFind("AC") ? "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 std.ascii;
import std.uni; | D |
import std.stdio;
immutable mod = 4294967311L;
void main(){
long x, y;
int n, op;
scanf("%d", &n);
long[] inv = new long[1000_001];
inv[1] = 1;
foreach(i; 2..inv.length){
inv[i] = mul(inv[mod%i], mod - mod/i);
}
foreach(_; 0..n){
scanf("%d%lld", &op, &y);
if(op >= 3 && y < 0) x = -x, y = -y;
if(op == ... | D |
import std.stdio;
long div = 1_000_000_007;
void main() {
long n, m;
scanf("%ld %ld\n", &n, &m);
auto dp = new long[n+2];
dp[0] = 1;
auto check = new bool[1_0000];
foreach(_; 0..m) {
long a;
scanf("%ld\n", &a);
check[a] = true;
}
foreach(i; 0..n) {
if (check[i]) continue;
dp[i+1] = (dp[i+1] + dp[i]) %... | D |
import std.stdio,std.conv,std.string,std.algorithm;
void main(){
for( int i;;++i ){
auto arg = readln().chomp().to!int;
if( !arg ) break;
writeln("Case ",i+1,": ",arg );
}
} | D |
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import c... | D |
// Your code here!
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.conv;
import std.string;
void main(){
auto input = readln().chomp().to!int;
if(input <= 999){
writeln("ABC");
}else{
writeln("ABD");
}
} | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.