akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,c,d,e,h,w;
 
ll x[500005],y[500005],z[500005];

int main(){
    cin>>n;
	if(n<=1199){
		p("ABC");
	}else if(n<=2799){
		p("ARC");
	}else{
		p("AGC");
	}
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <sstream>
#include <limits>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#define PI (acos(-1.0))
#define Abs(a) (((a)<0) ? (-(a)) :(a) )
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i,n) for(int i=((n)-1);i>=0;i--)
#define rrep(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define Pii pair<int,int>
#define PB push_back
#define Size(x) ((int)(x.size()))
using namespace std;
typedef long long mint;
typedef unsigned long long umint;
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b;
    cin >> a >> b;
    string ans = "Alice";
    if(a == b)
    {
        ans = "Draw";
    }
    else if(b == 1)
    {
        ans = "Bob";
    }
    else if(a != 1)
    {
        ans = (a > b) ? ans : "Bob";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stdio.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int ans = 0;
	if (A < K) {
		ans += A;
		K -= A;
	}
	else {
		cout << K << endl;
		return 0;
	}

	if (B < K) {
		K -= B;
	}
	else {
		cout << ans << endl;
		return 0;
	}

	if (C < K) {
		cout << ans - C << endl;
	}
	else {
		cout << ans - K << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#define N 305
using namespace std;

int n, a[N][N], v[N][N];
int main()
{
	int i,j, k, num;
	cin >> n;
	for (i = 1; i <= n; i++) {
		for (j= 1; j <= n; j++) {
			scanf ("%d", &a[i][j]);
		}
	}
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				if (i == j) continue;
				num = a[i][k] + a[k][j];
				if (num < a[i][j]) {
					cout << -1;
					return 0;
				}
				if (num == a[i][j] && i != k && j != k) v[i][j] = 1;
			}
		}
	}
	long long s = 0;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			s += a[i][j] * (1 - v[i][j]);
		}
	}
	cout << s / 2;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int a,b;
    cin >> a >> b;

    if(a <= 9 && b <= 9){
        cout << a*b << endl;
    }else{
        cout << "-1" << endl;
    }
  

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using ll=long long;
const int MAXN=100010;

bool check(int m,int k){
    if((1<<m)-1>=k)return true;
    return false;
}
vector<int> ans;
int main() {
    ios::sync_with_stdio(false);
    int res=0;

    int m,k;
    cin>>m>>k;
    if(m==1){
        if(k==0){
            for(int i=0;i<(1<<m);i++){
                ans.push_back(i);
                ans.push_back(i);
            }
        }else{
            ans.push_back(-1);
        }
    }
    else if(check(m,k)){
        ans.push_back(k);
        for(int i=0;i<(1<<m);i++){
            if(i==k)continue;
            ans.push_back(i);
        }
        ans.push_back(k);
        for(int i=(1<<m)-1;i>=0;i--){
            if(i==k)continue;
            ans.push_back(i);
        }
    }else{//
        ans.push_back(-1);
    }

    for(int i=0;i<ans.size()-1;i++){
        cout<<ans[i]<<" ";
    }
    cout<<ans.back()<<endl;



    return 0;
}

Measured memory_bytes: 2932
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    vector<int> cnt(3);
    for(char c:S)cnt[c == 'a' ? 0 : c == 'b' ? 1 : 2 ]++;
    int N = S.size();
    if(N == 1){
        cout << "YES" << endl;
        return 0;
    }
    //if(cnt[0] > N / 2 || cnt[1] > N / 2 || cnt[2] > N / 2){
    if (cnt[0] > (N + 2) / 3 || cnt[1] > (N + 2) / 3 || cnt[2] > (N + 2) / 3){
        cout << "NO" << endl;
        return 0;
    }


    cout << "YES" << endl;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
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
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 = INT()
k = int(0.5+(2*N)**0.5)
if k*(k+1) == 2*N:  # 集合の数がk+1, サイズがk
	print("Yes")
	print(k+1)
	ans = [[] for _ in range(k+1)]
	for i, (x, y) in enumerate(combinations(range(k+1), 2)):
		ans[x].append(i+1)
		ans[y].append(i+1)
	for l in ans:
		print(k, *l)
else:
	print("No")


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

using namespace std;

int d[100020];

int resi(int h[], int i, int n)
{   
    if(i == n-1)
        return 0;
    
    int pom1;

    if(d[i+1] == -1)
        {
            d[i+1] = resi(h, i+1, n);
        }
 
    pom1 = d[i+1] + abs(h[i]-h[i+1]);
    
    
    //cout << "i:   " << i << "POM1 :" << pom1 << endl;

    if(i == n-2)
    {
        return pom1;
    }
    else
    {
        if(d[i+2] == -1)
        {
            d[i+2] = resi(h, i+2, n);
        }
        int pom2 = d[i+2] + abs(h[i]-h[i+2]);
        //cout << "i:   " << i << "POM222 :" << pom2 << endl;
        return min(pom1, pom2);
    }
}

int main()
{
    int n;

    cin >> n;

    int h[100020];
    
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
        d[i] = -1;
    }


    cout << resi(h,0,n) << endl;

    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int n,k,i,ans=999999999,a[200001];

int main(){
	cin >> n >> k;
	for(i=1;i<=n;i++)
		cin >> a[i];
	sort(a+1,a+n+1);
	for(i=k;i<=n;i++)
		if(a[i-k+1]>=0)
			ans=min(ans,a[i]);
		else if(a[i]<=0)
			ans=min(ans,-a[i-k+1]);
		else
			ans=min(ans,a[i]-a[i-k+1]+min(-a[i-k+1],a[i]));
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
bool p[300];
int n;
bool prime(int n)
{
    for (int i=2; i<=sqrt(n)+1; ++i)
        if (n%i==0)
            return 0;
    return 1;
}
int pnum(int n)
{
    int sum=0;
    for (int i=1; i<=n; ++i)
    {
        if (n%i==0)
            sum++;
    }
    return sum;
}
int main()
{
    cin>>n;
    for (int i=2; i<=200; ++i)
    {
        p[i]=prime(i);
    }
    int sum=0;
    for (int i=1; i<=n; i+=2)
        if (pnum(i)==8)
            sum++;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#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()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

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

    vi r(n), g(n), b(n);

    char c = s[n-1];
    if(c=='R'){
        r[n-1] = 1;
        g[n-1] = 0;
        b[n-1] = 0;
    }else if(c=='G'){
        r[n-1] = 0;
        g[n-1] = 1;
        b[n-1] = 0;
    }else{
        r[n-1] = 0;
        g[n-1] = 0;
        b[n-1] = 1;
    }

    drep(i, n-1){
        char c = s[i];
        if(c=='R'){
            r[i] = r[i+1] + 1;
            g[i] = g[i+1];
            b[i] = b[i+1];
        }else if(c=='G'){
            r[i] = r[i+1];
            g[i] = g[i+1] + 1;
            b[i] = b[i+1];
        }else{
            r[i] = r[i+1];
            g[i] = g[i+1];
            b[i] = b[i+1] + 1;
        }
    }

    ll ans = 0;

    if(n==1 || n==2){
        cout << 0 << endl;
        return 0;
    }

    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            char fi = s[i];
            char se = s[j];
            if(fi == se) continue;
            int tmp = 2*j - i;
            bool ok = true;
            if(2*j - i >= n) ok = false;
            //fiがRの場合
            if(fi=='R'){
                if(se=='G'){
                    ans += b[j];
                    if(ok){
                        if(s[2*j - i]=='B') ans--;
                    }
                }
                if(se=='B'){
                    ans += g[j];
                    if(ok) if(s[2*j - i]=='G') ans--;
                }
            }
            //fi==G
            if(fi=='G'){
                if(se=='R'){
                    ans += b[j];
                    if(ok) if(s[2*j - i]=='B') ans--;
                }
                if(se=='B'){
                    ans += r[j];
                    if(ok) if(s[2*j - i]=='R') ans--;
                }
            }
            //fi==B
            if(fi=='B'){
                if(se=='R'){
                    ans += g[j];
                    if(ok) if(s[2*j - i]=='G') ans--;
                }
                if(se=='G'){
                    ans += r[j];
                    if(ok) if(s[2*j - i]=='R') ans--;
                }
            }
        }
    }

    cout << ans << endl;


    /*
    rep(i, n){
        printf("(%d, %d, %d)\n", r[i], g[i], b[i]);
    }
    */
    


    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repn(i, j, k) for (int i = (j); i < (k); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

int main()
{
  int A, B;
  cin >> A >> B;
  cout << 6 - (A + B) << endl;
  return 0;
}

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

using namespace std;

const int Mod = 1e9 + 7;
const int Nmax = 2005;
typedef long long ll;

int n, i, j, x;
vector<int> v[Nmax];
int dp[Nmax][Nmax][3], fact[Nmax], D[Nmax][3], w[Nmax];

void add_to(int &x, int y) { x+=y; if(x>=Mod) x-=Mod; }
int inm(int x, int y) { return (ll)x*y%Mod; }

void Merge(int node, int son)
{
    int i, j, dg, dgr;
    for(i=0; i <= w[node] + w[son]; ++i)
        for(j=0; j<3; ++j)
            D[i][j] = 0;

    for(i=0; i<=w[node]; ++i)
        for(j=0; j<=w[son]; ++j)
            for(dg=0; dg<3; ++dg)
                for(dgr=0; dgr<3; ++dgr)
                    if(dp[node][i][dg] && dp[son][j][dgr])
                    {
                        add_to( D[i+j][dg], inm(dp[node][i][dg], dp[son][j][dgr] * (dgr ? 2 : 1)) );

                        if(dg < 2 && dgr < 2)
                            add_to( D[i+j-1][dg+1], inm(dp[node][i][dg], dp[son][j][dgr]) );
                    }

    w[node] += w[son];
    for(i=0; i<=w[node]; ++i)
        for(j=0; j<3; ++j)
            dp[node][i][j] = D[i][j];
}

void solve(int node)
{
    w[node] = 1; dp[node][1][0] = 1;
    for(auto son : v[node])
    {
        solve(son);
        Merge(node, son);
    }
}

int main()
{
 //   freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=2; i<=n; ++i)
    {
        cin >> x;
        v[x].push_back(i);
    }

    fact[0] = 1;
    for(i=1; i<=n; ++i) fact[i] = inm(fact[i-1], i);

    solve(1);

    int ans = 0;
    for(i=0; i<=n; ++i)
        for(j=0; j<3; ++j)
            if( (n-i) % 2 == 0 ) add_to(ans, inm( dp[1][i][j] * (j ? 2 : 1), fact[i] ) );
                else add_to(ans, Mod - inm( dp[1][i][j] * (j ? 2 : 1), fact[i] ) );

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 47488
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, k;
bool dp[MAXN];
int arr[MAXN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>k;
    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }
    dp[0] = false;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(arr[j] > i){
                break;
            }
            dp[i] = (dp[i] | (!dp[i - arr[j]]));
        }
    }
    if(dp[k]){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 384
n = int(input())
h_li = list(map(int, input().split()))

dp = [10**18] * n
dp[0] = 0
for i in range(1,n):
    if i == 1:
        dp[i] = abs(h_li[i] - h_li[0])
    else:
        dp[i] = min(abs(h_li[i] - h_li[i-1]) + dp[i-1], abs(h_li[i] - h_li[i-2]) + dp[i-2])

print(dp[-1])

Measured memory_bytes: 20524
import sys
import numpy as np
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    h, w, k = map(int, input().split())
    ans = 0
    grid = []
    index = [i for i in range(h + w)]
    for _ in range(h):
        grid.append(list(input()))
    grid = np.array(grid)
    if np.count_nonzero(grid == '#') == k:
        ans += 1
    for i in range(1, h+w+1):
        for combs in itertools.combinations(index, i):
            tmp = grid.copy()
            row, col = [], []
            for comb in combs:
                if comb >= w:
                    row.append(comb - w)
                else:
                    col.append(comb)
            tmp = np.delete(tmp, row, 0)
            tmp = np.delete(tmp, col, 1)
            if np.count_nonzero(tmp == '#') == k:
                ans += 1
    print(ans)                
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 27280
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll N,X;
vector<ll> A,B;
ll dfs(int i, ll x){
    if(i == 0)return 1;
    if(x == 1)return 0;
    if(x == A[i-1] + 2)return B[i-1] + 1;
    if(x == A[i-1] * 2 + 3)return B[i];
    if(x < A[i-1] + 2){
        return dfs(i-1, x-1);
    }else{
        return dfs(i-1, x-(A[i-1]+2)) + B[i-1] + 1;
    }
}
main(){
    cin >> N >> X;
    A.resize(N+1);
    B.resize(N+1);
    A[0] = B[0] = 1;
    rep(i,0,N){
        A[i+1] = A[i] * 2 + 3;
        B[i+1] = B[i] * 2 + 1;
    }
    cout << dfs(N, X) << endl;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int X, Y; cin >> X >> Y;
	cout << X + Y/2 << endl;


	return 0;

}


Measured memory_bytes: 256
x,y = map(float, input().split())
t = (y-2*x)/2
c = x-t
if(t>=0 and c>=0):
  t = t-int(t)
  c = c-int(c)
  if(t==0 and c==0):
    print('Yes')
  else:
    print('No')
else:
   print('No')

Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int k, x;
	cin >> k >> x;
	for (int i = 0; i < 2 * k - 1; i++) {
		cout << (x - k + 1) + i << " ";
	}
}


Measured memory_bytes: 256
import itertools

n = int(input())
p = tuple(map(int, input().split()))
# p = ''.join(p)
q = tuple(map(int, input().split()))
# q = ''.join(q)

sorted_num = list(itertools.permutations(range(1, n + 1)))
# sorted_num.sort()

a = sorted_num.index(p)
b = sorted_num.index(q)

print(abs(a-b))


Measured memory_bytes: 8052
import sys

N=int(input())

a=[int(t.strip()) for t in input().split()]

num=[]
num= [0] * (max(a)+3)
for i in range(N):
	num[a[i]] += 1
	
maximum=0
for i in range(len(num)-2):
	tmp=num[i] + num[i+1] +num[i+2]
	if maximum < tmp:
		maximum = tmp

print(maximum)		
#print(num)


Measured memory_bytes: 13964
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  vector<ull> a;
  each(i, n+1) {
    ull tmp;
    cin >> tmp;
    a.push(tmp);
  }

  vector<ull> b;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    b.push(tmp);
  }

  ull result = 0;
  each(i, n) {
    auto current = b[i];

    if (a[i] <= current) {
      current = current - a[i];
      result += a[i];
    } else {
      result += current;
      current = 0;
    }

    if (current != 0) {
      if (a[i+1] <= current) {
        current = current - a[i];
        result += a[i+1];
        a[i+1] = 0;
      } else {
        result += current;
        a[i+1] = a[i+1] - current;
        current = 0;
      }
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 2548
<?php
$arr = explode(" ", trim(fgets(STDIN)));
$a = $arr[0];
$b = $arr[1];

// 電源プラグの数
$sum = 0;
// 必要電源タップの数
$count = 0;

do {
	if ($b == 1) {
		break;
	} elseif ($count == 0) {
		$sum += $a;
		$count++;
	} else {
		$sum += ($a-1);
		$count++;
	}
} while ($sum < $b);

echo $count;

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

#define INF (1<<30)
#define MAX 100010

int dp[MAX];
int h[MAX];

int main(){

	int n,k;	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
		dp[i]=INF;
	}
	dp[0]=0;

	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			dp[i+j]=min(dp[i+j], dp[i] + abs(h[i+j]-h[i]) );
		}
	}

	cout<<dp[n-1]<<endl;

	return 0;
}


Measured memory_bytes: 1024
fun main() {
    val N = readLine()!!.toInt()
    val input = readLine()!!.split(" ").map { it.toInt() }
    val L = input.toMutableList()
    L.add(0, 0)
    var cnt = 0

    for (i in 1..N-2) {
        for (j in i+1..N-1) {
            for (k in j+1..N) {
                val list = mutableListOf<Int>(L[i], L[j], L[k])
                list.sortDescending()
                val set = list.toSet()
                if (list[0] < list[1] + list[2] && set.size == 3) {
                    cnt ++
                }
            }
        }
    }

    println(cnt)
}

Measured memory_bytes: 56428
import itertools
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


D, G = list(map(int, sys.stdin.buffer.readline().split()))
P, C = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(D)]))
P = np.array(P, dtype=int)
C = np.array(C, dtype=int)

scores = P * np.arange(1, D + 1, dtype=int) * 100 + C
ans = INF
for completes in itertools.product([True, False], repeat=D):
    completes = np.where(completes)[0]

    score = scores[completes].sum()
    cnt = P[completes].sum()
    if score >= G:
        ans = min(ans, cnt)
        continue
    for i in range(D):
        if i in completes:
            continue
        rem = math.ceil((G - score) / ((i + 1) * 100))
        if rem < P[i]:
            ans = min(ans, cnt + rem)
print(ans)


Measured memory_bytes: 12448
#include <stdio.h>
#define NUM 100
int main(void)
{
	int n;
	int i,j;
	int a[NUM];

	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &a[i]);

	for (j = n - 1 ; j >= 0; j--){
		printf("%d", a[j]);
		if (a[j]==a[0])break;
		printf(" ");
	}
	printf("\n");

	return 0;
}

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

void ioThings() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
}

using   ll        = long long;
#define debug(x)    cerr << #x << ": <" << x << ">\n"
#define dotc()      int tcs; if (cin >> tcs) for (int tc = 0; tc < tcs; tc++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second
#define mod         1000000007

int main() {
    ioThings();

    cout << setprecision(6) << fixed;

    int n, k; cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    
    int cur = accumulate(p.begin(), p.begin() + k, k);
    int max = cur;
    for (int i = k; i < n; i++) {
        cur = cur - p[i - k] + p[i];
        if (cur > max)
            max = cur;
    }
    cout << max / 2.0;

    return 0;
}


Measured memory_bytes: 1024
//It’s never too late to become what you might have been....
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

pair<ll,ll>a[maxn];
int main()
{
	boost1;boost2;	
	ll i,j,n,curx,cury,x,y,lo,mid,hi,infi=1000000000000000000;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i].F>>a[i].S;
	curx=a[1].F;
	cury=a[1].S;
	for(i=2;i<=n;i++)
	{
		lo=0;
		hi=infi/max(a[i].F,a[i].S);
		while(hi-lo>1)
		{
			mid=(lo+hi)/2;
			x=a[i].F*mid;
			y=a[i].S*mid;
			if(x>=curx && y>=cury)
			hi=mid;
			else
			lo=mid;
		}
		curx=hi*a[i].F;
		cury=hi*a[i].S;
	}
	cout<<curx+cury;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};


int main(){
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;
}


Measured memory_bytes: 256
mod = 998244353

n, s = gets.to_s.split.map{|e| e.to_i }
a = gets.to_s.split.map{|e| e.to_i }.sort

dp = [0] * (s+1)
dp[0] = 1

a.each do |t|
  s.downto(0) do |j|
    dp[j] *= 2
    dp[j] += dp[j-t] if j - t >= 0
    dp[j] %= mod if dp[j] >= mod
  end
end

puts dp[s]

Measured memory_bytes: 14344
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back
#define SIZE 100005

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort( a, a + 3 );

    int res = 0;

    res = a[2] - a[1];
    a[0] += a[2] - a[1];
    a[1] = a[2];
    if( ( a[1] - a[0] ) % 2 ) {
        ++res;
        ++a[1];
        ++a[2];

    }

    res += ( a[1] - a[0] ) / 2 ;

    cout << res << endl;

    return 0;
}



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

int main() {
  int N, Y;
  cin >> N >> Y;

  int x = -1;
  int y = -1;
  int z = -1;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
        x = i;
        y = j;
        z = N - i - j;
      }
    }
  }

  cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
/* Written by Filip Hlasek 2016 */
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstring>

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,b) for(int i=0;i<(b);i++)

using namespace std;

#define MAXN 1111111
int L[MAXN];

int main(int argc, char *argv[]) {
  int N;
  scanf("%d", &N);
  REP(i, 2 * N) scanf("%d", L + i);
  sort(L, L + 2 * N);
  int ans = 0;
  REP(i, N) ans += L[2 * i];
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#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()
#define mod 1000000007
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int a = n % 10;
    if(a==2 || a==4 || a==5 || a==7 || a==9){
        cout << "hon" << endl;
    }else if(a==0 || a==1 || a==6 || a==8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
n=int(input())
A=[]
for i in range(n):
  A.append(input())
from collections import Counter
C=Counter(A)
qq=max(C.values())
ans=[]
for word,times in C.items():
  if times==qq:
    ans.append(word)
ans.sort()
for i in range(len(ans)):
  print(ans[i])


Measured memory_bytes: 35472
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 2e5 + 7;
const LL MOD = 1e9 + 7;

LL f[N], g[N], fac[N], inv[N];
vector<int > p[N];
int sz[N], n;

LL qpow(LL x, LL y){
	LL z = 1;
	while (y){
		if (y & 1) z = z * x % MOD;
		x = x * x % MOD;
		y /= 2;
	}
	return z;
}

void gao1(int x, int fa){
	sz[x] = 1; f[x] = 1;
	for (int i = 0; i < p[x].size(); i++) if (p[x][i] != fa){
		gao1(p[x][i], x);
		sz[x] += sz[p[x][i]];
		f[x] = f[x] * f[p[x][i]] % MOD;
		f[x] = f[x] * inv[sz[p[x][i]]] % MOD;
	}
	f[x] = f[x] * fac[sz[x] - 1] % MOD;
}

void gao2(int x, int fa){
	for (int i = 0; i < p[x].size(); i++) if (p[x][i] != fa){
		LL t = f[x] * qpow(f[p[x][i]], MOD - 2) % MOD * fac[sz[p[x][i]]] % MOD;
		t = t * inv[sz[x] - 1] % MOD;
		t = t * fac[n - sz[p[x][i]] - 1] % MOD;
		if (x != 1) t = t * g[x] % MOD * inv[n - sz[x]] % MOD;
		g[p[x][i]] = t;
		gao2(p[x][i], x);
	}
}

int main(){
	scanf("%d", &n);
	fac[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;
	for (int i = 0; i <= n; i++) inv[i] = qpow(fac[i], MOD - 2);

	for (int i = 1; i < n; i++){
		int u, v; scanf("%d%d", &u, &v);
		p[u].push_back(v); p[v].push_back(u);
	}
	gao1(1, 0);
	gao2(1, 0);
	for (int i = 1; i <= n; i++){
		if (i == 1) printf("%lld\n", f[1]);
		else {
			LL t = f[i] * g[i] % MOD * inv[n - sz[i]] % MOD;
			t = t * inv[sz[i] - 1] % MOD * fac[n - 1] % MOD;
			printf("%lld\n", t); 
		}
	}	
	return 0;
}

Measured memory_bytes: 20980
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

// Node(parent)
int Node[10000] = {};

int same(int x, int y){
    int x_i = x,y_i = y;
    while (x_i != Node[x_i]) {
        x_i = Node[x_i];
    }
    while (y_i != Node[y_i]) {
        y_i = Node[y_i];
    }
    
    if (x_i - y_i) {
        return 0;
    }else{
        return 1;
    }
}

void unite(int x, int y){
    
    if (same(x,y) == 1) {
        return;
    }
    
    int x_i = x,y_i = y;
    while (x_i != Node[x_i]) {
        x_i = Node[x_i];
    }
    while (y_i != Node[y_i]) {
        y_i = Node[y_i];
    }
    
    Node[y_i] = x_i;
}

int main(){
    INT(n);
    INT(q);
    REP1(i,n) Node[i] = i;
    REP1(i,q){
        INT(com);INT(x);INT(y);
        if (com) {
            printf("%d\n",same(x,y));
        }else{
            unite(x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 1228
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (Math.abs(c-a) <= d) {
			System.out.println("Yes");
		} else if (Math.abs(b-a) <= d && Math.abs(c-b) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 21076
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

if N % 2 == 0:
    small = A[:N // 2]
    big = A[N//2:]
    x = 2 * sum(small) - small[-1]
    y = 2 * sum(big) - big[0]
    ans = y - x
else:
    small = A[:N // 2]
    big = A[N // 2 + 1:]
    mid = A[N // 2]

    left = 2 * sum(big) - 2 * sum(small) - mid + small[-1]
    right = 2 * sum(big) - 2 * sum(small) + mid - big[0]

    ans = max(left, right)

print(ans)

Measured memory_bytes: 7764
# -*- coding: utf-8 -*-

def assignColor():
    global C
    for i in range(n):
        if C[i] == -1:
            #BFS(i)
            DFS(i)
            
#@profile
def BFS(start):
    global C
    Q = [start]
    C[start] = start

    while len(Q) != 0:
        u = Q.pop(0)
        v = [i for i in G[u] if C[i] == -1] # v := ??£??\???????????????????????¢?´¢??????????????????
        
        for i in v:
            Q.append(i)
            C[i] = C[start]

#@profile
def DFS(start):
    global C
    S = [start]
    C[start] = start
    while len(S) != 0:
        u = S.pop(0)
        for i in G[u]:
            if C[i] == -1:
                C[i] = start
                S.append(i)

if __name__ == "__main__":
    n, m = list(map(int, input().split()))
    G = [[] for i in range(n)]
    C = [-1]*n
    
    for i in range(m):
        s, t = list(map(int, input().split()))
        G[s].append(t)
        G[t].append(s)
    assignColor()
    q = int(input())
    for i in range(q):
        s, t = list(map(int, input().split()))
        if C[s] == C[t]:
            print("yes")
        else:
            print("no")
            

Measured memory_bytes: 32852
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

set<int> s;
void solve()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size();
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int,int>> vii;

inline int64_t LSOne(int64_t b) {
    return (b & (-b));
}

class FenwickTree {
private:
    vector<int64_t> ft;
public:
    FenwickTree(int64_t n) {
        ft.assign(n + 1, 0);
    }
    int64_t rsq(int64_t b) {
        int sum = 0;
        for (; b; b -= LSOne(b)) {
            sum += ft[b];
        }
        return sum;
    }
    int64_t rsq(int64_t a, int64_t b) {
        if (a > b) return 0;
        return rsq(b) - rsq(a - 1);
    }
    void update(int64_t a, int64_t v) {
        for ( ; a < (int)ft.size(); a += LSOne(a)) {
            ft[a] += v;
        }
    }
    void update(int64_t a, int64_t b, int64_t v) {
        update(a, v);
        update(b + 1, -v);
    }
};

class arc068E {
public:
    void solve(istream& in, ostream& out) {
        int N, M;
        in >> N >> M;
        
        vector<pair<int,int>> souv(N);
        for (int i = 0; i < N; ++i) {
            in >> souv[i].first >> souv[i].second;
        }
        sort(souv.begin(), souv.end(), [](const pair<int,int> &lhs, const pair<int,int> &rhs) {
            return (lhs.second - lhs.first) > (rhs.second - rhs.first);
        });
        
        FenwickTree ft(M+10);
        for (int i = 0; i < N; ++i) {
            //out << souv[i].first << " " << souv[i].second << endl;
            ft.update(souv[i].first, souv[i].second, 1);
        }
        
        vector<int> ans(M);
        int j = 0;
        for (int i = M; i >= 1; --i) {
            //cout << "-> " << i << ": ";
            
            while (j < N && souv[j].second - souv[j].first + 1 > i) {
                //cout << "rem: " << souv[j].first << "," << souv[j].second << "; ";
                ft.update(souv[j].first, souv[j].second, -1);
                ++j;
            }
            
            int64_t k = i, res = 0;
            while (k <= M) {
                res += ft.rsq(k);
                k += i;
            }
            //cout << res << " + " << j << endl;
            ans[i-1] = res + j;
        }
        for (int i = 0; i < M; ++i) {
            out << ans[i] << endl;
        }
    }
};


int main() {
	std::ios::sync_with_stdio(false);

	arc068E solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4480
N = int(input())
ans = 0
if N <= 9:
    print(N)
elif 10 <= N <= 99:
    print(9)
elif 100 <= N <= 999:
    print(9 + (N - 99))
elif 1000 <= N <= 9999:
    print(909)
elif 10000 <= N <= 99999:
    print(909 + (N - 9999))
else:
    print(90909)


Measured memory_bytes: 2940
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  int h;cin>>h;

  map<int, int> dp;
  dp[1] = 1;
  dp[0] = 0;
  auto dfs = [&](const auto& dfs, int x) -> int {
    // dfs(dfs, nx);
    if (dp.find(x)!=dp.end()){
      return dp[x];
    }

    int res = 1;
    res += 2*dfs(dfs, x/2);
    dp[x] = res;
    return res;
  };
  int ans = dfs(dfs, h);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> a( N );
    for( auto &x : a )
    {
        cin >> x;
    }
    set<int> st;
    int cnt = 0, overRED = 0;
    REP( i, N )
    {
        if( a[ i ] >= 1 && a[ i ] <= 399 )
        {
            st.emplace( 1 );
        }
        if( a[ i ] >= 400 && a[ i ] <= 799 )
        {
            st.emplace( 2 );
        }
        if( a[ i ] >= 800 && a[ i ] <= 1199 )
        {
            st.emplace( 3 );
        }
        if( a[ i ] >= 1200 && a[ i ] <= 1599 )
        {
            st.emplace( 4 );
        }
        if( a[ i ] >= 1600 && a[ i ] <= 1999 )
        {
            st.emplace( 5 );
        }
        if( a[ i ] >= 2000 && a[ i ] <= 2399 )
        {
            st.emplace( 6 );
        }
        if( a[ i ] >= 2400 && a[ i ] <= 2799 )
        {
            st.emplace( 7 );
        }
        if( a[ i ] >= 2800 && a[ i ] <= 3199 )
        {
            st.emplace( 8 );
        }
        if( a[ i ] >= 3200 )
        {
            cnt++;
            overRED++;
        }
    }
    if( overRED == N )
    {
        cout << 1 << " " << cnt << endl;
    }
    else
    {
        cout << st.size() << " " << st.size() + cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w;
  int cnt = 4280;
  int ans;
  
  cin >> w;

  while(w != -1){
    if(w <= 10){
      ans = cnt - 1150;
    }else if(w <= 20){
      w -= 10;
      ans = cnt - (1150 + 125 * w);
    }else if(w <= 30){
      w -= 20;
      ans = cnt - (1150 + 125 * 10 + 140 * w);
    }else{
      w -= 30;
      ans = cnt - (1150 + 125 * 10 + 140 * 10 + 160 * w);
    }

    cout << ans << endl;
    cin >> w;
  }
  return 0;
}




Measured memory_bytes: 3140
import java.util.Scanner;

public class Main  {

	public static  void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
		String s = String.valueOf(N);
		int size = s.length();
		s = s.substring(size - 1);
			N = Integer.parseInt(s);
			
			if (N == 2 | N == 4 | N == 5 | N ==7 | N == 9) {
				System.out.println("hon");
			}else if(N == 0 | N == 1 | N == 6 | N == 8) {
				System.out.println("pon");
			}else if(N == 3) {
				System.out.println("bon");
				
				
			}
			
		

	}

}


Measured memory_bytes: 27032
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////




int main() {
	int W,H; cin >> H >> W;
	char A[W+2][H+2] = {'.'};
	FORq(i,1,H)
	{
		FORq(j,1,W)
		{
			cin >> A[j][i];
		}
	}
	int B[W+2][H+2] = {};
	int dx[8] = {0,1,1,1,0,-1,-1,-1};
	int dy[8] = {1,1,0,-1,-1,-1,0,1};
	FORq(i,1,H)
	{
		FORq(j,1,W)
		{
			if(A[j][i]=='#'){cout << '#';}
			else
			{
				rep(k,8)
				{
					if(A[j+dx[k]][i+dy[k]] == '#'){B[j][i]++;}
				}
				cout << B[j][i];
			}
			
		}
		cout << endl;
	}

}

Measured memory_bytes: 256
#選択ソート
def print_output(_list):
    for index in range(len(_list)):
        if index == len(_list) - 1:
            print(_list[index])
        else:
            print(_list[index],end=' ')

target_length = int(input())
target_list = list(map(int,input().split()))
choice_count = 0
for i in range(0, target_length - 1):
    minj = i
    for j in range(i, len(target_list)):
        if target_list[j] < target_list[minj]:
            minj = j
    if i != minj:
        choice_count += 1
    tmp = target_list[i]
    target_list[i] = target_list[minj]
    target_list[minj] = tmp
print_output(target_list)
print(choice_count)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int l,r,d;
    cin>>l>>r>>d;
    int low=ceil(1.0*l/d);
    int c=0;
    while(low*d<=r){
        c++;
        low++;
    }
    cout<<c++;
}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline

def main():
    x, y = map(int, input().split())

    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]

    if x in a and y in a:
        print("Yes")
    elif x in b and y in b:
        print("Yes")
    elif x in c and y in c:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='7') {cout<<"Yes";return 0;}
    }
    cout<<"No";;
    return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b,n;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);

            if (a <= 9 && b <= 9)
            {
                n = a * b;
                Console.WriteLine(n);
            }
            else
                Console.WriteLine("-1");

            Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
static const int l = 10000;

int main(){
    int n, array[l], max, min;
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> array[i];

    max = 0;
    min = 1000000000;
    for(int i = 0; i < n; ++i){
        if (array[i] > max) max = array[i];
        if (array[i] < min) min = array[i];
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
llist = [int(input()) for i in range(q)]

point_list = [k - q]*n

for i in range(0,q):
    point_list[llist[i]-1] += 1

ans_list = ['']*n

for i in range(0,n):
    if point_list[i] >= 1:
        ans_list[i] = 'Yes'
    else:
        ans_list[i] = 'No'

for List in ans_list:
    print(List)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main(){
	llong N, A;
	map<llong, int> m;
	m[0]++;

	cin >> N;
	llong sum = 0, ans = 0;
	for(int i = 0; i < N; i++){
		cin >> A;
		sum += A;
		ans += m[sum];
		m[sum]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    vector<int64_t> lucas(87);
    lucas.at(0) = 2;
    lucas.at(1) = 1;

    for(int i = 2; i < N+1; i++){
        lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
    }

    cout << lucas.at(N) << endl;
  
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	int n, r;//参加回数n 表示レーティングr
	cin >> n >> r;
	int ans;
	if (n < 10)
		ans = r + 100 * (10 - n);
	else
		ans = r;
	cout << ans;
	return (0);
}


Measured memory_bytes: 256
Var  i:byte;ch:char;
Begin
  for i:=1 to 5 do 
    begin
       read(ch);
       write(ch);
    end;
    read(ch);
    write(' ');
  for i:=1 to 7 do 
    begin
       read(ch);
       write(ch);
    end;
    read(ch);
    write(' ');
  for i:=1 to 5 do 
    begin
       read(ch);
       write(ch);
    end;
    read(ch);
    writeln;
End.

Measured memory_bytes: 128