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, 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;
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 |
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.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 |
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 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 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.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.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;
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 |
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);
auto b = iota(n).map!(i => readln.chomp).array;
int checkLeft(string s) {
int h;
foreach (ch ; s)... | 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 = 2*10^^9 + 7;
void main() {
int n, k; scan(n, k);
auto a = new int[](n);
auto b = new int[](n);
foreach (i ; 0 .. n) {
int ai, bi... | 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 |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
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() {
string s;
... | D |
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
void main() {
readln.chomp.count('1').writeln;
} | D |
void main() {
writeln("ABC", readln.chomp);
}
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.ascii;
import std.uni; | 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();
ulong bignu... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], m = tmp[1];
int[] road = new int[n];
foreach (i; 0 .. m) {
tmp = readln.split.to!(int[]);
int a = tmp[0] - 1, b = tmp[1] - 1;
++road[a], ++road[b];
}
foreach (x; road) {
x.writeln;
}
}
import ... | D |
import std;
import core.bitop;
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "g");
alias PQueue(T, alias less = "a>b") ... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), w = rd[0], a = rd[1], b = rd[2];
if (a > b) swap(a, b);
writeln(b <= a+w ? 0 : b-(a+w));
}
| D |
import std.stdio, std.conv, std.string, std.math;
void main(){
auto ip = readln.chomp.to!int;
if(ip < 1200){
"ABC".writeln;
} else {
"ARC".writeln;
}
} | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
auto nm = readints();
int n = nm[0], m = nm[1];
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
writeln(180 * (readln.chomp.to!int-2));
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto ri = n.iota.map!(_ => readln.chomp.to!int).array;
auto maxR = ri.back;
auto maxP = int.min;
foreach_reverse (i; 0..n-1) {
maxP = max(maxP, maxR - ri[i]);
maxR = max(maxR, ri[i]);
... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long k = tmp[0], a = tmp[1], b = tmp[2];
long op = k - a + 1;
long cal = a + (b - a) * (op / 2) + op % 2;
max(k + 1, cal).writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a, b, c, d;
scan(a, b, c, d);
writeln(max(a*b, c*d));
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.... | 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();
string s;
string t;
scan(s, 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.string;
immutable long INF = 1L << 59;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1]... | 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();
alias Point... | 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.range;
import std.array;
import std.algorithm;
void main(){
auto Z=readln.split.to!(int[]),a=Z[0],b=Z[1],c=Z[2];
if(a+b>=c)writeln("Yes");
else writeln("No");
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math, std.typecons;
void main() {
int n; scan(n);
writeln(euler_phi(n));
}
int euler_phi(int n) {
int ans = n;
for (int p = 2; p*p <= n; p++) {
if (n % p == 0) {
ans = ans / p * (p - 1);
... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], a = tmp[1], b = tmp[2];
min(a*n, b).writeln;
}
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;
i... | 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 |
/* 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.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;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
void main() {
int N = 100;
int[] ary = new int[N+1];
while(true) {
... | 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() {
string n;
scan(n);
bool yn = n[0 .. 3].to!int % 111 == 0 || n[1 .. 4].to!int % 111 == 0;
writeln(yn ? "Yes" : "No");
}
void scan(T...)(r... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
auto data = split(readln());
( to!int(data[0]) * to!int(data[1]) / 2 ).writeln();
} | D |
// Vicfred
// https://atcoder.jp/contests/abc177/tasks/abc177_c
// math
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main() {
const long mod = 10^^9+7;
long n = readln.chomp.to!long;
long[] a = readln.split.map!(to!long).array;
long sum = 0;
fo... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
foreach(i; 0..n) pred();
}
auto ... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
writeln(s.lastIndexOf("Z") - s.indexOf("A") + 1);
}
| 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;
void main() {
auto S = readln.chomp;
auto N = S.length.to!int;
int v_count = 0;
int h_count = 0;
foreach... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
immutable inf = 1<<30;
string ng = "UNRESTORABLE";
void main() {
string s, t;
scan(s);
scan(t);
int n = s.length.to!int, k = t.length.to!int;
foreach_reverse (i ... | 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() {
auto s = readln.chomp;
writeln... | D |
import std.stdio, std.string, std.array, std.conv;
void main() {
int[] tmp = readln.chomp.split.to!(int[]);
int a = tmp[0], b = tmp[1];
writeln(a > 2 * b ? a - 2 * b : 0);
} | 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!(long[]);
auto N = nx[0];
auto X = nx[1];
long[51] as, ps;
as[0] = 1;
ps[0] = 1;
foreach (i; 1..51) {
as[i] = as[i-1] * 2 + 3;
ps[i... | D |
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
T[] readToArray(T)() {
return readln.split.to!(... | D |
/+ dub.sdl:
name "B"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner scn = new Scanner(stdin);
scope(exit) assert(!scn.hasNext);
int h, w, n, sr, sc;
string s, t;
scn.read(h, w, n,... | D |
import std.stdio, std.algorithm, std.range, std.conv;
void main(){
iota(1, 10).map!(a => iota(1, 10).map!(b => text(a, "x", b, "=", a*b)).join("\n")).join("\n").writeln;
} | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;
void main()
{
auto
x = readln.chomp.to!int,
t = x / 500,
s = (x % 500) / 5;
(t * 1000 + s * 5).writeln;
}
| 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 |
// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio, std.string, std.array, std.algorithm, std.ascii;
void main() {
readln();
auto xs = split(chomp(readln()));
auto ys = xs.map!( (x) => x.count!( isUpper ) );
writeln(ys.maxCount[0]);
} | 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.datetime;
void main() {
auto N = readln.chomp.to!int;
auto G = new int[][](N);
foreach (i; 0..N-1) {
auto v = readln... | 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;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof) {
return fals... | 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.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;
void main(string[] args)
{
inputFile = stdin;
debug inputFile = File(args[1]);
auto nt = next!int;
foreach(t; 0 .. nt)
{
auto n = next!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() {
const int MOD = 998244353;
string s = chomp(readln());
int n = to!int(s.length);
int[] a = new int[n];
foreach (i; 0..n) {
a[i] = s[i]-'a';
}
bool same() {
... | 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 ab = aryread!string();
// writeln(ab);
string ab_str = ... | 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;
void main()
{
auto r = readln.chomp.to!int;
writeln(3 * r^^2);
} | D |
void main(){
int[] x = _scanln!()();
foreach(i, elm; x){
if(elm == 0){
writeln(i+1);
return;
}
}
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] _scanln(T = int)(){
T[] ln;
foreach(string elm... | D |
import std.stdio, std.string, std.conv;
void main()
{
auto ip = readln.chomp, X = ip[0], Y = ip[2];
if(X > Y){
writeln(">");
} else if(X < Y){
writeln("<");
} else {
writeln("=");
}
} | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto N = readln.chomp.to!int;
string[] wordList;
bool result = true;
foreach (i; 0..N) {
auto W = readln.chomp;
scope(exit) wordList ~= W;
if (wordList is null) con... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
readln.count('1').writeln;
} | D |
import core.stdc.stdio;
import std.algorithm;
import std.stdio;
int lowerBound(int[] data,int t){
int l=0;
int r=cast(int)data.length+1;
while(r-l>1){
int m=(l+r)/2;
if(data[m-1]<t)
l=m;
else
r=m;
}
return l;
}
void main(){
int n,m;
scanf("%d%d",&n,&m);
int[] u = new int[n];
int[] k = new int[n];... | 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;
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 = sread();
// writeln(n);
long ans;
foreach (i; 0... | D |
void main() {
problem();
}
void problem() {
const MAX = 1_000_000_000_000_001;
auto N = scan!long - 1;
string solve() {
char[] ans;
foreach(i; 0..1000) {
auto mod = N % 26;
N /= 26;
N -= 1;
ans ~= 'a' + cast(char)mod;
if (N < 0) {
break;
}
}
... | 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 a, b;
scan(a, b);
writeln(max(a + b, a - b, a * b));
}
void scan(T...)(ref T args) {
import ... | D |
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;
T diff(T)(const T a, const T b) { return a > b ? a - b : b - a; }
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
T[] readToArray(T)() {
return readln.split.to!(T[]);
}
void main() {
const ip = readToArray!(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;
void main() {
int n;
scan(n);
auto p = iota(n).map!(i => readln.chomp.to!int).array;
auto dp = new int[](n + 1);
int ans = 1<<30;
foreac... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.