akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,m,n) for(int i=m;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int a,b;
	cin>>a>>b;
	for(int i=0;i<5000;i++){
		if((int)(i*0.08)==a && (int)(i*0.1)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M, V, P;
	cin >> N >> M >> V >> P;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	sort(begin(A), end(A));
	int ans_l = -1, ans_r = N-P;
	while(ans_r-ans_l > 1) {
		int K = (ans_l+ans_r)/2;
		if(A[K]+M < A[N-P]) {
			ans_l = K;
			continue;
		}
		if(P-1+K+1 >= V) {
			ans_r = K;
			continue;
		}
		int v = V-P-K;
		cat sum = 0;
		for(int i = N-P; i > K; i--) sum += min(M, A[K]+M-A[i]);
		if(sum >= 1LL*v*M) ans_r = K;
		else ans_l = K;
	}
	cout << N-ans_r << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int n;
  cin>>n;
  for(int k=0;k<n;k++){{
      int a;
      cin>>a;
      printf("Case %d:\n",k+1);
      for(int i=0;i<10;i++){
	long long sq=a*a;
	long long s=sq;
	s/=1000000;s*=1000000;
	sq-=s;
	sq/=100;
	cout<<sq<<endl;
	a=sq;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int64_t h,w;
    cin >> h >> w;
    if(h==1)cout << 1 << endl;
    else if(w==1) cout << 1 << endl; 
    else if(h%2==1&&w%2==1) cout << (h*w)/2+1 << endl;
    else cout << (h*w)/2 << endl;
}    
    


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000;
const ll MOD = 1000000000 + 7;

const int MAX_N = 100 + 2;
const int MAX_K = 100000 + 2;
ll a[MAX_N];
ll dp[MAX_N][MAX_K];

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

  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> a[i];

  dp[0][0] = 1;
  
  for (int i = 1; i <= N; i++) {
    ll tmp = 0;

    for (int j = 0; j <= K; j++) {
      if (j - a[i] - 1 >= 0) {
	tmp -= dp[i - 1][j - a[i] - 1];
	tmp = (tmp + MOD) % MOD;
      }
      
      tmp += dp[i - 1][j];
      tmp %= MOD;
      dp[i][j] = tmp;
    }
  }
  
  cout << dp[N][K] << endl;
  return 0;
}



Measured memory_bytes: 81260
import sys


fin = sys.stdin.readline
N, M, X = [int(elem) for elem in fin().split()]
A_list = [int(elem) for elem in fin().split()]
is_cost_taken = [False] * N
for A in A_list:
    is_cost_taken[A] = True

min_total_cost = min(
    sum(is_cost_taken[i] for i in range(X)),
    sum(is_cost_taken[i] for i in range(X + 1, N))
)
print(min_total_cost)


Measured memory_bytes: 38256
import sys
input = sys.stdin.readline
#N, M, C = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
N = int(input())
A = [int(x) for x in input().split()]

persons = [0]*(N+1)

for i in range(N-1):
    persons[A[i]] += 1

for i in range(1, N+1):
    print(persons[i])


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

int main() {
   int x; 
   cin >>x;
   int r=0;
   if(x>=2000)r=1;
   int h;
   int a;
   if(x<2000){  
        h=x/100;
		a=x%100;
		if(a<=h*5) r=1;
   }
   cout << r << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        while(true) {
            int a = scan.nextInt();
            String op = scan.next();
            int b = scan.nextInt();
            
            int ans = 0;
            if(op.equals("?")) break;

            switch(op) {
                case "+":
                    ans = a + b;
                    break;
                case "-":
                    ans = a - b;
                    break;
                case "*":
                    ans = a * b;
                    break;
                case "/":
                    ans = a / b;
                    break;
            }
            System.out.println(ans);

        }
    }
}

Measured memory_bytes: 26024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007

void ayn(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll gcd(ll a, ll b)
{
    if (a == 0) return b;
    return gcd(b % a, a);
}
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }
ll mulmod(ll a, ll b, ll mod)
{
    ll res = 0;
    a = a % mod;
    while (b > 0)
    {
        if (b % 2 == 1) res = (res + a) % mod;
        a = (a * 2) % mod;
        b /= 2;
    }
    return res % mod;
}
int binCoeff(int n, int k)
{
    int C[n + 1][k + 1]; int i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
    return C[n][k];
}

const int maxn = 100005;
int dfs(ll v, ll ans2, vector<bool>& visited, vector<vector<ll>>& vc){
    visited[v]=true;
    ans2++;
    for(auto z:vc[v])
    {
        if(!visited[z])
        {
           ans2+=dfs(z,0,visited,vc);
        }
    }
    return ans2;
}

ll conv(string n)
{
    string num = n;
    ll dec_value = 0;
    int base = 1;

    int len = num.length();
    for (int i=0; i<len; i++) {
        if (num[i] == '1') dec_value += base;
        base = base * 2;
    }
    return dec_value;
}

int main(){
    fastio;
    ayn();
    ll t; t=1;
    while(t--){
        ll n,k; cin>>n>>k;
        set<ll> st;
        while(k--){
            ll x; cin>>x;
            while(x--){
                ll y; cin>>y; st.insert(y);
            }
        }
        cout<<n-st.size();
    }
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e16;
const ll N=5e5+10;

struct point
{
	long double x,y;
	int get_quad()
	{
		if(x>=0 and y>=0 ) return 0;
		if(x<=0 and y>=0) return 1;
		if(x<=0 and y<=0) return 2;
		if(x>=0 and y<=0 ) return 3;

	}
	bool operator < ( point &other)
	{
		int q1=get_quad();
		int q2=other.get_quad();
		if(q1!=q2) return q1<q2;
		if(q1==0)
		{
			return abs(y/x) < abs(other.y/other.x);
		}
		if(q1==1)
		{
			return abs(y/x) > abs(other.y/other.x);
		}
		if(q1==2)
		{
			return abs(y/x) < abs(other.y/other.x);
		}
		if(q1==3)
		{	
			return abs(y/x) > abs(other.y/other.x);
		}	
	}
	point operator + (const point &other)
	{
		point a=point{x+other.x,y+other.y};
		return a;
	}
	point operator - (const point &other)
	{
		point a=point{x-other.x,y-other.y};
		return a;
	}	

};

long double dist(point a)
{
	return (a.x*a.x+a.y*a.y);
} 

int main()
{
	boost;
	int n;
	cin>>n;
	point a[n];
	for(auto &i:a)
	{
		cin>>i.x>>i.y;
	}
	sort(a,a+n);
	long double ans=0;
	for(int i=0;i<n;i++)
	{
		int now=i;
		point temp=point{0,0};
		for(int j=0;j<n;j++)
		{
			temp=temp+a[now];
			ans=max(ans,dist(temp));
			now++;
			now%=n;
		}
	}
	cout<<fixed<<setprecision(30)<<sqrt(ans);
	return 0;
}


Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    # A, B, K = get_inputs(int)
    # if A >= K:
    #     print(A-K, B)
    # elif A + B >= K:
    #     print(0, B - (K-A))
    # else:
    #     print(0, 0)
    X = get_input(int)
    n = X
    while True:
        if is_prime(n):
            print(n)
            return
        else:
            n += 1


if __name__ == '__main__':
    main()


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

template< typename T >
map<T,int> prime_factorization(T n) {
	map<T,int> res;
	for(T i=2;i*i<=n;i++) {
		while(n%i==0) {
			res[i]++;
			n/=i;
		}
	}
	if(n!=1) res[n]=1;
	return res;
}

vector<bool> eratosthenes(int n) {
	vector<bool> is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i*i<=n;i++) {
		if(is_prime[i]) {
			for(int j=2*i;j<=n;j+=i) {
				is_prime[j]=false;
			}
		}
	}
	return is_prime;
}

vector<int> prime_list(int n) {
	vector<int> res;
	auto is_prime=eratosthenes(n);
	for(int i=0;i<=n;i++) {
		if(is_prime[i]) {
			res.push_back(i);
		}
	}
	return res;
}

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

	ll n;
	while(cin>>n) {
		auto ls=prime_list(n);
		cout<<(int)ls.size()<<endl;
	}

}



Measured memory_bytes: 3948
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
const int inf=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};


int main(){
  string s;
  cin>>s;
  map<int,int> mp;
  rep(i,s.size())mp[s[i]-'a']++;
  if(mp.size()==26)cout<<"None"<<endl;
  else{
    rep(i,26){
      if(mp[i]==0){
        cout<<(char)('a'+i)<<endl;
      break;
        }
      }
    }
  
  return 0;
  }

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main() {
    int i, j;
    int n;
    char s[100000];
    int res = 0;

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

    for(i = 0; i < n; i++) {
        if (s[i] == s[i + 1]) continue;
        res++;
    }
    printf("%d\n", res);

    return 0;
}

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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )

template <typename T,typename E>
struct SegmentTree{
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  int n;
  G g;
  H h;
  T ti;
  E ei;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(){};
  SegmentTree(int n_,G g,H h,T ti,E ei):
    g(g),h(h),ti(ti),ei(ei){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(n,ti);
    laz.clear();
    laz.resize(2*n-1,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i]=v[i];
  }
  void update(int a,int b,E x,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
  }
  void update(int a,int b,E x){
    update(a,b,x,0,0,n);
  }
  T query(int k){
    T c=dat[k];
    k+=n-1;
    E x=laz[k];
    while(k>0){
      k=(k-1)/2;
      x=h(x,laz[k]);
    }
    return g(c,x);
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;

  vector<int> b1(N+2, 0);  
  for ( int i = 0; i < N; i++ ) {
    cin >> b1[i];    
  }

  for ( int k = 0; k < min(100LL, K); k++ ) {
    vector<int> b2(N+2, 0);    
    for ( int i = 0; i < N; i++ ) {
      int l = max(0LL, i-b1[i]);
      int r = min(N-1, i+b1[i]);
      b2[l]++;
      b2[r+1]--;      
    }
    for ( int i = 1; i < N; i++ ) {
      b2[i] += b2[i-1];      
    }
    b1= b2;    
  }
  
  for ( int i = 0; i < N; i++ ) {
    if ( i ) cout << " ";
    cout << b1[i];    
  } cout << endl;
  
  return 0;
}


Measured memory_bytes: 6364
import sys
def input():
    return sys.stdin.readline()[:-1]
s=input()
if len(s)%2==0:
    ans=0
    for i in range(len(s)//2):
        if s[i]!=s[-1-i]:
            ans+=1
    print(ans)
else:
    ans=0
    for i in range(len(s)//2):
        if s[i]!=s[-1-i]:
            ans+=1
        
    print(ans)

Measured memory_bytes: 38496
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;


int main(void) {
  int N, M;
  cin >> N >> M;
  if (N%2==1) rep(i, 1, M+1) printf("%d %d\n", i, N-i+1);
  else {
    int x = (((N-2)/2+1)/2);
    rep(i, 1, M+1) {
      if (i<=x) printf("%d %d\n", i, N-i+1);
      else printf("%d %d\n", i, N-i);
    }
  
  }
    

    return 0;
}






Measured memory_bytes: 3696
n = int(input())
s = input()

li = [[] for _ in range(10)]

for i in range(n):
    li[int(s[i])].append(i)


ans = 0

for i in range(10):
    if li[i]:
        count1 = li[i][0]
        for j in range(10):
            if li[j] and li[j][-1] > count1:
                count2 = 0
                count3 = 0
                while count1 >= count2:
                    count2 = li[j][count3]
                    count3 += 1
                for k in range(10):
                    if li[k] and count2 < li[k][-1]:
                        ans += 1

print(ans)


Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 2000005
const int mod=1e6+3;
int main(){
    int cnt=0;
    LL ans=0;
    vector<pii> v;
    vector<char> vv;
    vector<pii> remove;
    v.pb(mp(0,0));
    cnt=1;
    char c[200005];
    scanf("%s",c);
    for(int i = 0;c[i]!=0;i++){
        if(c[i]=='('){
            vv.pb('(');
            v.pb(mp(v.back().x+1,0));
        }
        else if(c[i]==')'){
            vv.pb(')');
            if(v.back().x==0){
                v.pb(mp(0,0));
            }
            else{
                remove.pb(v.back());
                v.pop_back();
                
                v.back().y++;
                ans+=v.back().y;
            }
        }
        else{
            if(vv.back()=='('){
                vv.pop_back();
                v.pop_back();
            }
            else{
                vv.pop_back();
                if(v.back()==mp(0,0)){
                    v.pop_back();
                }
                else{
                    ans-=v.back().y;
                    v.back().y--;
                    v.pb(remove.back());
                    remove.pop_back();
                }
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;

  int sum = 0;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;

    sum += a;
  }

  int ans = n - sum;
  cout << (ans < 0 ? -1 : ans) << '\n';

  return (0);
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0;s[i];i++) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n), b(n+1), c(n+1);
	rep(i, n) cin >>a[i];
	ll kei = accumulate(all(a), 0LL);
	rep(i, n) b[i+1] = a[i] + b[i];
	repr(i,n-1, 0) c[i] = c[i+1] + a[i];
	//for(auto x :b) cerr<<x<<" "; cerr<<"\n";
	//for(auto x :c) cerr<<x<<" "; cerr<<"\n";
	
	ll ans = 1LL<<50;
	rep(i, n+1) ans = min(ans, abs(c[i] - b[i]));
	cout << ans <<"\n";
	return 0;
}


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


int main() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  while(S!=""){
  	if (S.substr(0,7)=="remaerd") S=S.substr(7);
    else if (S.substr(0,5)=="maerd") S=S.substr(5);
    else if (S.substr(0,6)=="resare") S=S.substr(6);
    else if (S.substr(0,5)=="esare") S=S.substr(5);
    else break;
  }
  
  if (S.size()) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int k, array[5];

int main() {
    for (int i=0; i<5; i++){
        cin >> array[i];
    }
    cin >> k;

    bool x = false; 
    for (int i=4;i>0; i--){
        if (abs(array[i] - array[0]) > k){
            x = true;
        }
    }

    if (x==false){
        cout << "Yay!";
    }

    if (x==true){
        cout << ":(";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
long long int Min(long long int a, long long int b) { if (a < b) { return a; }return b; }
int main()
{
	long long int Q, H, S, D, N;
	scanf("%lld%lld%lld%lld%lld", &Q, &H, &S, &D, &N);

	long long int tmp1, tmp2;
	long long int ans;
	tmp1 = Min(Min(8 * Q, 4 * H), Min(2 * S, D));
	tmp2 = Min(Min(4 * Q, 2 * H), S);
	ans = N / 2 * tmp1 + N % 2 * tmp2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	var r, sum, ans int
	for i := 0; i < N; i++ {
		for r < N {
			if sum^a[r] != sum+a[r] {
				break
			}
			sum ^= a[r]
			r++
		}
		ans += r - i
		sum -= a[i]
	}
	out(ans)
}


Measured memory_bytes: 3840
import collections
n,x,y=map(int,input().split())
ls = [[] for i in range(n)]
for i in range(n-1):
    ls[i].append(i+1)
ls[x-1].append(y-1)
ls[y-1].append(x-1)
co = collections.Counter()
for i in range(n):
    for j in range(i):
        d = min(i-j,abs(x-1-j)+abs(y-1-i)+1)
        co[d] +=1
for k in range(1,n):
    print(co[k])


Measured memory_bytes: 49372
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x:x[1])
s=0
ans='Yes'
for i in range(N):
    s += AB[i][0]
    if s > AB[i][1]:
        ans='No'
print(ans)

Measured memory_bytes: 53600
import * as fs from 'fs';

// parameter "input" gets all data
function Main(input: string) {
    const r = parseInt(input);
    // const c = 2 * Math.PI * r;
    const c = 0.6283185307179586 * r;

    //output
    console.log(c * 10);
}

// Don't edit this line!
Main(fs.readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29540
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[110][100010];


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    int w[110], v[110];
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N) {
        rep(j, W + 1) {
            dp[i + 1][j] = dp[i][j];
            if (j - w[i] < 0) continue;
            else dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        }
    }
    cout << dp[N][W] << endl;


    return 0;
}


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

int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")cout<<"Rainy"<<endl;
    else if(s=="Rainy")cout<<"Sunny"<<endl;
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;
int n;


void solve(){
    cin >> n;
    if(n == 3){
        cout << 2 << ' ' << 5 << ' ' << 63;
        return;
    }
    if(n == 4){
        cout << 2 << ' ' << 5 << ' ' << 20 << ' ' << 63;
        return;
    }

    vector<int> a;
    a.clear();
    int s = 0;
    for(int i = 1; i <= 30000; i++) {
        if(i % 2 == 0 || i % 3 == 0){
            a.pb(i);
            s += i;
            if(a.size() == n) {
                break;
            }
        }
    }
    int need = (6 - s % 6) % 6;
    for(int i = n - 1; i >= 0; i--) {
        if(a[i] + need <= 30000 && ((a[i] + need) % 2 == 0) || (a[i] + need) % 3 == 0) {
            a[i] += need;
            break;
        }
    }
    for(int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
}

int main(){

solve();

return 0;
}


Measured memory_bytes: 512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

//j ga i wo fukumu
llint countin(llint x,llint y,int fxb,int fyb){
	//ziyuuni naru bubunnha x ha 0 y ha 1
	if((y&x)!=x){return 0;}
	int h=0;
	llint ans=1;
	for(h=0;h<=max(fxb,fyb);h++){
		if(h<=fxb&&h<=fyb){ans*=3;ans%=mod;}
		if(h<=fxb&&h>fyb&&(y&(1LL<<h))>0){ans*=2;ans%=mod;}
		if(h>fxb&&h<=fyb&&(x&(1LL<<h))==0){ans*=2;ans%=mod;}
	}
	return ans;
}
//L to R wo uekara kimetiku 
llint countR(llint L,llint R,int fxb,int fyb){
	//R gawa
	if(fyb<0||((R&((1LL<<(fyb+1))-1))==((1LL<<(fyb+1))-1))){return countin(L,R,fxb,fyb);}
	if(R&(1LL<<fyb)){
		llint itR=((R-(1LL<<fyb))|((1LL<<fyb)-1));
		return countin(L,itR,fxb,fyb-1)+countR(L,R,fxb,fyb-1);
	}else{return countR(L,R,fxb,fyb-1);}
	
}
llint countLR(llint L,llint R,int fxb,int fyb){
	cerr<<L<<" "<<R<<" "<<fxb<<" "<<fyb<<endl;
	if(fxb<0||((L&((1LL<<(fxb+1))-1))==0)){return countR(L,R,fxb,fyb);}
	if((L&(1LL<<fxb))==0){
		llint itL=((L+(1LL<<fxb))|((1LL<<fxb)-1))-((1LL<<fxb)-1);
		return countR(itL,R,fxb-1,fyb)+countLR(L,R,fxb-1,fyb);
	}else{return countLR(L,R,fxb-1,fyb);}
}
int main(void){
	llint L,R,i,j;cin>>L>>R;
	llint ans=0;
	for(int h=0;h<61;h++){
		//max bit
		if((1LL<<(h+1))<=L){continue;}
		if(R<(1LL<<h)){continue;}
		//zituunabit ni kiriwakeru
		llint inL=max(L,(1LL<<h));
		llint inR=min(R,(1LL<<(h+1))-1);
		ans+=countLR(inL,inR,h-1,h-1);
	}
	cout<<ans%mod<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

N, M = map(int, input().split())
A = [0 for i in range(N+1)]
for i in range(M):
	A1, A2 = map(int, input().split())
	if A[A1] > A2 or A[A1] == 0:
		A[A1] = A2
	
ans = 0
min_dir = sys.maxsize
for i in range(1, N+1):
	if A[i] != 0:
		min_dir = min(A[i], min_dir)
	if i >= min_dir:
		ans += 1
		if A[i] != 0:
			min_dir = A[i]
		else:
			min_dir = sys.maxsize
print(ans)


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

signed main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << a + a - 1 << endl;
    } else if (a < b) {
        cout << b + b - 1 << endl;
    } else {
        cout << a + a << endl;
    }
    return 0;
}


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

int main(){
    while(1){
        int x,y,s;  cin>>x>>y>>s;
        if(x==0)break;
        int max=0;
        int small=0;
        int big=0;

        for(int i=1;i<=s;i++){
            for(int j=s; j>=1;j--){
                if((i*(100+x)/100 + j*(100+x)/100) == s){
                    if((i*(100+y)/100 + j*(100+y)/100)>max){
                        max= i*(100+y)/100 + j*(100+y)/100;
                        small=i;
                        big=j;

//                        cout<<small<<":"<<big<<endl;
                    }
                }
            }
        }

//        cout<<"Small="<<small<<" : Big="<<big<<endl;
        cout<<small*(100+y)/100 + big*(100+y)/100<<endl;
    }

    return 0;

}



Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}

		int min = a[0];
		int ans = -1001001001;
		for(int i = 1 ; i < n ; i++) {
			ans = Math.max(ans, a[i] - min);
			min = Math.min(min, a[i]);
		}
		System.out.println(ans);
	}
}

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

namespace ProgrammingContest
{
    class MainClass
    {
        Scanner sc;
        static void Main(string[] args)
        {
            new MainClass().Solve();
        }

        void Solve()
        {
#if DEBUG
            string backPath = "..";
            char dirSep = System.IO.Path.DirectorySeparatorChar;
            string inFilePath = backPath + dirSep + backPath + dirSep + "in.txt";
            sc = new Scanner(new System.IO.StreamReader(inFilePath));
#else
            sc = new Scanner();
#endif

            int x = sc.NextInt;
            Write(Math.Abs(x - sc.NextInt) < Math.Abs(x - sc.NextInt) ? "A" : "B");
        }

        void Write(object val)
        {
            Console.WriteLine(val.ToString());
        }
        void Write(string format, params object[] vals)
        {
            Console.WriteLine(format, vals);
        }
    }
    class Scanner
    {
        Queue<String> buffer;
        char[] sep;
        System.IO.TextReader reader;
        public Scanner(System.IO.TextReader reader = null)
        {
            this.buffer = new Queue<string>();
            this.sep = new char[] { ' ' };
            this.reader = (reader ?? Console.In);
        }
        private void CheckBuffer()
        {
            if (this.buffer.Count == 0 && this.reader.Peek() >= 0)
            {
                string[] sreArray = this.reader.ReadLine().Split(this.sep);
                foreach (String elStr in sreArray)
                {
                    this.buffer.Enqueue(elStr);
                }
            }
        }

        public String Next
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Dequeue();
            }
        }

        public int NextInt
        {
            get
            {
                return int.Parse(this.Next);
            }
        }
        public double NextDouble
        {
            get
            {
                return double.Parse(this.Next);
            }
        }

        public long NextLong
        {
            get
            {
                return long.Parse(this.Next);
            }
        }
        public bool IsEmpty
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Count == 0;
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    bool p = 1, s = 1;

    set<int> st;
    rep(i, 0, n) {
        int q = a[i];
        for (int j = 2; j * j <= q; j++) {
            if (q % j == 0) {
                assert((*st.find(j)==j)==(st.count(j)>0));
                //if (*st.find(j) == j) {
                if(st.count(j)>0){
                    p = 0;
                    break;
                }
                st.insert(j);
                while (q % j == 0) {
                    q /= j;
                }
            }
        }
        assert(q>=1);
        if (q != 1) {
            //if (*st.find(q) == q) p = 0;
            if(st.count(q)>0)p=0;
        }
        st.insert(q);
        if (!p) break;
    }

    // for (auto p : st) cout << p << " ";

    int now = a[0];
    rep(i, 0, n) { now = gcd(now, a[i]); }
    if (now != 1) s = 0;

    if (p) {
        cout << "pairwise coprime\n";
    } else if (s) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }
}


Measured memory_bytes: 11396
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2)){
    cout << "No" << endl;
  }
  else{ 
    cout << "Yes" << endl;
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i,ans=0,j;
    cin>>n;
    int s[n+1];
    for(i=1;i<=n;i++)
        s[i]=1;
    for(i=2;i<=n;i++)
    {
        if(s[i]==1)
        {
            for(j=i;j<=n;j+=i)
            {
                int p=j,c=0;
                while(p%i==0)
                {
                    c++;
                    p/=i;
                }
                s[j]*=(c+1);
            }
        }
    }
    for(i=1;i<=n;i++)
        ans+=(i*s[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 81708
use std::io;

fn main() {
    let mut S = String::new();
    let mut T = String::new();
    io::stdin().read_line(&mut S);
    io::stdin().read_line(&mut T);
    let mut count :usize = 0;
    let vecS :Vec<char> = S.chars().collect();
    let vecT :Vec<char> = T.chars().collect();
    for i in 0..vecS.len(){
        if vecS[i] != vecT[i]{
            count += 1;
        }
    }
    println!("{}",count);
}

Measured memory_bytes: 3972
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
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
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, M, X = MAP()
L = [LIST() for i in range(N)]

dp =[[0] * (1+M) for i in range(1+N)]

A = []
B = [0] * M
C = []
for l in L:
    c = l[0]
    C.append(c)
    A.append(l[1:])
    for i, a in enumerate(l[1:]):
        B[i] += a
# print(B)

for b in B:
    if b < X:
        print(-1)
        exit()

L = [0, 1] #生成する数字
num = N #生成するビット数
bit_list = list(product([0, 1], repeat=N))
# print(bit_list)
ma = INF
for bit in bit_list:
    bit = list(bit)
    # print(bit)
    # print(bit)
    l = [0] * M
    cost = 0
    for i, b in enumerate(bit):
        if b == 1:
            for m, a in enumerate(A[i]):
                l[m] += a
            cost += C[i]
    # print(l, cost)
    # print(l)
    cnt = 0
    for k, b in enumerate(l):
        if b >= X:
            cnt += 1
    if cnt == M:
        # print(l)
        # print(cost)
        ma = min(ma, cost)
print(ma)








# for i in range(1, N+1):
#     for j in range(1, M+1):
#         c = C[i]
#         if i - w

Measured memory_bytes: 10524
import sys
from math import sqrt, gcd, ceil, log
# from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
# from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# sys.setrecursionlimit(5*10**6)

def f(n):
	i = 0
	while n%10 == 7:
		n //= 10
		i += 1
	return((n,i))
def f2(a, b):
	return(b + [0, 10][a > b] - a)
def main():
	n = int(input()); 
	dic = defaultdict(int)
	for i in range(1, 10):
		for j in (1, 3, 7, 9):
			dic[(j, (i*j)%10)] = i
	# print(dic)
	if n%10 in (1, 3, 7, 9):
		t = n%10; ans = 0
		m, ans = f(n*(dic[(t, n%10)]))
		# print(m, ans)
		while m != 0:
			# print(m, f2(m%10, 7), n*dic[(t, f2(m%10, 7))])
			m += n*dic[(t, f2(m%10, 7))]
			# print(m)

			# print(m, "1")
			m, y = f(m)
			# print(m, y, "2")
			ans += y
		print(ans)



	else:print(-1)
	# print(f2(8, 9))





if __name__ == "__main__":
	main()

Measured memory_bytes: 68448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(),S.end());
    // cout << endl;
    // for(int i = 0; i < N; i++)
    // {
    //     cout << S[i] << endl;
    // }
    vector<pair<int,string> > times;
    int count = 1;
    int Max = 0;
    for(int i = 0; i < N - 1; i++)
    {
        if(S[i] == S[i+1]) count++;
        else
        {
                times.push_back(pair<int ,string>(count,S[i]));
                Max = max(Max,count);
                count = 1;
        }
    }
    if(count != 1 || Max == 1)
    {
        times.push_back(pair<int ,string>(count,S[N - 1]));
        Max = max(Max,count);
    }
    for(int i = 0; i < times.size(); i++)
    {
        if(times[i].first == Max)
        {
            cout << times[i].second << endl;
        }
    }
    return(0);

}

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n;
        cin >> n;
        vector<int> a(n); cin >> a;
        int ans = 0;
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                        for (int k = 0; k < j; k++) {
                                if (a[i] < a[j] + a[k] && a[j] < a[i] + a[k] && a[k] < a[i] + a[j]) {
                                        set<int> s={a[i], a[j], a[k]};
                                        if (s.size() == 3) ++ans;
;                               }
                        }
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n;
  int a,b;
  int c;
  int temp;
  vector<int> d;
  int cal;
  int price;
  int best_pizza=0;

  cin>>n;
  cin>>a>>b;
  cin>>c;

  for(int i=0;i<n;++i){
    cin>>temp;
    d.push_back(temp);
  }

  sort(d.begin(),d.end(),greater<int>());

  for(int i=0;i<=n;++i){
    cal=c;
    for(int j=0;j<i;++j){
      cal+=d[j];
    }
    price=a+i*b;

  if(best_pizza<cal/price)
    best_pizza=cal/price;

  }
  cout<<best_pizza<<endl;
}

Measured memory_bytes: 3152
#include<stdio.h>

int main(void) {
	unsigned long x=0, bank=0;
	
	
	scanf("%ld", &x);
	
	bank = 100;
	for (int i = 1;;i++)
	{
		bank *= 1.01;

		if (bank>=x)
		{
			printf("%d\n",i);
			break;
		}
		
	}
	
	
	return 0;
}

Measured memory_bytes: 1736
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):
    p = A[i] + A[i+1]
    if(p - B[i] >= 0):
        ans += B[i]
        if(A[i] - B[i] < 0):
            A[i+1] = p - B[i]
    else:
        ans += p
        A[i+1] = 0
print(ans)

Measured memory_bytes: 25300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		final int N = sc.nextInt();
		final long[] a = new long[N];
		final long[] b = new long[N];
		for(int i=0; i<N; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		int n = 0; // a < b
		int m = 0; // a > b
		int k = 0; // a == b
		for(int i=0; i<N; i++) {
			if(a[i]<b[i]) {
				n++;
			} else if(a[i]>b[i]){
				m++;
			} else {
				k++;
			}
		}
		if(m==0) {
			System.out.println(0);
		} else {
			long ans = 0;
			long minb = Long.MAX_VALUE;
			for(int i=0; i<N; i++) {
				if(a[i]>b[i]) {
					minb = Math.min(minb, b[i]);
				}
				ans += a[i];
			}
			System.out.println(ans-minb);
		}

	}
	
	static class Pair {
		long fst;
		long snd;
		Pair(long a, long b) {
			this.fst = a; this.snd = b;
		}
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 30820
import sys,itertools
def input():
    return sys.stdin.readline()[:-1]

H,W,K = map(int,input().split(' '))
l = [list(input()) for _ in range(H)]

MAP = [None]*H
for i in range(H):
    MAP[i] = [None]*W

cnt = 1
dp = []
for i in range(H):
    all_white_f = True
    flag = True
    for j in range(W):
        k = l[i][j]
        if k=='#':
            if not flag:
                cnt += 1
            all_white_f = False
            flag = False
        MAP[i][j] = str(cnt)
    if all_white_f:
        MAP[i] = None
        dp.append(i)
        cnt -= 1
    cnt += 1
pre = -1
tmp = []

if len(dp)==0:
    for i in range(H):
        print(' '.join(MAP[i]))
    exit()


if dp[0]==0:
    for i in dp:
        if i-pre==1:
            tmp.append(i)
            pre = i
        else:
            if len(tmp)!=0:
                for j in tmp:
                    first = tmp[-1]+1
                    MAP[j] = MAP[first]
                tmp = []
            MAP[i] = MAP[i-1]
    if len(tmp)!=0:
        for j in tmp:
            first = tmp[-1]+1
            MAP[j] = MAP[first]
else:
    for i in dp:
        MAP[i] = MAP[i-1]
for i in range(H):
    print(' '.join(MAP[i]))

Measured memory_bytes: 51312
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;


int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if(a * b == 15) puts("*");
	else if(a +b == 15) puts("+");
	else puts("x");
	return 0;
}

Measured memory_bytes: 128
int_N = int(input())
str_S = input()

str_list = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

ans = ""

for i in range(len(str_S)):
	cur = (str_list.index(str_S[i]) + int_N ) % 26
	ans += str_list[ cur ]

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	long long x,y,i,sum;
	scanf("%lld %lld",&x,&y);
	sum=0;
	for(i=x;i<=y;i=i+i)
	{
		if(i<=y)sum++;
	};
	printf("%lld",sum);
	return 0;			
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		Arrays.setAll(a, i -> sc.nextInt());
		Arrays.sort(a);
		System.out.println(a[n - 1] - a[0]);
		sc.close();
	}
	
}




Measured memory_bytes: 32436
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n, m, k;
  cin >> n >> m >> k;
  vector<llong> a(n), b(m);

  REP(i,n){
    cin >> a[i];
  }

  REP(i,m){
    cin >> b[i];
  }


  REP(i,n-1){
    a[i+1] += a[i];
  }
  REP(i,m-1){
    b[i+1] += b[i];
  }

  llong ans = 0;
  llong t = 0;
  llong j = m-1;
  for(llong i = 0; i <= n; ++i){
    
    if(i != 0){
      t = a[i-1];
    }

    while(j >= 0 && t + b[j] > k){
      j--;
    }
    if(j < 0){
      if(t <= k){
        ans = max(ans, i);
      }
    }else{
      ans = max(ans, i + j + 1);
    }
  }

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



Measured memory_bytes: 6372