akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

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

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
class UF{
  vector<int> par,rank,size_uf;
  int chunk_size;
public:
  UF(int size):chunk_size(size){
    for (int i = 0; i < size; i++) {
      par.push_back(i);
      rank.push_back(0);
      size_uf.push_back(1);
    }
  }
  int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    --chunk_size;
    if(rank[x]<rank[y]){
      par[x]=y;
      size_uf[y]+=size_uf[x];
    }
    else{
      par[y]=x;
      size_uf[x]+=size_uf[y];
      if(rank[x]==rank[y])rank[x]++;
    }
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  int operator [](int x){
    return this->find(x);
  }
  int size(int x){
    x=find(x);
    return size_uf[x];
  }
  long uf_size(){
    return this->chunk_size;
  }
};

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, long long Q, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
  UF uf(N);
  tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  s;
  REP(Q){
    if(C[i]==0){
      uf.unite(A[i],B[i]);
    }
  }
  REP(N){
    s.insert(uf[i]);
  }
  UF ufuf(s.size());
  REP(Q){
    if(C[i]){
      ll tmpa=s.order_of_key(uf[A[i]]),tmpb=s.order_of_key(uf[B[i]]);
      if(uf.same(A[i],B[i])){
        cout<<NO<<endl;
        return;
      }
      ufuf.unite(tmpa,tmpb);
    }
  }
  if(uf.uf_size()>ufuf.uf_size()&&(M==N-1||uf.uf_size()<=2)){
    cout<<NO<<endl;return;
  }
  ll max_edge=N-uf.uf_size()+(uf.uf_size()*(uf.uf_size()-1))/2;
  if(M<=max_edge){
    cout<<YES<<endl;
  }else{
    cout<<NO<<endl;
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q-1-0+1);
    std::vector<long long> B(Q-1-0+1);
    std::vector<long long> C(Q-1-0+1);
    for(int i = 0 ; i < Q-1-0+1 ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, Q, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 11500
#include<stdio.h>
#include<string.h>
int main(void){
  int n,s,i,k;
  scanf("%d",&n);
  char a[n];
  scanf("%s",a);
  s=strlen(a);
  for(i=1;i<n;i++){
   if(a[i-1]==a[i]){
    
     s--;
  
  }
  }
  printf("%d",s);
  return 0;
}

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

int main ()
{
    int N, p = 0, q = 0;
    std::string s, t;
    cin >> N >> s;
    for (int i = 0; i < N; ++i)
    {
        if (')' == s[i])
        {
            if (0 < p)
            {
                --p;
            }
            else
            {
                ++q;
            }
        }
        else if ('(' == s[i])
        {
            ++p;
        }
    }
    for (; q > 0; --q)
    {
        t += '(';
    }
    t += s;
    for (; p > 0; --p)
    {
        t += ')';
    }

    cout << t << endl;
    return 0;
}

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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int ans=0;
    vi v;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        v.pb(k);
    }
    sort(v.begin(),v.end());
    v.pb(-1);
    int t=v[0];
    int count=1;
    for(int i=1;i<=n;i++){
        if(v[i]==t){
            count+=1;
        }
        else{
            t=v[i];
            ans+=(count&1);
            count=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

std::vector<std::vector<std::pair<int, int>>> g;
int n, m;

std::vector<int> solve(int s) {
	typedef std::pair<int, int> P;
	std::vector<int> min_cost(n, 1 << 30); min_cost[s] = 0;
	std::priority_queue<P, std::vector<P>, std::greater<P>> qu; qu.push({0, s});
	while(!qu.empty()) {
		auto p = qu.top(); qu.pop();
		
		for(auto e : g[p.second]) {
			if(p.first + e.second >= min_cost[e.first]) continue;
			min_cost[e.first] = p.first + e.second;
			qu.push({min_cost[e.first], e.first});
		}
	}
	return min_cost;
}

int main() {
	cin >> n >> m; g.resize(n);
	for(int i = 0; i < m; i++) {
		int a, b, c; cin >> a >> b >> c;
		
		g[a - 1].push_back({b - 1, c});
		g[b - 1].push_back({a - 1, c});
	}
	
	int ma = 0;
	std::vector<std::vector<int>> dist(n);
	for(int i = 0; i < n; i++) {
		dist[i] = solve(i);
		for(int j = 0; j < n; j++) ma = std::max(ma, dist[i][j]);
	}
	
	std::set<int> st;
	for(int i = 0; i < n; i++) {
		std::queue<int> qu;
		for(int j = i + 1; j < n; j++) if(dist[i][j] == ma) qu.push(j);
		
		std::vector<bool> used(n, false);
		while(!qu.empty()) {
			auto p = qu.front(); qu.pop(); st.insert(p);
			if(used[p]) continue; used[p] = true;
			
			for(auto e : g[p]) {
				if(dist[i][p] != dist[i][e.first] + e.second) continue;
				qu.push(e.first);
			}
		}
	}
	cout << n - st.size() << endl;
	for(int i = 0; i < n; i++) if(!st.count(i)) cout << i + 1 << endl;
	return 0;
}



Measured memory_bytes: 12012
li = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
num = int(input())
inputs = input()
char = ""
char_list = list(inputs)
for x in char_list:
    pos = li.index(x)
    pos += num
    while pos >= 26:
        pos -= 26
    char += li[pos]

print(char)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
long long m, n;
#define mod 1000000007

long long pow_mod(long long a, long long b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		long long d = pow_mod(a, b / 2);
		return ((d%mod)*(d%mod)) % mod;
	}
	return ((a%mod)*(pow_mod(a, (b - 1)) % mod)) % mod;
}
int main() {
	cin >> m >> n;
	cout << pow_mod(m, n) << endl;
	return 0;
}


Measured memory_bytes: 3068
n = int(input())
res = input()

dic = {"J":0, "O":1, "I":2}
zo = [0,1]
dp =[[[0 for j in zo] for o in zo] for i in zo]

res1 = dic[res[0]]

if res1 == 0:
  for o in zo:
    for i in zo:
      dp[1][o][i] = 1
elif res1 == 1:
  for i in zo:
    dp[1][1][i] = 1
else:
  for o in zo:
    dp[1][o][1] = 1

for d in range(1, n):
  resd = dic[res[d]]
  new = [[[0 for i in zo] for o in zo] for j in zo]
  new[0][0][0] = 0
  new[1][1][1] = sum([dp[x][y][z] for x in zo for y in zo for z in zo])
  new[0][0][1] = sum([dp[x][y][1] for x in zo for y in zo]) if resd == 2 else 0
  new[0][1][0] = sum([dp[x][1][y] for x in zo for y in zo]) if resd == 1 else 0
  new[1][0][0] = sum([dp[1][x][y] for x in [0,1] for y in [0,1]]) if resd == 0 else 0
  new[0][1][1] = sum([dp[x][1][y] + dp[x][y][1] for x in zo for y in zo]) - sum(dp[x][1][1] for x in zo) if resd in [1, 2] else 0
  new[1][0][1] = sum([dp[1][x][y] + dp[x][y][1] for x in zo for y in zo]) - sum(dp[1][x][1] for x in zo) if resd in [0, 2] else 0
  new[1][1][0] = sum([dp[x][1][y] + dp[1][x][y] for x in zo for y in zo]) - sum(dp[1][1][x] for x in zo) if resd in [0, 1] else 0
  dp = new

ans = 0
for i in zo:
  for j in zo:
    for k in zo:
      ans += dp[i][j][k]

print(ans % 10007)


Measured memory_bytes: 5648
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
// #define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;


int main(){
	FAST;
	int a, b;
	cin >> a >> b;
	if (a>9||b>9) cout << -1 << LF;
	else cout << a*b <<LF;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

	vector<int> K(31, k);
	for(auto i = 0; i < 31; ++i) {
		if((K[i] & (1 << i))) {
			K[i] = K[i] & ~(1 << i) | ((1 << i) - 1);
		}
	}

	long long result = 0;
	for(auto x : K) {
		long long temp = 0;
		for(auto i = 0; i < n; ++i) {
			if(x == (x | a[i])) {
				temp += b[i];
			}
		}
		result = max(result, temp);
	}

	cout << result << endl;
}


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

using namespace std;

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

    int n;
    cin >> n;
    int mx = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        ans += max(mx - x, 0);
        mx = max(mx, x);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int k, x;cin>>k>>x;
    500*k>=x?co("Yes"):co("No");
}


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


int main() {
    int N, P;
    cin >> N >> P;
    bool even = true;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a % 2 == 1) {
            even = false;
        }
    }
    if (P == 0) {
        if (even == true) {
            cout << (long long)pow(2, N) << '\n';
        }
        else 
            cout << (long long) pow(2, N-1) << '\n';
    }
    else {
        if (even == true) {
            cout << 0 << '\n';
        }
        else {
            cout << (long long) pow(2, N-1) << '\n';
        }
    }
}



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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n ; i++) cin >> p.at(i);
  int cnt = 0;
  for (int i = 0; i < n - 1  ;i++){
    if( i - 1 < 0) continue;
    else if((p.at(i - 1) < p.at(i)) && (p.at(i) < p.at(i+1)))cnt++;
    else if((p.at(i - 1) > p.at(i)) && (p.at(i) > p.at(i+1)))cnt++;
  }
  
  cout << cnt << endl;
    
 }


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n==1) printf("1\n");
    if(n>=2 && n<4) printf("2\n");
    if(n<8 && n>=4) printf("4\n");
    if(n<16 && n>=8) printf("8\n");
    if(n<32 && n>=16) printf("16\n");
    if(n<64 && n>=32) printf("32\n");
    if(n<128 && n>=64) printf("64\n");
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):
  for j in range(i+1,n):
    kmax=n
    kmin=j
    while True:
      k=(kmax+kmin)//2
      if l[i]+l[j]>l[k]:
        ans=ans+k-kmin
        kmin=k
      else:
        kmax=k
      if kmax-kmin==1:
        break
print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> H(n);
    rep(i,n)cin>>H[i];
    vector<set<ll>> s(n,set<ll>());
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        s[a].insert(b);
        s[b].insert(a);
    }
    ll ans=0;
    rep(i,n){
        bool isOK=true;
        for(auto x:s[i]){
            if(H[i]<=H[x]){
                isOK=false;
                break;
            }
        }
        if(!isOK)continue;
        ans++;
        //cout<<i<<endl;
    }

    cout<<ans<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 18044
#include <bits/stdc++.h>
#define pb push_back
#define ll long long 
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    for(int T = 0; T < t ; T++){
        ll n, ans = 0, k;
        cin >> n >> k;
        ll a[n];
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
        }
        sort(a , a+ n);
        for(int i = 0; i < k; i++){
            ans += a[i];
        }
        
        cout << ans<< "\n";
    }
    return 0;
}

Measured memory_bytes: 3664
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int>sumW(n + 1, 0);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			sumW[i + 1] = sumW[i] + 1;
		}
		else {
			sumW[i + 1] = sumW[i];
		}
	}
	vector<int>sumE(n + 1, 0);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'E') {
			sumE[i + 1] = sumE[i] + 1;
		}
		else {
			sumE[i + 1] = sumE[i];
		}
	}

	int ans = 1e9;
	for (int i = 0; i < n+1; i++) {
		ans = min(ans, (sumW[i] + sumE[n] - sumE[i]) );
		
	}
	cout << ans << endl;
	return 0;
}

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

#define M (L+R>>1)
#define kl (k<<1)
#define kr (k<<1|1)
using namespace std;

int H, W, T[1 << 19], p[1 << 19];

void push_down(int k, int d) {
    if (p[k]) {
        p[kl] = p[k];
        p[kr] = p[k] + d;
        p[k] = 0;
    }
}

void maintain(int k, int L, int R) {
    if (L < R)
        T[k] = min(T[kl], T[kr]);
    if (p[k])
        T[k] = p[k];
}

void modify(int k, int L, int R, int l, int r, int t) {
    if (l <= L && R <= r) {
        p[k] = t + L - l;
        T[k] = p[k];
        return;
    }
    push_down(k, M + 1 - L);
    if (l <= M)
        modify(kl, L, M, l, r, t);
    else
        maintain(kl, L, M);
    if (r > M)
        modify(kr, M + 1, R, l, r, t);
    else
        maintain(kr, M + 1, R);
    maintain(k, L, R);
}

int query(int k, int L, int R, int pos) {
    if (L == R) {
        maintain(k, L, R);
        return T[k];
    }
    push_down(k, M + 1 - L);
    int val;
    if (pos <= M) {
        val = query(kl, L, M, pos);
        maintain(kr, M + 1, R);
    } else {
        val = query(kr, M + 1, R, pos);
        maintain(kl, L, M);
    }
    maintain(k, L, R);
    return val;
}

int main() {
    scanf("%d%d", &H, &W);
    for (int i = 1, l, r; i <= H; i++) {
        scanf("%d%d", &l, &r);
        int t = l == 1 ? 1E9 : query(1, 1, W, l - 1) + 1;
        modify(1, 1, W, l, r, t);
        if (T[1] < 1E9)
            printf("%d\n", T[1] + i);
        else
            puts("-1");
    }
    return 0;
}

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

using namespace std;

int main() {
    multiset<int> mst;

    int q;
    cin >> q;
    while (q--) {
        int op, x;
        cin >> op >> x;

        switch (op) {
            case 0:
                mst.insert(x);
                cout << mst.size() << endl;
                break;
            case 1:
                cout << mst.count(x) << endl;
                break;
            case 2:
                mst.erase(x);
                break;
            case 3:
                int r;
                cin >> r;
                for (auto itr = mst.lower_bound(x); itr != mst.end() and *itr <= r; ++itr) {
                    cout << *itr << endl;
                }
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 12272
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int table[26];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin>>s;
    vector<char> st;
    REP(i,s.size()){
        if(s[i]=='B' && !st.empty()) st.pop_back();
        else if(s[i]=='0' || s[i]=='1') st.push_back(s[i]);
    }
    REP(i,st.size()) cout << st[i];
    cout << endl;
    return 0;
}

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

using namespace std;


int main() {

	int N, M;
	cin >> N >> M;
	
	vector<int> AA(N);
	
	for(int i = 0; i < N; i++){
		cin >> AA[i];
	}
	
	make_heap(AA.begin(), AA.end());
	
	int MP;
	for(int i = 0; i < M; i++){
		MP = AA.front();
		MP = MP/2;
		pop_heap(AA.begin(), AA.end());
		AA.pop_back();
		AA.push_back(MP);
		push_heap(AA.begin(), AA.end());
	}
	
	long long sum = 0;
	for(int i = 0; i < N; i++){
		sum += AA[i];
	}
	
	cout << sum << endl;

	return 0;
	
}


/*

for(int i = 0; i < N; i++){
	
}

for(int i = 0; i < N; i++){
	for(int j = 0; j < N; j++){
		
	}
}


*/


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

int main()
{
	int a[6];
	for(int i=1; i<=5; i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+5);
	for(int i=1; i<=4; i++)
	{
		if(a[i]+1!=a[i+1])
		{
			cout<<a[i]+1;
			break;
		}	
	}
	
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define rt "\n"

int main(){
	int n;
	cin >> n;
	vint a(n, 0);
	double ans = 0;
	rep(i, n) {
		cin >> a[i];
		ans += 1/(double)a[i];
	}
	cout << 1 / ans << endl;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, substring, erase, push_back,stoll、stoi

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

using namespace std;

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

#define ff first
#define ss second

const int maxn = 1e5+10;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin >> a >> b;
	if(a<=9 && b<=9)
		cout << a*b << '\n';
	else
		cout << -1 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main(){
	ll n;
	scanf("%lld",&n);
	ll sum=0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++ )
		{
			for(ll k=1;k<=n;k++){
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,k,c=0,num;
    string s;
    cin>>s;
    cin>>n;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='1')
            c++;
        else if(s[i]!='1')
        {
            k=i;
            break;
        }
    }
    if(c==s.size())
        cout<<"1"<<endl;
    else if(c>=n)
        cout<<"1"<<endl;
    else
        cout<<s[k]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n,x,y;
    cin>>n>>x>>y;
    x--; y--;
    vector<ll> ans(n,0);
    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n;j++){
            ll dis;
            if(j<=x || y<=i){
                dis=j-i;
            }else if(i<=x && j>=x && j<=y){
                dis=x-i+min(j-x,1+y-j);
            }else if(i>=x && i<=y && j>=x && j<=y){
                dis=min(j-i,y-j+1+i-x);
            }else if(i<=x && j>=y){
                dis=x-i+j-y+1;
            }else{
               dis=j-y+min(y-i,1+i-x);
            }
            ans[dis-1]++;
            //cout<<i<<j<<dis<<endl;
        }
    }
    for(ll i=0;i<n-1;i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll power(ll p,ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
int main()
{
ll k,x,i;
cin>>k>>x;
for(i=(x-k)+1;i<(x+k);i++)
cout<<i<<" ";
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    long N, M;
    long s = 0;

    scanf("%ld", &N);
    M = N;
    while (M > 0) {
        s += (M % 10);
        M /= 10;
    }

    if (N % s == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

class Dice //クラスのメンバの宣言はデフォルトでprivate
{
    int top;    //1
    int front;  //2
    int right;  //3
    int left;   //4
    int back;   //5
    int bottom; //6
public:
    void diceroll(char dir);
    Dice(int top, int front, int right, int left, int back, int bottom);
    void place_front(int q2);
    void if_top(int q1);
    void place_top(int q1);
    int show_right();
    bool is_same_dice(Dice d);
};

void Dice ::diceroll(char dir)
{
    int tmp;
    switch (dir)
    {
    case 'E':
    {
        tmp = top;
        top = left;
        left = bottom;
        bottom = right;
        right = tmp;
        break;
    }
    case 'N':
    {
        tmp = top;
        top = front;
        front = bottom;
        bottom = back;
        back = tmp;
        break;
    }
    case 'S':
    {
        tmp = top;
        top = back;
        back = bottom;
        bottom = front;
        front = tmp;
        break;
    }
    case 'W':
    {
        tmp = top;
        top = right;
        right = bottom;
        bottom = left;
        left = tmp;
        break;
    }
    }
}

Dice ::Dice(int top, int front, int right, int left, int back, int bottom)
{
    this->top = top;
    this->front = front;
    this->right = right;
    this->left = left;
    this->back = back;
    this->bottom = bottom;
}

void Dice ::place_front(int q2)
{
    char direction[] = "NENEN";
    int i = 0;
    while (top != q2)
    {
        diceroll(direction[i]);
        i++;
        if (i == 5)
        {
            break;
        }
    }
    diceroll('S');
}

void Dice ::place_top(int q1)
{
    int i = 0;
    while (top != q1)
    {
        diceroll('W');
        i++;
        if (i == 3)
        {
            break;
        }
    }
}

void Dice ::if_top(int q1)
{
    if (top != q1)
    {
        place_top(q1);
    }
}

bool Dice ::is_same_dice(Dice d)
{
    place_front(d.front);
    if (d.front != this->front) //サイコロが1周しても違う数字ならfalse
    {
        return false;
    }
    place_top(d.top);
    if (d.top != this->top)
    {
        return false;
    }
    if (d.right == this->right && d.left == this->left && d.back == this->back && d.bottom == this->bottom)
    {
        return true;
    }
    return false;
}

bool loop(vector<Dice> d, int count)
{
    int i, j;
    for (i = 0; i < count; i++)
    {
        for (j = 1; j < count - i; j++)
        {
            if (d[i].is_same_dice(d[i + j])) //d[i]とd[i]より添え字が大きい全てのdを比較
            {
                return false;
            }
        }
    }

    return true;
}

int main(void)
{
    vector<Dice> d;
    int count, i;
    int top, front, right, left, back, bottom;
    cin >> count;

    for (i = 0; i < count; i++)
    {
        cin >> top >> front >> right >> left >> back >> bottom;
        d.push_back(Dice(top, front, right, left, back, bottom));
    }

    if (loop(d, count))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3108
#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 ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

vvl memo(205, vl(205, -1));

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
long long gcd_using_memo(long long a, long long b) {
	if (a > b) swap(a, b);
	if (memo[a][b] != -1) return memo[a][b];
	return memo[a][b] = gcd(a, b);
}

void Main() {
	int K; cin >> K;
	ll res = 0;
	FOR(i,1,K+1) FOR(j,1,K+1) FOR(k,1,K+1) {
		res += gcd_using_memo(gcd_using_memo(i, j), k);
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 4012
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.ArrayInt(5);

            var ans = 0;
            foreach (var time in a)
            {
                ans += time;
                if (time % 10 != 0)
                {
                    ans += 10 - time % 10;
                }
            }
            if (a.Select(x => x % 10).Any(x => x != 0))
            {
                var min = a.Select(x => x % 10).Where(x => x != 0).Min();
                ans -= 10 - min;
            }
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
    long long  N, W;
    vector <long long> w(101), v(101);
    vector < vector <long long > > dp(101, vector <long long> (100001, 0));        cin >> N >> W;
        for (int i=1; i<=N; i++){
                cin >> w[i];
                cin >> v[i];
        }
        for (int i=1; i<=N; i++){
            for (int j=1; j<=W; j++){
                if (j<w[i]){dp[i][j] = dp[i-1][j];}
                else{
                    dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
                }
            }
        }
    
    
        cout << dp[N][W] << "\n";

    return 0;
}


Measured memory_bytes: 83052
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll h,w;
char a[105][105];
int32_t main(){
CODE_START;
cin>>h;
cin>>w;
for(ll i=1;i<=h;i++)
    for(ll j=1;j<=w;j++)
    cin>>a[i][j];
for(ll i=1;i<=2*h;i++){
for(ll j=1;j<=w;j++)
cout<<a[(i+1)/2][j];
cout<<endl;
}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
const int maxn = 3009;
string s, t;
int dp[maxn][maxn];
 
int main () {
    cio();
    cin>>s>>t;
    int n = size(s), m = size(t);
    s = '0' + s;
    t = '0' + t;
    FORN(i, 1, n) {
        FORN(j, 1, m) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if ( s[i] == t[j] ) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
        }
    }
    string ans = "";
    int i = n, j = m;
    while ( i >= 1 && j >= 1 ) {
        if ( s[i] == t[j] &&  dp[i][j] == dp[i-1][j-1] + 1 ) {
            if ( i == 1 ) ans += s[i];
            else if ( j == 1 ) ans += t[j];
            else ans += s[i];
 
            i = i - 1;
            j = j - 1;
        }
        else if ( dp[i][j] == dp[i][j-1] ) {
            j = j - 1;
        }
        else {
            i = i - 1;
        }
    }
    reverse(all(ans));
    cout<<ans<<endl;
}

Measured memory_bytes: 38816
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main() {
  auto n = readln.chomp.to!int;
  auto s = readln.chomp.split.map!(to!int).array;
  auto q = readln.chomp.to!int;
  auto t = readln.chomp.split.map!(to!int).array;

  auto c = 0;

  foreach (e_t; t) {
    foreach (e_s; s) {
      if (e_t == e_s) {
	c++;
	break;
      }
    }
  }

  c.writeln;
}

Measured memory_bytes: 1236
#include<stdio.h>
int main(void) {
	int  p, q, r;
	int temp = 0;
	scanf("%d %d %d", &p, &q, &r);
	
	if (p > q) {
		temp = p;
		p = q;
		q = temp;
	}
	if (q > r) {
		temp = q;
		q = r;
		r = temp;
	}
	printf("%d", p + q);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
int N;
string S,T;

int main(){
    ios_base::sync_with_stdio(false);
    cin >> N >> S >> T;

    int ans=S.size()+T.size();
    for(int i=N-T.size(); i<S.size(); i++){
        bool ok=true;
        for(int j=i; j<S.size(); j++){
            if(S[j] != T[j-i]) ok=false;
        }
        if(ok){
            ans = i+T.size();
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
def factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(n ** 0.5)):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            arr.append(cnt)
    if tmp != 1:
        arr.append(1)

    if not arr:
        arr.append(1)

    return arr


def main():
    n = int(input())
    if n == 1:
        print(0)
    else:
        arr = factorization(n)
        cnt = 0
        for e in arr:
            if 1 <= e < 3:
                cnt += 1
            elif 3 <= e < 6:
                cnt += 2
            elif 6 <= e < 10:
                cnt += 3
            elif 10 <= e < 15:
                cnt += 4
            elif 15 <= e < 21:
                cnt += 5
            elif 21 <= e < 28:
                cnt += 6
            elif 28 <= e < 36:
                cnt += 7
            elif 36 < e:
                cnt += 8
        print(cnt)


if __name__ == '__main__':
    main()

    

Measured memory_bytes: 9488
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

n = int(input())

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[n-1])


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n; cin >> n;
  int mi = 1e9 + 7, ii;
  rep(i, n) {
    int a, b; cin >> a >> b;
    if (mi > b) mi = b, ii = a;
  }
  cout << ii + mi << '\n';
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

int main(){
    int k;
    cin >> k;
    int res = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = i; j <= k; ++j) {
            for (int l = j; l <= k; ++l) {
                int g = gcd(gcd(i, j), l);
                if(i == j && j == l){
                    res += g;
                }
                else if(i != j && j != l){
                    res += 6 * g;
                }
                else{
                    res += 3 * g;
                }
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
def main():
  #points = [[False for i in range(5001)] for j in range(5001)]
  while True:
    n = int(input())
    if not n:
      break
    ps = []
    dic = {}

    for i in range(n):
      x, y = map(int,input().split())
      dic[(x, y)] = 1;
      #points[x][y] = True
      ps.append((x,y))
  
    ans = 0
  
    for i in range(n):
      for j in range(n):
        p1 = ps[i]
        p2 = ps[j]
        vx = p2[0] - p1[0]
        vy = p2[1] - p1[1]
        #if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000:
        #  if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:
        if (p1[0] + vy, p1[1] - vx) in dic and (p2[0] + vy, p2[1] - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    
    #for p in ps:
    #  points[p[0]][p[1]] = False

    print(ans)
main()  





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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int count = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      if (x == v[i]) {
        count++;
      }
    } else if (x >= v[i]) {
      x -= v[i];
      count++;
    } else {
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int num = 0;
        int count = 0;
        if(b==1) {
            System.out.println(0);
            System.exit(0);
        }
        while(num<b) {
            if(count == 0) {
                num += a;
            } else {
                num += a;
                num -= 1;
            }
            count++;
        }
        System.out.println(count);     
    }
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 1000010;

int n, m;
int cnt, head[MAXN], data[MAXN << 1], nxt[MAXN << 1], sta[MAXN];
int fa[MAXN];
bool is[MAXN];

int find(int x)
{
	int tmp = x, pre;
	while (tmp != fa[tmp]) tmp = fa[tmp];
	while (x != tmp) pre = fa[x], fa[x] = tmp, x = pre;
	return tmp;
}

void merge(int x, int y)
{
	fa[find(x)] =find(y);
}

void dfs(int now, int tmp)
{
	sta[now] = tmp;
	for (int i = head[now]; i != -1; i = nxt[i]) {
		if (!sta[data[i]]) dfs(data[i], tmp == 1 ? 2 : 1);
		else if (sta[data[i]] == sta[now]) is[find(now)] = true;
	}
}

void add(int x, int y)
{
	nxt[cnt] = head[x]; data[cnt] = y; head[x] = cnt++;
	nxt[cnt] = head[y]; data[cnt] = x; head[y] = cnt++;
}

int sz1, szj, szo, sz[MAXN];

int main()
{
	memset(head, -1, sizeof head);
	
	in(n); in(m);
	FOR(i, 1, n) fa[i] = i;

	FOR(i, 1, m) {
		int u, v; in(u); in(v); add(u, v); merge(u, v);
	}

	FOR(i, 1, n) if (!sta[i]) dfs(i, 1);

	FOR(i, 1, n) sz[find(i)]++;

	int sum = 0;
	
	FOR(i, 1, n) if (find(i) == i) {
		sum += sz[i];
		if (is[i]) szj++;
		else if (sz[i] == 1) sz1++;
		else szo++;
	}

	LL ans = 0;
	ans += 1ll * sz1 * (sum - sz1) * 2 + 1ll * sz1 * sz1;
	ans += 1ll * szj * szo * 2 + 1ll * szj * szj;
	ans += 1ll * szo * szo * 2;

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 19328
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    x = list(map(int, rl().split()))
    
    for i in range(5):
        if x[i] == 0:
            print(i + 1)
            return


if __name__ == '__main__':
    solve()


Measured memory_bytes: 8996
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair



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

	int n, k, p, ans;
	scanf("%d%d", &n, &k);
	k--;
	printf("%d\n", (n - 1 + k - 1) / k);
	return 0;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if (x == 1) p = i;
	}
	ans = 0;
	k--;
	ans += (p + k - 1) / k;
	ans += (n - p - 1 + k - 1) / k;
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        s: String,
        t: String, 
    }
    let mut cnt = 0;
    let sv = s.chars().collect::<Vec<char>>();
    let tv = t.chars().collect::<Vec<char>>();

    for i in 0..s.len() {
        if sv[i] != tv[i] {
            cnt += 1;
        }
    }
    println!("{}",cnt);
}


Measured memory_bytes: 4444
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i = a; i < b; i++)
#define all(a) a.begin(),a.end()
using ll = long long;
using namespace std;

int N, i;
int main() {
    cin>>N;
    vector<int> a; a.resize(N);
    forn(i, 0, N) scanf("%i", &a[i]); 
    sort(all(a), greater<int>());

    int n = a[0];

    int res = INT_MAX;
    int found = a[0];
    forn(i,0,N) {
	int hf = n/2;
	int diff =  abs(n-a[i] -hf);
	if(diff <= res) {
	    res = diff;
	    found = a[i];
	}
    }

    cout << n << " " << found << endl;

    
}

Measured memory_bytes: 640