akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n);
  rep(i,n) cin >> a[i];

  bool flag[1000000];
  memset(flag, false, sizeof(flag));

  rep(i,5){
    // i+1文字繋げたとき
    ll cnt = 0;
    rep(j,i+1) {
      cnt *= 10;
      cnt += a[j];
    }
    // if(i == 2)cout << cnt << endl;
    flag[cnt] = true;
    FOR(j,i+1,n){
      // if(i == 2) cout << cnt << endl;
      cnt %= (int)pow(10,i);
      // if(i == 2) cout << cnt << endl;
      cnt *= 10;
      // if(i == 2) cout << cnt << endl;
      cnt += a[j];
      // if(i == 2) cout << cnt << endl;
      flag[cnt] = true;
    }
  }

  rep(i,10000){
    if(flag[i] == false){
      cout << i << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W,N;
  cin>>H>>W>>N;
  
  if(H>=W){
    int x;
    while(H*x<N){
      x=x+1;
    }
    cout<<x<<endl;
  }
    
    else{
    int x;
    while(W*x<N){
      x=x+1;
    }
    cout<<x<<endl;
    }
}

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

int main (){
  string str;
  int n,J=0,O=0,I=0,JOI=0,IOI=0,JO=0;
  cin>>n;
  cin>>str;
  for(int i=0;i<n;i++){
    if(str[i]=='J') J++;
    else if(str[i]=='I'){
      I++;
      if(J && JO) JOI++,J--,JO--,O--;
      else if(I && O) O--,IOI++;
    }
    else if(J+I-IOI>O){
      O++;
      if(J>JO) JO++;
    }
  }
  
  cout<< JOI+ min( (I-JOI)/2,IOI)<<endl;
  return 0;
}

Measured memory_bytes: 2068
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n;
	cin >> n;
	int ans = 1;
	while(ans * 2 <= n){
		ans *= 2;
	}
	cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
int main()
{
    std::string S;
    std::cin >> S;
    long counter=3;
    for(long i=0; i<S.length(); i++){
        if(S[i]!=S[S.length()-i-1]){
            counter-=1;
            break;
        }
    }

    for(long i=0; i<(S.length()-1)/2; i++){
        if(S[i]!=S[(S.length()-1)/2-i-1]){
            counter-=1;
            break;
        }
    }

    for(long i=(S.length()+3)/2-1; i<S.length(); i++){
        if(S[i]!=S[S.length()-i-1]){
            counter-=1;
            break;
        }
    }
    if(counter==3){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<stack>
#include<array>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<numeric>
#include<random>
#include<functional>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
using namespace std;




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

	int a, b;
	cin >> a >> b;
	if (0 < a) {
		cout << "Positive" << endl;
		return 0;
	}
	if (a * b <= 0) {
		cout << "Zero" << endl;
		return 0;
	}
	cout << ((abs(a - b) % 2) ? "Positive" : "Negative") << endl;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            ans++;
        }
    }
    cout << ans << endl;
}


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


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

	int n, m;
	ll k;
  	cin>>n>>m>>k;

  	vector<ll> a(n), b(m), p1(n), p2(m);

  	for(int i = 0; i < n; i++) {
  		cin>>a[i];
  		if(i == 0) p1[i] = a[i];
  		else p1[i] = p1[i - 1] + a[i];
  	}
  	
  	for(int i = 0; i < m; i++) {
  		cin>>b[i];
  		if(i == 0) p2[i] = b[i];
  		else p2[i] = p2[i - 1] + b[i];
  	}

  	int ans1 = -1;
  	auto at = upper_bound(p1.begin(), p1.end(), k);
  	if(at == p1.end()) {
  		ans1 = n;
  	} else ans1 = at - p1.begin();
  	
  	int ans2 = -1;
  	auto bt = upper_bound(p2.begin(), p2.end(), k);
  	if(bt == p2.end()) {
  		ans2 = m;
  	} else ans2 = bt - p2.begin();
  	
  	int ans3 = -1;
  	for(int i = 0; i < p1.size(); i++) {
  		if(k - p1[i] < 0) break;
  		auto ct = upper_bound(p2.begin(), p2.end(), k - p1[i]);
  		if(ct == p2.end()) ans3 = max(ans3, i + m + 1);
  		else{
  			int x = ct - p2.begin();
  			ans3 = max(ans3, i + x + 1);
  		}
  	}

  	int ans4 = -1;
  	for(int i = 0; i < p2.size(); i++) {
  		if(k - p2[i] < 0) break;
  		auto dt = upper_bound(p1.begin(), p1.end(), k - p2[i]);
  		if(dt == p1.end()) ans4 = max(ans4, i + n + 1);
  		else { 
  			int x = dt - p1.begin();
  			ans4 = max(ans4, i + x + 1);
  		}
  	}

  	cout<<max(ans1, max(ans2, max(ans3, ans4)))<<endl;
}

Measured memory_bytes: 9588
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def __det(matrix):
    return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]

def __sqdist(p1,p2):
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5

n = int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
    det = __det([[(x2-x1),(y2-y1)],[(x3-x1),(y3-y1)]])
    c1 = (x2**2-x1**2+y2**2-y1**2)/2
    c2 = (x3**2-x1**2+y3**2-y1**2)/2
    px = __det([[c1,(y2-y1)],[c2,(y3-y1)]])/det
    py = __det([[(x2-x1),c1],[(x3-x1),c2]])/det
    r = __sqdist([x1,y1],[px,py])
    print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)

Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, x, k, ans;
int p[100];

bool search(int num) {
    bool res = false;
    rep(0, n) {
        if (p[i] == num) res = true;
    }
    return res;
}

int main() {
    scanf(" %d %d", &x, &n);
    rep(0,n) scanf(" %d", &p[i]);
    if (!search(x)) {
        printf("%d\n", x);
        exit(0);
    }
    int minus = x - 1;
    int plus = x + 1;
    while (true) {
        if (!search(minus)) {
            printf("%d\n", minus);
            exit(0);
        } else if (!search(plus)) {
            printf("%d\n", plus);
            exit(0);
        }
        minus--; plus++;
    }
}

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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

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

    ll _lcm = lcm(c, d);
    ll cc   = b / c - a / c;
    if (a % c == 0) {
        cc++;
    }
    ll cd = b / d - a / d;
    if (a % d == 0) {
        cd++;
    }
    ll ccd = b / _lcm - a / _lcm;
    if (a % _lcm == 0) {
        ccd++;
    }
    ll len = b - a + 1;

    printf("%lld\n", len - (cc + cd - ccd));

    return 0;
}


Measured memory_bytes: 256
x,n=map(int,input().split())
a=sorted(list(map(int,input().split())))
if n==0:
  print(x)
  exit()
else:
  for i in range(100):
    aa=x-i
    if aa not in a:
      print(aa)
      exit()
    bb=x+i
    if bb not in a:
      print(bb)
      exit()

Measured memory_bytes: 9136
#include <iostream>
#include <algorithm>
#include <utility>
#include <limits>

#define phb push_back
#define mkp make_pair
#define frs first
#define scn second
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef pair< int, int > Pr;
typedef pair< int, Pr > Prr;
const int kInf = numeric_limits< int >::max() / 2;

int N, M;
vector< Prr > E;

int nset[110];

void read();
void solve();

int find_set(int x) {
  if (~nset[x])
    return nset[x] = find_set(nset[x]);
  return x;
}

void union_set(int x, int y) {
  nset[find_set(y)] = find_set(x);
}

int main() {
  while (cin >> N >> M, N != 0)
    read(), solve();

  return 0;
}

void read() {
  int u, v, c;

  E.clear();
  for (int i = 0; i < M; ++i) {
    cin >> u >> v >> c;
    E.phb(mkp(c, mkp(u, v)));
  }
}

void solve() {
  int res = kInf;

  stable_sort(all(E));
  for (int ei = 0; ei < sz(E); ++ei) {
    fill(&nset[0], &nset[110], -1);

    int i = ei, j = 0, t = 0, u, v;
    while (i < sz(E) && j < N - 1) {
      u = E[i].scn.frs, v = E[i].scn.scn;
      if (find_set(u) != find_set(v))
        union_set(u, v), ++j, t = E[i].frs;
      ++i;
    }

    if (j == N - 1)
      res = min(res, t - E[ei].frs);
  }

  cout << (res < kInf ? res : -1) << "\n";
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using qi=queue<int>;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,u,v;
  cin>>n>>m;
  vvi g(n);
  vi a(n),b(n);
  for(int i=0;i<m;i++){
    cin>>u>>v;
    u--;v--;
    g[u].push_back(v);
    a[v]++;
  }
  qi q;
  for(int i=0;i<n;i++)
    if(!a[i])
      q.push(i);
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(int v:g[u]){
      b[v]=max(b[v],1+b[u]);
      a[v]--;
      if(!a[v])
        q.push(v);
    }
  }
  int c=0;
  for(int i=0;i<n;i++)c=max(c,b[i]);
  cout<<c<<"\n";
}


Measured memory_bytes: 6528
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		long factorial = 1;
		for(int i = 1; i <= N; i++) {
			factorial = factorial * i % 1000000007;
		}
		System.out.println(factorial);
	}
}

Measured memory_bytes: 21844
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    ans = INF
    for a in range(1,N//2+1):
        b = N-a
        res = 0
        for i in str(a):
            res += int(i)
        for i in str(b):
            res += int(i)
        ans = min(ans, res)
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 9068
#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>;
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; }
const ll INF = 1LL << 60;

int main() {

    vector<int> vec;

    int P,Q,R;

    cin >> P >> Q >> R;

    vec.emplace_back(P);
    vec.emplace_back(Q);
    vec.emplace_back(R);

    sort(vec.begin(),vec.end());

    cout << vec[0]+vec[1] << endl;

}

Measured memory_bytes: 3632
#include<cstdio>
int myf(int x){
    if(x<0) x = -x;
    return x;
}

int main(){
    int a,v,b,w,t;
    scanf("%d %d %d %d %d", &a, &v, &b, &w, &t);
    int dis = myf(a-b);
    int fas = v-w;
    if(fas<=0) printf("NO");
    else{
        int T = (dis-1)/fas;
        if(T<t) printf("YES");
        else printf("NO");
    }
    return 0;
}

Measured memory_bytes: 1732
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	char S[12];

	scanf("%s", S);
	int len = strlen(S);

	int ngflg = 0;
	int cnt = 0;
	int i,z;

	if (S[0] != 'A') {
		ngflg = 1;
	}
	for (i = 2; i < strlen(S) - 1; i++) {
		if (S[i] == 'C') {
			if (cnt == 0) {
				z = i;
			}
			cnt++;
		}
	}
	if (cnt != 1) {
		ngflg = 1;
	}
	if (cnt == 1 && ngflg == 0) {
		for (int j = 1; j < strlen(S); j++) {
			if (j != z) {
				if (S[j] < 'a'|| S[j] > 'z') {
					ngflg = 1;
					break;
				}
			}
		}
	}
		if (ngflg == 0) { puts("AC"); }
		else { puts("WA"); }



#ifdef DEBUGF
		getch();
#endif
		return 0;
	}


Measured memory_bytes: 128
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;
main() {
  file("threesum");
  ios;
  cin >> s;
  if (s[2] == s[3] and s[4] == s[5]) return !(cout << "Yes");
  cout << "No";
  return 0;
}
/**

*/


Measured memory_bytes: 256
import sys
N,M=map(int,input().split(' '))
if M>0:
  As=set(map(int,sys.stdin))
else:
  As=set()

d=[0]*(N+1)
d[0]=1
if 1 in As:
  pass
else:
  d[1]=1

for i in range(2,N+1):
  if i in As:
    continue
  else:
    d[i]=(d[i-1]+d[i-2])%1000000007

print(d[-1])


Measured memory_bytes: 11884
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long i=0; i<n; ++i) { cout<<a[i]; if(i!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> vl;
typedef vector<vector<long long> > vll;
typedef vector<P> vp;
typedef vector<vector<P> > vpp;

int main() {
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	if(n<=m/2) {
		cout<<n+(m-2*n)/4<<endl;
	} else {
		cout<<m/2<<endl;
	}
}


Measured memory_bytes: 256
// 2011/05/23 Tazoe

#include <iostream>
#include <string>
#include <sstream>
#include <map>
using namespace std;

int main()
{
	map<int, int> teams;

	int rnk[31];
	for(int i=0; i<=30; i++)
		rnk[i] = 0;

	while(true){
		string str;
		getline(cin, str);

		for(int i=0; i<str.size(); i++)
			if(str[i]==',')
				str[i] = ' ';

		istringstream ist(str);
		int n, c;
		ist >> n >> c;
		if(n==0&&c==0)
			break;

		teams.insert( map<int, int>::value_type( n, c ) );
		rnk[c] = 1;
	}

	for(int i=29; i>=0; i--)
		rnk[i] += rnk[i+1];

	while(!cin.eof()){
		string str;
		getline(cin, str);
		if(str.empty())
			continue;

		istringstream ist(str);
		int n;
		ist >> n;

		cout << rnk[teams[n]] << endl;
	}

	return 0;
}

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

int main() {
    // 入力
    int a,b,c;
    cin >> a>>b>>c;
    printf("%d %d %d",c,a,b);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,k,s;
    cin >> n >> k >> s;
    vi v(n,0);
    if(s == INF){
        rep(i,n){
            if(i<k)v[i] = s;
            else v[i] = 1;
        }
    }else{
        rep(i,n){
            if(i<k)v[i] = s;
            else v[i] = INF;
        }
    }
    rep(i,n)cout << v[i] << " ";
    cout << endl;
}


Measured memory_bytes: 2176
import java.util.*;
class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if(N%10 == 3)
		{
			System.out.println("bon");
		}
		
		else if(N%10 == 0 || N%10 == 1 || N%10 ==  6 || N%10 == 8)
		{
			System.out.println("pon");
		}
		else
		{
			System.out.println("hon");
		}
	}
}


Measured memory_bytes: 35740
N, K = map(int, input().split())
D = list(map(int, input().split()))

for i in range(N, 10 * N + 1):
  A = list(map(int, str(i)))
  flag = 1
  for a in A:
    if a in D:
      flag = 0
      break
  if flag:
    print(i)
    exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N,M;
  cin>>N>>M;
  int a[N];
  int susum = 0;
  for(int i = 0;i<N;i++){
    cin>>a[i];
    susum += a[i];
  }
  if(susum%(4*M) == 0){
    susum /= (4*M);
    int ans = 0;
    for(int i = 0;i<N;i++){
      if(a[i]>=susum){
        ans++;
      }
    }
    if(ans>=M){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    susum /= (4*M);
    int ans = 0;
    for(int i = 0;i<N;i++){
      if(a[i]>susum){
        ans++;
      }
    }
    if(ans>=M){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007
using LL = long long;

LL sumNM(LL n, LL m) {
  return (n+m)*(m-n+1)/2;
}

int main()
{
  int N, K; cin >> N >> K;
  LL ans = 0;
  FOR(i, K, N+2) {
    ans = (ans + sumNM(N-i+1, N) - sumNM(0, i-1) + 1) % MOD;
  }
  cout << ans;
}

Measured memory_bytes: 3572
N=int(input())
L=list(map(int,input().split()))
count=0
while(1):
	K=max(L)
	if max(L)<N:
		print(count)
		exit()
	else:
		tmp=0
		#print(max(L))
		M=K//N
		count+=M
		for i in range(N):
			if L[i]==K and tmp==0:
				#print(i)
				tmp=1
				L[i]=K%N
			else:
				L[i]+=M
		#print(L)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::string s; std::cin >> s;
    if (s == "ABC") std::cout << "ARC" << std::endl;
    else std::cout << "ABC" << std::endl;
    return 0;
}



Measured memory_bytes: 3568
#include <iostream>
using namespace std;
long long max(long long x,long long y){
	if(x>y){
		return x;
	}else{
		return y;
	}
}

long long min(long long x,long long y){
	if(x<y){
		return x;
	}else{
		return y;
	}
}

int main(){
	int H,W;
//	int choco_1,choco_2,choco_3;
	cin >> H >> W;
	int answer=10000000;
	
	long long A_H=0,B_H,C_H;
	long long A_W,B_W,C_W;
	long long  S_A,S_B,S_C;
	while(true){
		A_H++;
		B_H=(H-A_H)/2;//40491
		C_H=(H-A_H)-B_H;//40492
		if(H-A_H==1){
			break;
		}
		S_A=A_H*W;
		S_B=B_H*W;
		S_C=C_H*W;
		answer=min(answer,max(S_A,max(S_B,S_C))-min(S_A,min(S_B,S_C)));
		if(answer<0){
			cout << A_H << endl;
			cout << 1<< endl;
			return 0;
		}
	}
	A_H=0;
	while(true){
		A_H++;
		if(H-A_H==0){
			break;
		}
		B_W=W/2;
		C_W=W-B_W;
		if(B_W<=0||C_W<=0){
			break;
		}
		S_A=A_H*W;
		S_B=(H-A_H)*B_W;
		S_C=(H-A_H)*C_W;
		answer=min(answer,max(S_A,max(S_B,S_C))-min(S_A,min(S_B,S_C)));
		if(answer<0){
			cout << A_H << endl;
			cout << 2<< endl;
			return 0;
		}
	}
	
	int memo=H;
	H=W;
	W=memo;
	A_H=0;
	
	while(true){
		A_H++;
		B_H=(H-A_H)/2;
		C_H=(H-A_H)-B_H;
		if(H-A_H==1){
			break;
		}
		S_A=A_H*W;
		S_B=B_H*W;
		S_C=C_H*W;
		answer=min(answer,max(S_A,max(S_B,S_C))-min(S_A,min(S_B,S_C)));
		if(answer<0){
			cout << A_H << endl;
			cout << 3<< endl;
			return 0;
		}
	}
	A_H=0;
	while(true){
		A_H++;
		if(H-A_H==0){
			break;
		}
		B_W=W/2;
		C_W=W-B_W;
		if(B_W<=0||C_W<=0){
			break;
		}
		S_A=A_H*W;
		S_B=(H-A_H)*B_W;
		S_C=(H-A_H)*C_W;
		answer=min(answer,max(S_A,max(S_B,S_C))-min(S_A,min(S_B,S_C)));
		if(answer<0){
			cout << A_H << endl;
			cout << 4<< endl;
			return 0;
		}
	}
	
	/*
	if(Max%3==0||Min%3==0){
		cout << 0 << endl;
		return 0;
	}else if(Max%3==2){
		choco_1=(Max/3+1)*Min;
		Max-=Max/3+1;
	}else{
		choco_1=(Max/3)*Min;
		Max-=Max/3;
	}
	
	if(Max%2==0||Min%2==0){
		choco_2=(Max*Min)/2;
	}else{
		int a,b;
		a=Max/2*Min;
		b=Max*Min-a;
		if(max(a,max(b,choco_max))==a){
			choco_min=
		}
	}
	
	choco_2=Max*(Min/2);
	choco_3=Max*Min-choco_2;
	
	
	if(choco_min>=choco_max){
		choco_min=Max*Min-choco_min;
	}
	cout << abs(max(choco_1,max(choco_2,choco_3))-min(choco_1,min(choco_2,choco_3))) << endl;
	*/
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;
#define Yes(ifeq) cout<<(( ifeq )? "Yes":"No")<<endl;

void Main(){
  ll k;
  cin>>k;

  v(set<string>) a(11);

  rep(i,9)
    a[1].insert(to_string(i+1));
  int cnt = 9;
  vl count(11,0);
  count[1] = 9;

  int keta = 2;
  while(cnt <= k){
    for(auto aa:a[keta-1]){
      if(aa.back()=='0'){
        a[keta].insert(aa+"0");
        a[keta].insert(aa+"1");
        cnt+=2;
      }else if(aa.back()=='9'){
        a[keta].insert(aa+"8");
        a[keta].insert(aa+"9");
        cnt+=2;
      }else{
        char c = aa.back();
        a[keta].insert(aa+string(1,c+1));
        a[keta].insert(aa+string(1,c  ));
        a[keta].insert(aa+string(1,c-1));
        cnt+=3;
      }
    }
    count[keta] = cnt;
    keta++;
  }
  keta--;

  k-=count[keta-1]+1;
  cout<<*next(a[keta].begin(),k)<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 19072
import math
def calculateKyori(x1, y1, x2, y2):
    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

if __name__ == '__main__':
    x1, y1, x2, y2 = map(float, input().split())
    n = calculateKyori(x1, y1, x2, y2)
    print('{0:.8f}'.format(n)) 


Measured memory_bytes: 5664
using System;
using System.Text;

public class Test
{
	static public void Main( )
	{
		StringBuilder output = new StringBuilder();
		int[] nml = Array.ConvertAll( Console.ReadLine().Split( ' ' ), int.Parse );
		int n = nml[0];
		int m = nml[1];
		int l = nml[2];
		
		Int64[,] C = new Int64[ n, l ];
		Int64[,] A = new Int64[ n, m ];
		Int64[,] B = new Int64[ m, l ];
		for( var i=0; i<n; i++ ) {
			Int64[] row = Array.ConvertAll( Console.ReadLine().Split( ' ' ), Int64.Parse );
			for( int j=0; j<m; j++ ) {
				A[ i, j ] = row[j];
			}
		}
		for( var i=0; i<m; i++ ) {
			Int64[] row = Array.ConvertAll( Console.ReadLine().Split( ' ' ), Int64.Parse );
			for( int j=0; j<l; j++ ) {
				B[ i, j ] = row[j];
			}
		}		
		for( var i=0; i<n; i++ ) {
			for( int j=0; j<l; j++ ) {
				for( int k=0; k<m; k++ ) {
					C[ i, j ] += A[ i, k ]*B[ k, j ];
				}
				output.Append( C[i,j].ToString() );
				output.Append( ( l-1 != j)?" ":"\n");
			}
		}
		
		Console.Write( output );
	}
}

Measured memory_bytes: 10640
#include<bits/stdc++.h>
using namespace std;
char tab[105];
char tab2[105];
bool czy;
int main()
{

    int p,i,j;
    char wynik1='{',wynik2='{';
    string s,t;
    cin>>s>>t;

    for(int i=0;i<s.size();i++)
    {
        tab[i]=s[i];
    }
    for(int j=0;j<t.size();j++)
    {
        tab2[j]=t[j];
    }
    sort(tab,tab +s.size());
    sort(tab2,tab2+t.size());
    reverse(tab2,tab2+t.size());


        for(int i=0;i<s.size()+1;i++)
        {
            if(tab[i]<tab2[i])
            {
                cout<<"Yes";
                czy=true;
                break;
            }
            if(tab2[i]<tab[i])
            {
                czy=false;
                break;
            }

        }
        if(czy==false)cout<<"No";

    /*
    if(s.size()<t.size())
    {
        for(int i=0;i<t.size();i++)
        {
            if(tab2[])
        }
    }
    */


    /*
    //tab[i+1][1]='{';
    //tab[i+1][2]='{';
    for(int i=0;i<s.size();i++)
    {
            for(int j=0;j<s.size();j++)
            {
                if(tab[i][1]<wynik1)wynik1=tab[i][1];
            }
            tab2[i][1]=wynik1;
    }
    for(int i=0;i<s.size();i++)cout<<tab2[i][1];
        */



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vc = vector<char>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    vc S(N+1);
    for(int i=1; i<N+1; i++){
        cin >> S[i];
    }
    if(C<D){
        bool m = true;
        for(int i=A+1; i<D-1; i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                m = false;
            }
        }
        if(m == true){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else{
        bool m = true;
        for(int i=A+1; i<C-1; i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                m = false;
            }
        }
        bool n = false;
        for(int i=B-1; i<D; i++){
            if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
                n = true;
            }
        }
        if(m==true&&n==true){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }
}

Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<f64>();
    let (a, b, x) = (v[0], v[1], v[2]);
    let theta = ((a * a * b - x) / a / a / a * 2.0).atan();
    let mut ans = theta * 360. / 2. / std::f64::consts::PI;
    if x < a * a * b / 2. {
        let theta = (2. * x / a / b / b).atan();
        ans = 90.0 - theta * 360. / 2. / std::f64::consts::PI;
    }
    // debug!(ans);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
//using mint = modint998244353;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #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){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;

template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

/*-----------------------------------------------------------------------------------------------------*/

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k; cin >> k;
  rep(i,k) cout << "ACL";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 200005;
const ll MOD = 998244353;


ll n;
pii pt[MAXN];
vector<ll> xval, yval;
ll ans;

ll mpow (ll ep, ll bs) {
    ll ret = 1;
    while (ep) {
        if (ep & 1) {
            ret = ret * bs % MOD;
        }
        bs = bs * bs % MOD;
        ep >>= 1;
    }
    return ret;
}

ll bit[MAXN];

void add (ll x) {
    for (x++; x<MAXN; x+=-x&x) {
        bit[x]++;
    }
}

ll qry (ll x) {
    ll ret = 0;
    for (x++; x>0; x-=-x&x) {
        ret += bit[x];
    }
    return ret;
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    REP (i, n) {
        cin >> pt[i].first >> pt[i].second;
        xval.emplace_back(pt[i].first);
        yval.emplace_back(pt[i].second);
    }

    {
        sort(xval.begin(), xval.end());
        sort(yval.begin(), yval.end());
        xval.resize(unique(xval.begin(), xval.end())-xval.begin());
        yval.resize(unique(yval.begin(), yval.end())-yval.begin());
    }

    REP (i, n) {
        pt[i].first = lower_bound(xval.begin(),xval.end(), pt[i].first)-xval.begin();
        pt[i].second = lower_bound(yval.begin(),yval.end(), pt[i].second)-yval.begin();
    }

    sort(pt, pt+n);

    ll total = mpow(n, 2);
    REP (i, n) {
    debug(i);
        int l = pt[i].first;
        int r = n - pt[i].first - 1;
        int u = n - pt[i].second - 1;
        int d = pt[i].second;

        int ld = qry(pt[i].second);
        int lu = l -ld;
        int rd = d - ld;
        int ru = r - rd;
        debug(l, u, r, d, lu, ld, ru, rd);
        assert(l >= 0);
        assert(r >= 0);
        assert(u >= 0);
        assert(d >= 0);
        assert(lu >= 0);
        assert(ld >= 0);
        assert(ru >= 0);
        assert(rd >= 0);

        ll cur = 0;
        cur -= (1 + mpow(l, 2) + mpow(r, 2) + mpow(u, 2) + mpow(d, 2));
        cur %= MOD;
        cur += (total + mpow(ld, 2) + mpow(lu, 2) + mpow(ru, 2) + mpow(rd, 2));
        cur %= MOD;
        if (cur < 0) {
            cur += MOD;
        }

        add(pt[i].second);

        ans = (ans + cur) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 8292
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    long long sum;
    if(a + b > 2 * c)
    {
        sum = min(x,y) * 2 * c;
        if(abs(x - y) * (x > y ? a : b) > abs(x - y) * 2 * c)
        {
            cout << max(x,y) * 2 * c << endl;
        }
        else
        {
            cout << sum + abs(x - y) * (x > y ? a : b) << endl;
        }
        
    }
    else
    {
        cout << a * x + b * y << endl; 
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a ??? b ????????°????????§?¢???????
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b ??\??????????°???´??°
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		int n, r;
		cin>>n>>r;
		vector<ll> card(n);
		REP(i, n) {
			card[i] = n - i;
		}
		if(n==0&&r==0) return 0;
		REP(i, r) {
			int p, c;
			cin>>p>>c;
			vector<ll> hoge(p - 1);
			REP(i, p - 1) hoge[i] = card[i];
			REP(i, c) card[i] = card[p - 1 + i];
			REP(i, p - 1) card[c + i] = hoge[i];
		}
		cout<<card[0]<<endl;
	}
}

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

using namespace std;

int dfs(int u, int t, int k, vector<vector<int>> &g, vector<map<int, int>> &cap, vector<int> &vis, int id) {
    if (u == t) {
        return k;
    }
    vis[u] = id;
    for (int v : g[u]) {
        if (vis[v] != id && cap[u][v] >= k) {
            int add = dfs(v, t, k, g, cap, vis, id);
            if (add == k) {
                cap[u][v] -= k;
                cap[v][u] += k;
                return add;
            }
        }
    }
    return 0;
}
int augment(int s, int t, int k, vector<vector<int>> &g, vector<map<int, int>> &cap) {
    int cur = 0;
    int add = 1, it = 0;
    int n = g.size();
    vector<int> vis(n, 0);
    while (add) {
        add = dfs(s, t, k, g, cap, vis, ++it);
        cur += add;
    }
    return cur;
}
int maxflow(int s, int t, vector<vector<int>> &g, vector<map<int, int>> &cap) {
    int flow = 0;
    for (int k = 1; k > 0; k >>= 1) {
        flow += augment(s, t, k, g, cap);
    }
    return flow;
}
void add_edge(int u, int v, vector<vector<int>> &g, vector<map<int, int>> &cap) {
    g[u].push_back(v);
    g[v].push_back(u);
    cap[u][v] += 1;
    cap[v][u] += 1;
}

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    vector<map<int, int>> cap(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        add_edge(a - 1, b - 1, g, cap);
    }
    
    vector<int> cnt4;
    int cnt6 = 0;
    bool ok = true;
    for (int u = 0; ok && u < N; ++u) {
        if (g[u].size() >= 4U) {
            cnt4.push_back(u);
        }
        cnt6 += (g[u].size() >= 6U);
        if (g[u].size() % 2 != 0) {
            ok = false;
        }
    }
    if (ok && cnt4.size() == 2U) {
        int flow = maxflow(cnt4[0], cnt4[1], g, cap);
        if (flow > 2) {
            ok = false;
        }
    }
    cout << ((ok && (cnt4.size() >= 2U || cnt6 >= 1)) ? "Yes" : "No") << "\n";
    

    return 0;
}

Measured memory_bytes: 23296
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int arith_sum1(long long int,long long int,long long int);
long long int arith_sum2(long long int,long long int,long long int);
long long int series_sum(long long int);

int main(){
    ll k,a,b,ans;
    cin>>k>>a>>b;
    if(b<=a+2){
        cout<<k+1<<endl;
        return 0;
    }else{
        k-=a-1;
        ans=a;
        if(k%2==1){
            k--;
            ans+=1;
        }
        ans+=k*(b-a)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#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>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// int main() {
//     int n;
//     cin>>n;
//     vector<int>p(n);
//     vector<int>q(n);
//     for(int i=0;i<n;i++){
//         cin>>p.at(i);
//         q.at(i)=p.at(i);
//     }
//     sort(q.begin(),q.end());
//     int ans=0;
//     for(int i=0;i<n;i++){
//         if(q.at(i)!=p.at(i)){
//             ans++;
//         }
//     }
//     if(ans==0 || ans==2){
//         cout<<"YES"<<endl;
//     }
//     else{
//         cout<<"NO"<<endl;
//     }





//     return 0;
// }
int main(){
  int n,tem,p[51], ans=0;
  bool flg=true;
  cin>>n;
  for (int i = 0; i < n; i++) {
    cin>>p[i];
  }

  for(int k=0; k<n; k++){
    // cout<<p[k]<<" ";
    if(p[k]!=k+1) flg=false;
  }
  if(flg){
    ans=1;
    cout<<"YES"<<endl;
    return 0;
  }


  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      tem=p[j];
      p[j]=p[i];
      p[i] =tem;
      flg=true;
      for(int k=0; k<n; k++){
        // cout<<p[k]<<" ";
        if(p[k]!=k+1) flg=false;
      }
      if(flg){
        ans=1;
        // cout<<"YES"<<endl;
      }
      // else cout<<"NO"<<endl;
      tem=p[j];
      p[j]=p[i];
      p[i] =tem;
    }
  }
cout<<((ans==1)?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func resolve(x, y int) string {
	if x == 1 {
		if y == 2 || y == 4 {
			return "Yes"
		} else {
			return "No"
		}
	}

	if x*4 < y {
		return "No"
	}

	if (y-2*x)%2 != 0 || (4*x-y)%2 != 0 {
		return "No"
	}

	if (y-2*x)/2 < 0 || (4*x-y)/2 < 0 {
		return "No"
	}

	return "Yes"
}

func main() {
	x, y := scanInt(), scanInt()

	fmt.Println(resolve(x, y))
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
int f[10001][101][2];
char a[10001];
int main()
{
	f[0][0][1]=1;
	int i,j,l;
	int n,D;
	scanf("%s",a);
	scanf("%d",&D);
	n=strlen(a);
	for(i=0;i<n;i++)
    	{
		for(j=0;j<D;j++)
		{
			for(l=0;l<=9;l++)
				f[i+1][(j+l)%D][0]=(f[i+1][(j+l)%D][0]+f[i][j][0])%1000000007;
			for(l=0;l<=a[i]-'0';l++)
				if(l==a[i]-'0')
					f[i+1][(j+l)%D][1]=(f[i+1][(j+l)%D][1]+f[i][j][1])%1000000007;
				else
					f[i+1][(j+l)%D][0]=(f[i+1][(j+l)%D][0]+f[i][j][1])%1000000007;
		}
      	}
	printf("%d",(f[n][0][1]+f[n][0][0]+1000000006)%1000000007);
}

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

int main(){
    int N, D; cin >> N >> D;

    if(N % (2*D+1) == 0){
        cout << (N/(2*D+1)) << endl;  
    }

    else{
    cout << (N/(2*D+1)) + 1 << endl;
    }
     
}

Measured memory_bytes: 256
# 重み付きUnion-Findデータ構造
class WeightedUnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.weights = [0] * numV

    def find(self, x):
        if self.pars[x] == x:
            return x
        else:
            parXOld = self.pars[x]
            self.pars[x] = self.find(parXOld)
            self.weights[x] += self.weights[parXOld]
            return self.pars[x]

    def union(self, x, y, wt):
        wtX = self.getWeight(x)
        wtY = self.getWeight(y)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return wtY == wtX+wt
        wt += wtX - wtY
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.weights[x] = -wt
        else:
            self.pars[y] = x
            self.weights[y] = wt
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def getWeight(self, x):
        self.find(x)
        return self.weights[x]

    def getDiff(self, x, y):
        if self.find(x) == self.find(y):
            return self.getWeight(y) - self.getWeight(x)
        else:
            return float('inf')


N, M = map(int, input().split())

WUF = WeightedUnionFind(N)
ans = 'Yes'
for _ in range(M):
    L, R, D = map(int, input().split())
    if not WUF.union(L-1, R-1, D):
        ans = 'No'

print(ans)


Measured memory_bytes: 10612