code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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;
}
voi... | D |
/+ dub.sdl:
name "E"
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);
scope(exit) assert(!sc.hasNext);
int n;
sc.read(n);
int[] wpos = new int[n], bpos = ... | 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.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()
{
string s; readV(s);
long k; read... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
long ask (int lo, int hi)
{
writeln ("? ", lo, " ", hi);
stdout.flush ();
return readln.strip.to !(long);
}
void solve (int n)
{
auto total = ask (1, n);
int lo = 1;
int hi = n;
while (lo < hi)
{
int me = (lo + hi... | 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[]); }
void solve() {
auto a = reads();
writeln(abs(a[0] - a[1]) > 1 ? ":(" : "Yay!");
}
void main() {
solve();
readln;
} | 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) {
auto line = readln.split;
foreach (ref arg; args) {
arg = line.front.to!(typeof(arg));
line.popFro... | 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 readC(T...)(size_t n,ref T t){foreach(ref v;t)... | 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;
N abs(N)(N a) {
return (a < 0 ? -1 : 1) * a;
}
enum MOD = 10L^^9 + 7;
long fa... | 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.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
void main() {
int n, m;
scan(n, m);
auto a = iota(n).map!(i => readln.split.map!(x => x.to!int - 1).array).array;
auto closed = new bool[](m);
... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
int x; readV(x);
auto m = 1;
... | D |
import std;
const MOD = 10^^9 + 7;
long modPow(long x, long k, long m) {
if (k == 0) return 1;
if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
return x * modPow(x, k - 1, m) % m;
}
long calc(int n, int k) {
long[long] memo;
for (int g = k; g >= 1; g--) {
long cnt = modPow(k / g, n, MO... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.math;
void main(string[] args) {
auto input = readln().chomp.split.map!(to!int).array;
if(input[1] == 100){input[1]++;}
auto ans = input[1] * pow(100,input[0]);
ans.writeln;
} | D |
unittest
{
assert( [ "10" ].parse.expand.solve == 5 );
assert( [ "1111111111111111111" ].parse.expand.solve == 162261460 );
assert( [ "111" ].parse.expand.solve == 27 ); // 追加ケース
assert( [ "101" ].parse.expand.solve == 15 ); // 追加ケース
assert( [ "011" ].parse.expand.solve == 9 ); // 追加ケース
assert( [ "010" ].par... | 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;
immutable long INF = 1L << 59;
void main() {
auto C = 3.iota.map!(_ => readln.split.map!... | 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;
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 a = readln.chomp.to!BigInt();
auto b = readln.chomp.to!BigI... | 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;
alias Pair = Tuple!(int, "a", int, "b");
void main() {
... | D |
module Main;
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.math;
import std.algorithm;
void main() {
string input;
immutable limitList = 50022;
bool[] listPrimeNumber = new bool[](limitList);
int number, primeNumberSmaller, primeNumberBigger;
listPrimeNumber... | 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 |
/* 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;
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;
int overlap(int a, int b, int c, int d) {
int lo = max(a, c);
int hi = min(b, d);
return max(0, hi - lo);
}
void m... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
void main() {
int ans;
foreach (dchar[] line; stdin.lines) {
line = line.chomp;
if (line == line.retro.array) ans++;
}
ans.writeln;
} | D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto input1=readln.chomp;
writeln(input1[0],input1.length-2,input1[input1.length-1]);
} | D |
import std.stdio,std.algorithm;
long n,no,ne,mino,so,se,temp;
void main()
{
scanf(" %d",&n);
mino=long.max;
for(int i=0;i<n;++i)
{
scanf(" %d",&temp);
if(temp%2)
{
mino=min(mino,temp);
so+=temp;
++no;
}else{
se+=temp;
++ne;
}
}
writeln(se+so-(no%2?mino:0));
}
| 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() {
long x;
scan(x);
long t;
while (t * (t + 1) / 2 < x) ... | 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()
{
foreach (line; stdin.byLine) {
line.split.map!(to!int).reduce!("a+b").writeln;
}
} | D |
void main(){
int m = _scan();
writeln(48-m);
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] _scanln(T = int)(){
T[] ln;
foreach(string elm; readln().chomp().split()){
ln ~= elm.to!T();
}
r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nuv = readln.split.to!(int[]);
auto N = nuv[0];
auto u = nuv[1]-1;
auto v = nuv[2]-1;
int[][] T;
T.length = N;
foreach (_; 0..N-1) {
auto ab = readln.split.to!(... | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
import std.numeric;
void main()
{
auto buf = readln.chomp.split.to!(long[]);
(buf[0] * (buf[1] / buf[0].gcd(buf[1]))).writeln;
}
| D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
int[] primes = [2,3,5];
for(int i=7;primes.length <= 10000;i++){
bool flg = true;
for(int j=0;primes[j]*primes[j]<=i;j++){
if(i%primes[j]==0){
flg = false;
break;
}
}
if(flg) primes ~= i... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, q; rd(n, q);
auto tree=new SquareRootDecomposition(n);
while(q--){
auto args=readln.split.to!(int[]);
if(args[0]==0){
tree.update(args[1], args[2]+1, args[3]);
}else{
writeln(tree.rmin(args[1], args[2]+1));
}... | D |
import 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.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
string str = readln.chomp;
writeln = str.indexOf("9") == -1 ? "No" : "Yes... | 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 nm = readln.split.to!(int[]);
auto N = nm[0];
auto M1 = nm[1];
auto M2 = nm[2];
int[] as, bs, cs;
foreach (_; 0..N) {
auto abc = readln.sp... | D |
void main() {
problem();
}
void problem() {
auto S = scan;
auto N = S.length;
bool solve() {
auto head = S[0..(N-1)/2];
auto tail = S[(N+3)/2-1..$];
S.deb;
head.deb;
tail.deb;
auto s = S;
for(long i = 0; i < s.length/2; i++) {
if (s[i] != s[$-i-1]) return false;
}
... | 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; readV(a);
int b; readV(b)... | D |
void main()
{
long n = rdElem;
string s = "ACGT";
long[][][][] dp = new long[][][][](n+1, 4, 4, 4);
foreach (i, a; s)
{
foreach (j, b; s)
{
foreach (k, c; s)
{
if (a == 'A' && b == 'G' && c == 'C') continue;
if (a == 'A' && b =... | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
int n = readln.chomp.to!int - 1;
int[] a = readln.split.to!(int[]);
int ans = 0;
for (int i = 0; i < n; i++)
{
if (a[i] == a[i + 1])
{
ans++;
i++;
}
}
writeln(ans);
}
| D |
immutable long mod=998244353;
immutable int M=1_000_00*4;
void main(){
import std.stdio, std.algorithm;
long n, a, b, k; rd(n, a, b, k);
auto fact=genFact(M, mod);
auto invFact=genInv(fact, mod);
long comb(long nn, long rr){
if(nn<rr) return 0;
long ret=fact[nn]%mod;
(ret*=invFact[rr])%=mod;... | D |
import std.stdio;
enum conv = [
'I':1,
'V':5,
'X':10,
'L':50,
'C':100,
'D':500,
'M':1000
];
void main()
{
foreach(input; stdin.byLine())
{
int arabia = 0;
if(input.length == 1) arabia = conv[input[0]];
else
{
foreach(i; 1 .. input.length)... | D |
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;
void main() {
int n;
scan(n);
int ans = 1;
while (ans <= n / 2) {
... | 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;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int n, m;
scan(n, m);
auto adj = new int[][](n, 0);
foreach (i ; 0 .. m) {
int ai, bi;
scan(ai, bi);
ai--, bi--;
adj[ai... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
readln.split.to!(int[]).map!(a => a-1).reduce!((a,b) => a*b).writeln;
}
| D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;
void main()
{
auto
buf = readln.chomp.split.to!(int[]),
k = buf[0],
n = buf[1],
a = readln.chomp.split.to!(int[]),
l = a[0] + k - a[$-1];
foreach (i, e; a[1..$])
l = l.max(e - a[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()
{
int a, e, k;
foreach (i; 0..6) {
if (i == 0) a = readln.chomp... | D |
import std.stdio, std.string, std.conv;
void main(){
auto ip = readln.chomp.to!(dchar[]);
ip[3] = '8';
writeln(ip);
} | 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.to!(char[]);
auto t = readln.chomp.to!(char[]);
bool[char] ... | 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.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;
auto readInts() {
return array(map!(to!int)(readln().strip().split()));
}
auto readInt() ... | 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;
if (s.length % 2) s.length -= 1;
else s.length -= 2;
whi... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
void main(){
auto arr = readln.chomp.split.map!(to!int).array;
int a = arr[0], b = arr[1];
auto s = readln.chomp;
auto t = readln.chomp;
auto dp = new int[][][](a+2, b+2, 2);
fore... | D |
import std.stdio;
void main(){
auto cin = new Cin();
//auto j = new Joint();
auto NK = cin.line();
auto D = cin.line();
auto N = NK[0];
solve( N , D ).writeln();
}
auto solve( size_t n , size_t[] ng ){
bool[10] nglist;
nglist[] = true;
bool up = false;
foreach( elm ; ng ){
nglist[elm] = false;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum next = [
"Sunny": "Cloudy",
"Cloudy": "Rainy",
"Rainy": "Sunny"
];
void main()
{
writeln(next[readln.chomp]);
} | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
switch (readln.chomp[$-1])
{
case '0', '1', '6', '8':
return "pon".writeln;
case '2', '4', '5', '7', '9':
return "hon".writeln;
default:
return "bon".writ... | 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, std.bitmanip;
class SegmentTree {
int[] table;
int N, table_size;
this(int n) {
N = n;
ta... | D |
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional, std.traits;
import std.algorithm, std.container;
void main()
{
long N = scanElem;
auto S = readln.strip;
auto T = readln.strip;
long res;
foreach(i;1..N+1)
{
... | D |
import std.stdio,std.conv, std.algorithm;
import std.container,std.array,std.range;
import std.string,std.typecons,std.numeric;
import std.math,std.random,std.functional,std.regex;
double getExpected(int[] vs,double[] rs,int n,int m){
double res = 0;
double sum = rs.sum;
foreach(i;0..m){
res += vs[i] * rs[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;
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.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
void main() {
auto N = readln.chomp.to!int;
int[][] gameOrders;
gameOrders.length = N;
foreach(i; N.iota()) {
gameOrders[i] = readln.split.to!(int[]);
}
int days = ... | D |
import std.stdio,
std.range,
std.conv;
import std.math;
void main(){
int w, h;
while(true){
scanf("%d %d", &h, &w);
if(h == 0 && w == 0) break;
foreach(i; 0..h){
foreach(j; 0..w){
write(((i+j)%2) ? "." : "#");
}
writeln();
}
writeln();
}
} | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;
alias sread = () => readln.chomp();
ulong bignu... | D |
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
import std.string;
import std.traits : isSome... | D |
void main() {
auto N = ri;
ulong res;
foreach(i; iota(1, N+1, 2)) {
ulong tmp;
foreach(j; 1..i+1) {
if(i % j == 0) tmp++;
}
if(tmp == 8) res++;
}
res.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
imp... | D |
import std.conv, std.stdio, std.string;
void main()
{
auto a = readln.chomp.to!int;
auto s = readln.chomp;
((3200 <= a) ? s : "red").writeln;
}
| 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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const tmp = readln.split.to!(int[]);
writeln(tmp[1] % tmp[0] == 0 ? tmp[0] + tmp[1] : tmp[1] - tmp[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.bitmanip;
void main() {
immutable long MOD = 924844033;
auto s = readln.split.map!(to!int);
auto N = s[0];
auto K = s[1... | D |
void main() {
problem();
}
void problem() {
const N = scan!long;
const S = scan;
long solve() {
long ans;
const totalR = S.count('R');
const totalG = S.count('G');
const totalB = S.count('B');
long[] R = new long[N];
long[] G = new long[N];
long[] B = new long[N];
int countR... | D |
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.range;
class State
{
public:
bool[] xx;
int[] yy;
bool[] zz;
bool[] ww;
Chunks!(dchar[]) board;
}
bool ad(State state, int y)
{
if (y == 8)
{
... | 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() {
string x;
scan(x);
int st, ans;
foreach (ch ; x) {
if (ch == 'S') {
st++;
}
else {
i... | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
void main() {
int n = readint();
int[] a = readints();
int m = a.reduce!max;
int mid = m / 2;
int md = 11451419... | 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 = readln.split.to!(int[]);
long[][] DP;
DP.length = N;
foreach (ref dp; DP) dp.length = N;
auto x = (N-1)%2;
long solve(int i, int j) ... | 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, a, b, c, d;
scan(n, a, b, c, d);
a... | 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 |
import std.stdio;
import std.conv;
import std.math;
void main() {
double n;
scanf("%lf", &n);
auto y = n / 1.08;
auto n2 = n.to!int;
auto y2 = y.ceil.to!int;
if (floor(y2 * 1.08).to!int == n2 || floor((y2+1) * 1.08).to!int == n2) {
y2.write;
}
else {
":(".write;
}
}
| D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
void main() {
auto a = readln.split.map!(to!int);
writeln("a ", a[0] == a[1] ? "==" : (a[0] < a[1] ? "<" : ">"), " b");
} | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
int[][10^^5] NS;
int[10^^5] ORIGIN, DEPS;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
foreach (i; 0..N+M-1) {
auto ab = readln.split.to!(int[]);
... | D |
void main()
{
long n, a, b;
rdVals(n, a, b);
long[] h = n.rdCol;
bool check(long x)
{
long cnt;
foreach (y; h)
{
long rem = max(0, y-x*b);
cnt += (rem + a - b - 1) / (a - b);
}
return cnt <= x;
}
long ok = 10 ^^ 10, ng = -1;
... | 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 s = sread();
auto tmp = new long[](4); //北西南東
foreach (... | 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 = readln.split.to!(long[]);
auto DP = new long[][](N+5, 3);
foreach (ref dp; DP) dp[] = long.min/3;
DP[0][0] = 0;
foreach (i; 0..N) {
... | 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.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;
void main() {
auto N = readln.chomp.to!int;
N.iota.map!(i => readln.split.to!(ulong[]).pipe!(range => range[1] - range[0] + 1)).sum.writeln;
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n;
scan(n);
int[string] a;
foreach (i ; 0 .. n) {
auto s = readln.chomp;
if (s in a) {
a[s]++;
}
else {
a[s] = 1;
}
}
int m;
... | 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 |
import std.algorithm;
import std.range;
import std.stdio;
import std.string;
immutable int letters = 26;
void main ()
{
string s;
while ((s = readln.strip) != "")
{
auto a = new int [] [letters];
foreach (int i, c; s.map !(x => x - 'a').array)
{
a[c] ~= i;
}
int n = cast (int) (s.length);
int res = ... | D |
import std.stdio;
import std.conv;
import std.string;
import std.array;
void main(){
int n=to!int(readln.chomp);
while(n--){
auto s=new bool[32];
auto input=readln.chomp;
for(int i=0;i<8;++i){
int a=(input[i]<='9')?input[i]-'0':input[i]-'a'+10;
for(int j=0;j<4;++j){
s[4*i+j]=(a&(1<... | D |
import std.algorithm;
import std.ascii;
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.... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;
void main() {
int n, m;
scan(n, m);
auto cnt = new int[](n);
auto red = new bool[](n);
cnt[] = 1;
red[0] = 1;
foreach (i ; 0 .. m) {
int xi, yi;
scan(xi, yi);
xi--, yi--;
... | 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 = [0] ~ readln.split.to!(int[]);
int r;
foreach (i; 1..N+1) {
if (as[as[i]] == i) ++r;
}
writeln(r/2);
} | D |
void main(){
int n = _scan();
int[string] dic;
foreach(i; 0..n){
dic[readln().chomp()]++;
}
dic.length.writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] _scanln(T = int)(){
T[] ln;... | D |
import std.stdio,std.string,std.conv;
int main()
{
string s;
while((s = readln.chomp).length != 0)
{
string[] _s = s.split(" ");
int a = _s[0].to!int;
int b = _s[1].to!int;
int n = _s[2].to!int;
int ans = 0;
a %= b;
foreach(i;0..n)
{
a *= 10;
ans += (a/b);
a %= b;
}
ans.writeln;
}
r... | D |
void main(){
string s = readln().chomp();
s.count('1').writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] _scanln(T = int)(){
T[] ln;
foreach(string elm; readln().chomp().split()){
ln... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
long n; rd(n);
long m=1;
while(m<n){
if((n&m)!=m){
writeln(m);
return;
}
m*=2;
}
writeln(n+1);
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
foreach(i, ref e; ... | 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;
import std.ascii;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
bool ... | 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;
alias C = Tuple!(int, int);
immutable C[] dirs = [
tuple (1, 0),
tuple (-1, 0),
tuple (0, 1),
tuple (0, -1)
];
enum inf = int.max;
void main() {
auto s = re... | D |
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);
int[][] c;
void main() {
int n = read();
foreach (i;0..n) c ~= ... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.