akhauriyash/Code-Regression huggingface dataset:
def main():
    n=int(input())
    a=[int(i) for i in input().split(' ')]
    b=[int(i) for i in input().split(' ')]
    ans = 0
    for i in range(n):
        if a[i]>=b[i]:
            ans += b[i]
        elif a[i+1] >= b[i]-a[i]:
            ans += b[i]
            a[i+1] = a[i+1]-(b[i]-a[i])
        else:
            ans += a[i]+a[i+1]
            a[i+1] = 0
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 19648
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		in.nextLine();
		String S = in.nextLine();
		
		int a = 0;
		int b = 0;
		for(int i = 0;i<S.length();i++){
			if(S.charAt(i)=='a'){
				if(a+b<A+B){
					System.out.println("Yes");
					a++;
				}
				else{
					System.out.println("No");
				}
			}
			else if(S.charAt(i)=='b'){
				if(a+b<A+B && b<B){
					System.out.println("Yes");
					b++;
				}
				else{
					System.out.println("No");
				}
			}
			else{
				System.out.println("No");
			}
		}
		return;
	}
	
}

Measured memory_bytes: 23580
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0; i < n; ++i)
			a[i] = Integer.parseInt(sc.next());
		printArray(a);
		insertionSort(a);
	}
	
	public static void printArray(int[] a){
		int n = a.length;
		for(int i = 0; i < n; ++i){
			if(i != 0) System.out.print(" ");
			System.out.print(a[i]);
		}
		System.out.println();
	}
	
	public static void insertionSort(int[] a){
		int n = a.length;
		for(int i = 1; i < n; ++i){
			int instnum = a[i], j;
			for(j = i - 1; j >= 0 && a[j] > instnum; --j)
				a[j+1] = a[j];
			a[j+1] = instnum;
			printArray(a);
		}
	}
}



Measured memory_bytes: 33400
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

class BIT//1-index
{
public:
    vector<int> bit;
    int M;

    BIT(const int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(const int i) {//1~iまでの和
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(const int i, const int x) {//bit[i]にxを足す更新
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};


int main(){
	int n,k;
	cin>>n>>k;
	vector<LL> a(n);
	vector<LL> b(n+1,0);
	map<LL,LL> mp;
	LL ans=0;
	FOR(i,0,n){
		cin>>a[i];
		a[i]-=k;
		b[i+1]=a[i];
		b[i+1]+=b[i];
		mp[b[i+1]]++;
		if(b[i+1]>=0)ans++;
		//cerr<<" "<<b[i+1]<<endl;
	}
	int idx=1;
	for(auto &x:mp){
		x.ND=++idx;
	}
	int last=n+10;
	BIT bit(last+1);
	cerr<<"test:"<<ans<<endl;
	FOR(i,0,n){
		ans+=bit.sum(mp[b[i+1]]);
		bit.add(mp[b[i+1]],1);
		//cerr<<i<<" "<<ans<<endl;
	}

	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll n;
    cin >> n;
    vector<ll> v(n,0);
    for(ll i=0;i<n;i++){
        cin>>v[i]
    ;}
    sort(v.begin(), v.end());
    cout<<v[n/2]-v[n/2-1]<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
using namespace std;
#define ll long long

int main(){
  int n, y;
  cin >> n >> y;
  for(int i=0; i*10000<=y; i++){
    for(int j=0; j*5000<=y; j++){
      if((n-(i+j))*1000+j*5000+i*10000 == y && n-(i+j) >= 0){
        cout << i << " " << j << " " << n-(i+j) << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s-1);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n, mt; cin>>n>>mt;
    int mi = 1e9;

    REP(i, n) {
        int c, t; cin>>c>>t;
        if (t > mt) continue;
        mi = min(mi, c);
    }

    if (mi == 1e9) {
        cout << "TLE" << endl;
    } else {
        cout << mi << endl;
    }
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << 3*r*r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

const ll INF = 1e15;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


const ll MAX = 510000;
const ll MOD = 1000000007;

int N, Q;
vector<int> v[200010];
ll d[200010];


int main(void) {
	cin >> N;
	vector<double> v;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	
	double ans = v[0];
	for (int i = 1; i < N; i++) {
		ans = (ans + v[i]) / 2.0;
	}
	cout << ans << endl;
}


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

using namespace std;

#define REP(i,a,b) for(ll i = a; i < b; i++)
#define DB( x ) cout << #x << " = " << x << endl;
#define sz(s) ((int)((s).size()))
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<int, pii> tri;
typedef vector <vector <ll>> matrix;
typedef pair<string, string> pss;

const ll mod = (ll)1e9 + 7;
const int MAX = (int)1e6 + 100;

const int oo = 0x3f3f3f3f;

ll dp[MAX];

void knapsack(vector<pii> &v, int max_w){

    ll solve = 0;

    for(int i = 0;i < sz(v);++i){
        for(int j = max_w; j >= 1;--j){
            if(j - v[i].first >= 0){
                dp[j] = max(dp[j], dp[j - v[i].first] + v[i].second);
                solve = max(solve, dp[j]);
            }
        }
    }

    cout << solve << endl;
}

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

    int n, w; cin >> n >> w;

    vector<pii> v(n);

    for(auto &it : v)
        cin >> it.first >> it.second;

    knapsack(v, w);
}


Measured memory_bytes: 1024
#○要するに共役複素数とは，それぞれの複素数（a+bi）の実部（a）を変えずに虚部（b）の符号だけを変えたものです

a, b,c,d = map(float,input().split())
a = complex(a,b)
b = complex(c,d)

for _ in [0] *int(input()):
  c = complex(*map(float, input().split()))
  q = b-a
  c -= a
  p = a+q*(c/q).conjugate()
  print(p.real, p.imag)


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<vector<int> > connect(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        connect[a[i]].push_back(b[i]);
        connect[b[i]].push_back(a[i]);
    }
    //for (int i = 0; i < N; ++i) {
    //    printf("%d:", i);
    //    for (int next : connect[i]) {
    //        printf("%d ", next);
    //    }
    //    printf("\n");
    //}

    int ans = 0;
    while (true) {
        vector<int> grade1;
        int all = 0;
        for (int i = 0; i < N; ++i) {
            //printf("connect[%d].size() == %u\n", i, connect[i].size());
            if (connect[i].size() == 0) {
                continue;
            }
            if (connect[i].size() == 1) {
                //次数が1のものを記録する
                grade1.push_back(i);
            }
            all++;
        }
        if (grade1.size() != 0) {
            if (all == 2) {
                //最後もう2つしか残ってない状況だったら1つ取って終わり
                ans++;
                break;
            }
            for (int g : grade1) {
                //connect[g]はsize() == 1
                //connect[g][0]が繋がった先
                //そこからgを探して削除
                //printf("g = %d\n", g);
                auto itr = std::find(connect[connect[g][0]].begin(), connect[connect[g][0]].end(), g);
                connect[connect[g][0]].erase(itr);
                connect[g].clear();
                ans++;
            }
        } else {
            //次数0のものがなくなっていれば終わり
            break;
        }
    }
    cout << ans << endl;
}


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

#define INF 999999999

class P{
public:
	int x,y,cost,flg;

	P(int _x,int _y,int _cost,int _flg){
		x = _x;
		y = _y;
		cost = _cost;
		flg = _flg;
	}

	bool operator<(const P &p)const{
		return cost > p.cost;
	}
};

int w,h;
int t[62][62];
int dx1[] = {1,1,1,1,1,2,2,2,3};
int dy1[] = {-2,-1,0,1,2,-1,0,1,0};
int dx2[] = {-1,-1,-1,-1,-1,-2,-2,-2,-3};
int dy2[] = {-2,-1,0,1,2,-1,0,1,0};
bool closed[62][62][2];

int solve(priority_queue<P> open){
	memset(closed,0,sizeof(closed));

	while(!open.empty()){
		P p = open.top(); open.pop();
		if(closed[p.x][p.y][p.flg]) continue;
		closed[p.x][p.y][p.flg] = true;

		if(t[p.y][p.x] == -1){
			return p.cost+1;
		}

		if(p.flg){
			for(int i=0;i<9;i++){
				int nx = p.x + dx1[i];
				int ny = p.y + dy1[i];
				if(nx>=0 && nx<w && ny>=0 && ny<h && t[ny][nx]!=INF){
					open.push(P(nx,ny,p.cost+t[ny][nx],0));
				}
			}
		}
		else{
			for(int i=0;i<9;i++){
				int nx = p.x + dx2[i];
				int ny = p.y + dy2[i];
				if(nx>=0 && nx<w && ny>=0 && ny<h && t[ny][nx]!=INF){
					open.push(P(nx,ny,p.cost+t[ny][nx],1));
				}
			}
		}
	}

	return -1;
}

int main(void){
	while(cin>>w>>h, w||h){
		priority_queue<P> open;

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				char ch;
				cin>>ch;
				if(ch == 'S'){
					open.push(P(j,i,0,0));
					open.push(P(j,i,0,1));
					t[i][j] = 0;
				}
				else if(ch == 'T') t[i][j] = -1;
				else if(ch == 'X') t[i][j] = INF;
				else t[i][j] = ch - '0';
			}
		}

		int res = solve(open);
		cout<<res<<endl;
	}

	return 0;
}

Measured memory_bytes: 1044
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
    except:
        break
    if max(xa2, xb2) - min(xa1, xb1) <= xa2 - xa1 + xb2 - xb1 and\
       max(ya2, yb2) - min(ya1, yb1) <= ya2 - ya1 + yb2 - yb1:
        print('YES')
    else:
        print('NO')

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

int main() {
  int n,x,count;
  cin >> n >> x;
  count = n;
  vector<int> m(n);
  for(int i=0;i<n;i++){
    cin >> m.at(i);
    x -= m.at(i);
  }
  sort(m.begin(),m.end());
  cout << count + x/m.at(0) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#@k0gane_p 
a, b, c, d = [int(i) for i in input().split()]
def gcd(x,y):#最大公約数
    while y:
        x,y = y, x%y
    return x
def lcm(x,y):#最小公倍数
    return x*y // gcd (x,y)
def count(A,B,C):#A以下で、BでもCでも割り切れない個数
    D=A//B
    E=A//C
    F=A // lcm(B,C)
    return A-D-E+F
ans = count(b, c, d) - count(a, c, d)
#A以上B以下の整数のうち、CでもDでも割り切れないものの個数
if(a % c != 0 and a % d != 0):
    ans += 1#AがCでもDでも割り切れないなら、足す１
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, char const *argv[])
{
	double ans;
	int i = 0, cnt = 0;
	double height;
	double max, min;

	while (scanf("%lf", &height) != EOF) {
		if (i == 0) {
			min = height;
			max = height;
		}
		if (height > max)
			max = height;
		if (height < min)
			min = height;
		i++;
	}

	ans = max - min;
	printf("%0.1f\n", ans);
	return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
int main()
{
unsigned long int x;
int i,a[]={500,5},t[]={1000,5},c,h=0;
    scanf("%ld",&x);
    for(i=0;i<2;i++)
    {
        c=x/a[i];
        x=x%a[i];
        h+=c*t[i];
    }
    printf("%d",h);

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

#define int long long 

const int mod=1e9+7;

int bm(int x,int p){
    if(p==1)return x;
    if(p==0)return 1;
    if(p&1) return (x*bm(x,p-1))%mod;
    int f=bm(x,p/2);
    return (f*f)%mod;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    int a[n];

    long long sum=0;

    for(int& i : a){
        cin >> i;
        sum+=i;
        sum%=mod;
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans=(ans+a[i]*(sum-a[i]+mod)%mod)%mod;
    }
    ans=(ans*bm(2,mod-2))%mod;
    cout<<ans<<endl;

}



Measured memory_bytes: 5200
#include "bits/stdc++.h"
using namespace std;

long long int inf=1e9+7;

int main(){
	long long int n,W;
	cin>>n>>W;
	vector<long long int> w(n);
	vector<long long int> v(n);
	long long int minw=1e9+7;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		minw=min(minw,w[i]);
	}
	
	vector<long long int> ww1;
	vector<long long int> ww2;
	vector<long long int> ww3;
	vector<long long int> ww4;
	
	for(long long int i=0;i<n;i++){
		if(w[i]==minw){
			ww1.push_back(v[i]);
		}else if(w[i]==minw+1){
			ww2.push_back(v[i]);
		}else if(w[i]==minw+2){
			ww3.push_back(v[i]);
		}else if(w[i]==minw+3){
			ww4.push_back(v[i]);
		}
	}
	
	sort(ww1.begin(),ww1.end(),greater<long long int>());
	sort(ww2.begin(),ww2.end(),greater<long long int>());
	sort(ww3.begin(),ww3.end(),greater<long long int>());
	sort(ww4.begin(),ww4.end(),greater<long long int>());
	
	vector<long long int> w1;
	vector<long long int> w2;
	vector<long long int> w3;
	vector<long long int> w4;
	
	w1.push_back(0);
	w2.push_back(0);
	w3.push_back(0);
	w4.push_back(0);
	
	for(int i=0;i<ww1.size();i++){
		w1.push_back(w1[w1.size()-1]+ww1[i]);
	}
	for(int i=0;i<ww2.size();i++){
		w2.push_back(w2[w2.size()-1]+ww2[i]);
	}
	for(int i=0;i<ww3.size();i++){
		w3.push_back(w3[w3.size()-1]+ww3[i]);
	}
	for(int i=0;i<ww4.size();i++){
		w4.push_back(w4[w4.size()-1]+ww4[i]);
	}
	
	//for(int i=0;i<w1.size();i++)cout<<w1[i]<<endl;
	long long int ans=0;
	for(int i=0;i<w1.size();i++){
		for(int j=0;j<w2.size();j++){
			for(int k=0;k<w3.size();k++){
				for(int l=0;l<w4.size();l++){
					if(minw*i+(minw+1)*j+(minw+2)*k+(minw+3)*l<=W){
						ans=max(ans,w1[i]+w2[j]+w3[k]+w4[l]);
					}
				}
			}
		}
	}
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	vector<long long> arr(n);
	long long sum = 0;
	for(int i=0;i<n;++i){
		cin>>arr[i];
		sum+=arr[i];
	}
	long long tmp = 0;
    long long res= 1e18;
	for(int i=0;i<n;++i){
		tmp += arr[i];
		res = min(res,abs(2*tmp-sum));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
MAX = 1000000

N, M = map(int, input().split())
ab = [0]*M
C = [0]*M
for i in range(M):
    ab[i] = list(map(int, input().split()))
    c = list(map(int, input().split()))
    for cc in c:
        C[i] += (1<<(cc-1)) # bit

dp = [[MAX]*(2**N) for _ in range(M)]
dp[0][0] = 0

for i in range(M-1):
#    for p in range(M):
#        print(dp[p])
    for j in range(1<<N):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][j|C[i]] = min(dp[i+1][j|C[i]], dp[i][j]+ab[i][0])

res = dp[-1][-1]
if res == MAX:
    print(-1)
else:
    print(res)

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

/*int main() {
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    printf("%d", (x - a) % b);
}*/


int main() {
    int a, b, c, x;
    scanf("%d %d %d %d", &a, &b, &c, &x);
    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (i * 500 + j * 100 + k * 50 == x) ans++;
            }
        }
    }
    printf("%d", ans);
    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int v[MAXN];

void solve(){
	int n;
	ll sum = 0ll;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &v[i]);
		sum += v[i];
	}
	ll cur = v[0];
	ll ans = abs(sum - 2 * cur);
	REP(i, 1, n - 1) {
		cur += v[i];
		ans = min(ans, abs(sum - 2 * cur));
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main(){
    int n; cin>>n;
    vector<int> A(n),B(n),C(n-1);
    int ans=0;
    for(int i=0; i<n; i++) cin >> A[i];
    for(int i=0; i<n; i++) cin >> B[i];
    for(int i=0; i<n-1; i++) cin >> C[i];
    for(int i=0; i<n-1; i++){
        ans += B[A[i]-1];
        if(A[i]+1==A[i+1]) ans+=C[A[i]-1];
    }
    ans += B[A[n-1]-1];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int g[555][555], col[33][33], c, n, cng[4][33];
vi v[4];

int solve(int i, int j, int k){

    int temp, res=inf;
    vi q;
    q.pb(0);q.pb(1);q.pb(2);

    do{
        temp = cng[q[0]][i] + cng[q[1]][j] + cng[q[2]][k] ;
        res = min(temp, res);
    }
    while(next_permutation(all(q)));

    return res;

}

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n >> c;

rep(i, 1, c){
    rep(j, 1, c)
    cin >> col[i][j];
}

rep(i, 1, n){
    rep(j, 1, n){
    cin >> g[i][j];
    int temp = (i+j)%3;
    v[temp].pb(g[i][j]);
    }
}

rep(i, 1, c){
    rep(j, 0, 2){
        int ans = 0;
        int m = v[j].size()-1;
        rep(k,0, m ){
        ans+=col[v[j][k]][i];
        }
        cng[j][i] = ans;
}
}
int ans = inf;
rep(i, 1, c){
    rep(j, i+1, c){
        rep(k,j+1,c ){
        ans = min(ans, solve(i, j, k) );
        }
    }
}

cout << ans << endl;
return 0;}


Measured memory_bytes: 2544
def main():
  n = int(input())

  i = 1
  for a_i in input().split():
    if i == int(a_i):
      i += 1
  
  if i == 1:
    i = n + 2
    
  print(n - i + 1)


if __name__ == "__main__":
  main()
      

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

int main() {
  int a,b,c,d,e,f,g,h,i;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
  if(b-a==e-d&&e-d==h-g && c-b==f-e&&f-e==i-h && a-d==b-e&&b-e==c-f && d-g==e-h&&e-h==f-i)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	int i;
	char a[1000];
	scanf("%s", &a);
	for (i=0;a[i]!='\0';i++)
	{
		if (a[i]==',')
		{
			a[i]=' ';
		
		}
	}
	printf ("%s", a);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (str != null) {
			int dx = Integer.parseInt(str);
			long s = 0;
			for (int i = 1; i < 600 / dx; i++) {
				s = s + dx * i * i * dx * dx;
			}
			System.out.println(s);
			str = br.readLine();
		}
	}
}

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

void conv(int n)
{
	if(n/4!=0){
		conv(n/4);
	}

	cout << n%4;
}

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

		if(n==-1)
			break;

		conv(n);
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e3+5;
ll a[maxn];
ll b[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n==m)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N, M;
int H[110000];
using Graph = vector<vector <int>>;
// Graph G;
int main() {
    cin >> N >> M;

    rep(i, N) {
        cin >> H[i];

    }
    int res = 0;
    Graph G(N);
    // cout << "aaa" << endl;
    rep(i, M) {
        // cout << "aaa" << endl;

        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);

    }
    rep(i, N) {

        bool flag = true;
        if (G[i].size() != 0) {
            for(auto g : G[i]) {
                if(H[i] <= H[g]) {
                    flag = false;
                }
            }
        }
        if (flag) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 8728
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

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

    int sl=0;
    REP(i,n){
        if(i==0){
            sl+=1;
        } else if(s.at(i) != s.at(i-1)){
            sl+=1;
        }
    }
    cout<<sl<<endl;
    
    // cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, K;
ll A[200005];
ll F[200005];

bool check(ll n) {
    ll k = 0;
    REP(i, N) {
        if (A[i] * F[i] <= n)
            continue;
        ll p = n / F[i];
        k += A[i] - p;
    }
    return k <= K;
}

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

    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> F[i];
    }
    sort(A, A + N, greater<ll>());
    sort(F, F + N);

    ll ans = INF, ng = -1;
    while (abs(ans - ng) > 1) {
        ll mid = (ans + ng) / 2;
        if (check(mid))
            ans = mid;
        else
            ng = mid;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = ( i - h * 3600 ) / 60;
   s = i - h * 3600 - m * 60;
   cout << h << ":" << m << ":" << s << endl;
   
   
   
   return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int x=0;
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x;
}
int main(){
	puts(read()<1200?"ABC":"ARC");
	return 0;
}


Measured memory_bytes: 256
# import numpy as np
# import collections
# import math


S=input()
#int(input())
#map(int, input().split())
#list(map(int, input().split()))

if "RRR" in S:
    ans = 3
elif "RR" in S:
    ans=2
elif "R" in S:
    ans=1
else:
    ans=0

print(ans)

Measured memory_bytes: 61568
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N = int(input())
D,X = inputlist()
A = [0]*N
ans = 0
for i in range(N):
    A[i] = int(input())
    ans += (D-1) // A[i] + 1
print(ans + X)

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

int main() {

    string s;
    cin >> s;
    int count = 0 ,tmp = 0;

    for (int i = 0; i < s.length(); i++) {

        if ( s[i] == 'A' || s[i] == 'T' || s[i] == 'C'|| s[i] == 'G')
            tmp ++;
        else
            tmp = 0;

        if (tmp > count)
            count = tmp;
        
    }

    cout << count << endl;

    return 0;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> a(m);
	for (int i = 0; i < m; i++) {
		int one, two;
		cin >> one >> two;
		int mask = 0;
		for (int j = 0; j < two; j++) {
			int x;
			cin >> x;
			x--;
			mask |= (1 << x);
		}
		a[i] = { mask, one };
	}

	vector<int> cost(1 << n, INF);
	for (int i = 0; i < cost.size(); i++) {
		for (int j = 0; j < m; j++) {
			if ((i & a[j].first) == i) cost[i] = min(cost[i], a[j].second);
		}
	}

	vector<int> dp(1 << n, INF);
	dp[0] = 0;
	for (int i = 1; i < dp.size(); i++) {
		for (int j = i; j > 0; j = (j - 1) & i) {
			dp[i] = min(dp[i], dp[i ^ j] + cost[j]);
		}
	}
	cout << (dp.back() == INF ? -1 : dp.back());
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 384
import math


n = int(input())
o = n / 1.080

o_floor = math.floor(o)
o_ceil = math.ceil(o)

if math.floor(o_floor * 1.08) == n:
    print(o_floor)

elif math.floor(o_ceil * 1.08) == n:
    print(o_ceil)

else:
    print(':(')
    

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main () {
  string s;
  cin >> s;
  int countf = 0, countb = 0;
  
  for(char a: s) {
    if(a == 'A') break;
    else countf++;
  }
  for(int i = s.size() - 1; i != 0; i--) {
    if(s.at(i) == 'Z') break;
    else countb++;
  }
  cout << s.size() - countf - countb << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  int d[n];
  FOR(i,0,n-1) cin >> d[i];
  int sum = 0;

  FOR(i,0,n-2){
    FOR(j,i+1,n-1){
      sum += d[i]*d[j];
    }
  }

  cout << sum << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int n,k;
int main(){
  cin>>n;
  int a[10];rep(i,n)cin>>a[i];
  sort(a,a+n);
  int ans = a[n-1]/2;
  rep(i,n-1)ans+=a[i];
  cout << ans << endl;
}


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

#define ll long long
#define OK puts("OK")

using namespace std;

ll siz(ll n)
{
    int c = 0;

    while (n)
    {
        n /= 10;
        c++;
    }

    return c;
}
ll pw(ll a, ll n)
{
    ll q = 1;
    for (int i = 0; i < n; i++)
        q *= a;

    return q;
}
main()
{
    long long n, an = 0, i = 0;
    cin >> n;

    while (n >= an + (9 * pw(10, i))){
        an += (9ll * 1LL * pw(10ll, i));
        i++;
    }

    ll s = siz(an);

    while (an + pw(10, s) <= n)
    {
        an += pw(10, s);
    }

    ll ans = 0;

    while (an)
    {
        ans += an % 10;
        an /= 10;
    }

    cout << ans;
}




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

int main(){
  int ans=10000;
  vector<int> x(3,0);
  REP(i,3) cin>>x.at(i);
  REP(i,3) ans=min(ans, x.at(i)+x.at((i+1)%3));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
k = int(input())
a = deque()
for i in range(1,10):
    a.append(i)
ans = []
for i in range(k):
    x = a.popleft()
    ans.append(x)
    y = x%10
    if y != 0:
        a.append(10*x + y - 1)
    a.append(10*x + y)
    if y != 9:
        a.append(x*10 + y + 1)
print(ans[k-1])

Measured memory_bytes: 47216
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    Int N, K; cin >> N >> K;
    Int ok = 0, ng = K + 1;
    N = min(N, 64LL);
    while (abs(ok - ng) > 1) {
        Int mid = (ng + ok) / 2;
        Int t = mid;
        Int rest = K - t;
        bool success = true;
        for (int i = 1; i < N; i++) {
            t = t / 2;
            rest -= t;
            if (rest < 0) success = false;
        }
        (success ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <stdio.h>
int main (void)
{
  int a,b;
  
  scanf("%d%d",&a,&b);
  
  if(a>=13) printf("%d",b);
  
  else if (a>=6 && a<=12) printf("%d",b/2);
  
  else if (a<=5) printf("0");
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
map<char,int>mp;
int main(){
    int n;
    char s;
    while(scanf("%d",&n)!=EOF){
        mp.clear();
        int sum=0;
        for(int i=0;i<n;i++){
            getchar();
            scanf("%c",&s);
            if(mp[s]==0){
                sum++;
            }
            mp[s]++;
        }
        if(sum==0) printf("Zero\n");
        else if(sum==1) printf("One\n");
        else if(sum==2) printf("Two\n");
        else if(sum==3) printf("Three\n");
        else if(sum==4) printf("Four\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int N,minx = INF,maxx = 0,a;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> a;
        minx = min(minx,a);
        maxx = max(maxx,a);
    }
    cout << maxx-minx << endl;
}

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

 int main (){
     int n,x;
     
     while (1){
         int count=0;
         cin >> n >> x;
         if (n==0 && x==0){
             break;
         }
         else{
             for (int i=1;i<=n;i++){
                
                 for (int j=2;j<=n;j++){
                         if(i<j){
                            for(int k=3;k<=n;k++){
                                if(j<k){
                                    if ((i+j+k)==x){
                                    
                                    count++;
                            
                                    }   
                                }
                            }
                        }
                    }
                }
         }  cout << count << endl;
     }
 }



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	vpii a(n);
	FOR(i,0,n){in(a[i].first);a[i].second = i+1;}
	ll total = 0;
	sort(all(a));
	reverse(all(a));
	multiset<int> greater;
	greater.insert(0);
	greater.insert(0);
	greater.insert(n+1);
	greater.insert(n+1);
	for(auto x:a){
		ll num = x.first;
		int id = x.second;
		auto it = greater.lower_bound(id);
		int R1 = *it;it++;
		int R2 = *it;
		it--;it--;
		int L1 = *it;it--;
		int L2 = *it;
		total+=num*((R1-id)*(L1-L2)+(R2-R1)*(id-L1));
		greater.insert(id);
	}
	out(total);
	return 0;
}


Measured memory_bytes: 5760
import java.util.*;

public class Main{
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		
		
		int ans=1;
		long mod=7;
		
		HashSet<Long> Amari=new HashSet<>();
		while(true) {
			if(mod%k==0) break;
			mod=(mod*10+7)%k;
			if(Amari.contains(mod)) {
				ans=-1;
				break;
			}
			else Amari.add(mod);
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 131660
import java.util.*;

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

        int result=-1000;
        for (int i =0; i < X; i++) {
            int lower = i*(i+1)/2;
            int upper = (i+1)*(i+2)/2;
            if (lower<X && X<=upper) {
                result = i+1;
                break;
            }
        }

        System.out.println(result);
    }
}


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

int main(){

  int a, z;
  string s;

  cin>>s;

  for(int i=0;i<s.length();i++){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  for(int i=s.length()-1;i>=0;i--){
    if(s[i]=='Z'){
      z=i;
      break;
    }
  }

  cout<<z-a+1<<endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = n * n;

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    System.out.println((n % x == 0 ? (n / x) : (n / x + 1)) * t);
  }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	bool ok = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			ok = true;
			break;
		}
	}
	if (ok) cout << "OK" << "\n";
	else cout << "NG" << "\n";
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<math.h>
#include<limits.h>
#define _USE_MATH_DEFINES

using namespace std;

long long n, x, a[100], ans = 0, sum = 0;

int main(){
	cin >> n >> x;
	for (auto i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n);

	for (auto i = 0; i < n; i++) {
		sum += a[i];
		if (sum > x) {
			break;
		}
		ans = i + 1;
	}

	if (ans == n && sum < x) {
		ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
MOD = 1000000007

n , m = map(int,input().split())

count = [0 for i in range(n+1)]
nxt = 0

def scount(s,e):
    #print(s,e,file=sys.stderr)
    global count
    for i in range(s,e):
        if i == 0:
            count[i] = 1 
        elif i == 1:
            count[i] = 1
        else:
            count[i] = (count[i-1] + count[i-2]) % MOD

for i in range(m):
    a = int(input())
    if nxt == a:
        print(0)
        exit(0)
    scount(nxt,a)
    nxt = a+1

scount(nxt,n+1)

#print(count,file=sys.stderr)
print(count[n])


Measured memory_bytes: 7064
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXBLACK=100000;
const int MAXWHITE=100000;
const int MOD=1000000007;
const int INV2=(MOD+1)/2;
const int MAXN=MAXBLACK+MAXWHITE;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
void dec(int &a,int b) { inc(a,MOD-b); }

int nblack,nwhite,n;

int inv[MAXN+1];
int fac[MAXN+1];
int ifac[MAXN+1];
int C(int n,int k) { if(k<0||k>n) return 0; return (ll)fac[n]*ifac[k]%MOD*ifac[n-k]%MOD; }

int invp2[MAXN+1];

int plastblack[MAXN],plastwhite[MAXN];
int pdoneblack[MAXN+1],pdonewhite[MAXN+1];
int pblack[MAXN];

void solve() {
	inv[1]=1; FORE(i,2,n) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1; FORE(i,1,n) fac[i]=(ll)fac[i-1]*i%MOD;
	ifac[0]=1; FORE(i,1,n) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;
	invp2[0]=1; FORE(i,1,n) invp2[i]=(ll)invp2[i-1]*INV2%MOD;
	
	REP(i,n-1) plastblack[i]=i+1<nblack?0:(ll)invp2[i+1]*C(i,nblack-1)%MOD; plastblack[n-1]=1; REP(i,n-1) dec(plastblack[n-1],plastblack[i]);
	REP(i,n-1) plastwhite[i]=i+1<nwhite?0:(ll)invp2[i+1]*C(i,nwhite-1)%MOD; plastwhite[n-1]=1; REP(i,n-1) dec(plastwhite[n-1],plastwhite[i]);
	//printf("plastblack:"); REP(i,n) printf(" %d",plastblack[i]); puts("");
	//printf("plastwhite:"); REP(i,n) printf(" %d",plastwhite[i]); puts("");
	pdoneblack[0]=0; REP(i,n) pdoneblack[i+1]=pdoneblack[i],inc(pdoneblack[i+1],plastblack[i]);
	pdonewhite[0]=0; REP(i,n) pdonewhite[i+1]=pdonewhite[i],inc(pdonewhite[i+1],plastwhite[i]);
	//printf("pdoneblack:"); REPE(i,n) printf(" %d",pdoneblack[i]); puts("");
	//printf("pdonewhite:"); REPE(i,n) printf(" %d",pdonewhite[i]); puts("");
	REP(i,n) { pblack[i]=1; dec(pblack[i],pdoneblack[i]); inc(pblack[i],pdonewhite[i]); pblack[i]=(ll)pblack[i]*INV2%MOD; }
	//printf("pblack:"); REP(i,n) printf(" %d",pblack[i]); puts("");
}

void run() {
	scanf("%d%d",&nblack,&nwhite); n=nblack+nwhite;
	solve();
	REP(i,n) printf("%d\n",pblack[i]);
}

int main() {
	run();
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
 
#define TARGET "slv"

using namespace std;

using ll = long long;
using pii = pair<int, int>;

const int MOD = (int) 1e9+7;

int main() {
#ifdef INSPIRATION
    freopen(TARGET".in", "r", stdin);
    freopen(TARGET".out", "w", stdout);
#endif    
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    map<char, int> cnt;
    for (char c; n--;) {
        cin >> c;
        cnt[c]++;
    }
    ll ans = 1;
    for (auto occ : cnt)
        ans = ans*(occ.second+1)%MOD;
    cout << ans-1;
    return 0;
}

Measured memory_bytes: 256
s = input()
l = len(s)
a = 0
f = 0
z = 0

for i in range(l):
    if s[i] == "A":
        if f == 0:
            a = i
            f = 1
        else:
            pass
    elif s[i] == "Z":
        z = i
    else:
        pass

print(z-a+1)

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using psi = pair<string, int>;
using psii = pair<psi, int>;
int N;
psi M[100];
psii O[100];

void input1() {
  cin >> N;
  rep(i, N) {
    string x;
    int y;
    cin >> x >> y;
    M[i].first = x;
    M[i].second = 100 - y;
  }
}

void input2() {
  cin >> N;
  rep(i, N) {
    string x;
    int y;
    cin >> x >> y;
    O[i].first.first = x;
    O[i].first.second = 100 - y;
    O[i].second = i + 1;
  }
}

inline void Main() {
  // code
  // input1();
  // sort(M, M+N);
  // rep(i, N) cout << M[i].first << 100 - M[i].second << endl;

  input2();
  sort(O, O+N);
  rep(i, N) cout << O[i].second << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n; cin >> n;
    vector<vector<int>> dp(n, vector<int>(3, 0));
    int a, b, c;
    for(int i=0; i<n; i++){
        cin >> a >> b >> c;
        if(i==0){
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
            continue;
        }
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    // for(auto& line:dp){
    //     for(auto& v:line){
    //         cout << v << " ";
    //     }
    //     cout << "\n";
    // }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";
    return 0;
}

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

using namespace std;

int main(){
    int a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    for(int i=0;i<5;i++){
        if(a[i]==0){
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n;
	cin >> n;
	int d[n];
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		mp[d[i]]++;
	}
	int m;
	cin >> m;
	int t[m];
	for (int i = 0; i < m; i++) {
		cin >> t[i];
		if (mp[t[i]] > 0) {
			mp[t[i]]--;
		} else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

using ll = long long;

const ll INF = (1LL << 60);

ll n, m;

bool is_valid(ll x) {
    // cのうちfor_s個分だけ, Sのために使う
    ll for_s = max((x - n) * 2, 0LL),
       for_c = min(2 * x, m - for_s);   // cのために使える分
    return for_c >= 2 * x;
}

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

    ll lb = 0, ub = INF;
    while (ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        if (is_valid(mid)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << lb << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Restaurant struct {
	City  string
	Score int
	Index int
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Less(i, j int) bool {
	if r[i].City != r[j].City {
		return r[i].City < r[j].City
	} else {
		return r[i].Score > r[j].Score
	}
}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	n := nextInt()
	r := make([]Restaurant, n)

	for i := 0; i < n; i++ {
		r[i] = Restaurant{
			next(), nextInt(), i,
		}
	}

	sort.Sort(Restaurants(r))

	for _, res := range r {
		fmt.Println(res.Index + 1)
	}
}


Measured memory_bytes: 640