code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;
int main() {
string l;
while((l = readln()).length >= 2){
int a, b, aorg, borg, r;
a = aorg = to!int(l.split()[0]), b = borg = to!int(l.split()[1]);
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long P = 998244353L;
void main()
{
auto ns = readln.split.to!(int[]);
auto N = ns[0];
auto S = ns[1];
auto AS = readln.split.to!(int[]);
auto DP = new long[][](N+1, S+1);
DP[0][0] = 1;
... | D |
import std.string;
import std.stdio;
import std.algorithm;
void main() {
auto s = readln.chomp.dup;
auto t = readln.chomp.dup;
if (s.length == 0 || t.length == 0) {
writeln();
return;
}
auto dp = new int[][t.length + 1];
foreach (ref e;dp) {
e = new int[s.length + 1];
}
foreach (size_t i, te;t) {
fo... | 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() {
int N = readln.chomp.to!int;
foreach(int i; 0..N) {
lon... | 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;
// 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 scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[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;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;
void main()
{
while (true)
{
auto a = readln;
if (a == "0\n") break;
writeln(a.strip.map!(x => x - '0').sum);
}
}
| D |
import std.stdio,
std.string,
std.conv;
void main(){
string s, w = readln.chomp;
while(true){
string tmp = readln.chomp;
if (tmp == "END_OF_TEXT") break;
s ~= tmp.toLower ~ " ";
}
int c = 0;
foreach(x; s.split){
if (x == w) c++;
}
writeln(c);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto L = readln.chomp.to!int;
if (L <= 60) {
writeln(2, " ", L);
foreach (l; 0..L) {
writeln("1 2 ", l);
}
return;
}
int[] AS, BS, CS;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
alias Path = Tuple!(int, "to", long, "d");
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
Path[][] G;
G.length = N;
foreach (_; 0..M) {
auto lrd = re... | D |
import std.stdio, std.string, std.conv;
void main()
{
auto input = readln.split.to!(int[]);
auto N = input[0];
auto i = input[1];
writeln(N-i+1);
} | 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.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.string;
void main()
{
int n, k;
n = readln.chomp.to!int;
k = readln.chomp.to!int;
int res = 1;
foreach (int i; 0..n) {
res = min(res * 2, res + k);
}
writeln(res);
}
| D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n, k;
rd(n, k);
auto x = new long[](n), y = new long[](n);
foreach (i; 0 .. n)
rd(x[i], y[i]);
long mn = 9 * 10L ^^ 18;
foreach (a; 0 .. n) {
foreach (b; 0 .. n) {
foreach (c; 0 .. n) {
foreach (d; 0 .. n) {
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
long[10^^5] XS;
long[10^^5] VS;
void main()
{
auto nc = readln.split.to!(long[]);
auto N = nc[0];
auto C = nc[1];
foreach (i; 0..N) {
auto xv = readln.split.to!(long[]);
XS[i] = xv[0];
VS[i] = xv[1];
... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
immutable int base = 2050;
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto n = readln.strip.to !(long);
if (n % base != 0)
{
writeln (-1);
}
else
{
n /= base;
write... | D |
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons, std.format;
// }}}
// nep.scanner {{{
class Scanner {
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
impor... | 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 s = readln.chomp;
(s.count('+').to!int - s.count('-').to!int).writeln;
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
int[][] G;
G.length = N;
foreach (i; 0..M) {
auto ab = readln.split.to!(int[]);
auto A = ab[0]-... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.exception;
int n; rd(n);
void q(int i){
writeln(i); stdout.flush();
}
const M=0, F=1, V=-1;
int read(){
auto t=readln.chomp.to!(char[]);
if(t[0]=='M') return M;
else if(t[0]=='F') return F;
else return V;
... | D |
import std.stdio,std.conv,std.string;
void main(){
auto AB = readLine!int();
if ( AB[0] <= 8 && AB[1] <= 8 ){
writeln("Yay!");
}else{
writeln(":(");
}
}
T[] readLine(T)(){
T[] ret;
foreach( elm ; readln().split() ){
ret ~= elm.to!int();
}
return ret;
} | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;
string[] C = ["dreamer", "eraser", "dream", "erase"];
bool judge(string sub_str) {
if (sub_str.length == 0)
return true;
bool ok = false;
... | 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, a, b;
scan(n, a, b);
int mx = min(a... | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.string;
import std.conv;
// 素因数分解
uint[] prime_factor(uint n) {
uint[] res = [];
for(uint i = 2; i * i <= n; i++) {
if (n % i == 0) {
do {
res ~= i;
n = n / i;
} while (n % i == 0);
}
}
if (n > 1) res ~= n... | D |
import std.stdio,
std.string,
std.range,
std.algorithm;
void main(){
int n, x, cnt;
while (true){
scanf("%d %d", &n, &x);
if (n == 0 && x == 0) break;
cnt = 0;
n+=1;
foreach (i; 1..n){
foreach (j; i..n){
foreach (k; j..n){
if (i == j || i == k || j == k) continue;
if (i+j... | 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(){
string s = readStr;
int l = s.length.to!int;
if(s.count("o") + 15... | 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 |
void main(){
string n = readln().chomp();
char[] ans;
foreach(elm; n){
ans ~= (elm=='9')? '1': '9';
}
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行に同一型の複数入力
T[] _scanln(T = int)(){
T[] ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
string[] input = new string[](2);
bool[] cup = new bool[](3);
cup.fill(false);
cup[0] = true;
while ((input = readln.chomp.split(",")).length != 0) {
swap(cup[(input[0][0] - 'A').to!int], cup[(input[1... | D |
void main(){
char[] s = readln().chomp().dup();
char[] t = readln().chomp().dup();
sort!("a<b")( cast(ubyte[]) s);
sort!("a>b")( cast(ubyte[]) t);
writeln(s<t?"Yes":"No");
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
// 1要素のみの入力
T... | 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 s = sread();
long i = 1;
string previous; //前の文字
pr... | 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 core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
import std.stdio, std.string, std.conv;
import std.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, z, w;
scan(n, z, w);
auto a = readl... | 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 |
//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 |
// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio : readln, writeln;
import std.string : chomp;
import std.array : split;
import std.conv : to;
import std.algorithm : min;
auto gets() { return readln.chomp; }
auto getV(T)() { return gets.to!T; }
auto getVals(T)() { return gets.... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
alias P = Tuple!(int, "a", int, "b");
void main()
{
auto hwn = readln.split.to!(int[]);
long H = hwn[0];
long W = hwn[1];
auto N = hwn[2];
int[P] ps;
foreach (_; 0..... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
alias Point = Tuple!(int, "x", int, "y", int, "c");
void main() {
int n;
scan(n);
int ans = 10^^9;
foreach (a ; 1 .. n) {
ans = min(ans, ... | D |
import std.stdio, std.conv, std.string;
void main(){
auto ip = readln.chomp.to!int;
int res;
for(int i = 0; i <= ip; i++){
res += i;
}
res.writeln;
} | 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()
{//try{
auto N = my_readln().to!ulong();
auto tokens = split(my_readln());
auto A = tokens[0].to!ulong()... | 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 G = new int[][](N);
foreach (_; 0..N-1) {
auto s = readln.split.map!(t... | 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 a, b, c, d; readV(a, b, c, d);... | 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.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()
{
long R = scanElem;
if(R<1200){
writeln("ABC");
return;
}
if(R<2800){... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
import core.bitop;
void main()
{
auto N = readln.chomp.to!int;
auto AS = readln.split.to!(int[]);
auto BS = readln.split.to!(int[]);
auto DP = new int[][](51, 2^^N);
foreach (ref dp; DP) dp[] = -... | D |
import std.stdio,std.conv,std.string,std.algorithm;
void main(){
int m;
auto sm=readln().split();
m=to!int(sm[0]);
writeln(48-m);
} | 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();
long bignum... | 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.algorithm, std.string, std.conv, std.array;
void main()
{
foreach(unused; 0 .. readln.chomp.to!int)
{
int left = 0, right = -1;
bool flag = true;
foreach(n; readln.split.map!(to!int))
{
if(n > left && n > right)
{
if(... | 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!(char[]).array.count('9');
writeln(n?"Yes":"No");
}
| D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.bitmanip;
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 ... | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;
void main()
{
auto s = readln.chomp.to!dstring;
if (s[0..$/2].isPalindrome && (s[0..$/2] == s[$/2+1..$]))
"Yes".writeln;
else
"No".writeln;
}
auto isPalindrome(T)(in T[] a)
{
return a.equal(a.retro);
}
| 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[] 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 readS(T)(size_t n,ref T t){t=new T(n);foreach(... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto a = readln.chomp.to!int;
auto b = readln.chomp.to!int;
auto h = readln.chomp.to!int;
writeln((a + b) * h / 2);
}
| D |
import std.stdio, std.string, std.conv;
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 dp = new long[][][][... | D |
void main()
{
long n = readln.chomp.to!long;
long[] t = new long[n];
foreach (i; 0 .. n)
{
t[i] = readln.chomp.to!long;
}
long time = t[0];
foreach (i; 1 .. n)
{
long g = gcd(time, t[i]);
time = time / g * t[i];
}
time.writeln;
}
import std.stdio;
impor... | 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 chie template :) {{{
static if (__VERSION__ < 2090) {
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons, std.format,
std.bitmanip, std.numeric;
} else {
import std;
}
// }}}
// nep.scanner {{{
class Scanner {
... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
auto N = readln.chomp.to!int;
int E = 0;
auto used = new bool[][](N, N);
auto black = new st... | 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;
void main() {
scan(n, m);
writeln((n - 1) * (m - 1));
}
void scan(T...)(ref T args) {
string[] line... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long P = 10^^9+7;
long[10^^5+50] F, RF;
void init()
{
F[1] = 1;
foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;
{
RF[$-1] = 1;
auto x = F[$-1];
auto k = P-2;
while ... | D |
void main() {
auto a = ri, b = ri, c = ri, d = ri, e = ri, k = ri;
if(e - a > k) writeln(":(");
else writeln("Yay!");
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.contain... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto s=readln.chomp.to!(char[]);
int f=0;
int k=0;
foreach(i; 0..n){
if(s[i]=='('){
k++;
}else{
if(k==0){
f++;
}else{
k--;
}
}
}
foreach(_; 0..f) write("(");
write(s)... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
writeln("2018", s[4..$]);
}
| 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;
void main() {
string[] inputs = split(readln());
int A = to!int(inputs[0]);
int B = to!int(inputs[1]);
int C = to!int(inputs[2]);
if(A == B) writeln(C);
else if(A == C) writeln(B);
else writeln(A);
}
| D |
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons;
import core.bitop, std.datetime, std.range;
void main(){
auto rd = readln.split.to!(int[]);
auto n = rd[0], q = rd[1];
auto uf = new UnionFind(n);
foreach(lp ; 0 .. q){
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.15f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.stdio, std.array, std.conv, std.string;
void main()
{
string[] input;
solve: while(!stdin.eof()) {
input = readln.split(",");
if(input.length != 8) return;
auto inx = new double[](4);
auto iny = new double[](4);
for(int i = 0; i < 4; i++)
{
inx[i] = input[2 * i].chomp.to!double;
iny[i] =... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
immutable inf = 10^^9 + 7;
alias Edge = Tuple!(int, "to", int, "cost", int, "rev");
void main() {
int h, w;
scan(h, w);
auto adj = new Edge[][](h + w + 2, 0);
int s... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std;
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 n = lread();
auto a = aryread();
auto b = aryread();
... | 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 |
void main()
{
long n = rdElem;
n %= 10;
if (n == 3)
{
"bon".writeln;
}
else if (n == 0 || n == 1 || n == 6 || n == 8)
{
"pon".writeln;
}
else
{
"hon".writeln;
}
}
enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;
T rdE... | D |
import std.stdio, std.array, std.conv;
void main() {
while (true) {
string[] input = split(readln());
int H = to!int(input[0]);
int W = to!int(input[1]);
if (H == 0 && W == 0) break;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
write(is_dots(i, j) ? "." : "#");
... | 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 memo = new long[][](10, 10);
foreach (n; 1..N+1) {
auto y = n%10;
int x;
while (n) {
x = n;
n /= 10;
... | 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;
int[] Z_algorithm(string s) {
auto A = new int[](s.length);
A[0] = s.length.to!int;
for (int i = 1, j = 0; i < s.length; ) {
... | 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.split.map!(to!int);
auto N = s[0].to!int;
auto M = s[1];
auto edges = new int[][](N);
fore... | 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.algorithm, std.regex;
void main(){
auto ip = readln.split.to!(int[]), a = ip[0], b = ip[1], c = ip[2];
if(a == b + c || b == a + c || c == a + b){
writeln("Yes");
} else {
writeln("No");
}
} | D |
void main()
{
long n = rdElem;
string march = "MARCH";
long[] list = new long[5];
foreach (i; 0 .. n)
{
string s = rdStr;
foreach (j, m; march)
{
if (m == s[0]) ++list[j];
}
}
long result;
foreach (i; 0 .. 3)
{
foreach (j; i+1 .. ... | D |
import std.stdio, std.string, std.algorithm, std.conv, std.range;
void main() {
foreach (string line; lines(stdin)) {
if (line == "0 0\n")
break;
auto inputArray = line.chomp.split.map!(to!int);
auto h = inputArray[0];
auto w = inputArray[1];
for (int i = 0; i < h; i++) {
for (int j... | 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 |
//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 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 a;
string s;
scan(a);
scan(s);
... | D |
void main()
{
auto sieve = Sieve!long(10^^5);
long[] dp = new long[10^^5+1];
foreach (i; 1 .. 10^^5+1)
{
dp[i] = dp[i-1];
if (sieve.isPrime(i) && sieve.isPrime((i+1)/2))
{
++dp[i];
}
}
long q = readln.chomp.to!long;
foreach (i; 0 .. q)
{
... | 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 a, b;
scan(a, b);
int ans;
if (b ... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.array;
auto expr=readln.chomp.to!(char[]);
int res; rd(res);
auto n=expr.length;
int[] a; a~=(expr[0]-'0');
for(auto i=1; i<n; i+=2){
if(expr[i]=='+') a~=(expr[i+1]-'0');
else{
auto bk=a.back; a.popBack;
... | D |
void main()
{
long l, r;
rdVals(l, r);
long m = 2019;
if (l / m != r / m)
{
0.writeln;
}
else
{
long x = l % m, y = r % m;
long result = m;
foreach (i; x .. y)
{
foreach (j; i+1 .. y+1)
{
result = min(resul... | 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.ascii;
import std.array;
import std.container;
import std.conv;
import std.numeric;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) {
stderr.writeln(arg);
}
int size(T)(in T s) {
return cast(int)s.length;
}
const int INF = 10000;
int op(char c,... | 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[]);
writeln(S[0] == S[1] || S[1] == S[2] || S[2] == S[3] ? "Bad" : "Good");
} | D |
void main()
{
int[] path = new int[4];
foreach (i; 0 .. 3)
{
int[] tmp = readln.split.to!(int[]);
int a = tmp[0] - 1, b = tmp[1] - 1;
++path[a], ++path[b];
}
writeln(path.all!"a < 3" ? "YES" : "NO");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.