akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int N,Q;
string s;
pair<char,char>td[200010];
int Deleted(int n){
    for(int i=0;i<Q;i++){
        if(s[n]==td[i].first){
            if(td[i].second=='L'){
                n--;
            }else{
                n++;
            }
        }
        if(n<0) return 0;
        if(n>N-1)return 2;
    }
    return 1;
}

int main(){
    cin>>N>>Q>>s;
    for(int i=0;i<Q;i++){
        cin>>td[i].first>>td[i].second;
    }

    if(N<=2){
        int ans=0;
        for(int i=0;i<N;i++){
            if(Deleted(i)==1){
                ans++;
            }
        }
        cout<<ans<<endl;
        return 0;
    }

    int ansL;
    int l=0,r=N-1;
    while(1){
        if(r-l <= 1){
            if(Deleted(r)==0){
                ansL=r+1;
            }else{
                ansL=r;
            }
            break;
        }
        int c=(l+r)/2;
        if(Deleted(c)==0){
            l=c;
        }else{
            r=c;
        }
    }
    int ansR;
    l=0;r=N-1;
    while(1){
        if(r-l <= 1){
            if(Deleted(r)==2){
                ansR=r;
            }else{
                ansR=r+1;
            }
            break;
        }
        int c=(l+r)/2;
        if(Deleted(c)==2){
            r=c;
        }else{
            l=c;
        }
    }
    cout<<ansR-ansL<<endl;
    return 0;
}

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

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

Measured memory_bytes: 3860
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def popcorn(i,k):
    num = 0
    ii = i
    while ii > 0:
        if ii&1:
            num += 1
        ii //= 2
    if i%num:
        return popcorn(i%num,k+1)
    else:
        return k+1

def main():
    n = int(ipt())
    x = list(map(int,list(input())))
    si = sum(x)
    su = si+1
    sd = max(1,si-1)
    amu = 0
    amd = 0
    n2u = [1]
    if si == 2:
        n2d = [0]
    else:
        n2d = [1]
    for i in x[::-1]:
        if i:
            amu = (amu+n2u[-1])%su
            amd = (amd+n2d[-1])%sd
        n2u.append((n2u[-1]*2)%su)
        n2d.append((n2d[-1]*2)%sd)
    for i,xi in enumerate(x):
        if xi:
            ni = (amd-n2d[-2-i])%sd
            if si == 1:
                print(0)
            elif ni == 0:
                print(1)
            else:
                print(popcorn(ni,1))
        else:
            ni = (amu+n2u[-2-i])%su
            if ni == 0:
                print(1)
            else:
                print(popcorn(ni,1))


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 122520
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static void kMarsh(String[] grid) {
        int n=grid.length;
        int m=grid[0].length();
        char[][] mat=new char[n][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                mat[i][j]=grid[i].charAt(j);
            }
        }
        int[][] first=new int[m][n];
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                int ind=n;
                for(int k=j;k<n;k++)
                {
                    if(mat[k][i]=='x')
                    {
                        ind=k;
                        break;
                    }
                }
                first[i][j]=ind;
            }
        }
        boolean[][][] there=new boolean[n][m][m];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                for(int k=j;k<m;k++)
                {
                    boolean b1=(mat[i][k]=='x')?false:true;
                    boolean b2=true;
                    if(k!=j)
                    b2=there[i][j][k-1];
                    if(!b1 || !b2)
                    there[i][j][k]=false;
                    else
                    there[i][j][k]=true;
                }
            }
        }
        int ans=0;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(mat[i][j]=='x')
                continue;
                int f1=first[j][i]-1;
                for(int k=j+1;k<m;k++)
                {
                    if(mat[i][k]=='x')
                    break;
                    int f2=first[k][i]-1;
                    int x=Math.min(f1,f2);
                    if(x==i)
                    continue;
                    if(!there[x][j][k])
                    continue;
                    int p=2*(x-i+k-j);
                    // System.out.println(i+" "+x+" "+k+" "+j+" "+p);
                    ans=Math.max(ans,p);
                }
            }
        }
        if(ans!=0)
        System.out.println(ans);
        else
        System.out.println("impossible");
    }
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		int b=0;
		int a=0;
		for(int i=0;i<3;i++)
		{
			a=a+(s.charAt(i)=='A'?1:0);
			b=b+(s.charAt(i)=='B'?1:0);
		}
		if(a==3 || b==3)
			System.out.println("No");
		else
			System.out.println("Yes");
	}
}


Measured memory_bytes: 32652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple


void love() {
	int n, k;
	cin>>n>>k;
	int d = 0;
	int s = 0;
	int ans = 0;
	string ss;
	cin>>ss;

	for(int i = 1; i<n; i++){
		if(ss[i-1] == ss[i]) {
			s++;
		}
		else {
			d++;
		}
	}
	if((k<<1)>=d) cout<<s+d<<endl;
	else cout<<s+(k<<1)<<endl;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<iomanip>
#include<vector>

using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e18,flag;

ll c[10000000];
ll idx;
int main(){
	ll n,m;
	cin>>n>>m;
	for(ll i=0; i<m; i++){
		ll a,b;
		cin>>a>>b;
		if(a == 1) c[idx++]=b;
		else if(b==n) c[idx++]=a;
	}
	sort(c,c+idx);
	for(ll i=0; i<idx; i++){
		if(c[i]==c[i+1]){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
}

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

int main() {
    string s;
    int n, m;
    cin >> s >> m;
    n = s.length();
    
    long long dp[110][2][5] = {0};
    dp[0][0][0] = 1;
    
    for (int i = 0; i < n; i++) {
        const int c = s[i] - '0';
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= m; k++) {
                for (int d = 0; d <= (j ? 9 : c); d++) {
                    dp[i+1][j || (d < c)][(d == 0) ? k : k+1] += dp[i][j][k];
                }
            }
        }
    }
    
    long long ans = dp[n][0][m] + dp[n][1][m];
    cout << ans << endl;
    return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H, W, N; cin >> H >> W >> N;
  vector a(N, 0LL);
  for (ll i = 0; i < N; i++) {
    cin >> a.at(i);
  }

  vector C(H, vector(W, 0LL));
  {
    ll r = 0;
    ll c = 0;
    for (ll i = 0; i < N; i++) {
      ll d = a.at(i);
      for (; d > 0; d--) {
	C.at(r).at(c) = i + 1;
	if (r % 2 == 0) {
	  c++;
	  if (c == W) {
	    r++;
	    c = W - 1;
	  }
	}else {
	  c--;
	  if (c == -1) {
	    r++;
	    c = 0;
	  }
	}
      }
    }
  }
  for (ll r = 0; r < H; r++) {
    for (ll c = 0; c < W; c++) {
      if (c > 0) cout << " ";
      cout << C.at(r).at(c);
    }
    cout << "\n";
  }

  return 0;
}



Measured memory_bytes: 3728
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)

int main()
{
	int n = 0, a = 0;
	scanf("%d",&n);

	for (int i = 2; i < 10; i++)
	{
		if (n%i == 0&&n/i<10)
		{
			a = 1;
			break;
		}
	}
	if(a==1)printf("Yes\n");

	else if (n == 1)printf("Yes\n");
	
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
int n, len;
string s;

vector<int> l, r;

void ReadInput()
{
    cin >> s;
    len = s.length();
    n = len + 1;
    l.resize(n); r.resize(n);
}

void Solve()
{
    int cnt = 0;
    l[0] = 0;
    for(int i = 0; i < len; ++i)
    {
        if(s[i] == '<') ++cnt;
        else cnt = 0;
        l[i + 1] = cnt;
    }
    r[n - 1] = 0;
    for(int i = len - 1; i >= 0; --i)
    {
        if(s[i] == '>') ++cnt;
        else cnt = 0;
        r[i] = cnt;
    }
    lli ans = 0;
    for(int i = 0; i < n; ++i)
        ans += max(l[i], r[i]);
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


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

const double PI  = 3.141592653589793238463;

int main() {
    int a, b;
    cin >> a >> b;    
    if(b >= a){
        cout << "unsafe";
    }
    else
    {
        cout << "safe";
    }
    
    cout << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    A[0] =  1;
    rep(i, N-1) cin >> A[i+1];
    vector<int> cnt(N+1);
    rep(i, N){
        cnt[A[i+1]]++;
    }
    rep(i, N){
        cout << cnt[i+1] << endl;
    }

}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;


string s;
ll n;
ll ans;

ll toint(string buf) {
  ll res = 0;
  for (char c: buf) {
    res*=10LL;
    res += (c-'0');
  }
  return res;
}

void dfs(string buf) {
  if (toint(buf) > n) {
    return;
  }
  //cout<<toint(buf)<<" "<<buf<<" "<<n<<endl;

  set<char> st;
  for (char c: buf) {
    st.insert(c);
  }
  if (int(st.size())==3) {
    ans++;
  }
  dfs(buf+"7");
  dfs(buf+"5");
  dfs(buf+"3");
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  assert(toint("353")==353);
  assert(toint("577777")==577777);
  assert(toint("5")==5);
  cin>>s;
  n=toint(s);
  dfs("");
  cout<<ans<<endl;  

  return 0;
}


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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define OF(i,a,b) for (int (i) = (a)-1; (i) >= (b); --(i))
#define SZ(v) int(v.size())
#define pb push_back

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/

const int MAXN = 100005;
int N;
vector<int> allE[MAXN];
int par[MAXN];

vector<int> dfs (int c) {
    int cnt[20];
    fill(cnt, cnt+20, 0);
    for (int nxt : allE[c]) {
        if (nxt == par[c]) continue;
        par[nxt] = c;
        auto chV = dfs(nxt);
        for (int v : chV) {
            cnt[v]++;
        }
    }
    int endSpot = 0;
    for (int c = 19; c >= 0; c--) {
        if (c == 0 || cnt[c] > 1) {
            endSpot = c;
            while (cnt[endSpot]) endSpot++;
            break;
        }
    }
    cnt[endSpot] = 1;
    vector<int> ret;
    for (int c = 19; c >= endSpot; c--) {
        if (cnt[c]) ret.push_back(c);
    }
    return ret;
}


int main() {
    scanf ("%d", &N);
    FO (i,0,N-1) {
        int a, b;
        scanf("%d %d", &a, &b);
        allE[a].pb(b);
        allE[b].pb(a);
    }
    auto v = dfs(1);
    printf ("%d\n", v[0]);
    return 0;
}


Measured memory_bytes: 17536
from bisect import bisect_left
from bisect import bisect_right
N = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))


cnt = 0
for b in Bs:
    ind_c = bisect_left(Cs,b+1)
    ind_a = bisect_right(As,b-1)
    if ind_c == N:continue
    # print(b,ind_a,ind_c)
    cnt += (N - ind_c) * (ind_a)
print(cnt)


Measured memory_bytes: 23232
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t H;
  cin>>H;
  int64_t ans=0;
  for(int i=0;1<=H;i++){
  ans+=pow(2,i);H/=2;
  
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
A,B=map(int,input().split())
quotient = 0
mod = 0
ans=0
for i in range(A,B+1):
	num=[]
	quotient=i
	while quotient !=0:
		mod= quotient%10
		quotient = quotient//10
		num.append(mod)
	if num[0]==num[4] and num[1]==num[3]:
		ans =ans+1
print(ans)
	

Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().rstrip().decode('utf_8')

def F(S):
	yield int(S)
	for i in range(len(S)-1):
		left = S[:i+1]
		right = S[i+1:]
		x = int(left)
		for y in F(right):
			yield x+y

print(sum(F(S)))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  ll K,A,B; cin>>K>>A>>B;
  if(B-A<=2) {cout<<K+1<<endl; return 0;}
  K-=(A-1);
  ll ans=A;
  ans+=(B-A)*(K/2)+K%2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import *
from sys import *

def solve(n,w):
  lp,lw = [],[]
  for i in xrange(n):
    s = map(int, raw_input().split(","))
    lp.append(s[0])
    lw.append(s[1])
  c = [-1]*(w+1)
  c[0] = 0
  for i in xrange(n):
    for j in reversed(xrange(w)):
      if c[j] == -1 or j+lw[i] > w : continue
      c[j+lw[i]] = max( c[j]+lp[i], c[j+lw[i]] )
  print max(c)
  print c.index(max(c))

case = 1
while True:
  w = int(raw_input())
  if w == 0: break
  n = int(raw_input())
  print "Case %d:" % (case)
  solve(n,w)
  case += 1

Measured memory_bytes: 4436
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

double F(double K) {
	while (1) {
		K -= 360;
		if (K <= 0) {
			return K + 360;
		}
	}
}

int main() {
	double pi = 3.14159265358979;
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double T = H * 60 + M;
	double K = T * 11 / 2;
	K = F(K);
	K *= (pi / 180);
	double ans = sqrt(A * A + B * B - 2 * A * B * cos(K));
	cout <<fixed<<setprecision(20)<< ans << enld;
}

Measured memory_bytes: 4216
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std; using ll=long long; const int m=1e9+7; using P=pair<int,int>;

int main() {
  int n; cin>>n;
  string s; cin>>s;
  ll a[26]; fill(a,a+26,0); for(int i=0;i<n;i++) a[s[i]-'a']++;

  ll an=1;
  for(int i=0;i<26;i++) {
    an = an * (a[i] + 1) % m; 
  }
  an = (an+m-1) % m;
  cout<<an<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;


typedef long long  ll;

int main() {
    int n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end(),greater<ll>());
    ll x=0;
    ll y=0;
    for(int i=0;i<n-1;i++){
        if(a.at(i)==a.at(i+1)){
            if(x==0){
                x=a.at(i);
            }
            else if(y==0){
                y=a.at(i);
                if(x==y and i+3<n and a.at(i)!=a.at(i+3)){
                    y=0;
                }
            }
        }
        if(y!=0)break;
    }
    cout<<x*y<<endl;



    return 0;
}


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



int main()
{
	int n,N,K,dis=1000000000;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	N=v[n-1];
	for(int i=0;i<n-1;i++)
	{
		if(abs(N-2*v[i])<=dis)
		{
			K=v[i];
			dis=abs(N-2*v[i]);
		}
	}
	cout<<N<<" "<<K<<endl;
	return 0;
}

Measured memory_bytes: 640
#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 ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e7 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	ll a;
	string b;
	cin >> a >> b;

	int nat = b[0] - '0';
	int frac = (b[2] - '0') * 10 + (b[3] - '0');

	// cout << nat << " " << frac << endl;

	ll res = a * nat;

	res += (a * frac) / 100;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main() {
	int w, n, i, a, b, c[30], temp;
	scanf("%d", &w);
	for (i = 0;i < w;i++) {
		c[i] = i + 1;
	}
	scanf("%d", &n);
	for(i=0;i<n;i++){
	scanf("%d,%d", &a, &b);
	temp=c[a-1];
	c[a-1] = c[b-1];
	c[b-1] = temp;
	}
	for (i = 0;i < w;i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 596
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace ABC130A
{
    partial class Program
    {
        public void Solve()
        {
            var x = Num;
            var a = Num;
            if (x < a)
                Console.WriteLine("0");
            else
                Console.WriteLine("10");
        }
    }

    class StartingPoint
    {
        static void Main(string[] args)
        {
            if (args?.Any() == true)
            {
                var assembly = Assembly.GetExecutingAssembly();
                var resourceName = "AtCoder.Resources.In.txt";
                var stream = assembly.GetManifestResourceStream(resourceName);
                var streamReader = new StreamReader(stream, Encoding.UTF8);
                var str = streamReader.ReadToEnd();
                var textReader = new StringReader(str);
                Console.SetIn(textReader);
            }

            try
            {
                new Program().Solve();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                if (args?.Any() != true)
                    throw e;
            }

            if (args?.Any() == true)
                Console.ReadLine();
        }
    }

    partial class Program
    {
        long Num => long.Parse(Str);

        StringBuilder sb = new StringBuilder();

        string Str => GetStr();
        string GetStr()
        {
            sb.Clear();

            int r = 0;
            bool? b = null;
            do
            {
                r = Console.Read();
                b = IsBreak(r);
            } while (b == true);

            if (b == null)
                throw new Exception("input error: unexpected end of stream");

            do
            {
                sb.Append((char)r);
                r = Console.Read();
                b = IsBreak(r);
            } while (b == false);

            return sb.ToString();
        }

        bool? IsBreak(int c)
        {
            switch (c)
            {
                case -1:
                    return null;
                case (int)' ':
                case (int)'\n':
                case (int)'\r':
                    return true;
                default:
                    return false;
            }
        }
    }
}

Measured memory_bytes: 13268
N = int(input())
T = list(map(int, input().split()))
M = int(input())
p = []
x = []
ans = []
for i in range(M):
    p, x = map(int, input().split())
    ans.append(sum(T[:p-1])+x+sum(T[p:]))

for _ in ans:
    print(_)

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

using namespace std;

string str,f[3005];
int pos[3005];
bool kind[3005];

int bel[6005];

int main() {
  int n;
  cin>>n>>str;
  int cnt=0,s=0;
  for(int i=0;i<2*n;i++) {
  	s+=((str[i]=='b')?1:-1);
  	if (!s) {
  		pos[++cnt]=i;
  		kind[cnt]=((str[i]=='a')?0:1);
	  }
  }
  pos[0]=-1;
  bool v=1;
  for(int i=cnt;i>0;i--)
    if (!kind[i]) {
    	v=0;
    	int s1=0,s2=0;
    	for(int j=pos[i-1]+1;j<=pos[i];j++)
    	  if (str[j]=='b') bel[j]=++s1; else bel[j]=++s2;
    	f[i]=f[i+1];
    	for(int j=1;j<=s1;j++) {
          string cur;
    	  for(int k=pos[i-1]+1;k<=pos[i];k++)
    	    if (bel[k]>=j) cur+=str[k];
    	  f[i]=max(f[i],cur+f[i+1]);
    	}
	}
	else if (v) {
		int s1=0,s2=0;
		for(int j=pos[i-1]+1;j<=pos[i];j++)
    	  if (str[j]=='a') bel[j]=++s1; else bel[j]=++s2;
    	int r=pos[i-1]+1;
    	for(;;) {
    		while (r<=pos[i]&&str[r]=='b') r++;
    		if (r>pos[i]) break;
    		f[i]+="ab";
    		int t=bel[r];
    		r++;
    		while (bel[r]!=t) r++;
    		r++;
		}
		f[i]+=f[i+1];
	}
	else f[i]=f[i+1];
  cout<<f[1]<<endl;
  return 0;
}

Measured memory_bytes: 10496
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	x := n
	s := 0
	for x > 0 {
		s += x % 10
		x /= 10
	}
	if n%s == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod - a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if (t == 0) return mint(1);
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
class modutils {
  vector<mint> fact, invfact;

 public:
  modutils(int n = 200005) : fact(n + 1), invfact(n + 1) {
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
    invfact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) invfact[i - 1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) { return x.pow(n); }
  mint comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] * invfact[k] * invfact[n - k];
  }
  mint perm(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] * invfact[n - k];
  }
  mint fac(ll n) { return fact[n]; }
};

int main() {
  ll n;
  cin >> n;
  vll as(n);
  vll bs(n);
  rep(i, n) cin >> as[i];
  rep(i, n) cin >> bs[i];
  ll acnt = 0;
  ll bcnt = 0;
  rep(i, n) {
    if (as[i] > bs[i]) bcnt += as[i] - bs[i];
    if (as[i] < bs[i]) acnt += (bs[i] - as[i])/2;
  }
  cout << ((bcnt <= acnt) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 384
using System;

class Program {

    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        int r = int.Parse( values[ 0 ] );
        int c = int.Parse( values[ 1 ] );

        int[ , ] data = new int[ r + 1, c + 1 ];

        for( int i = 0; i < r; ++i ) {
            input = Console.ReadLine();
            values = input.Split( ' ' );

            int sum = 0;
            for( int j = 0; j < c; ++j ) {
                var value = int.Parse( values[ j ] );
                data[ i, j ] = value;
                data[ r, j ] += value;
                sum += value;
            }
            data[ i, c ] = sum;
            data[ r, c ] += sum;
        }

        for( int i = 0; i < r + 1; ++i ) {
            for( int j = 0; j < c + 1; ++j ) {
                var output = string.Format( "{0}{1}", data[ i, j ], ( j != c ) ? " " : string.Empty );
                Console.Write( output );
            }
            Console.WriteLine();
        }

        return 0;
    }

}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        if (A.at(i)+A.at(j)>A.at(k))
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> P(N);
  for(int i = 0;i < N;i++) cin >> P.at(i);
  int num = 0,m = P.at(0);
  for(int i = 0;i < N;i++) {
    if(P.at(i) <= m)  {
      num++;
      m = P.at(i);
    }
  }

  cout << num << endl;
  
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
  int a[5],i;
  
  for(i=0;i<5;i++){
    scanf("%d", &a[i]);
    if(a[i] == 0)
      break;
  }
  
  printf("%d", i+1);
  
  return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;

    map<int,int> mp; mp.clear();
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
    }

    vector<int> v; v.clear();
    set<int> bad; bad.clear();
    for (auto p: mp) {
        if (p.second > 1) {
            bad.insert(p.first);
            continue;
        }
        v.push_back(p.first);
    }

    set<int> take; take.clear();
    for (auto x: v) {
        // cout << "\n";
        // cout << "x = " << x << "\n";
        bool valid = true;
        for (int i = 1; i*i <= x; i++) {
            if (x%i == 0) {
                if (take.count(i) || take.count(x/i)) {
                    valid = false;
                    break;
                }
                if (bad.count(i) || bad.count(x/i)) {
                    valid = false;
                    break;
                }
            }
        }
        if (valid) {
            // cout << "Took it!\n";
            take.insert(x);
        }
    }

    int ans = take.size();
    out(ans);
    
    
    return 0;
}


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

using namespace std;

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

	int n, x;
	cin >> n >> x;

	vector<int> a;
	a.resize(n);

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

	long long ans = 0;

	for(int i = 0; i < n - 1; ++i) {
		int d = max(a[i] + a[i + 1] - x, 0);

		ans += d;
		a[i + 1] -= min(a[i + 1], d);
	}

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

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


int main()
{
   int n;
   cin >> n;
   int now = 1;
   int tmp;
   int ans = 0;
   for (int i = 1; i <= n; i++) {
      cin >> tmp;
      if (now == tmp) now++;
      else ans++;
   }
   if (ans != n) cout << ans << endl;
   else cout << -1 << endl;
   return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0 ;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
#define SORT(x,n) sort(x,x)
#define P pair<int,int>
typedef long long LL;
const int INF=1000000007;
using namespace std;
int gcd(int a,int b){
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}

int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  REP(i,N){
    cin>>d[i];
  }
  sort(ALL(d));
  int answer=d[N/2]-d[N/2-1];
  cout<<answer;
}


Measured memory_bytes: 640
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,amax,a[N],k;
signed main(){
	n=read();k=read();
	F(i,1,n) amax=max(amax,a[i]=read());
	F(i,2,n) a[i]=__gcd(a[i-1],a[i]);
	if (k%a[n]==0&&amax>=k) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[] = new int[M];
		int b[] = new int[M];
		int c[][] = new int[M][M];
		int s[] = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			for(int j = 0; j < b[i]; j++) {
				c[i][j] = sc.nextInt();
				s[i] |= (1 << (c[i][j] - 1));
			}
		}
		
		int dp[] = new int[1 << N];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for(int i = 0; i < 1 << N; i++) {
			for(int j = 0; j < M; j++) {
				if(dp[i] != Integer.MAX_VALUE) {
					int t = i | s[j];
					int cost = dp[i] + a[j];
					dp[t] = Math.min(dp[t], cost);
				}
			}
		}
		
		System.out.println(dp[(1 << N) - 1] == Integer.MAX_VALUE ? -1 : dp[(1 << N) - 1]);
	}
}


Measured memory_bytes: 44480
#include<stdio.h>

int main(void){
    int n,i,j,a,b;
    char command[20],str[2000],s[2000];

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

    for(j = 0;j < n;j++){
        scanf("%s",command);
        scanf("%d%d",&a,&b);

        if(command[2] == 'i'){
            for(i = 0;i <= b - a;i++)
                s[i] = str[a + i];
            s[i] = '\0';
            printf("%s\n",s);
        }else if(command[2] == 'p'){
            scanf("%s",s);
            for(i = 0;i <= b - a;i++)
                str[a + i] = s[i];
        }else{
            for(i = 0;i <= b - a;i++)
                s[i] = str[b - i];
            for(i = 0;i <= b - a;i++)
                str[a + i] = s[i];
        }
    }
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct Tree{
	int V;
	vector<int> G[100010];
	int dp(int v,int p){
		int ret = 0;
		for(int u: G[v]){
			if(u == p)continue;
			int d = dp(u,v);
			if(d == -1)return -1;
			ret += d;
		}
		if(ret >= 2)return -1;
		return ret^1;
	}
}tree;

int main(){
	static int n;
	static int a[100010],b[100010];
	scanf("%d",&n);
	rep1(i,n-1){
		scanf("%d%d",&a[i],&b[i]);
	}
	
	tree.V = n;
	rep1(i,n-1){
		tree.G[a[i]].pb(b[i]);
		tree.G[b[i]].pb(a[i]);
	}
	
	int ret = tree.dp(1,0);
	if(ret == 0)puts("Second");
	else puts("First");
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  string s;cin>>s;
  int maxn=0;
  for(int i=0;i<n-1;i++){
    int cnt=0;
    map<char, int> mp1,mp2;
    for(int j=0;j<i+1;j++){
      mp1[s[j]]++;
    }
    for(int j=i+1;j<n;j++){
      mp2[s[j]]++;
    }
    for(char c='a';c<='z';c++){
      if(mp1[c]>=1 && mp2[c]>=1){
        cnt++;
      }
    }
    maxn=max(maxn, cnt);
  }
  P(maxn);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

LL count(int N, int x, int y) 
{
    LL ret = 0;
    int b = 10;
    while (b*x+y <= N) {
        if (b*10 <= N) {
            ret += b/10;
        } else {
            int t = N / b;
            if (x < t) {
                ret += b/10;
            } else if (x == t) {
                if (b == 10) {
                    if ((x*10+y <= N)) {
                        ++ ret;
                    }
                } else {
                    int bottom = N % 10;
                    int middle = (N%b)/10 +1;
                    if (bottom < y) {
                        middle = max(0, middle-1);
                    }
                    ret += middle;
                    // ret += max(0, (b-10+y) - N%b + 1);
                    // cout << "b-10+y = " << (b-10+y) << endl;
                    // cout << "N%b = " << (N%b) << endl;
                    // cout << "(b-10+y) - N%b + 1 = " << ((b-10+y) - N%b + 1) << endl;
                }
            }     
        }
        b *= 10;
    }
    return ret;
}

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

    int N;
    cin >> N;

    LL ans = 0;

    if (N < 10) {
        ans = N;
    } else {
        ans = 9; //! for 1digit numbers
        //! A = x..y, B = y..x
        // cout << count(N, 1, 2) << endl;
        // cout << count(N, 2, 1) << endl;
        // cout << count(N, 2, 5) << endl;
        // cout << count(N, 2, 9) << endl;
        // cout << count(N, 3, 1) << endl;
        for (int x = 1; x <= 9; ++x) {
            for (int y = 1; y <= 9; ++y) {
                int numA = count(N, x, y);
                int numB = count(N, y, x);
                ans += numA * numB;
                if (x == y) {
                    ans += numA + numB;
                }
            }
        }
    }



    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    string s; cin >> s;
    string ss = s;
    reverse(ss.begin(), ss.end());

    int ans = 0;
    for (int i=0; i<s.size(); i++) {
        if (s[i] != ss[i]) ans++;
    }

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



Measured memory_bytes: 760
#include<stdio.h>

int main()
{
    int N,i,x;
    scanf("%d\n", &N);
    int A[N];
    for(i=1;i<=N;i++){
        scanf("%d", &x);
        A[x]=i;
    }
    for(i=1;i<=N;i++){
        printf("%d ", A[i]);
    }
    return 0;
}


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

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

int sa,sb,sc;

ll solve() {
	ll ret=0; int a=sa,b=sb,c=sc;
	{
		int cur=min(b,c);
		ret+=2*cur;
		b-=cur;
		c-=cur;
	}
	{
		int cur=min(a,c);
		ret+=cur;
		a-=cur;
		c-=cur;
	}
	ret+=b+min(c,1);
	return ret;
}

void run() {
	scanf("%d%d%d",&sa,&sb,&sc);
	printf("%d\n",solve());
}

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


Measured memory_bytes: 768
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int T[2][maxN << 1];
int n;

void upd(int l, int r, int x, int* T) {
	for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
		if(l & 1) T[l] = min(T[l], x), l++;
		if(r & 1) --r, T[r] = min(T[r], x);
	}
}

int qry(int w, int* T) {
	w += n;
	int ret = n;
	while(w > 0) {
		ret = min(ret, T[w]);
		w >>= 1;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int q;
	cin >> n >> q;
	n--;
	ll tot = ll(n - 1) * ll(n - 1);
	for(int i = 0; i < n * 2; i++) T[0][i] = T[1][i] = n;
	
	while(q--) {
		int ty, x;
		cin >> ty >> x;
		ty--, x--;
		int beste = qry(x, T[ty]);
		tot -= beste - 1;
		upd(0, beste, x, T[ty ^ 1]);
	}
	cout << tot << '\n';
}



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

typedef double dbl;
int main() {
	int l[10], v1, v2;
	while (cin >> l[0]) {
		int s = l[0];
		char c;
		for (int i = 1; i < 10; i++) {
			cin >> c >> l[i];
			s += l[i];
		}
		cin >> c >> v1 >> c >> v2;
		dbl t = (dbl)s / (v1 + v2);
		dbl sum = 0.0;
		int p = 0;
		while (sum < v1 * t) {
			sum += (dbl)l[p++];
		}
		cout << p << endl;
	}
}


Measured memory_bytes: 3076
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
const int M = 1e9 + 7;


inline int my_mod(const LL a, const int m = M)
{
    return (a % m + m) % m;
}


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

    int N;
    cin >> N;

    vector<int> nrs(N);
    LL mod_sum = 0;
    for (int &nr : nrs)
    {
        cin >> nr;

        mod_sum = my_mod(mod_sum + nr);
    }
    // mod_sum = my_mod(mod_sum - nrs.front());
    // cerr << "mod sum: " << mod_sum << "\n";

    LL res = 0;
    for (int i = 0; i < N; ++i)
    {
        mod_sum = my_mod(mod_sum - nrs[i]);

        res = my_mod(res + my_mod(nrs[i] * mod_sum));
    }

    cout << res;
}


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

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

    string ans;
    
    ans += toupper(a.front());
    ans += toupper(b.front());
    ans += toupper(c.front());

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine(a + a * a + a *a *a);
        }
    }
}


Measured memory_bytes: 27540
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = -1;
    for (int x = 13; x <= 1009; x++) {
        if ((int)(x * 0.08) != A) {
            continue;
        }
        if ((int)(x * 0.1) != B) {
            continue;
        }
        ans = x;
        break;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    int n, m, a, b;
    int h[111111];
    cin>>n>>m;
    for (int i = 0; i < n; i++) {
        cin>>h[i];
    }
    vector<int> g[111111];
    for (int i = 0; i < m; i++) {
        cin>>a>>b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool flag = true;
        for (int p: g[i]) {
            if (h[p] >= h[i]) flag = false;
        }
        if (flag) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10480
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll N,X,L,robo=0;
    vector<tuple<ll, ll>> vc;
    cin >>N;
    for(ll i=0; i<N;i++){
        cin >> X >> L;
        vc.emplace_back(X,L);
    }
    sort( begin( vc ), end( vc ) );
    ll Xi=0,Li=0;
    X=-1;
    for(auto x : vc){
        Xi = get<0>(x);
        Li = get<1>(x);
        if(X+L > Xi-Li &&  X > -1 ){
            if(X+L>=Xi+Li){
                X=Xi;
                L=Li;
            }
        }else{
            X=Xi;
            L=Li;
            robo++;
        }
    }

    cout << robo << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

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

    vector<ll> dp(2, 0), jdp(2, 0);
    jdp[0] = 1;
    ll origin = 0, jplus = 0, oplus = 0;
    ll icnt = count(s.begin(), s.end(), 'I');
    for(int i = 0; i < n; i++){
        oplus = max(oplus, dp[0]*icnt);
        if(s[i] == 'J') dp[0]++, jdp[0]++;
        if(s[i] == 'O') dp[1] += dp[0], jdp[1] += jdp[0];
        if(s[i] == 'I') origin += dp[1], jplus += jdp[1], icnt--;
    }
    ll iplus = dp[1]+origin;
    oplus += origin;
    cout << max({jplus, oplus, iplus}) << endl;
    return 0;
}


Measured memory_bytes: 3308