code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
void main()
{
auto input = readln.split.to!(int[]);
auto N = input[0];
auto M = input[1];
ulong X;
( 2 ^^ M * (M * 1900 + (N - M) * 100) ).writeln;
} | D |
import std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
void main() {
auto sw = readln.chomp.split.to!(int[]);
if(sw[0]<=sw[1]) writeln("unsafe");
else writeln("safe");
}
| 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, k;
scan(n, k);
writeln(n % k == 0 ? 0 : 1);
}
void scan(T...)(ref T args) {
import std.stdio : re... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum R = [
"SUN": 7,
"MON": 6,
"TUE": 5,
"WED": 4,
"THU": 3,
"FRI": 2,
"SAT": 1
];
void main()
{
writeln(R[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.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 |
void main()
{
string[] n = readln.split;
n.sort!"a < b";
writeln(n.join == "1479" ? "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.container;
import std.typecons; | D |
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(... | D |
import std.stdio, std.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;
enum P = 10L^^9+7;
bool[10^^3+1] PS;
int[] QS;
void prime_init()
{
PS[] = true;
PS[0] = false;
PS[1] = false;
foreach (i; 2..10^^3+1) {
if (PS[i]) {
QS ~= i;
auto x =... | 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.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;
void main()
{
long n = readln.chomp.to!long;
for (long cake = 0; cake <= 100; ++cake)
{
for (long donuts = 0; donuts <= 100; ++donuts)
{
if (cake * ... | D |
import std.stdio,std.conv,std.string;
void main(){
bool[9][9] m;
foreach(y;0..8){
foreach(x,c;readln.chomp){
m[y*2][1+x*2]=c=='1';
}
foreach(x,c;readln.chomp){
m[y*2+1][x*2]=c=='1';
}
}
int x,y,dir=6;
while(true){
final switch(dir){
... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int H, W;
scan(H, W);
auto a = ... | D |
module app;
import core.bitop;
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;
struct Input
{
int n;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
auto single = readln().strip();
n = single.to!int;
}
}
struc... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm: canFind;
void main() {
string[] inputs = split(readln());
string A = inputs[0];
string B = inputs[1];
string C = inputs[2];
if(A[$-1] == B[0] && B[$-1] == C[0]) "YES".writeln;
else "NO".writeln;
}
| D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
alias sread = () => readln.chomp();
alias Point2 ... | D |
import std.stdio, std.conv, std.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;
void main() {
string s = read!string;
writeln(s.canFind('7') ? "Yes" : "No");
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main ()
{
foreach (line; stdin.byLineCopy ())
{
writeln ("NO");
stdout.flush ();
}
}
| D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto n=readln.chomp.to!int,k=readln.chomp.to!int;
int i,ans=1;
for(i=0;i<n;i++){
ans=min(2*ans,ans+k);
}
writeln(ans);
} | 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() {
immutable int INF = 1 << 29;
auto N = readln.chomp.to!int;
auto A = new int[](2*N);
... | 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 s = readln.chomp;
auto k = readln.chomp.to!long;
int ... | 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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto a=new int[][](n, 10);
foreach(i; 0..n) a[i]=readln.split.to!(int[]);
auto c=new int[][](n, 11);
foreach(i; 0..n) c[i]=readln.split.to!(int[]);
long sum=-10000000000;
for(int bit=1; bit<(1<<10); bit++){
auto cnt=... | D |
import std.stdio, std.string, std.conv;
void main()
{
auto u = readln.chomp, A = u[0], B = u[1], C = u[2];
auto s = readln.chomp, D = s[0], E = s[1], F = s[2];
if(A == F && B == E && C == D){
writeln("YES");
} else {
writeln("NO");
}
} | 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; }
/*
行列累乗 有向パス 数え上げ
--------... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long[10^^5] AS, BS, AS2B, BS2A;
void main()
{
auto abq = readln.split.to!(int[]);
auto A = abq[0];
auto B = abq[1];
auto Q = abq[2];
foreach (i; 0..A) AS[i] = readln.chomp.to!long;
foreach (... | 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;
bool solve() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto Q = s[1];
if (N == 0) return false;... | 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;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return r... | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
void main() {
int x = readint();
int ans = 1;
foreach (b; 2..1000) {
for (int p = 2; b^^p <= x; p++) {
... | D |
import std;
const MOD = 10^^9 + 7;
int fac(int n) {
int res = 1;
for (int i = 1; i <= n; i++) {
res = (res * i) % MOD;
}
return res;
}
long modPow(long x, long k, long m) {
if (k == 0) return 1;
if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
return x * modPow(x, k - 1, m) % 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;
// 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.algorithm;
import std.conv;
import std.string;
import std.array;
int[] read_nums() {return readln.strip.chomp.split(" ").map!(to!(int)).array;}
void main() {
int times = readln.chomp.to!(int);
int index = -1;
int max = -1;
foreach(t; 0..times) {
int[] result = read_nums;
... | 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!long;
long res = (10L^^12)+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;
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, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int L;
string s, t;
scan(L);
scan(s);
scan(t);
if (s > t) {
swap(s, t);
}
if (s == t[0 .. s.length]) {
st... | D |
import std.stdio,std.string,std.conv;
int main()
{
string s;
int count = 0;
while((s = readln.chomp).length != 0)
{
if(s.length == 1)
{
count++;
}
else
{
bool flag = true;
foreach(i;0..s.length/2)
{
if(s[i] != s[s.length - i - 1])
{
flag = false;
}
}
if(flag)
{
... | 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.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];
auto M = s[1];
auto A = new int[](N+1);
foreach (i; 0.... | D |
void main(){
int r = _scan();
if( r<1200 )writeln("ABC");
else if( r<2800 )writeln("ARC");
else writeln("AGC");
}
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;
for... | D |
import std.stdio;
import std.string;
void main(){
string str = chomp(readln());
int len = cast(int)str.length;
char[1000] str2;
foreach(i; 0 .. len){
str2[i] = str[len - i - 1];
}
str2[len] = '\0';
writeln(str2);
} | 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 x; readV(x);
auto c = 0;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
struct Graph(T)
{
T L, R;
T[][] adj;
this(T L, T R)
{
this.L = L;
this.R = R;
adj.length = L + R;
}
void add_edge(T u, T v)
{
adj[u] ~= v+L;
adj[v... | 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;
immutable long inf = 10L^^15;
void main() {
int n;
scan(n);
auto a = readln.split.to!(int[]);
auto m = 1<<n;
auto dp = new int[][](m, 2);
... | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
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 .. $].combin... | D |
import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;
// Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eo... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, q; rd(n, q);
auto tree=new SquareRootDecomposition(n);
while(q--){
auto args=readln.split.to!(int[]);
if(args[0]==0){
tree.update(args[1], args[2]+1, args[3]);
}else{
writeln(tree.rmin(args[1], args[2]+1));
... | D |
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){
auto line = readln().split();
foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
void ma... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n, k;
scan(n, k);
auto c = ... | 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 |
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;
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 std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;
import std.typecons;
import std.format;
void main(string[] args) {
readln;
readln.solve.writeln;
}
auto solve(string line1) {
auto hash = line1.chomp.split.map!... | D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto n=readln.chomp.to!int;
int ans=1;
for(int i=1;i<n;i++){
if(ans>n){
break;
}else{
ans*=2;
}
}
if(n==1){
ans=2;
}
writeln(ans/=2);
} | 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, std.bitmanip;
// }}}
// nep.scanner {{{
class Scanner {
import std.stdio : File, stdin;
import std.conv : to;
import std.array : ... | 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 |
void solve(){
}
void main(){
int[] val = inary();
( (val[0]-1)*(val[1]-1) ).writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
alias instr = () => readln().chomp();
T inelm(T= int)(){ return to!(T)( readln().chomp() ); }
T[] inary(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.stdio;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
if (N % 3 != 0) {
... | 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];
writeln(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0 ? "Possible" : "Impossible");
}
| 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 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 |
void main()
{
string s = readln.chomp;
string t = readln.chomp;
bool[26][26] table;
foreach (i; 0 .. s.length)
{
table[s[i]-'a'][t[i]-'a'] = true;
}
bool ok = true;
foreach (i; 0 .. 26)
{
long row, col;
foreach (j; 0 .. 26)
{
if (table[i]... | 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() {
int[] HW = readln.chomp.split.to!(int[]);
int H = HW[0],
... | 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 |
/+ dub.sdl:
name "C"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int h, w;
sc.read(h, w);
int[26] cnt;
int[5] d;
foreach (i; 0..h) {
string... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto xy = readln.split.to!(int[]);
auto X = xy[0];
auto Y = xy[1];
foreach (i; 0..X+1) {
auto j = X-i;
if (i*2 + j*4 == Y) {
writeln("Yes");
retur... | D |
void main(){
switch(_scan()%10){
case 0,1,6,8:
writeln("pon");
break;
case 3:
writeln("bon");
break;
default:
writeln("hon");
}
}
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... | 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.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; }
const long mod = 1_000_000_0... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
string N = readln.chomp;
writeln(N[0] == N[2] ? "Yes" : "No");
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range... | 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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto s=new char[][](n);
foreach(i; 0..n) s[i]=readln.chomp.to!(char[]);
long[char] cnt;
cnt['M']=cnt['A']=cnt['R']=cnt['C']=cnt['H']=0L;
foreach(i; 0..n){
auto c=s[i][0];
if(c in cnt) cnt[c]++;
}
long tot=0;
... | 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;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
void main() {
immutable EPS = 1.0e-10;
string[] input = new string[](8);
while ((input = readln.chomp.split(" ")).length != 0) {
auto points = input.map!(to!double);
auto innerProduct = fabs((poi... | D |
import std.stdio;
import std.array;
import std.conv;
void main(){
string[] input = readln.split;
int A = input[0].to!int;
int B = input[1].to!int;
if(B % A == 0) write(A + B);
else write(B - A);
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum mod = 10L^^9 + 7;
void main() {
auto k = readln.chomp;
int n = k.length.to!int;
int d;
scan(d);
auto dp = new long[][][](n + 1, 2, d);
... | D |
import std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
void main() {
int n = readln.chomp.to!int;
string s = readln.chomp;
int[] rcs = new int[n+1];
int[] gcs = new int[n+1];
int[] bcs = new int[n+1];
long sum = 0;
for(int i=0; i<s.length; i++) {... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;
void main() {
int k, t; scan(k, t);
auto a = readln.split.to!(int[]);
auto amax = a.reduce!max;
auto ans = max(0, amax - (k - amax) - 1);
writeln(ans);
}
void scan(... | D |
void main(){
int[] fares;
foreach(_;0..4){
fares ~= inelm();
}
min( fares[0]+fares[2], fares[0]+fares[3],
fares[1]+fares[2], fares[1]+fares[3])
.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= i... | 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()
{
bool f;
auto s = readln.chomp;
auto prev = 'a';
foreach (e; s... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
auto N = readln.chomp.to!int;
auto AS = readln.split.to!(long[]);
auto ts = new int[](N);
ts[N-1] = 2;
foreach (i; 0..N-1) {
if (AS[i] < AS[i+1]) {... | 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; }
/*
ゲーム
区間DP
------------
... | 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 N = readln.chomp.to!double;
foreach (i; 0..50000+1) {
if ((i * 1.08).to!int == N) {
writeln(i);
return;
}
}
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.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 File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() ... | D |
import std.stdio,std.string,std.conv,std.math;
void main(){
while(1){
string[] arr;
int[] arr2;arr2.length=2;
auto rd = chomp( readln() );
if(rd){
arr = split(rd);
arr2[0] = to!int(arr[0]);
arr2[1] = to!int(arr[1]);
auto sum = to!string(arr2[0] + arr2[1]);
writeln( sum.length );
}else{
brea... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nmc = readln.split.to!(int[]);
auto N = nmc[0];
auto M = nmc[1];
auto C = nmc[2];
auto bs = readln.split.to!(int[]);
int cnt;
foreach (_; 0..N) {
int d;
... | 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.typecons;
import std.algorithm, std.array, std.range, std.container;
void main() {
auto X = readln.split[0].to!int;
writeln(X == 7 || X == 5 || X == 3 ? "YES" : "NO");
}
| 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;
immutable inf = 10^^6;
void main() {
int k;
scan(k);
auto d = new int[](k);
d[] = inf;
d[1] = 1;
auto deq = Deque!(int)(3*k);
deq.pushBack(1... | D |
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;
void main()
{
readln;
auto A = readln.chomp.split.to!(long[]);
A.map!(a => a - 1).sum().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;
void main()
{
readln.chomp.replace(".", "").replace(",", "").split.filter!(a=> a.length >= 3 && a.length <= 6).join(" ")... | D |
void main() {
string[] tmp = readln.split;
string a = tmp[0], b = tmp[1];
writeln(a == b ? "H" : "D");
}
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;
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;
int sum;
foreach (_; 0..n) {
auto l = readln.ch... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
void main() {
int[string] a;
ubyte N = readln.chomp.to!ubyte;
foreach(_; 0..N) {
a[readln.chomp]++;
}
ubyte M = readln.chomp.to!ubyte;
foreach(_; 0..M) {
a[readln.chomp]--;
}
max(a.values.reduce!max, 0).writeln;
} | D |
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
std.typecons, std.math, std.container, std.format, std.traits;
/** Computes the value of a positive integer `x`, raised to the power `n`, modulo `m`.
*
* Params:
* x = base
* n = exponent
* m = modulus
*
* Returns:... | D |
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;
alias lread = () => readln.chomp.to!long;
alias aryread = () => readln.split.to!(long[]);
void main()
{
auto ab = aryread()... | D |
import std.stdio;
import std.string, std.conv;
import std.algorithm, std.array;
import std.typecons;
void main() {
for(;;) {
auto s = readln.split.map!(to!int).array;
int N = s[0], M = s[1];
if(N == 0 && M == 0) break;
if((N * M) % 2 == 0) writeln("yes");
else writeln("no");
}
} | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }
string solve(string s) {
int w = read();
string r;
foreach (i, c; s) if (i % w == 0) r ~= c;
return r;
}
void main() {
... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.