code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
readln;
long r;
foreach (a; readln.split.to!(long[])) r += a-1;
writeln(r);
} | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
int[] input = readln.split.to!(int[]);
int k = input[0];
int s = input[1];
long ans = 0;
foreach_reverse (i; 0..k + 1) {
foreach_reverse (j; 0..k + 1) {
auto tmp = s - i - j;
if (tmp <= k && tmp >= ... | 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 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;
// }}}
// nep.scanner {{{
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
import ... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.range;
auto s=readln.chomp.to!(char[]);
int[char] cnt;
foreach(c; s){
if(!(c in cnt)) cnt[c]=1;
}
auto mi=s.length;
foreach(tg; cnt.keys){
int i=-1, j;
int r=0;
while(j<s.length){
if(s[j]==tg){
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
int n;
foreach (c; readln.chomp) if (c == '2') ++n;
writeln(n);
} | D |
import std.stdio, std.array, std.conv, std.string;
void main() {
while (true) {
string[] input = split(readln());
if (input[1] == "?") break;
writeln(calc(input));
}
}
int calc(string[] s) {
int a = to!int(s[0]), b = to!int(s[2]);
string op = s[1];
if (op == "+") return a + b;
if (op == "-")... | D |
void main()
{
auto io = new IO();
auto N = io.line!size_t()[0];
auto input = io.line!size_t();
size_t pair = 0;
foreach( i,v ; input ){
if( i<v-1 && i==input[v-1]-1 ){
pair++;
}
}
writeln(pair);
}
import std.stdio,std.string,std.conv;
class IO
{
string str( size_t lines = 1 )
{
return readln()... | 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;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto A=readln.chomp;
writeln(A.count('1'));
} | D |
import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;
void main(){
int sScore = 0; int tScore = 0;
string[] sInput = readln().split();
string[] tInput = readln().split();
foreach(string s; sInput){
sScore += s.to!int();
}
foreach(string s; tInput)... | D |
import std.stdio, std.array, std.conv, std.string, std.algorithm, std.math;
void main() {
auto n = readln.chomp.to!int;
auto a = readln.chomp.split;
for (int i = n - 1; i >= 0; i--) {
write(a[i]);
if (i != 0) { write(" "); }
}
writeln;
} | 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;
auto DP = new int[][](N.length+1, 2);
DP[0][0] = 0;
DP[0][1] = 1;
foreach (i; 0..N.length) {
auto n = (N[i] - '0').to!int;
... | D |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
class BIT {
int[] data;
this(int n) {
data = new int[n+1];
}
BIT dup() {
BIT ret = new BIT(to!int(data.length));
ret.data = data.dup;
return ... | 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() {
char a;
scan(a);
writeln('a' <= a && a <= 'z' ? 'a' : 'A');
}
void scan(T...)(ref T args) {
auto line = readln.split; // ... | 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, std.algorithm;
void main() {
auto w = readln.chomp;
int[char] char_count;
auto beautiful = true;
foreach (c; w) {
char_count[c]++;
}
if (char_count.values.all!"a % 2 == 0") {
"Yes".writeln;
} else {
"No".writeln;
}
}
| 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.algorithm;
import std.array;
import std.conv;
import std.stdio;
void main()
{
long[] n_and_k;
long n;
long k;
n_and_k = readln.split.to!(long[]);
n = n_and_k[0];
k = n_and_k[1];
writeln(min(n % k, k - n % k));
}
| D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto n = sread();
long sum_n;
foreach (i; 0 .. n.length)
{
// writeln(n[i] - '0');
sum_n += (n[i] - '0');
}
// write... | D |
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;
void main(){
while(true){
long n = to!long(chomp(readln()));
if(n == 0) break;
long[] a;
a ~= 0;
a ~= to!long(chomp(readln()));
for(long i=1;i<n;i++){
a ~= a[i] + to!long(chomp(readln()));
}... | 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;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
long n = read.to!long;
... | 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 = 10L^^15;
void main() {
int n, w;
scan(n, w);
auto ws = new int[](n);
auto v = new int[](n);
int vs;
foreach (i ; 0 .. n) {
... | D |
/* imports all std modules {{{*/
import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.encoding,
std.exception,
std.file,
std.format,
std.functi... | 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, a, b; readV(x, a, b);
if... | 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], c = rd[2];
writeln(b-a == c-b ? "YES" : "NO");
}
| 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;
auto c = new char[](s.length);
int index;
foreach (i; 0..... | 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 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.algorithm;
void main() {
auto p = new long[2001];
foreach (i; 0 .. 1001) foreach (j; 0 .. 1001)
p[i + j]++;
while (true) {
if (stdin.eof) break;
int N; scanf("%d\n", &N);
long ans;
foreach (i; 0 .. min(N, 2000) + 1) if (0 <= N - i && N - i <= 20... | 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 |
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 a;
int b;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
a = readln().strip().to!int;
b = readln().strip().to!int;
}... | 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 h, w; scan(h, w);
if (h == 1 && w == 1) {
writeln("No");
return;
}
auto ban = new char[][](h, w);
iota(h).e... | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
string[] buf;
int w,h;
buf = split(readln());
w = to!(int)(buf[0]);
h = to!(int)(buf[1]);
writeln(w*h,' ',2*w+2*h);
} | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.math;
void main(){
int n = readln.chomp.to!int;
int[] tmp = readln.chomp.split.map!(to!int).array;
int t = tmp[0], a = tmp[1];
int[] hs = readln.chomp.split.map!(to!int).array;
real f(int x){
return abs(a.to!real - (t.to!real - x.to!real * ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nhw = readln.split.to!(int[]);
auto N = nhw[0];
auto H = nhw[1];
auto W = nhw[2];
int r;
foreach (_; 0..N) {
auto ab = readln.split.to!(int[]);
if (ab[0] >=... | D |
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;
void main()
{
auto s = readln.... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int h, w, k;
rd(h, w, k);
const int mod = 10 ^^ 9 + 7;
auto dp = new int[](w);
dp[0] = 1;
foreach (_; 0 .. h) {
auto nex = new int[](w);
foreach (bit; 0 .. (1 << (w - 1))) {
if (bit & (bit >> 1))
continue;
f... | D |
import std.stdio;
import std.math;
void main()
{
int n, m;
int[] a, b;
scanf("%d %d", &n, &m);
a.length = n;
b.length = m;
foreach (i; 0 .. n) scanf("%d", &a[i]);
foreach (i; 0 .. m) scanf("%d", &b[i]);
int result;
while (b.length) {
if (a.length == 0) break;
if (b[0] < a[0]) {
b = b[1..$];
} else {
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
void main() {
string input = readln.chomp;
switch(input) {
case "1 0 ... | 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 x = readln.chomp.to!long;
auto t = x % 11;
auto res = (x... | 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;
string S;
scan(N);
s... | 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.conv, std.stdio, std.algorithm, std.string, std.range, std.math;
void main() {
readln;
const S = readln.chomp;
S.uniq.count.writeln;
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
bool[1000001] MEMO;
void main()
{
auto s = readln.chomp.to!int;
int i;
for (;;) {
++i;
if (MEMO[s]) {
writeln(i);
return;
}
MEMO[s] = true;
... | D |
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.chomp.to!int;
writeln(N^^2 - A);
}
| D |
void main()
{
dchar[] s = rdDchar;
dchar[] t = rdDchar;
long len = s.length;
foreach (i; 0 .. len)
{
if (s == t)
{
"Yes".writeln;
return;
}
s = s[$-1] ~ s[0..$-1];
}
"No".writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n;
rd(n);
auto a = readln.split.to!(int[]);
long ans = 0;
for (int i = 0, j = 0, s = 0; i < n; s ^= a[i++]) {
while (j < n && ((s & a[j]) == 0)) {
s ^= a[j++];
ans += (j - i);
}
}
writeln(ans);
}
void rd(T...... | D |
import std.stdio;
void main(){
for(int x=1;x<10;x++){for(int y=1;y<10;y++){
writeln(x,"x",y,"=",x*y);
}}
} | D |
import std.stdio;
import std.string;
import std.algorithm;
void main() {
foreach (input; stdin.byLine) {
// 勝敗を判定
string result = judge(input.chomp);
// 結果を出力
result.writeln;
}
}
string judge(char[] banmen) {
// 勝ち筋
auto combs = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
while(true){
auto s1 = readln();
if(stdin.eof()) break;
auto s = split(s1);
int a = to!int(s[0]);
int b = to!int(s[1]);
int oth = to!int(s[2]);
int[11] cards;
cards = 0;
cards[a]--;
cards[b]--;
car... | 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, 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 n; readV(n);
string s; readV... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void main()
{
int n; readV(n);
writeln(n.nsqrt^^2);
}
pure T nsqrt(T)(T n)
{
import std.algorithm, st... | 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!long;
long r;
foreach (a; 1..N) {
auto b = N/a;
r += b - (N%a == 0 ? 1 : 0);
}
writeln(r);
} | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.math;
void main(){
writeln("Odd");
}
| 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.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.bigint, std.string;
void main() {
int n;
scanf("%d", &n);
int[] a = new int[n];
for(int i = 0; i<n; i++) {
scanf("%d", &a[i]);
}
int [] b= new int[n];
for (int i =0; i < n; ++i) {
b[i] = -1;
}
b[0] = a[0];
int c = 1;
int i = 1;
while (i < n) {
c +=1;
b[c-1] = a[... | 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, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int n;
scan(n);
int ans;
int set = (1<<26) - 1;
bool safe;
foreach (i ; 0 .. n-1) {
char e;
string s;
scan(... | D |
import std.stdio, std.conv, std.string;
void main() {
int n,m,k;
scanf("%d %d %d", &n, &m, &k);
foreach (i;0..(m+1)) {
foreach (j;0..(n+1)) {
auto a = n*i + (m-2*i)*j;
if (a == k) { writeln("Yes"); return; }
}
}
writeln("No");
}
| D |
import std.stdio; // ??\????????????????????????
import std.string; // chomp????????????????????????(?????????????????????)
import std.conv; // to????????????????????????
import std.array; // split?????????????????????
import std.algorithm; // map?????????????????????
void main() {
uint i = 1;
while (true) {... | 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;
auto N = S.length.to!int;
auto dp = new long... | D |
void main(){
int[] atox;
int cnt;
foreach(i; 0..4)atox ~= _scan();
for(int an; an<=atox[0]; an++){
for(int bn; bn<=atox[1]; bn++){
for(int cn; cn<=atox[2]; cn++){
if(500*an+100*bn+50*cn==atox[3])cnt++;
}
}
}
cnt.writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.ma... | 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.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 core.stdc.stdio;
import std.algorithm;
char[][] mapdata;
bool[] visited;
int[3][] queue;
int w,h,n;
int len(int[2] p1,int[2] p2){
visited[] = false;
queue[0]=[p1[0],p1[1],0];
visited[p1[0]*w+p1[1]] = true;
int[] dx = [0,-1,0,1];
int[] dy = [-1,0,1,0];
int qc=1;
for(int i=0;i<w*h;i++){
int y=queu... | 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 cs = [6,36,216,1296,7776,46656,279936,9,81,729,6561,59049,531441];
void main()
{
auto N = readln.chomp.to!int;
auto DP = new int[][](cs.length, N+1);
foreach (ref dp; DP) dp[] = -1;
int solve(i... | D |
import std.stdio;
import std.string;
import std.array;
import std.range;
import std.algorithm;
import std.conv;
void main(string[] args) {
auto input = readln().chomp.split.map!(to!int);
max(input[0]+input[1],input[0]-input[1],input[0]*input[1]).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;
enum mod = 1_000_000_007L;
void main() {
int N, T;
scan(N, T);
auto a =... | D |
import std.stdio,std.string,std.array,std.algorithm,std.range,std.conv;
import std.algorithm:rev=reverse;
void main(){
auto input=readln.chomp.split.to!(int[]);
auto n=input[0];
auto m=input[1];
auto result=n*(n-1)/2;
result+=m*(m-1)/2;
result.writeln;
} | 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;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
// 1*2*3*4*5*6 == 2^^4 * 3^^2 * 5
// 1*
// 2*
// 3*
// 2*2*
// 5*
// 2*3
auto n = lread();
long[long] aa;
foreach (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.format;
void main()
{
auto D = readln.chomp.to!int;
sw... | D |
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;
void main()
{
while (true) {
auto rd = readln.split.map!(to!int);
auto h = rd[0], w = rd[1];
if (h == 0 && w ==... | D |
// Vicfred
// https://atcoder.jp/contests/abc136/tasks/abc136_c
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main() {
const long n = readln.chomp.to!long;
long[] h = readln.split.map!(to!long).array;
long maxima = h[0] - 1;
foreach(square; h) {
... | 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;
writeln(N%2 == 0 ? N : N*2);
} | D |
import std.stdio;
import std.conv;
import std.string;
void main() {
int x = readln.chomp.to!int;
writeln(x * x * x);
} | 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;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
n = readln().strip().to!int;
}
}
auto main2(Input... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
int cnt;
void InsertionSort(int[] arr, int n, int g){
for(int i = g; i < n; ++i){
int v = arr[i];
int j = i - g;
while (j >= 0 && arr[j] > v){
arr[j+g] = arr[j];
j -= g;
++cnt;
}
arr[j+g] = v;
}
}
void ShellSort(int[] ar... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
auto s = chomp(readln());
char[] ss;
for(int i=0;i<s.length;i++){
ss ~= s[i];
}
for(int i=0;i<s.length-4;i++){
if(ss[i]=='a'&&ss[i+1]=='p'&&ss[i+2]=='p'&&ss[i+3]=='l'&&ss[i+4]=='e'){
ss... | 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;
void main() {
int n;
scan(n);
foreach (i ; 0 .. 100) {
foreach (j ; 0 .. 100) {
if (4*i + 7*j == n) {
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 std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main()
{
int n = readln.chomp.to!int;
string s = readln.chomp;
int leftW = 0;
int rightE = 0;
foreach (c; s) {
if (c == 'E') {
++rightE;
}
}
int ans = int.max;
foreach (c; s) {
if (c == 'E') {
--rig... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.algorithm, 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, b, c; readV(a, b, c);
... | 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.ascii;
import std.concurrency;
import std.traits;
import... | D |
void main(){
auto ABCD = readLine!long();
foreach( i ; 0..102 ){
ABCD[2] -= ABCD[1];
if( ABCD[2] <= 0 ){ writeln("Yes");return; }
ABCD[0] -= ABCD[3];
if ( ABCD[0] <= 0 ){ writeln("No");return; }
}
}
import std.stdio, std.string, std.conv;
import std.math, std.algorithm, std.array;
import std.rege... | D |
// Vicfred
// https://atcoder.jp/contests/abc162/tasks/abc162_a
// implementation
import std.stdio;
void main() {
string n = readln;
foreach(ch; n) {
if(ch == '7') {
"Yes".writeln;
return;
}
}
"No".writeln;
}
| D |
import std.algorithm;
import std.array;
import std.ascii;
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 log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }
void main() ... | D |
void main() {
int n = readln.chomp.to!int;
int k = readln.chomp.to!int;
int m = k.log2.ceil.to!int;
int ans = n - m > 0 ? 2 ^^ m + (n - m) * k : 2 ^^ n;
ans.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
im... | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.string;
int f(int a, int k) {
if (a < k) return 0;
if (a%k == 0) return a/k;
int c = a/k+1;
int l = a/k*k;
a -= ((a-l-1)/c+1)*c;
return f(a, k);
}
void main() {
int n = to!int(chomp(readln()));
//int ... | D |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
int a, b, c, x, y;
scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
a = min(a,c*2);
b = min(b,c*2);
int ans = a*x + b*y;
ans -= max(0, a+b-c*2) * min(x,y);
writeln(ans);... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ab = readln.split.to!(int[]);
auto A = ab[0];
auto B = ab[1];
int t = 1, r;
while (t < B) {
++r;
t = t - 1 + A;
}
writeln(r);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main()
{
string S = readln.chomp;
long n;
char prev = '#';
foreach(c;S)
{
if(c != prev)
{
prev = c;
n++;
}
}
writeln(n-1);
} | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
void main() {
int a, b;
scan(a, b);
foreach (x ; 0 .. 100000) {
... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.