akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100010];
bool f[100010];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=k;i++)
	{
		bool flag=true;
		for (int j=1;j<=n;j++)
		{
			if (i<a[j])
			{
				continue;
			}
			flag&=f[i-a[j]];
		}
		if (!flag)
		{
			f[i]=true;
		}
	}
	if (f[k])
	{
		puts("First");
	}
	else
	{
		puts("Second");
	}
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int n;
int MIN, MAX;
int main(void){
    cin >> n;
    vector<int> vec(n);
    MIN = INF;
    MAX = -INF;
    rep(i, n) {
        cin >> vec[i];
        if (MIN > vec[i]) MIN = vec[i];
        if(MAX < vec[i]) MAX = vec[i];
    }
    cout << MAX - MIN << endl;
    return 0;
}

Measured memory_bytes: 3588
import collections

N = int(input())

def prime_factorize(n):
    a = []

    for f in range(2, int(n**0.5) + 1):
        while n % f == 0:
            a.append(f)
            n /= f
    if n != 1:
        a.append(n)
    return a

if N == 1:
    print(0)
else:
    c = collections.Counter(prime_factorize(N))
    ans = 0
    for p, max_e in c.items():
        e = 1
        while max_e > 0:
            N /= p ** e

            ans += 1
            max_e -= e        
            e += 1
            if max_e < 0:
                ans -=1
    print(ans)

Measured memory_bytes: 9720
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c)puts("No");
	else if(a==b||b==c||c==a)puts("Yes");else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <cstring>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<stack>
using namespace std;
typedef long long LL;
const int maxn = 1e5+5;
LL a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n, c; cin>>n>>c;
    LL k; cin>>k;
    for(int i = 0; i < n; i++) cin>>a[i];
    sort(a, a+n);
    int cur = 0;
    int res = 0;
    while(cur < n)
    {
        res++;
        LL t = a[cur] + k;
        int num = 1;
        while(cur+1 < n && num < c && a[cur+1] <= t)
        {
            cur++;
            num++;
        }
        cur++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  bool ok = true;
  REP(i, n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        ok = false;
      }
    }
  }
  if (ok)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long maxW = scanner.nextLong();
			long[] w = new long[n], v = new long[n];
			IntStream.range(0, n).forEach(i -> {
				w[i] = scanner.nextLong();
				v[i] = scanner.nextLong();
			});
			System.out.println(getResult(0, 0L, maxW, w, v, new HashMap<>()));
		}
	}

	/**
	 * @param nowIndex 現在の計算対象Index
	 * @param nowW     現在選んだ物の重さ合計
	 * @param maxW     最大重さ
	 * @param w        重さの配列
	 * @param v        価値の配列
	 * @param map      計算結果を保存するマップ
	 * @return 現在の計算対象とすでに選んだ物の重さをもとに、得られる最大の価値
	 */
	private static long getResult(int nowIndex, long nowW, final long maxW, final long[] w, final long[] v,
			Map<List<Long>, Long> map) {
		int n = w.length;
		if (nowIndex >= n) {
			return 0L;
		}
		List<Long> key = Arrays.asList((long) nowIndex, nowW);
		Long result = map.get(key);
		if (null == result) {
			if (nowW + w[nowIndex] <= maxW) {
				result = Math.max(getResult(nowIndex + 1, nowW + w[nowIndex], maxW, w, v, map) + v[nowIndex],
						getResult(nowIndex + 1, nowW, maxW, w, v, map));
			} else {
				result = getResult(nowIndex + 1, nowW, maxW, w, v, map);
			}
			map.put(key, result);
		}

		return result;
	}
}


Measured memory_bytes: 49888
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

man = 0
for i in range(n-1):
    if a[i+1]-a[i]==1:
        man += c[a[i]-1]

print(man + sum(b))


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define ll              long long
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("A.txt","r",stdin);
    //freopen("A.txt","w",stdout);

    int a,b,c,d;
    cin>>a>>b>>c;
    d=a+b;
    if(d>=c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 764
def dist2(a, b):
    # 2点a,bの距離の2乗
    ax, ay = a
    bx, by = b
    return (ax-bx)**2+(ay-by)**2

def circum(a, b, c):
    # 三角形ABCの外心
    ax, ay = a
    bx, by = b
    cx, cy = c
    s = dist2(b, c)*(dist2(c, a)+dist2(a, b)-dist2(b, c))
    t = dist2(c, a)*(dist2(a, b)+dist2(b, c)-dist2(c, a))
    u = dist2(a, b)*(dist2(b, c)+dist2(c, a)-dist2(a, b))
    ox = (s*ax+t*bx+u*cx)/(s+t+u)
    oy = (s*ay+t*by+u*cy)/(s+t+u)
    return ox, oy

n = int(input())
P = [tuple(map(int, input().split())) for i in range(n)]
eps = 10**(-7)
if n == 2:
    r = dist2(P[0], P[1])**0.5 / 2
    print(r)
    exit()
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a, b, c = P[i], P[j], P[k]
            ax, ay = a
            bx, by = b
            cx, cy = c
            if dist2(a, b) + dist2(b, c) <= dist2(c, a):
                p = (cx+ax)/2, (cy+ay)/2
                r2 = dist2(a, p)
            elif dist2(b, c) + dist2(c, a) <= dist2(a, b):
                p = (ax+bx)/2, (ay+by)/2
                r2 = dist2(b, p)
            elif dist2(c, a) + dist2(a, b) <= dist2(b, c):
                p = (bx+cx)/2, (by+cy)/2
                r2 = dist2(c, p)
            else:
                p = circum(a, b, c)
                r2 = dist2(a, p)
            if all([dist2(p, q) <= r2 + eps for q in P]):
                print(r2**0.5)
                exit()


Measured memory_bytes: 3192
use proconio::marker::Bytes;
use proconio::{fastout, input};
use std::cmp::Ordering;

struct MyStr {
    pub min: i32,
    pub sum: i32,
    pub rmin: i32,
}
impl MyStr {
    fn make(s: Vec<u8>) -> MyStr {
        let mut sum: i32 = 0;
        let mut min: i32 = 0;
        let mut rsum: i32 = 0;
        let mut rmin: i32 = 0;
        for i in 0..s.len() {
            let c = s[i];
            if c == '(' as u8 {
                sum += 1;
            } else {
                sum -= 1;
            }
            min = min.min(sum);
        }
        for i in 0..s.len() {
            let c = s[s.len() - 1 - i];
            if c == ')' as u8 {
                rsum += 1;
            } else {
                rsum -= 1;
            }
            rmin = rmin.min(rsum);
        }

        MyStr { min, sum, rmin }
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [Bytes; n],
    }
    let mut obj: Vec<MyStr> = s.into_iter().map(|a| MyStr::make(a)).collect();
    let obj = &mut obj[..];
    obj.sort_unstable_by(|a, b| {
        if a.sum.is_negative() != b.sum.is_negative() {
            return a.sum.cmp(&b.sum).reverse();
        } else if a.sum.is_negative() == false {
            return a.min.cmp(&b.min).reverse();
        } else {
            a.rmin.cmp(&b.rmin)
        }
    });

    let mut now: i32 = 0;
    let mut min: i32 = 0;

    for x in obj {
        min = min.min(now + x.min);
        now += x.sum;
    }
    if now == 0 && min >= 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 70384
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL x, y, z, n, a[100000][3], ans[100000];
typedef pair<LL, int> PP;
PQ<PP> pq[3][3];

PP get(int f, int t) {
	PP p = pq[f][t].top();
	while(ans[p.SE] != f) { pq[f][t].pop(); p = pq[f][t].top(); }
	return p;
}

void add(int i, int v) {
	ans[i] = v;
	inc(j, 3) {
		if(j == v) { continue; }
		pq[v][j].emplace(a[i][j] - a[i][v], i);
	}
}

bool RT(int r) { // r: 1 or 2
	PP e[3];
	inc(j, 3) { e[j] = get(j, (j + r) % 3); }
	
	if(e[0].FI + e[1].FI + e[2].FI <= 0) { return false; }
	inc(j, 3) { add(e[j].SE, (j + r) % 3); }
	return true;
}

bool SW(int f, int t) {
	PP ft = get(f, t);
	PP tf = get(t, f);
	
	if(ft.FI + tf.FI <= 0) { return false; }
	add(ft.SE, t);
	add(tf.SE, f);
	return true;
}

LL calc() {
	LL sum = 0;
	inc(i, n) {
		sum += a[i][ans[i]];
	}
	return sum;
}

int main() {
	cin >> x >> y >> z;
	n = x + y + z;
	inc(i, n) {
	inc(j, 3) {
		cin >> a[i][j];
	}
	}
	
	inc(i, n) {
		int v;
		if(inID(i, 0,     x)) { v = 0; }
		if(inID(i, x, x + y)) { v = 1; }
		if(inID(i, x + y, n)) { v = 2; }
		add(i, v);
	}
	
	inc(x, 4) {
		// 適当
		inc(j, 3) {
			while(SW(j, (j + 1) % 3)) { }
		}
		inc1(r, 2) {
			while(RT(r)) { }
		}
	}
	
	cout << calc() << endl;
	
	return 0;
}


Measured memory_bytes: 9836
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;
ll extgcd(ll a, ll b, ll& x, ll& y) {//ax+by=1
  if (b == 0) {
    x = 1, y = 0; return a;
  }
  ll q = a/b, g = extgcd(b, a - q*b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}

ll invmod (ll a, ll m) { // a^-1 mod m
  ll x, y;
  extgcd(a, m, x, y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll n;
ll a,b;
ll nCk(ll n,ll k){
    ll ret=1;
    while(1){
        if(k==0)break;
        ll N=n%MOD;
        ll K=k%MOD;
        if(N<K)return 0;
        for(ll i=0;i<K;i++){
            ret=ret*(N-i)%MOD;
        }
        ll iMul=1;
        for(ll i=0;i<K;i++){
            iMul=iMul*(i+1)%MOD;
        }
        ret=ret*invmod(iMul,MOD)%MOD;
        n/=MOD;k/=MOD;
    }
    return ret;
}
int main(){
    cin>>n>>a>>b;
    ll ans=modpow(2,n,MOD)-nCk(n,a);
    if(ans<0){
        ans+=MOD;
    }
    ans-=nCk(n,b);
    if(ans<0){
        ans+=MOD;
    }
    ans--;
    if(ans<0){
        ans+=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
typedef long long lint;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define all(x) (x).begin(),(x).end()
#define INF (1LL<<60)
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define MOD 1000000007
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
int main(){
    lint n;
    cin>>n;
    vector<lint> dp(n,INF);
    priority_queue<pair<lint,lint>,vector<pair<lint,lint>>,greater<pair<lint,lint>>> que;
    dp[1]=1;
    que.emplace(1,1);
    while(!que.empty()){
        lint d=que.top().second;
        que.pop();
        if(chmin(dp[(d*10)%n],dp[d]))que.emplace(dp[d],(d*10)%n);
        if(chmin(dp[(d+1)%n],dp[d]+1))que.emplace(dp[d]+1,(d+1)%n);
    }
    cout<<dp[0];
}


Measured memory_bytes: 2168
<?php

fscanf(STDIN, "%d", $K);
$town = fscanf(STDIN, str_repeat("%d", $K));

$town = array_reverse($town);

if($town[0] !== 2){
    echo -1;
    exit;
}
$min = 2;
$max = 3;
unset($town[0]);
foreach($town as $value){

    if($min > $value){
        if($min % $value !== 0) {
            $min = ($min - ($min % $value) + $value);
        }
    }else{
        $min = $value;

    }
    $max = (int)($max - ($max % $value)) + $value - 1;
    if($min > $max){
        echo -1;
        exit;
    }


}

echo $min." " .$max.PHP_EOL;

Measured memory_bytes: 14836
from collections import deque
h, w = map(int,input().split())
s = [input() for _ in range(h)]
result = []
for xx in range(h):
    for yy in range(w):
        if s[xx][yy]==".":
            visit = [[-1 for _ in range(w)] for __ in range(h)]
            visit[xx][yy] = 0

            q = deque([[xx,yy]])
            while q:
                x, y = q.popleft()
                for i in [-1, 1]:
                    if 0 <= x+i and x+i < h:
                        if s[x+i][y] != "#" and visit[x+i][y] < 0:
                            visit[x+i][y] = visit[x][y]+1
                            q.append([x+i, y])
                    if 0 <= y+i and y+i < w:
                        if s[x][y+i] != "#" and visit[x][y+i] < 0:
                            visit[x][y+i] = visit[x][y]+1
                            q.append([x, y+i])
            result.append(max([max(i) for i in visit]))
print(max(result))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int>P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);*/
/*--------------------------------------------*/


int main(){
    int n;ll k;cin>>n>>k;
    int a[100000+10];int b[100000+10];
    REP(i,n)cin>>a[i]>>b[i];
    //vector<ll> c(n);//dummy
    //REP(i,n)c[i]=a[i];
    vector<ll> d(100000+10,0);
    REP(i,n)d[a[i]]+=b[i];
    //sort(ALL(c));
    //REP(i,n)cout<<c[i]<<","<<d[c[i]]<<endl;
    ll cnt=0;
    for(int now=1;now<=100000;now++){
        //printf("now=%lld\n",now);
        if(cnt<k){
            cnt+=d[now];
            if(cnt>=k){cout<<now--<<endl;break;}    
        }
    }
}



/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/


Measured memory_bytes: 1792
p = 2019
s = input()
n = len(s)
l = [0 for i in range(p)]
l[0] = 1
ten = 1
cnt = 0
 
ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
else:
    for i in range(n):
        cnt = (cnt + int(s[-i-1]) * ten) % p
        l[cnt] += 1
        ten = (ten * 10) % p
    for i in l:
        if i > 1:
            ans += i * (i - 1) // 2
print(ans)

Measured memory_bytes: 9280
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    array<int, 100005> a;
    for (auto& i : a) { i = 0; }
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        if (t > 0) { a[t-1] += 1; }
        a[t] += 1;
        a[t+1] += 1;
        
    }
    sort(a.begin(), a.end(), std::greater<int>());
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long a;
	scanf("%lld",&a);
	long long b;
	scanf("%lld",&b);

	if (a < b) {
		for (ll i = 0; i < b; ++i)
		{
			cout << a;
		}
	} else {
		for (ll i = 0; i < a; ++i)
		{
			cout << b;
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> A(N);

    for(int i = 0; i < N; i ++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    for(int i = 0; i < N - 1; i ++){
        if(A[i] == A[i + 1]){
            cout << "NO" << endl;

            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); i++)
#define ll long long
using namespace std;

int main() {
  int n, m; cin>>n>>m;
  vector<ll> a(n),b(n),c(n);
  rep(i, n) cin>>a[i]>>b[i]>>c[i];
  
  ll ans=0;
  rep(cnt, 8) {
    vector<ll> tmp(n, 0);
    rep(i, n) {
      if (cnt<4) tmp[i]+=a[i];
      else tmp[i]-=a[i];
    }
    rep(i, n) {
      if (cnt%4<2) tmp[i]+=b[i];
      else tmp[i]-=b[i];
    }
    rep(i, n) {
      if (cnt%1==1) tmp[i]+=c[i];
      else tmp[i]-=c[i];
    }
    sort(tmp.begin(), tmp.end());
    ll sum1=0;
    ll sum2=0;
    rep(i, m) sum1+=tmp[n-1-i];
    rep(i, m) sum2+=tmp[i];
    ans=max(ans, max(sum1, abs(sum2)));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
// #define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long double val = 2 * 3.141592653589793238;
   long int r;
   cin>>r;

   val *= r;

   cout<<fixed<<setprecision(15)<<val;
   return 0;
}

Measured memory_bytes: 3800
N, A, B = map(int, input().split(' '))
S = list(input())

passed_num = 0
limit = A + B
ranking_foreign = 1

results = []

for examinee in S:
    if passed_num < limit:
        if examinee == 'a':
            passed_num += 1
            results.append('Yes')
        elif examinee == 'b':
            if ranking_foreign <= B:
                passed_num += 1
                ranking_foreign += 1
                results.append('Yes')
            else:
                results.append('No')
        elif examinee == 'c':
            results.append('No')
    else:
        results.append('No')

for result in results:
    print(result)


Measured memory_bytes: 10520
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d]
    }

    let mut distr = Vec::new();
    for (i, c) in c.iter().enumerate() {
        for j in 0..*c {
            distr.push(i)
        }
    }

    let r = distr.len();
    for day in 0..d {
        let a = rand::random::<usize>() % r;
        println!("{}", distr[a] + 1);
    }
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n; cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];

    ll dp[n] = {};
    stack<P> s;
    drep(i,n-1){
        dp[i] = dp[i+1];
        if(a[i] > a[i+1]){
            int cnt = 0;
            ll ai = a[i+1];
            while(a[i] > ai){
                cnt++;
                ai *= 4;
            }
            while(cnt>0){
                if(s.size() == 0)break;
                P p = s.top();
                s.pop();
                if(cnt >= p.second){
                    dp[i] += (p.first - i) * p.second;
                    cnt -= p.second;
                }else{
                    dp[i] += (p.first - i) * cnt;
                    p.second -= cnt;
                    cnt = 0;
                    s.push(p);
                }
            }
            if(cnt>0){
                dp[i] += (n - 1 - i) * cnt;
            }
        }else{
            int cnt = 0;
            ll ai = a[i];
            while(ai*4 <= a[i+1]){
                cnt++;
                ai *= 4;
            }
            if(cnt>0){
                s.push(P(i,cnt));
            }
        }
    }
    rep(i,n)dp[i] *= 2;

    ll dp2[n] = {};
    stack<P> s2;
    srep(i,1,n){
        dp2[i] = dp2[i-1];
        if(a[i] > a[i-1]){
            int cnt = 0;
            ll ai = a[i-1];
            while(a[i] > ai){
                cnt++;
                ai *= 4;
            }
            while(cnt>0){
                if(s2.size() == 0)break;
                P p = s2.top();
                s2.pop();
                if(cnt >= p.second){
                    dp2[i] += (i - p.first) * p.second;
                    cnt -= p.second;
                }else{
                    dp2[i] += (i - p.first) * cnt;
                    p.second -= cnt;
                    cnt = 0;
                    s2.push(p);
                }
            }
            if(cnt>0){
                dp2[i] += (i) * cnt;
            }
        }else{
            int cnt = 0;
            ll ai = a[i];
            while(ai*4 <= a[i-1]){
                cnt++;
                ai *= 4;
            }
            if(cnt>0){
                s2.push(P(i,cnt));
            }
        }
    }
    rep(i,n)dp2[i] *= 2;
    rep(i,n)dp2[i] += i+1;
    /*
    rep(i,n)cout << dp[i] << ' ';
    cout << endl;
    rep(i,n)cout << dp2[i] << ' ';
    cout << endl;
    */

    ll mi = min(dp[0], dp2[n-1]);
    srep(i,1,n){
        mi = min(mi, dp[i]+dp2[i-1]);
    }
    cout << mi << endl;
    return 0;
}
 
 


Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int n;

inline bool check(pair<int,char> a, pair<int,char> b, pair<int,char> c) {
    if (a.second == b.second && b.second == c.second) {
        if (b.first == a.first + 1 && c.first == b.first + 1) return true;
        if (b.first == a.first && c.first == b.first) return true;
    }
    return false;
}

int main() {
    cin >> n;
    for (int AAA = 0; AAA < n; ++AAA) {
        vector< pair<int,char> > vec(9);
        for (int i = 0; i < 9; ++i) cin >> vec[i].first;
        for (int i = 0; i < 9; ++i) cin >> vec[i].second;
        sort(ALL(vec));
        bool ok = false;
        do {
            if (ok) break;
            if ( !check(vec[0], vec[1], vec[2]) ) continue;
            if ( !check(vec[3], vec[4], vec[5]) ) continue;
            if ( !check(vec[6], vec[7], vec[8]) ) continue;
            ok = true;
        } while (next_permutation(ALL(vec)));
        
        if (ok) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long sum = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 3 != 0 && i % 5 != 0) {
        sum += i;
      }
    }

    System.out.println(sum);
  }
}


Measured memory_bytes: 27200
from collections import deque
 
N, M = map(int, input().split())
g = {i:set() for i in range(N)}
v = [-1 for i in range(N)]
for _ in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].add(b)
  g[b].add(a)
  
Q = deque()
ans = 0
for a in g:
  if v[a]==-1:
    v[a] = 1
    ans_tmp = 1
    Q.append(a)
    while len(Q)>0:
      na = Q.popleft()
      for nb in g[na]:
        if v[nb] == -1:
          v[nb] = 1
          ans_tmp += 1
          Q.append(nb)
    ans = max(ans, ans_tmp)
print(ans)

Measured memory_bytes: 88048
#include <iostream>
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "Yes" << endl;    
  } else if  (s[1] == s[2] && s[2] == s[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;

const int MXN = 21, MOD = 1e9 + 7;

int n, dp[1 << MXN];
bool cn[MXN][MXN];

void npt() {
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> cn[i][j];
}

void slv() {
	dp[0] = 1;
	for (int msk = 0; msk < (1 << n) - 1; ++msk) {
		int a = __builtin_popcount(msk);
		for (int b = 0; b < n; ++b) {
			if (cn[a][b] && !(msk & (1 << b))) {
				int nm = msk ^ (1 << b);
				dp[nm] += dp[msk];
				dp[nm] %= MOD;
			}
		}
	}
}

void tpt() {
	cout << dp[(1 << n) - 1] << endl;
}

int main() {
	npt();
	slv();
	tpt();
	return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int a[105],n,d,x,sum,i,j,day;
    while(scanf("%d",&n)==1)
    {
        sum=0;
        scanf("%d%d",&d,&x);
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(i=0;i<n;i++)
        {
            sum++,day=a[i]+1;
            for(j=2;day<=d;j++)
            {
                day=(j*a[i])+1;
                sum++;
            }
        }
        printf("%d\n",sum+x);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    bool flag = true;
    string S;
    cin >> S;

    int len = (int)S.size();
    rep(i, len) {
        if (S[i] != S[len - i - 1]) flag = false;
    }
    rep(i, (len - 1) / 2) {
        if (S[i] != S[(len - 1) / 2 - i - 1]) flag = false;
    }
    int cnt = 1;
    repd(i, (len + 3) / 2 - 1, len) {
        if (S[i] != S[len - cnt]) flag = false;
        cnt++;
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

struct edge {
    int from, to, cost;
};

int main() {
    int n;
    cin >> n;

    vector<edge> E;
    int cost;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            cin >> cost;
            if (0 <= cost) {
                E.push_back((edge){ i, j, cost });
            }
        }
    }

    bool used[100] = {};
    used[0] = true;

    int ret = 0;

    while (1) {
        int next = -1;
        int min_cost = INT_MAX;
        for (int i=0; i<(int)E.size(); ++i) {
            edge &e = E[i];
            if (used[e.from] && ! used[e.to] && e.cost < min_cost) {
                next = e.to;
                min_cost = e.cost;
            }
        }
        if (next == -1) break;
        used[next] = true;
        ret += min_cost;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1340
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll pdiv = 1000000007LL;

// 処理内容
int main() {
    
    string k; cin >> k;
    ll d; cin >> d;
    
    const ll n = k.size();
    // dp[i][j][l] := i桁見てj mod dのもので、k未満が確定している(l)ものの数
    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(d, vector<ll>(2, 0)));
    dp[0][0][0] = 1;
    REP(i, n) {
        ll g = k[i] - '0';
        REP(j, d) {
            REP(h, 10) {
                // 俗
                (dp[i+1][(j + h) % d][1] += dp[i][j][1]) %= pdiv;
                if (h < g) { // 還俗
                    (dp[i+1][(j + h) % d][1] += dp[i][j][0]) %= pdiv;
                } else if (h == g) { // 精進
                    (dp[i+1][(j + h) % d][0] += dp[i][j][0]) %= pdiv;
                }
            }
        }
    }

    // 0は含まない
    cout << ((dp[n][0][0] + dp[n][0][1]) % pdiv + pdiv - 1) % pdiv << endl;
    
}

Measured memory_bytes: 55296
#include <bits/stdc++.h>
using namespace std;

long long N, K, A[1 << 18];
double B[1 << 18], M[1 << 18];

int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i <= N; i++) B[i] = B[i - 1] + log10(A[i]);
  for (int i = K; i <= N; i++) M[i] = B[i] - B[i - K];
  
  for (int i = K + 1; i <= N; i++) {
    if (M[i - 1] + 1e-10 < M[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 8468
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;cin >> s;
    string t;cin >> t;
    t.pop_back();
    if(s == t)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto p : mp) mx = max(mx, p.second);
  for (auto p : mp) {
    if (p.second != mx) continue;
    cout << p.first << endl;
  }
  return 0;
}

Measured memory_bytes: 25216
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

	char[] inputline;
	Scanner stdIn = new Scanner(System.in);

	inputline =  stdIn.nextLine().toCharArray();

	for(int i = 0; i < inputline.length; i++) {
		if(Character.isLowerCase(inputline[i])) {
			inputline[i] = Character.toUpperCase(inputline[i]);
		} else {
			inputline[i] = Character.toLowerCase(inputline[i]);
		}
	}

	System.out.println(inputline);

	stdIn.close();
	}
}

Measured memory_bytes: 26188
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,x,t;
	cin>>n>>x>>t;
	int i=1;
	for(i=1;;i++){
		if(x*i >= n){
			break;
		}
	}
	cout<<t*i<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int ast,game[4][4];

bool ex(int t){return game[t][t]>=0;}
bool eq(PP a,PP b){return a.f==b.f&&a.s.f==b.s.f;}

int score(int t){
  if(game[t][t]<0)return -1000;
  int res=0;
  for(int i=0;i<4;i++) {
    if(!ex(i))continue;
    int a=game[t][i],b=game[i][t];
    res+=(a>b)*3+(a==b);
  }    
  return res;
}

int goal(int t){
  int res=0;
  for(int i=0;i<4;i++)res+=game[t][i]*ex(i);
  return res;
}

int ngoal(int t){
  int res=0;
  for(int i=0;i<4;i++)res+=game[i][t]*ex(i);
  return res;
}

int nCr(int n,int r){
  int a=1,b=1;
  for(int i=0;i<r;i++)a*=(n-i),b*=(i+1);
  return a/b;
}
double calc(double p){return nCr(8,p)*pow(1.0/4,p)*pow(3.0/4,8-p);}

double check(int n){
  if(!ex(ast))return 0;
  PP p[4];
  for(int i=0;i<4;i++)
    p[i]=PP(P(score(i),goal(i)-ngoal(i)),P(goal(i),i));
  sort(p,p+4,greater<PP>());
  vector<int>er;

  if(eq(p[0],p[1])){
    double cnt=0;
    for(int i=0;i<4;i++){
      if(!eq(p[0],p[i])&&ex(p[i].s.s))er.push_back(p[i].s.s);
      cnt+=ex(i);
    }
    if(!er.size())return n/cnt;
  }
  else if(n==2&&eq(p[1],p[2])){
    if(p[0].s.s==ast)return 1;
    for(int i=0;i<4;i++)
      if(!eq(p[1],p[i])&&ex(p[i].s.s))er.push_back(p[i].s.s);
  }
  else return p[0].s.s==ast||(n==2&&p[1].s.s==ast);

  for(int i=0;i<er.size();i++)game[er[i]][er[i]]=-1;
  double res=check(n-!eq(p[0],p[1]));
  for(int i=0;i<er.size();i++)game[er[i]][er[i]]=0;
  return res;
}

vector<int> x,y;
double dfs(int idx){
  if(idx==4)return check(2);
  double res=0;
  for(int i=0;i<=8;i++){
    game[y[idx]][x[idx]]=i;
    res+=dfs(idx+1)*calc(i);
  }
  return res;
}

int main(){
  int T;
  cin>>T;
  while(T--){
    x.clear(),y.clear();
    memset(game,-1,sizeof(game));
    for(int i=0;i<4;i++) game[i][i]=0;

    string mp[5];
    for(int i=0;i<5;i++)cin>>mp[i];
    for(int i=0;i<4;i++)if(mp[0][5+5*i]=='*')ast=i;
    
    for(int i=0;i<4;i++)
      for(int j=i+1;j<4;j++) {
	int a=mp[i+1][5+5*j+1]-'0',b=mp[i+1][5+5*j+3]-'0';
	if(a=='_'-'0'){
	  x.push_back(i),y.push_back(j);
	  x.push_back(j),y.push_back(i);
	}
	else game[i][j]=a,game[j][i]=b;
      }
    printf("%.8f\n",dfs(0));
  }
  return 0;
}

Measured memory_bytes: 3408
#include <stdio.h>
#include <stdlib.h>
#define N 200001
#define K 10001

int main() {
  int n, i, C[K];
  int *A, *B;

  for(i = 0; i < K; i++) {
    C[i] = 0;
  }

  scanf("%d", &n);
  A = (int*)malloc(sizeof(int) * n + 1);
  B = (int*)malloc(sizeof(int) * n + 1);
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i+1]);
    C[A[i+1]]++;
  }

  for(i = 1; i < K; i++) {
    C[i] = C[i] + C[i-1];
  }
  for (i = 1; i <= n; i++) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }

  for (i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  free(A);
  free(B);
  return 0;
}

Measured memory_bytes: 16120
def main():
    N = int(input())
    B = [int(i) for i in input().split()]
    A_sum = 0
    A = []
    A.append(B[0])
    for i in range(N-2):
        if B[i] < B[i+1]:
            A.append(B[i])
        else:
            A.append(B[i+1])
    A.append(B[N-2])
    
    for i in range(N):
        A_sum += A[i]
    print(A_sum)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int n = sc.nextInt();
			int k = sc.nextInt();
			double[] ave = new double[n];
			double[] suma = new double[n];

			for(int i=0;i<n;i++) {
				ave[i]=(sc.nextInt()+1)/2.00;
				if(i==0) {
					suma[i]=ave[i];
				}else {
					suma[i] = suma[i-1]+ave[i];
				}
			}

			double ret = 0.00;

			for(int i=0;i<=n-k;i++) {
				if(i==0) {
					ret = suma[i+k-1];
				}else {
					ret = Math.max(ret, (suma[i+k-1]-suma[i-1]));
				}
			}

			System.out.println(ret);
		}



	}


Measured memory_bytes: 78100
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    bool wareru = false;
    int L, R,sa1,sa2,syou;
    int min = 3000;
    cin >> L >> R;
    for (int i = L; i <= R; i++) {
        if (i % 2019 == 0) {
            wareru = true;
            break;
        }
        //syou = i / 2019;
        //sa1 = i - 2019 * syou;
        //sa2 = 2019 - i + 2019 * syou;
        //if (sa1 < sa2) {
        //    if (min > sa1) {
        //        min = sa1;
        //    }
        //}
        //else {
        //    if (min > sa2) {
        //        min = sa2;
        //    }
        //}
    }


    if (wareru) {
        cout << 0 << endl;
        return 0;
    }
    
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            int x = i % 2019;
            int y = j % 2019;
            int syou = (x * y) % 2019;
            if (syou < min)min = syou;
        }
    }
    cout << min << endl;
    return 0;
}



Measured memory_bytes: 3600