akhauriyash/Code-Regression huggingface dataset:
// AOJ 0272: The Lonely Girl's Lie
// 2017.10.14 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 280000

int a[40003], b[40003];
char buf[280001], *p;

int getInt()
{
	int n = 0;
	if (*p == ' ') p++;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int n, k, ans;
	int *aa, *bb;

	while (fgets(p = buf, 20, stdin) && *p != '0') {
		n = getInt();

		fgets(p = buf, MAX, stdin);
		aa = a, k = n; while (k--) *aa++ = getInt();
		fgets(p = buf, MAX, stdin);
		bb = b, k = n; while (k--) *bb++ = getInt();

		qsort(a, n, sizeof(int), cmp);
		qsort(b, n, sizeof(int), cmp);

		for (ans = n, aa = a, bb = b, k = 0; k < n; k += 2, aa++) {
			if (*aa++ > *bb++) { ans = k + 1; break; }
		}
		if (ans == n) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl; 


ll max_ll(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll min_ll(ll a,ll b,ll c){
	return min(a,min(b,c));
}


bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second==b.second)
		return a.first<b.first;
    return (a.second < b.second); 
}

long long binexpmod(long long a, long long b){
    long long res =1;
    while(b>0){
        if(b&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b>>=1;
    }
    return(res);
}


ll lcm(ll a,ll b){
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}
void solve(){
    ll n,res=0;
	cin>>n;
    vi a(n);
    ain(a);
    ll dp1[n];
    dp1[0]=0;
    dp1[1]=abs(a[1]-a[0]);
    for(ll i=2;i<n;i++){
        dp1[i] = min(dp1[i-1]+abs(a[i]-a[i-1]), dp1[i-2]+abs(a[i]-a[i-2]));
    }
	cout<<dp1[n-1]<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main() {
	long long int n;
	scanf("%lld", &n);
	long long int sum = 0;
	for(int i = 0; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1728
n = int(input())
while n > 0:
    A = 0
    B = 0
    for i in range(n):
        a,b = [int(j) for j in input().split(" ")]
        if a > b:
            A += (a+b)
        elif b > a:
            B += (a+b)
        else:
            A += a
            B += b
    print(A,B,sep=" ")
    n = int(input())

Measured memory_bytes: 7592
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += B[A[i]-1]
    if i>0 and A[i]-A[i-1]==1:
        ans += C[A[i-1]-1]
    #print(i,ans)
print(ans)

Measured memory_bytes: 3064
def insertion_sort(array, num, interval)
  cnt = 0

  (interval).upto(num-1) do |i|
    v = array[i]
    j = i - interval
    while (j >= 0 && array[j] > v) do
      array[j+interval] = array[j]
      j -= interval 
      cnt += 1
    end
    array[j+interval] = v
  end

  return cnt
end

def shell_sort(array, num)
  cnt = 0
  intervals = [1]
  ci = 3
  interval = 4

  while (interval < num) do
    intervals << interval
    interval = (3**ci - 1) / 2
    ci += 1
  end

  puts intervals.size
  puts (intervals.reverse.join(' '))

  intervals.reverse.each do |i|
    cnt += insertion_sort(array, num, i)
  end

  puts cnt
end

num = gets.strip.to_i
array = []
(num).times do |n|
  array << gets.strip.to_i
end

shell_sort(array, num)
array.each{|i| puts i}

Measured memory_bytes: 16056
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,t,a,h,mg,ans;
  cin >> n >> t >> a;
  for (int i = 1; i <= n; i++) {
    cin >> h;
    if (abs((t*1000-h*6)-a*1000) < mg || i == 1){
      mg = abs((t*1000-h*6)-a*1000);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	long long int A, B; scanf("%lld %lld", &A, &B); // A ^ (A+1) ^ (A+2) ^ ...
	
	long long int xored = 0, checkpoint = -1;
	for(long long int C = A; C%4 !=0 && C <= B; C++) xored ^= C, checkpoint = C;
	for(long long int C = B; C%4 !=3 && C > checkpoint; C--) xored ^= C;
	printf("%lld", xored);
	
	return 0;
}

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

using namespace std;

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


Measured memory_bytes: 3648
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	long long int a,b,s,l,tmp;
	cin>>a>>b;
	s=(a<b)?a:b;
	l=(a<b)?b:a;
	while(s>0){
		l=l%s;
		if(l<s){
			tmp=s;
			s=l;
			l=tmp;
		}
	}
	if(l==1){
		cout<<1<<endl;
		return 0;
	}
	long long int cnt=0,i=2;
	while(l>1){
		if(l%i==0)cnt++;
		while(l%i==0){
			l=l/i;
		}
		i++;
		if(i*i>l)break;
	}
	if(l>1)cnt++;
	cout<<cnt+1<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
#include <math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int ans[505][505]={};
    int n,m,q;
    cin>>n>>m>>q;

    rep(i,m){
	int l,r;
	cin>>l>>r;
	ans[l][r]++;
    }

    reps(i,n){
	reps(j,n){
	    ans[i][j]+=ans[i][j-1];
	}
    }

    reps(i,n){
	reps(j,n){
	    ans[j][i]+=ans[j-1][i];
	}
    }

    rep(i,q){
	int a,b;
	cin>>a>>b;
	cout<<ans[b][b]-ans[a-1][b]-ans[b][a-1]+ans[a-1][a-1]<<'\n';
    }

    /*  reps(i,n){
	reps(j,n){
	    cout<<ans[i][j]<<" ";
	}
	cout<<'\n';
	}*/

    /*  lol n;
    cin>>n;

    lol low = 1,high = n;
    lol mid;

    while(high-low > 1){
	mid = (high + low) / 2;
	if(mid*2+1 < n){
	    high = mid;
	}
	else{
	    low = mid;
	}
    }
    lol copy = mid * 2 + 1;

    low = 1;
    high = n;

    while(high - low > 1){
	mid = (high + low) / 2;
	if((mid * 2 + 1) * 6 < n){
	    high = mid;
	}
	else{
	    low = mid;
	}
    }
    lol nasu = (mid * 2 + 1) *6;
    cout<<copy<<" "<<nasu<<'\n';*/
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;

const int N = 1e5;

int deg[N + 5];
int p[N + 5], sz[N + 5];

vector<int> block[N + 5];

int find(int x) {
	if(x == p[x]) return x;
	return p[x] = find(p[x]);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m, k;
	cin>>n>>m>>k;
	for(int i = 1;i <= n;i++) {
		p[i] = i;
		sz[i] = 1;
	}
	for(int i = 1;i <= m;i++) {
		int u, v;
		cin>>u>>v;
		if(find(u) != find(v)) {
			sz[find(v)] += sz[find(u)];
			p[find(u)] = find(v);
		}
		deg[u]++, deg[v]++;
	}
	for(int i = 1;i <= k;i++) {
		int u, v;
		cin>>u>>v;
		block[u].pb(v);
		block[v].pb(u);
	}
	
	for(int i = 1;i <= n;i++) {
		if(i != 1) cout<<" ";
		int total = sz[find(i)] - deg[i] - 1;
		for(int j = 0;j < block[i].size();j++) {
			int to = block[i][j];
			if(find(to) == find(i)) total--;
		}
		cout<<total;
	}
	cout<<endl;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N; cin >> N;
    map<char, int> m{};
    for(int i=0;i<N;i++){
        string s; cin >> s;
        m[s[0]]++;
    }
    long long ans =0;
    vector<long long> v(5);
    v[0] = m['M'];
    v[1] = m['A'];
    v[2] = m['R'];
    v[3] = m['C'];
    v[4] = m['H'];
    for(int i=0;i<=4;i++){
        for(int j=i+1;j<=4;j++){
            for(int k=j+1;k<=4;k++){
                ans += v[i]*v[j]*v[k];
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n,i,temp;
    cin >> n;
    for (i=1; i<=n; i++) {
        cin >> temp;
        if (temp%2==0) {
            if (temp%3!=0&&temp%5!=0) {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner (System.in);
		int a  = sc.nextInt();		
		System.out.println(a >= 30 ? "Yes" : "No");
 
	}
 
}

Measured memory_bytes: 35796
#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353;
typedef long long ll;
int main(){
    ll ans=1;

    int n;cin>>n;
    string s;cin>>s;
    int wu=n,r=0,g=0,b=0,rg=0,rb=0,gb=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            if(gb){
                (ans*=gb)%=mod;
                gb--;
                continue;
            }
            if(g){
                (ans*=g)%=mod;
                g--;rg++;
                continue;
            }
            if(b){
                (ans*=b)%=mod;
                b--;rb++;
                continue;
            }
            (ans*=wu)%=mod;
            wu--;r++;
            continue;
        }
        if(s[i]=='G'){
            if(rb){
                (ans*=rb)%=mod;
                rb--;
                continue;
            }
            if(r){
                (ans*=r)%=mod;
                r--;rg++;
                continue;
            }
            if(b){
                (ans*=b)%=mod;
                b--;gb++;
                continue;
            }
            (ans*=wu)%=mod;
            wu--;g++;
            continue;
        }
        if(s[i]=='B'){
            if(rg){
                (ans*=rg)%=mod;
                rg--;
                continue;
            }
            if(g){
                (ans*=g)%=mod;
                g--;gb++;
                continue;
            }
            if(r){
                (ans*=r)%=mod;
                r--;rb++;
                continue;
            }
            (ans*=wu)%=mod;
            wu--;b++;
            continue;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 900
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
#include <queue>
#include <iostream>
#include <cmath>
const int maxn=1e5+10;
const int mod=1e9+7;
const double eps=1e-15;
using namespace std;

int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    c=c-a-b;
    if(c<=0){
        printf("No\n");
    }
    else{
        if(4*a*b<c*c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 



int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,j,k,x,y,t,m;
    string s;
    cin >> s;
    n=sz(s);
    ll f=0,prev=0,last=1;
    for(i=0;i<n-1;i++)
        if(s[i]!=s[n-2-i])f=1;
    if(s[n-1]=='1' || s[0]=='0')f=1;

    if(f)
        cout<<-1<<endl;
    else
    {
        for(i=1;i<=n;i++)
        {
            if(s[i-1]=='0')
                continue;
            for(j=1;j<=i-prev;j++)
                cout<<last<<" "<<last+j<<endl;
            last=last+j-1;
            prev=i;
        }   
    }
}

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

int Min(int a,int b,int c);
#define inf 1000000010;

int main(void){
  int N,H;
  cin>>H>>N;
  int tables[N+1][H+1];
  for(int i=0;i<N+1;i++){
    for(int j=0;j<H+1;j++){
      tables[i][j]=0;
    }
  }
  int A[N];
  int B[N];

  for(int i=1;i<H+1;i++){
    tables[0][i]=inf;
  }

  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }

  for(int i=1;i<N+1;i++){
    for(int j=0;j<H+1;j++){
      if(j>=A[i-1]){
        tables[i][j]=Min(tables[i-1][j],tables[i-1][j-A[i-1]]+B[i-1],tables[i][j-A[i-1]]+B[i-1]);
      }
      else{
        tables[i][j]=min(tables[i-1][j],tables[i][0]+B[i-1]);
      }

    }
  }

  cout<<tables[N][H]<<endl;
  return 0;
}

int Min(int a,int b,int c){
  int retval=inf;
  int values[3]={a,b,c};
  for(int i=0;i<3;i++){
    retval=min(retval,values[i]);
  }
  return retval;
}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

ll w,h;

int main(){
  cin>>w>>h;
  if(w==1||h==1){
    cout<<1<<endl;
    return 0;
  }
  cout<<(w*h)/2+(w*h)%2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

int main() {
	//freopen("input.txt","r",stdin);// <--Remove Before Submit
	string n;
	cin >>n;
	if(n[0] == n[2]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/
    
    int n;cin>>n;
    vector<int> seg(2*n+5);
    auto up=[&](int l,int r){
        for(l+=n,r+=n;l<r;l>>=1,r>>=1){
            if(l&1){
                seg[l++]++;
            }
            if(r&1){
                seg[--r]++;
            }
        }
    };
    auto get=[&](int pos){
        int res=0;
        for(pos+=n;pos>0;pos>>=1){
            res+=seg[pos];
        }
        return res;
    };
    int m;cin>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        up(a-1,b);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(get(i)==m){
            ans++;
        }
    }
    cout<<ans;
    
    
    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
//int INF=100100100100100;
int a[200010];
signed main(){
  int n;cin>>n;
  int po=0;
  rep(i,n){
    cin>>a[i];
    po=po^a[i];
  }
  rep(i,n){
    cout<<(po^a[i])<<endl;
  }
  return 0;
}


Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> w,c,dp;


int main()
{
    ll n,i,k,j,ans=0,sum = 0;
     ll W;
    cin >> n;
    cin >> W;
    w.resize(n);
    c.resize(n);
    
    for(i =0;i < n;i++){
        cin >> w[i] >> c[i];
        sum += c[i];
    }
    dp.resize(sum+1);
    fill(begin(dp),end(dp),1000000001);
    dp[0] = 0;

    for(i = 0;i < n;i++){
        for(j = sum;j >= c[i];j--){
            dp[j] = min(dp[j],dp[j-c[i]]+w[i]);
            if(dp[j] <= W){
                ans = max(ans,j);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A, C = sorted(A), sorted(C)
    res = 0
    for b in B:
        ai = bisect_left(A, b)
        ci = bisect_right(C, b)
        if ci >= len(C):
            continue
        res += ai * (len(C) - ci)
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 106340
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
ch -= 1
cw -= 1
Dh, Dw = map(int, input().split())
Dh -= 1
Dw -= 1
s = []
for _ in range(h):
    s.append(list(input()))

def is_valid_point(ph, pw):
    if 0 <= ph < h and 0 <= pw < w and s[ph][pw] == '.':
        return True
    else:
        return False

dh = (1, 0, -1, 0)
dw = (0, 1, 0, -1)

inf = 10 ** 18
dist = [[inf] * w for _ in range(h)]
dist[ch][cw] = 0

q = deque([(ch, cw)])
while q:
    ph, pw = q.popleft()
    for k in range(4):
        nh, nw = ph + dh[k], pw + dw[k]
        if is_valid_point(nh, nw):
            if dist[ph][pw] < dist[nh][nw]:
                dist[nh][nw] = dist[ph][pw]
                q.appendleft((nh, nw))
    for nh in range(ph - 2, ph + 3):
        for nw in range(pw - 2, pw + 3):
            if is_valid_point(nh, nw):
                if dist[ph][pw] + 1 < dist[nh][nw]:
                    dist[nh][nw] = dist[ph][pw] + 1
                    q.append((nh, nw))

if dist[Dh][Dw] == inf:
    print(-1)
else:
    print(dist[Dh][Dw])


Measured memory_bytes: 123984
package main

import (
	"fmt"
	"sort"
)

const divNum = 1000000007

type data []uint64

func (d data) Len() int {
	return len(d)
}

func (d data) Swap(i, k int) {
	d[i], d[k] = d[k], d[i]
}

func (d data) Less(i, k int) bool {
	return d[i] > d[k]
}

func main() {
	c := input()
	sort.Sort(c)
	s := uint64(0)
	for i, v := range c {
		s += v * uint64(2+i) % divNum
		s %= divNum
	}
	s *= binary(len(c))
	s %= divNum
	fmt.Println(s)
}

func binary(n int) uint64 {
	if n == 1 {
		return 1
	}
	c := uint64(1)
	l := 2*n - 2
	for i := 0; i < l; i++ {
		c *= 2
		c %= divNum
	}
	return c
}

func input() data {
	var n int
	fmt.Scan(&n)
	c := make([]uint64, n, n)
	for i := range c {
		fmt.Scan(&c[i])
	}
	return c
}


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

int main() {
    int m,n,a,b,i;
    scanf("%d%d",&m,&n);
    a=m>n?m:n;
    b=m<n?m:n;
    if(m==n)
    {
        for(i=0;i<m;i++)
            printf("%d",n);
    }
    else
    {
        for(i=0;i<a;i++)
            printf("%d",b);
    }
}


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

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int[] x;
            while ((line = br.readLine()) != null) {
            	int n=Integer.parseInt(line);
            	String[] str=br.readLine().split(" ");
            	
            	x=new int[n];
            	long max=Integer.parseInt(str[0]);
            	long min=Integer.parseInt(str[0]);
            	long sum=0;
            	
            	for(int i=0;i<n;i++){
            		x[i]=Integer.parseInt(str[i]);
            		if(max<x[i]){
            			max=x[i];
            		}
            		if(min>x[i]){
            			min=x[i];
            		}
            		sum+=x[i];
            	}
            	System.out.println(min+" "+max+" "+sum);
            	break;
            }
        }
    }
}

Measured memory_bytes: 28720
#include<cstdio>
int main(){int h,b,i,j;char r[5],a[5];while(scanf("%s%s",r,a),r[1]!='\0'&&a[1]!='\0'){for(h=b=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])i==j?h++:b++;printf("%d %d\n",h,b);}}

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

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

    int c_w = 0, c_e = 0;
    // 累積和
    for(int i=0;i<n;i++){
        if(s[i] == 'E'){
            c_e++;
        }else{
            c_w++;
        }
    }

    int final_ans = 30000000;
    int change_w = 0;
    int change_e = c_e;
    for(int i=0;i<n;i++){
        if(s[i] == 'E'){
            change_e--;
        }
        if(change_e + change_w <= final_ans){
            final_ans = change_e + change_w;
        }
        if(s[i]=='W'){
            change_w++;
        }
    }
    cout << final_ans << endl;
    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int N,K;
    cin >> N >> K;
    vector<int> sunukes(N,0);
    int d,A;
    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> A;
            sunukes[A-1]++;
        }
        
    }
    int cnt=0;
    for (int i = 0; i < sunukes.size(); i++)
    {
        if (sunukes[i]==0)
        {
            cnt++;
        }
        
    }
    cout << cnt;
    
    
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>

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

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

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

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, x, a[100000];
LL ans;

int main() {
	scanf("%d%d", &n, &x);
	inc(i, n) { scanf("%d", &a[i]); }
	
	if(a[0] > x) { ans += a[0] - x; a[0] = x; }
	inc(i, n - 1) {
		if(a[i] + a[i + 1] > x) { ans += a[i] + a[i + 1] - x; a[i + 1] = x - a[i]; }
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 512
S = input()
if S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
S = [ord(a)-97 for a in S]
if len(S) < 26:
    for i in range(26):
        if i not in S:
            T = S + [i]
            print("".join([chr(a+97) for a in T]))
            exit()
else:
    for i in range(26)[::-1]:
        for j in range(S[i]+1, 26):
            if j in S[i:]:
                T = S[:i] + [j]
                print("".join([chr(a+97) for a in T]))
                exit()

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

w = []
for i in range(n):
	w.append(list(input()))

x = 0

for i in range(n-1):
	if w[i][len(w[i])-1] != w[i+1][0] or w.count(w[i])!=1:
		x +=1
if x==0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int a[810931], v[810931];
int main() {
	int n,x;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		cin >> x;
		a[i] = v[i] = x;
	}
	sort(v,v + n + 1);
	for (int i = 1; i <= n; i++) {
		cout << (a[i] <= v[n / 2] ? v[(n / 2) + 1] : v[n / 2]) << endl;
	}
	return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=1,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c>>d;
	if(a<=b){cout<<a*c;}
	else{cout<<b*c+(a-b)*d;}
} 


Measured memory_bytes: 256
//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define output2darr(n,m,in) if(in==0){loop(i,0,n-1,1){loop(j,0,m-1,1)cout<<a[i][j]<<" ";cout<<endl;}}else{loop(i,1,n,1){loop(j,1,m,1)cout<<a[i][j]<<" ";}cout<<endl;}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void AcDegaYe()
{
    ll n;
    cin>>n;
    cout(n+n*n+n*n*n);
}
int main()
{   
    fastio

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string N; cin >> N;
	cout << (N[0]==N[2]?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n,m;
string str;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> str;
            if (str == "snuke") printf("%c%d\n",j+'A',i+1);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, i, j, k, best, x;
	map<int, int> ct1, ct2;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		if (i % 2 == 0) ct1[x]++;
		else ct2[x]++;
	}

	vector<pair<int, int>> c1, c2;
	for (auto p : ct1) c1.push_back({ p.second, p.first });
	for (auto p : ct2) c2.push_back({ p.second, p.first });
	sort(c1.rbegin(), c1.rend());
	sort(c2.rbegin(), c2.rend());

	best = n * 10;
	for (i = 0; i < min(2, (int)c1.size()); i++) {
		for (j = 0; j < min(2, (int)c2.size()); j++) 
			if (c1[i].second != c2[j].second) {
				x = n - c1[i].first - c2[j].first;
				best = min(best, x);
			}
	}

	if ((c1.size() == 1) && (c2.size() == 1) && (c1[0].second == c2[0].second)) best = n / 2;
	
	cout << best << "\n";
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int d[10];
	for (int i = 0; i < N; i++) cin >> d[i];
	sort(d, d + N, greater<int>());
	int counter = 0;
	for (int i = 1; i < N; i++) counter += d[i];
	if (counter <= d[0]) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    rep(i,0,(1<<4)){
        string s = "";
        if((i>>0) & 1) s += "A";
        s += "KIH";
        if((i>>1) & 1) s += "A";
        s += "B";
        if((i>>2) & 1) s += "A";
        s += "R";
        if((i>>3) & 1) s += "A";
        if(s == S){
            print("YES");
            return 0;
        }
    }
    print("NO");

 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
//  cin>>t;
  int tt=1;
  while(t--){
    int n,i, ans=0;
    cin>>n;
    int cnt[mxn]={0};
    fr(i,0,n)
    {
      int x;
      cin>>x;
      cnt[x]++;
      
   // cout<<"Case #"<<tt<<": ";
   // tt++;
    }
    for(i=mxn-2;i>=0;i--)
      cnt[i]+=cnt[i+1];
    fr(i,0,1e5+1)
    {
      if(cnt[i]==n-cnt[i])
        ans++;
    }
    cout<<ans;
    }
  return 0;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> field = new ArrayList<>(Arrays.asList(0,0,0));
		long scoreCount = 0;
		int outCount = 0;
		int finishedGame = 0;
		try {
			int gameNumber = Integer.parseInt(br.readLine());
			while (finishedGame < gameNumber) {
				String line = br.readLine();
				if(line.equals("HIT")) {
					if(field.get(2)==1) {
						scoreCount++;
					}
					field.remove(2);
					field.add(0, 1);
				}else if(line.equals("OUT")) {
					outCount++;
					if (outCount == 3) {
						System.out.println(scoreCount);
						scoreCount = 0;
						outCount = 0;
						field = new ArrayList<>(Arrays.asList(0,0,0));
						finishedGame++;
					}
				}else if(line.equals("HOMERUN")) {
					scoreCount += 1 + field.stream().filter(base -> base==1).count();
					field = new ArrayList<>(Arrays.asList(0,0,0));
				}
			}
			
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 30524
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			if (line.equals("-")) {break;}
			int len = line.length();
			String word = line;
			String hst = br.readLine();
			int m = Integer.parseInt(hst);
			for (int i = 0; i<m ; i++) {
				String st = br.readLine();
				int h = Integer.parseInt(st);
				char[] c = word.toCharArray();
				word = "";
				
				for (int j = h; j < h+len ; j++ ) {
					if(j < len){
						word += String.valueOf(c[j]);
					}else{
						word += String.valueOf(c[j-len]);
					}
					
				}

			}	
			System.out.println(word);
		}
	}
}

Measured memory_bytes: 45004
#include<stdio.h>
int main(void){
  int n,a;
  int min=1001,max=-1;
  scanf("%d",&n);
  for(int loop=0;loop<n;loop++){
    scanf("%d",&a);
    if(min>a){
      min=a;
    }
    if(max<a){
      max=a;
    }
  }
  printf("%d\n",max-min);
  return 0;
}

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

int Q, p, x, a[309], v[7] = { 2,3,5,7,11,13,17 }, w[7] = { 8,5,3,2,2,2,2 }, maxn;
vector<int>primes;

void dfs(vector<int>vec) {
	if (vec.size() == 7) {
		long long s = 1;
		for (int i = 0; i < vec.size(); i++) { for (int j = 0; j < vec[i]; j++) s *= 1LL * v[i]; }
		for (int i = 7; i < primes.size(); i++) {
			int score = a[primes[i]];
			for (int j = 2; j*primes[i] <= 300; j++) {
				if (s%j == 0) score += a[j*primes[i]];
			}
			if (score > 0) { vec.push_back(1); }
			else { vec.push_back(0); }
		}
		int sum = 0;
		for (int i = 2; i <= 300; i++) {
			int cx = i; bool OK = true;
			for (int j = 0; j < primes.size(); j++) {
				int t = 0;
				while (cx%primes[j] == 0) { cx /= primes[j]; t++; }
				if (vec[j] < t) OK = false;
				if (cx == 1) break;
			}
			if (OK == true) sum += a[i];
		}
		maxn = max(maxn, sum);
		return;
	}
	for (int i = 0; i <= w[vec.size()]; i++) {
		vector<int>vec2 = vec; vec2.push_back(i);
		dfs(vec2);
	}
}

int main() {
	cin >> Q;
	for (int i = 2; i <= 300; i++) {
		bool OK = false;
		for (int j = 2; j*j <= i; j++) { if (i%j == 0)OK = true; }
		if (OK == false) primes.push_back(i);
	}
	for (int i = 1; i <= Q; i++) {
		cin >> p >> x;
		a[p] = x;
	}
	dfs(vector<int>{});
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 384
def main():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    
    a,b = [0],[0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])
        
    ans,j = 0,M
    for i in range(N+1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i+j)
        
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 47460
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<string>
#include<set>

const long long int MOD=1e9+7;

using namespace std;

int main(){
    int n, k;cin >> n>> k;
    string s;
    cin >> s;
    int cnt=0, l=0, block=1;
    char cur=s[0];
    for(int i=1;i<n;i++){
        if(s[i]!=cur){
            cnt+=i-1-l;
            cur=s[i];
            l=i;
            block++;
        }
    }
    cnt += n-1-l;
    for(int i=0;i<k;i++){
        if(block>2){
            block-=2;
            cnt+=2;
        }
        else if(block==2){
            cnt++;
            break;
        }
        else if(block==1){
            break;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(max(a+b, a-b), a*b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;


int *read_array(int N)
{
    int *array;
    int i,m;
    array = new int[N];
    for(i=0;i<N;i++){
        scanf("%d",&m);
        array[i] = m;
    }
    return array;
}

int *read_array1(int N)
{
    int *array;
    int i,m;
    array = new int[N+1];
    for(i=0;i<N;i++){
        scanf("%d",&m);
        array[i] = m;
    }
    return array;
}

void print_array(int *array, int N)
{
    int i;
    for(i=0;i<N;i++){
        if(i!=N-1){
            printf("%d ",array[i]);
        }else{
            printf("%d",array[i]);
        }
    }
    printf("\n");
    return;
}

int linearSearch(int *S, int N, int key)
{
    int i = 0;
    S[N] = key;
    while(S[i]!=key) i++;
    if(i==N) return false;
    return true;
}

int main()
{
    int N,M,*S,*T,count,i,key;
    cin >> N;
    S = read_array1(N);
    cin >> M;
    T = read_array(M);

    count = 0;
    for(i=0;i<M;i++){
        key = T[i];
        count += linearSearch(S,N,key);
    }
    cout << count << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll N, M;
	ll ans = 0;

	cin >> N >> M;

	vector<ll> bits(M);
	ll k, s;
	rep(i, M) {
		cin >> k;
		rep(j, k) {
			cin >> s;
			bits[i] |= 1 << (s - 1);
		}
	}
	vector<ll> p(M);
	rep(i, M) cin >> p[i];

	ll c, cnt;
	bool do_cnt;
	rep(i, (ll)pow(2,N)) {
		do_cnt = true;
		rep(j, M) {
			cnt = 0;
			c = i & bits[j];
			rep(k, 10) {
				if (c & (1 << k)) {
					cnt++;
				}
			}
			if (cnt % 2 != p[j]) {
				do_cnt = false;
				break;
			}
		}
		if (do_cnt) ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N;
    cin >> N;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += v[i] / 2;
        v[i] %= 2;
        if(i != N - 1){
            if(v[i] && v[i+1] > 0){
                ans += 1;
                v[i+1] -= 1;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <list>
using namespace std;

int main() {
	int n, x; 
	char order[15];
	list<int> v;
	scanf("%d", &n);
	while (n--) {
		scanf("%s", order);
		if (order[0] == 'i') {
			scanf("%d", &x); 
			v.push_front(x);
		} else if (order[0] == 'd' && order[6] == 'F') { 
            v.pop_front();
		} else if (order[0] == 'd' && order[6] == 'L') {
			v.pop_back();
		} else {
			scanf("%d", &x);
			for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
				if (*it == x) {
					v.erase(it); break;
				}
			}
		}
	}
	int i = 0;
	for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
	    if (i++) printf(" ");
	    printf("%d", *it);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 34076
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  ll a, b, c, d;
  cin>>a>>b>>c>>d;
  ll x, i, j, k;
  x = (c*d)/__gcd(c, d);
  if(a%c == 0)
  {
     i = b/c - a/c + 1;
  }
  else if(a%c != 0)
  {
      i = b/c - a/c;
  }
  if(a%d == 0)
  {
      j = b/d - a/d + 1;
  }
  else if(a%d != 0)
  {
      j = b/d - a/d;
  }

  if(a%x == 0)
  {
      k = b/x - a/x + 1;
  }
  else if(a%x != 0)
  {
      k = b/x - a/x;
  }

  cout<<b - a - i - j + k + 1<<endl;



return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int main(){
  string sl[200];
  int N,M;
  map<string,int> mp;
  cin>>N;
  string s;
  REP(i,0,N){
    cin>>s;
    mp[s]++;
  }
  cin>>M;
  REP(i,N,N+M){
    cin>>s;
    mp[s]--;
  }
  int ans=0;
  for(auto m:mp){
    ans=max(ans,m.second);
  }
  print(ans);

}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++)if(s[i]!=t[i])ans++;
  cout<<ans<<"\n";
}



Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

const int N = 55;
int x[N], y[N], cx[N], cy[N];

int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> x[i] >> y[i];
    for(int i = 1; i <= m; ++i) cin >> cx[i] >> cy[i];

    for(int i = 1; i <= n; ++i) {
        ll dist = 1e9;
        int k;
        for(int j = 1; j <= m; ++j) {
            ll cur = abs(cx[j] - x[i]) + abs(cy[j] - y[i]);
            if(dist > cur) {
                dist = cur;
                k = j;
            }
            else if(dist == cur) {
                if(make_pair(cx[k], cy[k]) > make_pair(cx[j], cy[j])) k = j;
            }
        }
        cout << k << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n, a, b; cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,d[SZ],up[SZ]; Edg
int pr[SZ],seg[SZ];
int qmin(int l,int r)
{
	int ans=1e9; ++l, ++r;
	for(l+=M-1,r+=M+1;l^r^1;l>>=1,r>>=1)
	{
		if(~l&1) ans=min(ans,seg[l^1]);
		if(r&1) ans=min(ans,seg[r^1]);
	}
	return ans;
}
bool mat(int l1,int r1,int r2)
{
	if(l1>r1) return 1;
	//for i in [l1,r1]
	//pr[i]>=r2+l1-i
	return qmin(l1,r1)>=l1+r2;
}
bool chk(int x,int l,int f=0)
{
	vector<int> ch;
	for esb(x,e,b) if(b!=f)
	{
		bool s=chk(b,l,x);
		if(!s||up[b]>l) return 0;
		ch.pb(up[b]);
	}
	sort(ch.begin(),ch.end());
	int s=ch.size();
	if(s%2==0) //easy
	{
		bool bad=0;
		for(int i=0;i<s/2;++i)
			if(ch[i]+ch[s-1-i]>l) bad=1;
		if(!bad) {up[x]=1; return 1;} --s;
	}
	for(int i=0,j=s-1;i<s;++i)
	{
		while(j>=0&&ch[i]+ch[j]>l) --j;
		pr[i]=j;
	}
	M=1; while(M<=s+3) M<<=1;
	for(int i=0;i<s;++i) seg[i+M+1]=pr[i]+i;
	for(int i=M-1;i>=1;--i)
		seg[i]=min(seg[i+i],seg[i+i+1]);
	up[x]=-1;
	for(int i=0;i<s;++i)
	{
		bool c1=0;
		if(i<s/2)
			c1=mat(0,i-1,s-1)&&mat(i+1,s/2,s-i-1);
		else
			c1=mat(0,s-i-2,s-1)&&mat(s-i-1,s/2-1,i-1);
		if(!c1) continue;
		up[x]=ch[i]+1; break;
	}
	if(up[x]==-1) return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1,a,b;i<n;++i)
		scanf("%d%d",&a,&b),adde(a,b),++d[a],++d[b];
	int ans=n,ro=1;
	for(int i=n;i>=1;--i)
		if(d[i]&1) ro=i;
	for(int i=1;i<=n;++i)
		ans-=(d[i]-(i!=ro)+1)/2;
	printf("%d ",ans);
	int l=0,r=n;
	while(l<r)
	{
		int m=(l+r)>>1;
		bool s=chk(ro,m);
		if(s&&up[ro]<=m+1) r=m; else l=m+1;
	}
	printf("%d\n",l);
}

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

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

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

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

int main()
{
    int N;
    int cnt = 0;
    string S;

    cin >> N >> S;
    
    for ( int i = 0; i < 1000; i++ ) {
        string T, pat;
        T = to_string(i);
        
        while ( pat.size() < 3 - T.size() ) pat += '0';
        T = pat + T;
        
        int cur = 0;
        for ( int j = 0; cur < 3 && j < S.size(); j++ ) {
            if ( T[cur] == S[j] ) cur++;
        }
        if ( cur == 3 ) cnt++;
    }

    cout << cnt << endl;

    return ( 0 );
}


Measured memory_bytes: 256