akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

def accumrate(h,w,acc,A):
  for i in range(1,h+1):
    for j in range(1,w+1):
      acc[i][j] = acc[i][j-1] + A[i-1][j-1]
  for i in range(1,h+1):
    for j in range(1,w+1):
      acc[i][j] += acc[i-1][j]
      
def cal(i,j,g,r,acc):
  return acc[g][r] + acc[i][j] - acc[g][j] - acc[i][r]

n,k = map(int,input().split())
K = 2*k
cw = [[0]*K for i in range(K)]
cb = [[0]*K for i in range(K)]
sw = 0
sb = 0
for i in range(n):
  x,y,c = input().split()
  if c == 'B':
    cb[int(x)%K][int(y)%K] += 1
    sb += 1
  else:
    cw[int(x)%K][int(y)%K] += 1
    sw += 1
    
acw = [[0]*(K+1) for i in range(K+1)]
acb = [[0]*(K+1) for i in range(K+1)]
accumrate(K,K,acb,cb)
accumrate(K,K,acw,cw)

ans = 0
for i in range(k):
  for j in range(k):
    chk_b = cal(0,0,i,j,acb)+cal(i,j,i+k,j+k,acb)+cal(i+k,j+k,K,K,acb)+cal(0,j+k,i,K,acb)+cal(i+k,0,K,j,acb)
    chk_w = cal(0,0,i,j,acw)+cal(i,j,i+k,j+k,acw)+cal(i+k,j+k,K,K,acw)+cal(0,j+k,i,K,acw)+cal(i+k,0,K,j,acw)
    ans = max(ans,max(chk_b+sw-chk_w,chk_w+sb-chk_b))
    
print(ans)

Measured memory_bytes: 201500
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  cin >> S;
  ll m = (S[5]-'0')*10+(S[6]-'0');
  ll d = (S[8]-'0')*10+(S[9]-'0');

  if(m>4){
    cout << "TBD\n";
    return 0;
  }
  if(m==4){
    if(d>30){
      cout << "TBD\n";
      return 0;
    }
  }

  cout << "Heisei\n";
  return 0;

  return 0;
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    Int time1 = a * 60 + b;
    Int time2 = c * 60 + d;
    print(time2 - time1 - e);
    return 0;
}

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

#define say(a) cout<<a<<endl
#define say1(a,b) cout<<a<<" "<<b<<endl
#define loop(a,b) for(int i=a;i<b;i++)

int main()
{
    long long L,R,m=2019;
    cin>>L>>R;
    bool flag =false;
    for(long long i=L;i<R;i++)
    {
        for(long long j=i+1;j<=R;j++)
        {
            m=min((i*j)%2019,m);
            if(m==0) {flag =true;break;}
        }if(flag)
        {break;}
    }say(m);
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void)
{
    int x;
    cin >> x;
        if(100 <= x && x <= 111)
            cout << 111 << endl;
        else if(112 <= x && x <= 222)
            cout << 222 << endl;
        else if(223 <= x && x <= 333)
            cout << 333 << endl;
        else if(334 <= x && x <= 444)
            cout << 444 << endl;
        else if(445 <= x && x <= 555)
            cout << 555 << endl;
        else if(556 <= x && x <= 666)
            cout << 666 << endl;
        else if(667 <= x && x <= 777)
            cout << 777 << endl;
        else if(778 <= x && x <= 888)
            cout << 888 << endl;
        else if(889 <= x && x <= 999)
            cout << 999 << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ab = [LIST() for _ in range(N)]
cd = [LIST() for _ in range(M)]

def M_dist(p1, p2):
	return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])

for i in range(N):
	dist = M_dist(ab[i], cd[0])
	ans = 1
	
	for j in range(1, M):
		if dist > M_dist(ab[i], cd[j]):
			dist = M_dist(ab[i], cd[j])
			ans = j+1
	print(ans)


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

//与えられるN個の整数のうちに異なるものはいくつあるか。

int main(){

int N=0;
cin >> N;
int d[110];
for(int i=0; i<N; i++) cin >> d[i];
int num[110]={0}; // ={0} が超重要！！やらないと変なの入ってる！
for (int i=0; i<N; i++){
    num[d[i]]++;
}
int ans=0;
for(int i=0; i<110; i++){
    if(num[i]) ans++;
}
cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp1, tmp2;
    string S;
    bool flag=true;
    
    cin >> A >>B >>C;

    if(B-A == C-B)
    	puts("YES");
    else
    	puts("NO");

    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
n, k = gets.strip.split.map(&:to_i)

okashi_count_of_ith_sunuke = Array.new(n) { 0 }

k.times do
  d = gets.strip.to_i
  a = gets.strip.split.map(&:to_i)
  (0..(d - 1)).each do |i|
    okashi_count_of_ith_sunuke[a[i] - 1] += 1
  end
end

okashi_count_of_ith_sunuke.select! { |x| x == 0 }

puts okashi_count_of_ith_sunuke.size()


Measured memory_bytes: 14376
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define int long long

using namespace std;

int n;

void write(char _1) {
    if(_1 == 'L') putchar('R');
    if(_1 == 'R') putchar('L');
    if(_1 == 'U') putchar('D');
    if(_1 == 'D') putchar('U');
}

void write(char _1, char _2) {write(_1), write(_2);}

int md(int x) {
    return (x % 3 + 3) % 3;
}
void solve(int x, int y, int b, int dep = 1) {
    if(dep == 20) {
        if(b == 1) {
            //if(x != 1 && x != -1 && y != 1 && y != -1) assert(0);
            if(x == 1) write('L'), x--;
            else if(x == -1) write('R'), x++;
            else if(y == 1) write('D'), y--;
            else if(y == -1) write('U'), y++;
            if(x != 0 || y != 0) assert(0);
        } else {
            if(md(x) == 0 && md(y) == 0) write('L', 'R');
            else if(md(x) == 0 && md(y) == 1) write('U', 'U'), y += 2;
            else if(md(x) == 0 && md(y) == 2) write('D', 'D'), y -= 2;
            else if(md(x) == 1 && md(y) == 0) write('R', 'R'), x += 2;
            else if(md(x) == 1 && md(y) == 1) write('L', 'D'), x--, y--;
            else if(md(x) == 1 && md(y) == 2) write('L', 'U'), x--, y++;
            else if(md(x) == 2 && md(y) == 0) write('L', 'L'), x--, x--;
            else if(md(x) == 2 && md(y) == 1) write('R', 'D'), x++, y--;
            else if(md(x) == 2 && md(y) == 2) write('R', 'U'), x++, y++;
            if(x != 0 || y != 0) assert(0);
        }
        return;
    }
    if(md(x) == 0 && md(y) == 0) write('L', 'R');
    else if(md(x) == 0 && md(y) == 1) write('U', 'U'), y += 2;
    else if(md(x) == 0 && md(y) == 2) write('D', 'D'), y -= 2;
    else if(md(x) == 1 && md(y) == 0) write('R', 'R'), x += 2;
    else if(md(x) == 1 && md(y) == 1) write('L', 'D'), x--, y--;
    else if(md(x) == 1 && md(y) == 2) write('L', 'U'), x--, y++;
    else if(md(x) == 2 && md(y) == 0) write('L', 'L'), x--, x--;
    else if(md(x) == 2 && md(y) == 1) write('R', 'D'), x++, y--;
    else if(md(x) == 2 && md(y) == 2) write('R', 'U'), x++, y++;
    solve(x / 3, y / 3, b, dep + 1);
}

int X[1010], Y[1010];

signed main() {
    scanf("%lld", &n);
    //while(n--) {
    //    int x, y;
    //    scanf("%lld%lld", &x, &y);
    //    solve(x, y);
    //    putchar('\n');
    //}
    for(int i = 1; i <= n; i++) scanf("%lld%lld", &X[i], &Y[i]);
    for(int i = 2; i <= n; i++) if((X[1] + X[i] + Y[1] + Y[i]) % 2 == 1) {
        puts("-1");
        return 0;
    }
    if(((X[1] + Y[1]) % 2 + 2) % 2 == 1) {//!!!
        printf("39\n");
        for(int i = 1, s = 1; i <= 19; i++, s *= 3) printf("%lld %lld ", s, s);
        printf("%lld", 3 * 387420489ll);
        putchar('\n');
        for(int i = 1; i <= n; i++) {
            //putchar('R');
            //X[i]++;
            solve(X[i], Y[i], 1, 1);
            putchar('\n');
        }
    } else {
        printf("40\n");
        for(int i = 1, s = 1; i <= 20; i++, s *= 3) printf("%lld %lld ", s, s);
        putchar('\n');
        for(int i = 1; i <= n; i++) {
            solve(X[i], Y[i], 0, 1);
            putchar('\n');
        }
    }
}

Measured memory_bytes: 256
//
//  main.c
//  B - Round Pond
//
//  Created by MD.SAKIBUL ISLAM  on 22/4/20.
//  Copyright © 2020 MD.SAKIBUL ISLAM . All rights reserved.
//

#include <stdio.h>
#include <math.h>

int main()
{
    double a;
    int r;
    scanf("%d",&r);
    a=2*r*M_PI;
    printf("%lf\n",a);
    return 0;
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    long long h;
    cin >> h;
    long long ans = 0;
    long long now = 1;
    while(1 < h){
        ans += now;
        h >>= 1;
        now <<= 1;
    }
    cout << ans + now << endl;
    return 0;
}

Measured memory_bytes: 256
import math
gun_list = [1]
for i in range(11):
    gun_list.append(gun_list[-1]+26**(i+1))
#print(gun_list)
#郡の始まりのnumをしまったリスト
a =int(input())
#print()
gun_sum = 12
for i in range(13):
    if gun_list[i] <= a and gun_list[i+1] > a:
        gun_num = i
        break
#print(gun_num)
b = a-gun_list[gun_num]
#print(b)

x_list = [26**i for i in range(gun_num+1)]
x_list = x_list[::-1]
#print(x_list)

ans_list = []
for i in range(len(x_list)):
    if i > 0:
        b -= x_list[i-1]*ans_list[i-1]
        
        ans_list.append(math.floor(b/x_list[i]))
    else:
        ans_list.append(math.floor(b/x_list[0]))
    

#print(ans_list)

ans = ''
for i in range(len(ans_list)):
    ans += chr(97+ans_list[i])
    #print(ans)
print(ans)

Measured memory_bytes: 9244
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

inline vector<int> bfs(int n,vector<vector<int> > &g,int s)
{
	vector<int> d(n,1e9);d[s]=0;
	queue<int>q;q.push(s);
	while(!q.empty())
	{
		int cur=q.front();q.pop();
		for(auto v:g[cur])
			if(d[v]>d[cur]+1)
			{
				d[v]=d[cur]+1;
				q.push(v);
			}
	}
	return d;
}

int main()
{
	int n;
	cin>>n;
	vector<vector<int> > g(n);
	
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);g[b].push_back(a);
	}
	
	vector<int> a=bfs(n,g,0);
	vector<int> b=bfs(n,g,n-1);
	
	int f=0,s=0;
	for(int i=0;i<n;i++) if(a[i]<=b[i]) f++; else s++;
	cout<<(f>s?"Fennec":"Snuke");
	
	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    unsigned long x{0}, o{0};
    for(const auto& i : A){
        x ^= i;
        o |= i;
    }
    for(auto& i : A)i &= ~x;
    unsigned long a{0};
    for(unsigned long i = 60; i--; ){
        if(partition(A.begin(), A.end(), [&i](auto a){return ~(a >> i) & 1;}) == A.end())continue;
        auto t = A.back();
        A.pop_back();
        if(a < (a ^ t))a ^= t;
        if(A.empty())break;
        for(auto& j : A)if((j >> i) & 1)j ^= t;
    }
    cout << x + (a * 2) << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

struct UnionFind{
    vector<int> d;
    UnionFind(int n = 0): d(n, -1){}
    int find(int x){
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x){return -d[find(x)];}
};


int deg[1000005];
vector<int> blk[1000005];

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
        uf.unite(a, b);
    }

    rep(i, k){
        int a, b;
        cin >> a >> b;
        a--; b--;
        blk[a].push_back(b);
        blk[b].push_back(a);
    }

    rep(i,n){
        int ans = uf.size(i) - deg[i] - 1;
        for(int b: blk[i]){
            if (uf.same(i, b)) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 30220
import Control.Monad
import Data.Char
import Data.Function

main = do
  n <- readLn
  forM_ (solve n) putStrLn

solve :: Int -> [String]
solve n = go 'a' n
  where
    go :: Char -> Int -> [String]
    go _ 0 = [""]
    go c n = concat [map (c' :) (go d (n-1))|c' <- ['a' .. c], let d = chr $ (max `on` fromEnum) c (succ c')]

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}
bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

ll N, M, bri, dge;
vp e(55);
vl E[55];
vb renketu(55);

void dfs(ll root){
    renketu[root] = true;
    for(auto t:E[root]){
        if((t==bri&&root==dge) || (root==bri&&t==dge));
        else if( renketu[t] );
        else dfs(t);
    }
    return;
}
ll check(){
    rep(i, N) if(!renketu[i]) return 1;
    return 0;
}

int main() {
    ios::sync_with_stdio(0);    cin.tie(0);

    // solution comes here

    cin >> N >> M;
    rep(i, M) cin >> e[i].F >> e[i].S;

    rep(i, M) {
        //0-indexed
        e[i].F--;
        e[i].S--;

        E[e[i].F].PB(e[i].S);
        E[e[i].S].PB(e[i].F);
    }

    ll ans=0;
    rep(i, M){
        bri=e[i].F;
        dge=e[i].S;
        rep(t, renketu.size()) renketu[t]=false;
        dfs(0);
        ans += check();
    }

    cout << ans << nl;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vec yakusuu;
    For(i, 1, sqrt(N)) if (N % i == 0 and N / i - 1 > i) yakusuu.pb(N / i - 1);
    print(sum_(yakusuu));

    return 0;
}


Measured memory_bytes: 384
const func2 = (input)=>{
let a = input.split("\n")
let b = a[0].split (" ")
a.shift();
//console.log (a)
let distance_origin = b [1]
let num = b [0]

cal(num,a,distance_origin);

}

const cal= (number, array,origin) =>{
  let output=0
  //numに応じて繰り返し実行。配列arrayから取り出した上で計算する。
  for(i=0; i<number;i++) {
   let target = array[i].split(" ").map( str => parseInt(str, 10));
  //console.log(target)
   let total = Math.sqrt(target[0]**2 + target[1]**2)
  // console.log(total)
   if(origin>=total){
     output ++
   }

}
console.log(output)
}



func2(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 62404
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int32_t X = 0;
  std::cin >> X;

  const int32_t max = 128;
  std::vector<int64_t> N5(max + 1);
  for (size_t i = 0; i <= max; i++) N5[i] = i * i * i * i * i;

  bool flag = false;
  for (int32_t absB = 0; absB <= max; absB++) {
    for (int32_t A = 0; A <= max; A++) {
      if (N5[A] - N5[absB] == X) {
        std::cout << A << " " << absB << std::endl;
        flag = true;
      } else if (N5[A] + N5[absB] == X) {
        std::cout << A << " " << -absB << std::endl;
        flag = true;
      }
      if (flag) break;
    }
    if (flag) break;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll count = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
        ll a2 = (b + c) / 2;
        ll b2 = (a + c) / 2;
        ll c2 = (a + b) / 2;
        a = a2; b = b2; c = c2;
        count++;
        if(a == b && b == c){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define MAX(x,y) (((x)>(y))?(x):(y))

struct node{
  int l,index;
};

void make_pr_queue(struct node *array, int n);
struct node pop_pr_queue(struct node *array,int n);

int main(void){
  struct node *ice,now;
  int *time;
  int i,k=0,n,L;

  scanf("%d%d",&n,&L);

  ice=(struct node *)calloc(n,sizeof(struct node));
  time=(int *)calloc(n,sizeof(int));

  for(i=0;i<n;i++){
    scanf("%d",&ice[i].l);
    ice[i].index=i;
  }

  make_pr_queue(ice,n);
  for(i=0;i<n;i++){
    now=pop_pr_queue(ice,n-i);
    time[now.index]=L-now.l;
    if(now.index==0) time[now.index]+=time[now.index+1];
    else if(now.index==n-1) time[now.index]+=time[now.index-1];
    else time[now.index]+=MAX(time[now.index-1],time[now.index+1]);
    
    if(time[now.index]>k) k=time[now.index];
  }
  printf("%d\n",k);
  free(ice);
  free(time);
  return 0;
}

void make_pr_queue(struct node *array, int n){
  int i,tmp;
  struct node swaps;

  for(i=n-1;i>=0;i--){
    if(2*i+1>=n) continue;
    if(2*i+2<n && array[2*i+2].l>array[2*i+1].l) tmp=2*i+2;
    else tmp=2*i+1;
    if(array[tmp].l>array[i].l){
      swaps=array[i];
      array[i]=array[tmp];
      array[tmp]=swaps;
    }
  }
}

struct node pop_pr_queue(struct node *array,int n){
  struct node ret;
  ret=array[0];
  array[0]=array[n-1];
  make_pr_queue(array,n-1);
  return ret;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    string s; cin >> s;
    vector<ll> lr, lg;
    ll cntb = 0;
    vector<bool> existb(n);
    for(ll i=0;i<n;i++){
        if(s[i] == 'R'){
            lr.push_back(i);
        }else if(s[i] == 'G'){
            lg.push_back(i);
        }else{
            cntb++;
            existb[i] = true;
        }
    }
    ll ans = 0;
    for(ll r: lr){
        for(ll g: lg){
            ll numb = cntb;
            if(r < g){
                // RGB, RBG, BRG
                if(g + (g - r) < n && existb[g + (g - r)]) numb--;
                if((g - r) %2 == 0 && existb[r + (g - r)/2]) numb--;
                if(0 <= r - (g - r) && existb[r - (g - r)]) numb--; 
            }else{
                // GRB, GBR, BGR
                if(r + (r - g) < n && existb[r + (r - g)]) numb--;
                if((r - g) %2 == 0 && existb[g + (r - g)/2]) numb--;
                if(0 <= g - (r - g) && existb[g - (r - g)]) numb--; 
            }
            ans += numb;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 2000000000
#define INFLL 9000000000000000000
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

int main() {
    string s;
    cin >> s;

    int begin, end;

    rep(i, s.length()) {
        if (s[i] == 'A') {
            begin = i;
            break;
        }
    }

    for (int i = s.length() - 1; i >= 0; --i) {
        if (s[i] == 'Z') {
            end = i;
            break;
        }
    }

    cout << end - begin + 1 << endl;
    return 0;

}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define int long long int

int32_t main() {
  FASTIO;
  int n; cin >> n;
  cout << 2*n*3.1415926535 << endl;
  return 0;
}

Measured memory_bytes: 3776
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    LL i, j, a, b, ans=0;
    scanf("%lld%lld",&a,&b);
    if(a == b)
        return 0*puts("1");
    for(i=60; i>=0; --i)
    {
        if((b>>i&1)^(a>>i&1))
            break;
        if(a>>i&1) a ^= 1LL<<i;
    }
    for(j=i-1; j>=0; --j)
        if(b>>j&1)
        {
            ans += (1LL<<j+1)-1;
            break;
        }
    ans += ((1LL<<i)-a)<<1;
    if(j != -1 && a <= (1LL<<j+1)-1) ans -= (1LL<<j+1)-a;
    printf("%lld\n",ans+(i!=0));
    return 0;
}


Measured memory_bytes: 256
s = list(list(map(int,input())))
n = len(s)
dp = [ [0,0] for i in range(n) ]
dp[0][0] = s[0]
dp[0][1] = 11-(s[0]-0)
for i in range(n-1):
  d = s[i+1]
  dp[i+1][0] = min(dp[i][0], dp[i][1]) + d
  dp[i+1][1] = min(dp[i][0]+11-d, dp[i][1]+9-d)
print(min(dp[n-1][0],dp[n-1][1]))


Measured memory_bytes: 187476
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        String p=sc.next();
        int sl=s.length();
        int pl=p.length();
        s=s+s.substring(0,pl-1);
        for(int i=0;i<sl;i++){
            for(int j=0;j<pl;j++){
                if(s.substring(i,i+pl).equals(p)){
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        System.out.println("No");
    }
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    string s; cin >> s;
    string res = "";
    rep(i, s.size()){
        if(s[i] == 'B'){
            if(res.size()){
                res.pop_back();
            }
        }else{
            res.push_back(s[i]);
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
cnt = 0
if l[0] == 0:
    print(cnt)
else:
    cnt += 1
    for i in range(1, n + 1):
        d += l[i - 1]
        if d <= x:
            cnt += 1
    print(cnt)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

vector<int> f(vector<char> x){
  vector<int> ret;
  int now = 0;
  ret.push_back(1);
  ret[now] = 1;
  char tmp = x[now];
  for(int i = 1; i < x.size(); i++){
    if (x[i] == tmp) ret[now]++;
    else {
      tmp = x[i];
      ret.push_back(1);
      now++;
    }
  }
  sort(ALL(ret));
  return ret;
}

int main(){
  string S, T;
  cin >> S >> T;
  vector<char> s(S.size()), t(T.size());
  rep(i, S.size()){
    s[i] = S[i];
    t[i] = T[i];
  }
  sort(ALL(s));
  sort(ALL(t));
  vector<int> a = f(s);
  vector<int> b = f(t);
  bool ok = true;
  if(a.size() == b.size()){
    rep(i, a.size()){
      if (a[i] != b[i]) ok = false;
    }
  } else {
    ok = false;
  }
  if (ok) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 1416
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d",res);
#define pfl(res) printf("%lld",res);
#define pfd(res) printf("%lf",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];

int main()
{
    int n,k;
    sc(n);
    sc(k);
    for(int i=1;i<=n;i++)
    {
        sc(arr[i]);
    }
    int xx=k;
    arr[0]=99999999;
    for(int i=2;i<=n;i++)
    {
        k=xx;
        arr2[i]=999999999;
        for(int j=i-1 ,k=xx;j>=1 && k>0;k--,j-- )
        {
            arr2[i]=min(abs(arr[i]-arr[j])+arr2[j],arr2[i]);
        }
    }
    cout<<arr2[n];
}






Measured memory_bytes: 1152
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

unsigned int randInt() {
	static unsigned int tx = 123456789, ty = 362436069, tz = 521288629, tw = 88675123;
	unsigned int tt = (tx ^ (tx << 11));
	tx = ty; ty = tz; tz = tw;
	return (tw = (tw ^ (tw >> 19)) ^ (tt ^ (tt >> 8)));
}
double randDouble() {
    return (double)(randInt())/UINT_MAX;
}
const int64_t CYCLES_PER_SEC=3000000000;
#define TIMES 1.0
double timeLimit=1.95*TIMES;
struct Timer {
	int64_t start;
	Timer() { reset(); }
	void reset() { start = getCycle(); }
	inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
	inline int64_t getCycle() {
		uint32_t low, high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((int64_t)low) | ((int64_t)high << 32);
	}
} timer;
bool move(long long int prev_score, long long int next_score, double temperature) {
    if (prev_score <= next_score) return true;
    long long int diff = next_score - prev_score;
    //std::cerr << pow(1.0001, diff/temperature) << " " << randDouble() << std::endl;
    return pow(1.003, diff/temperature) >= randDouble();
}
int D; 
int s[365][26];
int contest[365];
int c[26];

int score() {
	int S = 0;
	int last[26] = {};
	rep(i, 26) last[i] = -1;
	rep(i, D) {
		S += s[i][contest[i]];
		last[contest[i]] = i;
		rep(j, 26) {
			S -= c[j] * (i - last[j]);
		}
	}
	//cerr << S << endl;
	return S;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	// std::ifstream in("in1.txt");
    // std::cin.rdbuf(in.rdbuf());
	cin >> D;
	rep(i, 26) cin >> c[i];
	rep(i, 365) {
		rep(j, 26)  {
			cin >> s[i][j];
		}
	}
	rep(i, 365) {
		contest[i] = i % 26;
	}
	int now_score = score();
	while(true) {
		double t=timer.get();
        if(t >= timeLimit) break;
		int a = randInt() % 365;
		int b = randInt() % 26;
		int prev = contest[a];
		contest[a] = b;
		int next_score = score();
		if(now_score < next_score) {
			now_score = next_score;
		} else {
			contest[a] = prev;
		}
		//if(randInt() % 100 == 0) cout << score() << endl;
	}
	//cout << now_score + 1000000 << endl;
	rep(i, D) {
		cout << contest[i] + 1 << endl;
	}
	
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
int main(){
    q x,k,y,n;
    cin>>n>>k>>x>>y;
    if(n<=k){cout<<n*x;}
    else{cout<< k*x+(n-k)*y ;}










return 0;}


Measured memory_bytes: 256
use std::num;
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
  /// Return `true` if the slice was permuted, `false` if it is already
  /// at the last ordered permutation.
  fn next_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T] where T: Ord {
  /// Original author in Rust: Thomas Backman <serenity@exscape.org>
  fn next_permutation(&mut self) -> bool {
    // These cases only have 1 permutation each, so we can't do anything.
    if self.len() < 2 { return false; }

    // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
    let mut i = self.len() - 1;
    while i > 0 && self[i-1] >= self[i] {
      i -= 1;
    }

    // If that is the entire vector, this is the last-ordered permutation.
    if i == 0 {
      return false;
    }

    // Step 2: Find the rightmost element larger than the pivot (i-1)
    let mut j = self.len() - 1;
    while j >= i && self[j] <= self[i-1]  {
      j -= 1;
    }

    // Step 3: Swap that element with the pivot
    self.swap(j, i-1);

    // Step 4: Reverse the (previously) weakly decreasing part
    self[i..].reverse();

    true
  }
}

fn main() {
  let n: usize = read();
  let p: Vec<usize> = read_vec();
  let q: Vec<usize> = read_vec();

  let mut permutations: Vec<usize> = (0..n).map(|i| i+1).collect();
  let mut count = 0;
  let mut a= 0;
  let mut b= 0;
  loop {
    count += 1;
    if (0..n).all(|i| p[i] == permutations[i]) {
      a = count;
    }
    if (0..n).all(|i| q[i] == permutations[i]) {
      b = count;
    }
    if !permutations.next_permutation() { break; }
  }

  println!("{}", std::cmp::max(a, b) - std::cmp::min(a, b));

}




Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long long mod =1e9+7;


int main(){
  int N;
  cin >> N;
  if(N/10==9 || N%10==9){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

    return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/lexical_cast.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define PI acos(-1)
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

long mod=1e9+7;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			int temp=r*i+g*j;
			temp=n-temp;
			if(temp>=0)
			{
				if(temp%b==0)++ans;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [[0, 0, 0]for i in range(N)]
for i in range(N):
  a, b = list(map(int, input().split()))
  A[i] = a+b, a, b
A.sort(reverse=True)
x = 0
for i in range(N):
    x += (-1)**i * A[i][1+i%2]
print(x)

Measured memory_bytes: 23536
n = int(input())

import math

cnt = 0

for _ in range(n):
    x = int(input())
    
    flag = 1
    
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            flag = 0
            break
    cnt += flag
    
print(cnt)


Measured memory_bytes: 5672
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> vec(n+1);
	reps(i,n){
		cin >> vec[i];
	}
	int sum = 0;
	for(int i = n;i > 0;--i){
		sum += vec[i] / 2;
		vec[i] %= 2;
		if(i != 1 && vec[i] && vec[i-1]){
			++sum;
			--vec[i-1];
		}
	}
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int N;
	cin>>N;
	
	int A[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	int ans=0;
	
	while(1){
		for(int i=0;i<N;i++){
			if(A[i]%2==0){
				ans++;
				A[i]=A[i]/2;
			}
			else{
				cout<<ans/N<<endl;
				return 0;
			}
		}
	}
	
	
	
	
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):
    d = 0
    for i in range(0, N):
        if i + 1 == N:
            next = K - A[i] + A[0]
        else:
            next = A[i + 1] - A[i]
        d = max(d, next)
    print(K - d)
        
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26228
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    if A[i] > k:
        break
    #K<=A[i]+B[j]となるまでjを引く>>k-A<=B
    while A[i] + B[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

const int maxn = 2010, mod = 1e9 + 7;
int a, b, sol;
int choose[maxn][maxn], choose_s[maxn][maxn], f[maxn][maxn];

int add(int x, int y)
{
	return (x + y) % mod;
}

int mul(int x, int y)
{
	return ((long long) x * (long long) y) % mod;
}

int main()
{
	for (int i = 0; i < maxn; i++)
	{
		choose[i][0] = 1;
		choose_s[i][0] = 1;
		for (int j = 1; j <= i; j++)
		{
			choose[i][j] = add(choose[i - 1][j], choose[i - 1][j - 1]);
			choose_s[i][j] = add(choose_s[i][j - 1], choose[i][j]);
		}
	}
	for (int i = 0; i < maxn; i++)
	{
		f[i][0] = 1;
		f[0][i] = 1;
	}
	for (int i = 1; i < maxn; i++)
	{
		for (int j = 1; j < maxn; j++)
		{
			f[i][j] = add(f[i - 1][j], choose_s[j - 1][min(j - 1, i)]);
		}
	}
	cin >> a >> b;
	for (int i = 0; i <= a; i++)
	{
		for (int j = max(0, i + b - a - 1); j <= b - 1; j++)
		{
			sol = add(sol, mul(f[a - i - b + j + 1][b - j - 1], choose[b - 1][j]));
		}
	}
	cout << sol;
	return 0;
}

Measured memory_bytes: 47744
import sys
from operator import itemgetter

sys.setrecursionlimit(5000)
input = sys.stdin.readline


TIME = 0
VAL = 1

N, T = [int(a) for a in input().split()]
time_value = [None] * (N + 1)
time_value[0] = (-1, -1)
for i in range(1, N + 1):
    time_value[i] = tuple(int(a) for a in input().split())

# Sort the array in the increasing order of value
time_value.sort(key = itemgetter(VAL))


# T by (N + 1) table for knapsack problem
# maximum possible time is T-1
dp_table = [[-1] * T for _ in range(N + 1)]

# Fill in dp_table i.e. solve knapsack problem
for t in range(0, T):
    dp_table[0][t] = 0

for n in range(1, N + 1):
    dp_table[n][0] = 0
    for t in range(1, T):
        if time_value[n][TIME] > t:
            dp_table[n][t] = dp_table[n - 1][t]
        else:
            dp_table[n][t] = max(dp_table[n - 1][t],
                             time_value[n][VAL] + dp_table[n - 1][t - time_value[n][TIME]])


val_acum = time_value[N][VAL]
t = T - 1
max_val = val_acum + dp_table[N - 1][t]

for n in range(N - 1, 0, -1):  # food to eat at the end
    val_acum += time_value[n][VAL] # value[N] + value[N-1] + ... + value[n]
    t -= time_value[n + 1][TIME] # T - 1 - (time[N] + time[N-1] + ... + time[n + 1])
    if t < 0: break
    tmp = val_acum + dp_table[n - 1][t]
    max_val = max(max_val, tmp)

print(max_val)

Measured memory_bytes: 114012
import scala.io.Source.stdin

object Main extends App {
  var b = new StringBuilder

  for(d<-stdin.getLines.map(_.toInt)) {
    var (j,s) = (0,0)

    while((j-1)*d < 600-d) {
      s += j*j*d*d*d
      j += 1
    }
    b.append(s+"\n")
  }

  print(b.result)
}

Measured memory_bytes: 43732
#include<bits/stdc++.h>
using namespace std;
int input() {
	int r;
	scanf("%d", &r);
	return r;
}
int n; vector<string>ans;
void f(string s, bool b) {
	if (s.size() == 10) {
		ans.push_back(s); return;
	}
	if (ans.size() > n + 5)return;
	char slast = s[s.size() - 1];
	for (char c = (b ? max((char)(slast - 1) , '0') : '0'); c <= (b ? min((char)(slast + 1), '9') : '9'); c++) f(s + c, b || c > '0');
}
void output(string s) {
	bool b = 0;
	for (char ch : s) {
		if (ch > '0')b = 1;
		if (b)cout << ch;
	}
	printf("\n");
}
signed main() {
	n = input(); f("", 0); output(ans[n]);
}

Measured memory_bytes: 7284
N = int(input())
X = list(map(int, input().split()))
X.sort(reverse=True)
sum = []
p = 0

for k in range(X[0]):
	sum.append(0)
	p += 1
	for i in range(len(X)):
		sum[k] += abs(X[i] - p) ** 2

sum.sort(reverse=False)        
print(sum[0])

Measured memory_bytes: 3064
a,b,c=map(int,input().split());o=0
if a==b==c:print(a%2-1);exit() 
while 1-any([a%2,b%2,c%2]):a,b,c=(b+c)//2,(c+a)//2,(a+b)//2;o += 1
print(o) 

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   string x,y;
   cin>>x;
   for(int i=0;i<x.length();i++){
    if(i%2==0)
        y+=x[i];
   }
   cout<<y<<endl;

    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y,z,w,cnt=0;
vector<int> v;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(),v.end());
	x=v[0];
	y=v[1];
	z=v[2];
	cnt+=(z-y);
	w=x+z-y;
	if((z-w)%2==1)
	{
		printf("%d\n",cnt+(z-w-1)/2+2);
	}else
	{
		printf("%d\n",cnt+(z-w)/2);
	}
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    LL N, s = 0;
    cin >> N;
    vector<LL> A(N), B(N);
    for(int i = 0; i < N; i += 1) cin >> A[i] >> B[i];
    for(LL i = N - 1; ~i; i -= 1){
        A[i] = (A[i] + s) % B[i];
        s += A[i] ? B[i] - A[i] : 0;
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 1792
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    let s: String = read!();
    let s = s.chars().map(|c| c.to_digit(10).unwrap() as usize);
    const MOD: usize = 2019;

    let s = s.rev().scan((0, 1), |(acc, ten), u| {
        *acc = *acc + *ten * u;
        *ten *= 10;
        *ten = *ten % MOD;
        *acc = *acc % MOD;
        Some((*acc, *ten))
    });

    let mut vec = vec![0; 2019];
    vec[0] = 1isize;

    for (v, _j) in s {
        vec[v] += 1;
    }

    let ans = vec.iter().map(|&v| v * (v - 1) / 2).sum::<isize>();

    println!("{}", ans);
}


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

const int MOD = 1e9 + 7;

string s[1002];

int dp[1002][1002];

int main()
{
   int h,w;
   cin>>h>>w;

   for(int i = 0; i < h; i++)
   {
       cin>>s[i];
   }

   dp[0][0] = 1;
   for(int i = 0; i < h; i++)
   {
       for(int j = 0; j < w; j++)
       {
           if(s[i][j] == '#')
           {
               dp[i][j] = 0;
               continue;
           }
           if(i > 0)
           {
               dp[i][j] += dp[i - 1][j];
               dp[i][j] %= MOD;
           }
           if(j > 0)
           {
               dp[i][j] += dp[i][j - 1];
               dp[i][j] %= MOD;
           }
       }
   }
   cout<<dp[h - 1][w - 1]<<endl;
}


Measured memory_bytes: 9404
#include <iostream>

using namespace std;

int ans;
string s;

int main() {
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    ans = (ans + s[i] - '0') % 9;
  }
  cout << (ans ? "No" : "Yes");
  return 0;
}

Measured memory_bytes: 3716