code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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 = 998244353L;
void main() {
int n;
scan(n);
auto f = new long[](n + 1);
f[0] = f[1] = 1;
foreach (i ; 2 .. n + 1) {
f[i] = f[... | D |
import std.stdio, std.conv, std.math, std.string, std.range, std.array,
std.algorithm;
bool checkgood(char[][] a, int shift) {
size_t n(size_t x) {
return x % a.length;
}
for (size_t i = 0; i < a.length; ++i) {
for (size_t j = i+1; j < a[0].length; ++j) {
if(a[n(i + shif... | 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;
void main() {
auto n = to!int(readln().strip());
while(n > 0){
string[] s;
for(int i; i < n; ++i){
s ~= readln().chomp();
}
int[][] yoko = new int[][](n+1,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;
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() {
readi... | D |
// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio, std.string, std.conv, std.algorithm;
T[] getVals(T)() { return to!(T[])(readln().chomp().split(" ")); }
void main() {
auto nk = getVals!(int)();
auto n = nk[0], k = nk[1];
auto xs = getVals!(int)();
auto candies = 0, present = 0;
... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.range;
void main() {
auto N = readln.split[0].to!int;
auto s = new string[N];
foreach(i; 0..N) {
s[i] = readln.split[0];
}
auto bucket = new int[26][N];
foreach(i; 0..N) {
foreach(c; s[i]) {
bucket[i][c - 'a']++;
}
}... | D |
import std.stdio;
import std.string;
void main() {
string s = readln.chomp;
long a = s.indexOf('A');
long z = s.lastIndexOf('Z');
writeln(z - a + 1);
}
| 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() {
while (true) {
int n;
scan(n);
if (n == 0) return;
solve(n);
}
}
void solve(int n) {
int l=1, r=1;
int v;
... | 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() {
while (true) {
int n, r;
scan(n, r);
if (n == 0 && r == 0) return;
auto a = iota(1, n + 1).retro.array;
foreac... | 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 |
void main() {
int[] abc = readln.split.to!(int[]);
writeln(abc.count(5) == 2 && abc.count(7) == 1 ? "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;
im... | 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() {
string s, t;
scan(s);
scan(t);
auto n = s.length;
int ans;
foreach (i; 0 .. n) {
ans += s[i] != t[i];
... | D |
void main() {
auto X = ri, A = ri, B = ri;
X -= A;
(X % B).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;... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nx = readln.split.to!(int[]);
auto N = nx[0];
auto X = nx[1];
int min_m = int.max;
foreach (_; 0..N) {
auto m = readln.chomp.to!int;
X -= m;
min_m = min(... | 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 data = readln.split;
auto N = data[0].to!int, M = data[1].to!int;
auto D = M / N;
if (D == 1) { writeln(1); return; }
foreach_reverse (i; 1 .. D+1) {
if (M%... | D |
void main() {
auto S = rs, T = rs;
S ~= S;
if(S.canFind(T)) writeln("Yes");
else writeln("No");
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
im... | D |
// Vicfred
// https://atcoder.jp/contests/abc175/tasks/abc175_a
// implementation
import std.stdio;
import std.string;
void main() {
string S = readln.strip;
if(S.count("RRR") == 1) {
3.writeln;
return;
} else if(S.count("RR") == 1) {
2.writeln;
return;
} else if(S.count... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;
string FMT_F = "%.10f";
T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.t... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
enum MOD = 1000000007;
ulong _c(ulong n, ulong k) {
if(k == 0 || k == n) return 1;
if(k < 0 || n < k) return 0;
return (c(n-1, k) + c(n-1, k-1)) % MOD;
}
alias c = memoize!_c;
void main()... | D |
import std.stdio;
void main()
{
foreach(i; 1 .. 10)
{
foreach(j; 1 .. 10)
{
printf("%dx%d=%d\n",i,j,i*j);
}
}
} | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
int a, b; readV(a, b);
writeln((... | 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, dcomp.algorithm;
import std.container.rbtree;
int main() {
auto sc = new Scanner(stdin);
bool ans;
scope(exit) {
if (ans) writeln("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 = "%.15f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
void main() {
(ri.to!real.sqrt.floor ^^ 2).to!int.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
imp... | 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.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 solve(){
foreach(_; 0 .. scan!int){
int n = scan!int, m = scan!int;
int rb = scan!int - 1, cb = scan!int - 1;
int rd = scan!int - 1, cd = scan!int - 1;
int high = n + m;
int ans = high;
if(rd >= rb) ans.mini(rd - rb);
else ans.mini(n - 1 - rb + n - 1 - rd);
if(cd >= cb) ans.mini(cd - cb);
... | 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;
void main() {
auto S = readln.chomp;
if (S.canFind("ABC") ||
S.canFind("ACB") |... | 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.math;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.range;
import std.file;
import std.datetime;
void main()
{
int elemanSayısı = stdin.readln.strip.to!int;
string harfler = stdin.readln.strip.to!string;
int enBüyükIndeksi = 0;
char enB... | 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 |
//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;
void main() {
auto s = readln.stripRight;
int[26] c;
long[26][26] d;
foreach (ch; s) {
int i = ch.to!int - 97;... | 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.math;
void main()
{
int n, t;
scanf("%d%d", &n, &t);
printf("%.10f\n", n * pow(1.000000011, 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.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;
long a, b, c, d;
scan(n, a, b, c, d... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nmk = readln.split.to!(int[]);
auto N = nmk[0];
auto M = nmk[1];
auto K = nmk[2];
foreach (y; 0..N+1) {
auto b = 2*y - N;
if (b == 0) {
if (N*M == 2... | 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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto t = 1L, a = 1L;
foreach (_; 0..n) {
auto rd = readln.split.to!(long[]), ti = rd[0], ai = rd[1];
auto k = max((t+ti-1)/ti, (a+ai-1)/ai);
t = k*ti;
a = k*ai;
}
writeln(t+a);
}... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;
void main() {
(rs.uniq.array.length - 1).writeln;
}
// ===================================
T readAs(T)() if (isBasicType!T) {
return readln.chomp.t... | 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;
enum inf = 10^^9;
void main() {
string s;
scan(s);
auto n = s.length.to!int;
auto dp = new long[][](n + 1, 4);
dp[0][0]... | 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;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void main() {
int[] cs = new int[10^^5+... | 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 s... | D |
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
void main()
{
auto input = readln.split;
auto X = input[0];
auto Y = input[1];
(X < Y ? "<" : X > Y ? ">" : "=").writeln;
} | D |
import std.stdio;
import std.conv;
import std.string;
void main() {
auto n = readln.chomp.to!int;
string[] words = [];
auto ans = "Yes";
foreach (i; 0..n) {
auto word = readln.chomp;
foreach (w; words) {
if (w == word){
"No".writeln;
return;
... | 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, 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.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;
void main(){
auto as=readln.chomp.array;
auto bs=readln.chomp.array;
auto cs=readln.chomp.array;
auto turn=0;
while(true){
... | 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.conv : to;
import std.stdio;
import std.string : strip;
void main() {
int n = to!int(strip(stdin.readln()));
string sequence = strip(stdin.readln());
char last_symbol = sequence[0];
int length = 1;
for (auto i = 1; i < sequence.length; ++i) {
if (sequence[i] != last_symbol) {
++length;
last_... | D |
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.... | D |
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;
void main() {
auto s = readln.chomp;
long m;
foreach (e;s) {
m += cast(int)(e - '0');
}
if (m % 9 == 0) {
writeln("Yes");
} else {
writeln("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 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; readV(a, b);
writeln([... | 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;
struct Queue(T) {
private {
size_t cap, head, tail;
T[] data;
... | 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;
import std.typecons;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
buffer = uninitializedArray!(ubyte[])(16<<20);
p = stdin.rawRead ... | 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;
}
bool isParallel(Vec2 a, Vec2 b, Vec2 c, Vec2 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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
for (;;) {
auto s = readln.chomp;
if (s == "-") break;
auto m = readln.chomp.to!size_t;
auto hi = m.iota.map!(_ => readln.chomp.to!int);
foreach (h; hi)
s = s[h..$] ~ s[0..h];
writeln(s);
}
} | D |
void main(){
_scan();
int[] a = _scanln();
int ans_bit;
foreach(elm; a)ans_bit = elm|ans_bit;
int cnt;
while( (ans_bit&1) == 0){
cnt++;
ans_bit = ans_bit >> 1;
}
cnt.writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( re... | 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.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
bool[] seen, finished;
int pos = -1;
int[] hist;
void dfs... | 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;
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()
{
long a, b, c;
scan(a, b, c);
foreach (i; 1 .. 10 ^^ 6)
{... | D |
void main(){
auto SW = readLine!size_t();
if( SW[0] <= SW[1] ){
writeln("unsafe");
} else {
writeln("safe");
}
}
import std.stdio, std.string, std.conv;
import std.math, std.algorithm, std.array;
import std.regex;
T[] readLine( T = size_t )( string sp = " " ){
T[] ol;
foreach( string elm ; readln().cho... | 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.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;
void main()
{
long[] a = readln.chomp.split(" ").to!(long[]);
auto n = a[0];
auto k = a[1];
auto m = n % k;
if (m != 0)
{
writeln(1);
}
else
{
... | D |
void main()
{
string s = readln.chomp;
int[string] week;
week["SAT"] = 1;
week["FRI"] = 2;
week["THU"] = 3;
week["WED"] = 4;
week["TUE"] = 5;
week["MON"] = 6;
week["SUN"] = 7;
week[s].writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
int s_n(int n) {
int sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
void main() {
int n = readln.chomp.to!(int);
writeln((n % s_n(n) == 0) ? "Yes" : "No");
} | 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[]);
int[char] memo;
foreach (c; S) {
if (c !in memo) memo[c] = 0;
++memo[c];
}
foreach (k, v; memo) {
if (v != 2) {
... | 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.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;
import std.array;
import std.algorithm;
import std.range;
void main(){
auto A=readln.split.to!(int[]),a=A[0],b=A[1];
if(a+b<10)writeln(a+b);
else writeln("error");
} | 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.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 calc(string[] g) {... | 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;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
foreach(i... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], i = tmp[1];
writeln(n - i + 1);
}
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 |
import std.stdio;
void main() {
string s = readln;
if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
writeln("Yes");
} else {
writeln("No");
}
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto whn = readln.split.map!(to!int);
auto w = whn[0];
auto h = whn[1];
auto n = whn[2];
int t = h, b = 0, l = 0, r = w;
foreach (_; 0..n) {
auto xya = readln.split.map!(to!int);
auto x = xya[0];
... | D |
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
import std.math;
import std.algorithm;
void main()
{
string a = chomp(readln());
string b = chomp(readln());
int N = to!int(a); // 第0要素を整数に変換
int K = to!int(b); // 第1要素を整数に変換
int ans = 1;
for(int i=0;i<N;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;
void main()
{
auto n = readln.chomp.to!int;
auto t = readln.chomp.split.map!(to!int);
auto a = r... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto color=new char[](n*2), a=new int[](n*2);
auto pos_w=new int[](n*2), pos_b=new int[](n*2);
fill(pos_w, -1); fill(pos_b, -1);
foreach(i; 0..(n*2)){
rd(color[i], a[i]); a[i]--;
if(color[i]=='W') pos_w[a[i]]=i;
... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.math;
void main() {
int N = readln.chomp.to!int;
auto a = readln.chomp.split.map!(to!int).array;
int odd;
for (int i = 0; i < N; ++i) {
if (a[i] % 2 == 1) {
odd++;
}
}
if (odd % 2 == 1 ... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
foreach(s;stdin.byLine())
{
string t;
for(int i=0; i<s.length; ++i)
if(s[i]!='@') t~=s[i];
else t~=s[i+2].repeat().take(s[i+1]-'0').array(),i+=2;
writeln(t);
}
} | D |
void main()
{
string s = rdStr;
long k = rdElem;
long idx;
foreach (i, x; s)
{
if (x != '1')
{
idx = i;
break;
}
}
writeln(idx >= k ? s[0] : s[idx]);
}
enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;
T rdElem... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int x1 = tmp[0], y1 = tmp[1], x2 = tmp[2], y2 = tmp[3];
int xdiff = x2 - x1, ydiff = y2 - y1;
int x3 = x2 - ydiff, y3 = y2 + xdiff;
int x4 = x1 - ydiff, y4 = y1 + xdiff;
writeln(x3, " ", y3, " ", x4, " ", y4);
}
import std.stdio;
import std.str... | D |
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
void main(){
auto S = readln.chomp.to!(char[]);
int count;
foreach(i; 0..4){
if(S[i] == '+') count++;
else count--;
}
writeln(count);
} | 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;
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 x = readln.chomp.split.to!(int[]);
if (x[0] > 8 || x[1] > 8) {
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;
import std.bigint;
import std.numeric;
void main()
{
auto s = readln.chomp;
auto p = ["dreamer", "dream", "eraser", ... | 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.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const N = readln.chomp.to!int;
const ls = readln.split.to!(int[]);
const lsum = ls.sum;
writeln(ls.all!(l => l * 2 < lsum) ? "Yes" : "No");
}
| D |
void main()
{
string s = rdStr;
string now;
string bef;
long cnt;
foreach (x; s)
{
now ~= x;
if (now != bef)
{
bef = now;
now = "";
++cnt;
}
}
cnt.writeln;
}
T rdElem(T = long)()
{
//import std.stdio : readln;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto S = readln.chomp;
int r;
foreach (i; 0..1000) {
auto a = i/100;
auto b = (i/10)%10;
auto c = i%10;
int d;
fore... | D |
import
std.algorithm,
std.array,
std.conv,
std.functional,
std.stdio,
std.string;
void main()
{
auto b = readln.chomp.split.to!(int[]);
auto arr = readln.chomp.split.to!(int[]);
solve(b[1], b[2], arr).writeln;
}
int[] cards;
int _solveX(in int y, in size_t p)
{
int answer = abd... | 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 scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primiti... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.