code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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;
}
bool calc(int rows, int cols, int k) {
for (int ... | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
readln;
auto a = Solver(readln.chomp.split.to!(int[]));
immutable q = readln.chomp.to!size_t;
foreach (_; 0..q)
{
auto buf = readln.chomp.split.to!(int[]);
a.query(buf[0], buf[1]).writel... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
foreach(i; 0..n) fun();
}
auto re... | D |
import std.stdio,std.conv,std.algorithm,std.array;
int oneint(){ return readln().split().map!(to!int).array()[0];} //read from stdin as only one int
void main(){ for(int i=1,x;(x = oneint())!=0;i++){ writeln("Case ",i,": ",x); } } | 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;
const mod = 10^^9 + 7;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;
void main()
{
auto n = readln.chomp.to!int;
auto s = readln.chomp;
int r = int.max;
foreach (i; 0..n-3) {
int t;
t += min(abs(s[i] - 39), abs(s[i] - 65), abs(s[i] - 91));
... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.... | 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, int b, ... | D |
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
void main()
{
string s = chomp(readln());
int a = to!int(s); // 第0要素を整数に変換
if(a > 999){
writeln("ABD");
} else {
writeln("ABC");
}
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
if (S == "AAA" || S == "BBB") {
writeln("No");
} else {
writeln("Yes");
}
} | 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 core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
immutable k = readln.chomp.to!long;
enum N = 50;
lon... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto t = readln.split.to!(int[]), s = t.sum;
auto m = readln.chomp.to!size_t;
foreach (_; 0..m) {
auto rd = readln.splitter;
auto p = rd.front.to!size_t-1; rd.popFront();
auto x = rd.fro... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
foreach(i; 0..n) fun();
}
auto re... | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
T lread(T = long)()
{
return readln.chomp.to!T();
}
T[] aryread(T = long)()
{
ret... | D |
import std;
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 h = lread();
func(h).writeln();
}
long func(long h)
{
... | 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 std.algorithm;
import std.conv;
import std.stdio;
import std.string;
import std.math;
void main()
{
auto ab = readln.split.map!( to!int );
auto add = ab[ 0 ] + ab[ 1 ];
auto sub = ab[ 0 ] - ab[ 1 ];
auto mul = ab[ 0 ] * ab[ 1 ];
writeln( max( add, sub, mul ) );
}
| 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 N = readln.split[0].to!int;
auto S = readln.split[0].to!(dchar[]);
ulong[] wnum = [0], bnum = [S.count('#')];
foreach (d; S) {
if (d == '.') wnum ~= wnum[... | D |
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;
import std.math;
void main() {
int n = readln.chomp.to!int;
auto a = readln.chomp.split.map!(to!int).array;
auto m = reduce!(min, max)(a);
if (m[0] == m[1]) {
writeln(0);
}
else if (m[0] >= 0) {
writeln(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum PS = [300000, 200000, 100000];
void main()
{
auto xy = readln.split.to!(int[]);
auto X = xy[0];
auto Y = xy[1];
int r;
if (X <= 3) r += PS[X-1];
if (Y <= 3) r += PS[Y-1];
if (X == 1 ... | D |
/+ dub.sdl:
name "B"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n;
sc.read(n);
int[] p = new int[n];
int[] rp = new int[n];
foreach (i; 0..n)... | D |
import std;
void main(){
auto s = readln.chomp;
if (s == "ABC")
"ARC".writeln;
else
"ABC".writeln;
}
| 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 INF = 1L << 59;
void main() {
auto s = readln.split.map!(to!int);
auto D = s[0];
auto G = s[1].to!... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
void main(){
auto buf = readln.chomp.split.to!(int[]);
swap(buf[0], buf[1]);
swap(buf[0], buf[2]);
foreach(i; buf){
write(i, " ");
}
} | 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;
long INF = long.max/3;
void main() {
in... | D |
module main;
import std.stdio : readln, writeln, write, writefln, writef;
import std.conv : to;
import std.array : split, replace;
import std.string : strip;
import std.algorithm : max, min, map, reduce, sort, reverse;
import std.functional : memoize;
version = A;
version (A)
{
void main()
{
auto seq... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int a, b; rd(a, b);
auto s=readln.chomp.to!(char[]);
if(count(s, '-')!=1){writeln("No"); return;}
if(s[a]=='-') writeln("Yes");
else writeln("No");
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split... | 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.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;
void main(){
writeln( readln().chomp().to!int^^3 );
} | 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;
int[][10^^5] T;
void main()
{
auto N = readln.chomp.to!int;
foreach (b; 1..N) {
auto a = readln.chomp.to!int - 1;
T[a] ~= b;
}
int solve(int i) {
int[] rr;
foreach (j... | D |
import std.stdio, std.string, std.array, std.conv;
struct Card {
char suit, value;
}
void bubble(int n, Card[] x) {
foreach (i; 0 .. n) {
foreach_reverse (j; i+1 .. n) {
if (x[j].value < x[j-1].value) {
Card t = x[j];
x[j] = x[j-1];
x[j-1] = ... | D |
import std.stdio, std.conv, std.algorithm, std.string;
alias L = long;
L M = 998244353;
L[] X;
L[L] C;
L h(L m, L[] U){
L f;
foreach(u; U[0 .. m]) f = f * 2 % M + u;
foreach(i, u; U) if(i / m & 1 ^ U[i % m] ^ u) return f + u;
return f + 1;
}
void main(){
L n = readln.chomp.to!L, b = n * 2;
foreach(c; readln.chomp... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration;
void main()
{
immutable nm = readln.chomp.split(" ").map!(to!int).array;
immutable n = nm[0];
immutable m = nm[1];
string[] a;
a.length = n;
foreach(i; 0..n)
a[i] = readln.chomp;
string[] b;
b.length =... | D |
import std.stdio, std.string, std.array, std.conv;
long cnt;
int[] y;
void insertionSort(int n, int g, int[] x) {
foreach (i; g .. n) {
int v = x[i];
int j = i - g;
while (j >= 0 && x[j] > v) {
x[j+g] = x[j];
j -= g;
++cnt;
}
x[j+g] = v;
... | 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 std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp;
int X;
foreach (c; N.to!(char[])) X += c-48;
writeln(N.to!int % X == 0 ? "Yes" : "No");
} | 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 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;
alias M = Tuple!(int, "t", int, "d");
int[10^^5*2] TS;
M[10^^5*2] QS;
void main()
{
auto nq = readln.split.to!(int[]);
auto N = nq[0];
auto Q = nq[1];
foreach (int i, c; readln.chomp.to!... | 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 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.range, std.algorithm;
void main() {
string s = strip(readln());
size_t n = s.length;
auto odd = filter!(a => a%2 == 0)(iota(n));
foreach (c; map!(i => s[i])(odd)) {
write(c);
}
writeln();
}
| D |
void main() {
problem();
}
void problem() {
auto a = scan!long;
long solve() {
return a + a*a + a*a*a;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typ... | D |
import std.algorithm,
std.string,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
int[] g1 = [1,3,5,7,8,10,12],
g2 = [4,6,9,11],
g3 = [2];
int[] xy = readln.chomp.split.to!(int[]);
int x = xy[0],
y = xy[1];
bool found;
foreach (g; [g1, g2, g... | D |
void main(){
int n = _scan();
if(n>81){
writeln("No");
return;
}
foreach(i; 1..81+1){
if(i<=9 && n/i<=9 && n%i==0){
writeln("Yes");
return;
}
}
writeln("No");
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( readln().cho... | D |
void main() {
(ri / 3).writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
imp... | 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.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 mod = 10L^^9 + 7;
void main() {
int h, w, a, b;
scan(h, w, a, b);
auto fact = new long[](h + w + 1);
auto rfact = new long[... | 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;
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 k = lread();
long ans = 1;
foreac... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto AS = new int[](2^^N);
foreach (i; 0..2^^N) {
AS[i] = readln.chomp.to!int;
}
while (AS.length > 1) {
int[] NAS;
for (int i;... | D |
import std.stdio, std.string, std.conv, std.algorithm;
void main() {
int[] tmp = readln.split.to!(int[]);
int h = tmp[0], w = tmp[1];
string[] grid = new string[h];
foreach (i; 0 .. h) {
string s = readln.chomp;
grid[i] = s;
}
int[][] a = new int[][](h, w);
foreach (i; 0 .. ... | 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.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 M = s[1];
auto G = new Tuple!(int, i... | D |
void main() {
string s = readln.chomp;
int n = s.to!int;
int fx;
foreach (x; s) {
fx += x - '0';
}
writeln(n % fx == 0 ? "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;
... | D |
void main() {
auto S = rs;
long res;
res += S.count!(a => a == '+');
res -= S.count!(a => a == '-');
res.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import... | 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[] lreads(T = long)(long n){ret... | 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 A = new long[][](N, N);
foreach (i; 0..N) {
foreach (j, a; readln.split.to!(long[])) {
A[i][j] = a;
}
}
foreach (k; 0.... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
void main() {
string str = readln.chomp;
string[2] ss = ["eraser", "dreamer"];
// array.lengthの返り値の型はulongなので
// intに代入しようとすると(dmd64 v2.070.1では)CEになる
int p = str.length.to!int;
while (p > 0) {
bool flag = fa... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
string my_readln() { return chomp(readln()); }
long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mo... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto tmp = readln.split.to!(long[]);
writeln(tmp.all!(t => t < 10) ? tmp[0] * tmp[1] : -1);
}
| D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(size_t[]), n = rd[0], t = rd[1];
auto a = readln.split.to!(int[]);
auto b = new int[](n-1), m = a[0];
foreach (i; 0..n-1) {
b[i] = a[i+1] - m;
m = min(m, a[i+1]);
}
auto c = b.reduce!max;
... | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
void main(){
auto a = readln.split.map!(to!int);
int n = a[0];
int m = a[1];
int c;
int cnt,gomi;
for(uint i;i<m;++i){
auto b = readln.split.map!(to!int);
c = b[0];
if(c<n){
cnt += n-c;
if(n-c>gomi) gomi = n-c;
}
}
writeln(cnt-gom... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.range, std.typecons;
void main() {
auto S = readln.split.to!(ulong[]);
auto N = S[0], A = S[1], B = S[2];
auto X = readln.split.to!(ulong[]);
ulong res = 0;
foreach (i; 0..N-1) {
res += min((X[i+1] - X[i]) * A, B);
}
writeln... | 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.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
bool calc(long a, long b, long c) {
if (c - a - b <= 0) return false;
return 4 * a * b < (c - a - b) ^^ 2;
}
void main... | 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 a; readV(a);
string b; re... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;
T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.cho... | D |
void main()
{
dchar[] s = rdDchar;
dchar[] t;
foreach_reverse (x; s)
{
if (x == 'b') t ~= 'd';
if (x == 'd') t ~= 'b';
if (x == 'p') t ~= 'q';
if (x == 'q') t ~= 'p';
}
writeln(s == t ? "Yes" : "No");
}
enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum... | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
void main() {
int x;
scan(x);
x -= 400;
auto ans = 8 - (x / 200);
writeln(ans);
}
void scan(T...)(ref T args) {
auto line = rea... | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
void main() {
const MAX = 1000000;
auto budget = readln.chomp.to!int;
auto hasuu = budget % 100;
int purchasedCount;
while(hasuu > 0) {
if (hasuu < 5) {
purchasedCo... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.numeric;
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... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
const dx = [-1, 0, 1, -1, 1, -1, 0, 1];
const dy = [-1, -1, -1, 0, 0, 1, 1, 1];
void main() {
auto ip = readln.split.to!(int[]), H = ip[0], W = ip[1];
char[][] S;
foreach(_; 0..H) S ~= readln.chomp.dup;
... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons;
immutable int inf = 10^^9 + 7;
int n;
void main() {
scan(n);
long ans = 10L^^5;
foreach (i ; 0 .. n) {
ans = (ans * 105) / 100;
ans = ((ans + 999) / 1000) * 1000;
}
write... | 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 a = readNum!int;
writeln(a^^3);
}
| 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.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; }
void main(){
int n = read... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto hw = readln.split.to!(int[]);
auto h = hw[0];
auto w = hw[1];
auto ret = "";
foreach (_; 0..(w+1)) ret ~= "#";
ret ~= "#\n";
foreach (_; 0..h) {
ret ~= "#";
ret ~= readln.chomp;
r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nt = readln.split.to!(long[]);
auto N = nt[0];
auto T = nt[1];
auto ts = readln.split.to!(long[]);
ts ~= long.max;
long st;
foreach (i; 0..N) st += min(T, ts[i+1] - ts[i... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long a = tmp[0], b = tmp[1];
writeln(a * b / gcd(a, b));
}
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;
im... | 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, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int n;
scan(n);
auto a = readln.split.to!(int[]);
auto cnt = new int[](10^^5 + 10);
int over;
foreach (ai ; a) {
if (ai > ... | 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, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto a = new int[](n), b = new bool[](n);
foreach (i; 0..n) a[i] = readln.chomp.to!int-1;
auto c = 0, d = 0;
for (;;) {
++d;
b[c] = true;
c = a[c];
if (c == 1) {
writeln(d);... | 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() { // 日本語文字列のテスト
int w = readint;
... | 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.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math;
struct LazySegTree(alias opt, alias opu, alias _add, alias mul, alias E, alias F, T, U)
if (is(typeof(E) : T))
{
import std.functional : binaryFun;
alias OPT = binaryFun!opt;
alias OPU = binaryFun!opu;
... | D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | 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);
long ans = 1;
foreach (i ; 0 .. n) {
long t;
scan(t);
ans = lcm(ans, t);
}
writ... | 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;
import std.traits;
struct Input
{
int n, k;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
auto ar = readln().strip().split().map!(to!int).... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
struct Spl{auto r="".splitter;auto rd(){r=readln.splitter;}auto bd(T)(ref T t){t=r.front.to!T;r.popFront;}}
auto _s = Spl();
auto getV(T...)(ref T t){foreach(ref u;t)_s.bd(u);}
auto getA(T)(size_t n,ref T t){t=new ... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
import std.array;
int n;
rd(n);
auto a = readln.split
.to!(int[])
.map!((e) => (e - 1))
.array;
int num = 0;
foreach (i; 0 .. (n - 1)) {
if (i == a[i]) {
num++;
swap(a[i], a[i + 1]);
}
}
if (a[n - 1]... | D |
import std.stdio, std.algorithm, std.range, std.array, std.conv, std.string, std.math, std.container, std.typecons;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.to!(int[]);
auto B = readln.split.to!(int[]);
N.iota.map!(i => A[0..i+1].sum + B[i..$].sum).reduce!max.writeln;
}
| D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n, m;
rd(n, m);
int[] a;
for (int i = 2; i * i <= m; i++) {
if (m % i == 0) {
int cnt = 0;
while (m % i == 0) {
cnt++;
m /= i;
}
a ~= cnt;
}
}
if (m > 1) {
a ~= 1;
}
const lo... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.