akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(void) {
    int A, B; cin >>A >> B;
    int count = 0;
    //cout << "XXXXX" << endl;
    for(int i=1;i<10;i++) {
        int candi=i*10000 + i * 1000+i*100+i*10+i;
        //cout << candi << endl;
        if(A <= candi and candi <= B) {
            //cout << candi << "dayo" << endl;
            count += 1;
        }
    }
    //cout << "XXYXX" << endl;
    for(int i=1;i<10;i++) {
        for (int j=0;j<10;j++){
            if (i != j){
                int candi = i*10000 + i * 1000+j*100+i*10+i;
                //cout << candi << endl;
                if(A <= candi and candi <= B) {
                    //cout << candi << "dayo" << endl;
                    count += 1;
                }
            }
        }
    }
    //cout << "XYYYX" << endl;
    for(int i=1;i<10;i++) {
        for (int j=0;j<10;j++){
            if (i != j){
                int candi = i*10000 + j * 1000+j*100+j*10+i;
                //cout << candi << endl;
                if(A <= candi and candi <= B) {
                    //cout << candi << "dayo" << endl;
                    count += 1;
                }
            }
        }
    }
    //cout << "XZYZX" << endl;
    for(int i=1;i<10;i++) {
        for (int j=0;j<10;j++){
            for(int k=0; k<10;k++){
                if (i != j and k != j and k !=i){
                    int candi = i*10000 + k * 1000+j*100+k*10+i;
                    //cout << candi << endl;
                    if(A <= candi and candi <= B) {
                        //cout << candi << "dayo" << endl;
                        count += 1;
                    }
                }
            }
        }
    }
    //cout << "XYXYX" << endl;
    for(int i=1;i<10;i++) {
        for (int j=0;j<10;j++){
            if (i != j){
                int candi = i*10000 + j * 1000+i*100+j*10+i;
                //cout << candi << endl;
                if(A <= candi and candi <= B) {
                    //cout << candi << "dayo" << endl;
                    count += 1;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int cnt1=0,cnt2=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==0)cnt2++;
    if(a%2==1)cnt1++;
  }
  int ans=1;
  if(cnt1%2==1)ans=0;
  cnt2+=cnt1/2;
  cout<<(ans? "YES":"NO")<<endl;
  return 0;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

typedef struct quad{
    int a, b, c, d;
}qua;

int main()
{
    boost;
    ll tt = 1, n, m, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, a, b, c, d;

    bool poss = true;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        string s, t;
        cin >> s >> t;
        n = sz(s);

        for(i = 0; i < n; i++){
            if(s[i] != t[i]){
                poss = false;
                break;
            }
        }
        
        if(poss){
            cout << "Yes" << nl;
        }
        else cout << "No" << nl;

    }   
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

const int INF = 1e8;
char B[100][100];
int dist[100][100];
int H, W;

// void dfs(int y, int x, int cost) {
//    // if (dist[y][x] == INF) {
//    //    dist[y][x] = cost;
//    // } else {
//    //    if (dist[y][x] < cost) {
//    //       return;
//    //    } else {
//    //       dist[y][x] = cost;
//    //    }
//    // }

//    rep (i, 4) {
//       int ny = y+dy[i], nx = x+dx[i];
//       if (ny<0 || ny >= H || nx<0 || nx>=W || B[ny][nx]=='#') continue;
//       dfs(ny, nx, cost+1);
//    }
// }

void dfs(int y, int x, ll turn) {
   if (turn >= dist[y][x]) {
      return;
   } else {
      dist[y][x] = turn;
   }

   for (int i = 0; i < 4; i++) {
      int ny = y+dy[i], nx = x+dx[i];
      if (ny<0 || ny>=H || nx<0 || nx>=W) continue;
      if (B[ny][nx] == '#') continue;
      dfs(ny, nx, turn+1);
   }
}

int main() {
   rep (i, 99) {
      rep (j, 99) {
         dist[i][j] = INF;
      }
   }

   cin >> H >> W;
   int black = 0;
   rep (i, H) {
      rep (j, W) {
         cin >> B[i][j];
         if (B[i][j] == '#') black++;
      }
   }

   dfs(0, 0, 0);

   if (dist[H-1][W-1] != INF) {
      cout << max(0, H*W - black - dist[H-1][W-1] -1) << endl;
   } else {
      cout << -1 << endl;
   }

   return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
 
#define Endl endl
 
 
/*--------------------template--------------------*/
 
int main()
{
	vi v(4);
	REP(i, 4)
	{
		cin >> v[i];
	}
	cin >> n;
	ll a, b, c;
	a = v[0] * 4;
	b = v[1] * 2;
	c = v[2];
	ll one = min(min(a, b), c);
	ll two;
	if (one * 2 > v[3]) {
		two = v[3];
	} else {
		two = one * 2;
	}
	if (n % 2 == 0) {
		ans = n / 2 * two;
	} else {
		ans = n / 2 * two + one;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100001)
#define MOD (1000000007)


typedef struct
{
    int root;
    int size;
}UFnode;

//Union Find
void UFinit(UFnode* uf,int n)
{
    for(int i=0;i<n;i++)
    {
        uf[i].root = i;
        uf[i].size = 1;
    }
}

int UFroot(UFnode* uf,int i)
{
    if(uf[i].root==i) return i;
    uf[i].root = UFroot(uf,uf[i].root);
    return uf[i].root;
}

// 元々根が同じならfalse 違うなら統合してtrue
bool UFunite(UFnode* uf,int i,int j)
{
    int ri = UFroot(uf,i);
    int rj = UFroot(uf,j);

    if(ri == rj) return false;
    uf[ri].size += uf[rj].size;
    uf[rj].root = ri;
    return true;
}

typedef struct
{
    int x;
    int y;
    int id;
}point;

int acs_x(const void *a, const void *b){return ((point*)a)->x - ((point*)b)->x;} /* 1,2,3,4.. */
int acs_y(const void *a, const void *b){return ((point*)a)->y - ((point*)b)->y;} /* 1,2,3,4.. */

point ps[MAXN];
point pss[MAXN];

UFnode ufp[MAXN];
UFnode ufx[MAXN];
UFnode ufy[MAXN];

int main(void)
{
    ll n;
    scanf("%ld",&n);

    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        ps[i].x=x;
        ps[i].y=y;
        ps[i].id=i;
        pss[i] = ps[i];
    }
    UFinit(ufp,n);
    UFinit(ufx,MAXN);
    UFinit(ufy,MAXN);

    qsort(pss,n,sizeof(point),acs_x);
    for(int i=1;i<n;i++)
    {
        if(pss[i].x == pss[i-1].x)
        {
            UFunite(ufp, pss[i-1].id,pss[i].id);
            UFunite(ufx, ps[pss[i-1].id].x, ps[pss[i].id].x);
            UFunite(ufy, ps[pss[i-1].id].y, ps[pss[i].id].y);
        }
    }
    qsort(pss,n,sizeof(point),acs_y);
    for(int i=1;i<n;i++)
    {
        if(pss[i].y == pss[i-1].y)
        {
            UFunite(ufp, pss[i-1].id,pss[i].id);
            UFunite(ufx, ps[pss[i-1].id].x, ps[pss[i].id].x);
            UFunite(ufy, ps[pss[i-1].id].y, ps[pss[i].id].y);
        }
    }

    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(i==UFroot(ufp,i))
        {
            int rx = UFroot(ufx,ps[i].x);
            int ry = UFroot(ufy,ps[i].y);
            ans += (ll)ufx[rx].size * (ll)ufy[ry].size - ufp[i].size;
        }
    }


    printf("%ld\n",ans);
    return 0;
}



Measured memory_bytes: 6012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			if (n == 0 && x == 0) {
				break;
			}

			int count = 0;
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) count++;
					}
				}
			}
			System.out.println(count);
		}
		sc.close();
	}
}


Measured memory_bytes: 26752
#include <stdio.h>

int main(){
    int d;
    scanf("%d",&d);
    if(d==22) printf("Christmas Eve Eve Eve\n");
    else if(d==23) printf("Christmas Eve Eve\n");
    else if(d==24) printf("Christmas Eve\n");
    else if(d==25) printf("Christmas\n");
    return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    string s;
    cin>>n>>s;
    set<string>d1,d2,d3;
    for(int i=0;i<n;i++){
        for(auto x:d2)
            d3.insert(x+s[i]);
        for(auto x:d1)
            d2.insert(x+s[i]);
        d1.insert(string{s[i]});
    }
    cout<<d3.size()<<endl;
}


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

int main(){
  int n, q, count = 0;
  int S[10000], T[500];

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

  //T??????????????????????????????????????????S????????¨??????????¢????
  for(int i = 0; i < q; i++){
    //T[i] == S[j] ????????????S?????????????¢????????????¢??¢?´¢???
    for(int j = 0; j < n; j++){
      if(T[i] == S[j]){
        count++;
        break;
      }
    }
  }

  cout << count << endl;
  return 0;
}

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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque…双方向リスト
//stack…FILO, 深さ優先探索
//queue…FIFO, 幅優先探索
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

const int mod = 1e9+7;

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}
template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}
template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}

using Graph = vector<vector<int>>;

template <class T, class S>
class Edge {
  T to;  //辺の行き先
  S weight;  //辺の重み

public:
  Edge(T t, S w) : to(t), weight(w) {}
};

int ansi = 0;
ll ansl = 0;
double ansd = 0.0;

int accumul(int mul) {
  if (mul == 0) {
    return 1;
  } else {
    return mul * accumul(mul-1);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> p, c;
  rep(i, 0, n-1) {
    int x;
    cin >> x;
    p.push_back(x);
    c.push_back(x);
  }
  sort(c.begin(), c.end());

  int cont = 0;
  rep(i, 0, n-1) {
    if (p[i] != c[i])
      cont++;
  }

  cout << (cont == 2 || !cont ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    a, b = map(int, input().split())
    # a^2 -2ak+k^2 = b^2-2bk+k^2
    # 2k(a-b) = a^2-b^2
    # 2k=a+b
    # k = a+b/2
    k = (a + b) / 2
    if k.is_integer():
        print(int(k))
    else:
        print('IMPOSSIBLE')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

	int n,s;
	int a, b, c;
	int i;

	while (1){

		scanf("%d", &n);
		if (n == 0){
			break;
		}

		for ( i = 0; i < n; i++){
			scanf("%d %d %d", &a, &b, &c);

			a = a*a;
			b = b*b;
			c = c*c;

			if (a== (b+c) || b == (c + a) || c == (a + b)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}

		break;
	}

	return 0;
}

Measured memory_bytes: 580
N, K = map(int, input().split())
l = list(map(int, input().split()))

is_zero = l.count(0)
K -= is_zero

if K:
    ans = float('inf')
    for i in range(N-K+1):
        lb, rb = l[i], l[i+K-1]
        steps = abs(rb-lb) + min(abs(rb), abs(lb))
        ans = min(ans, steps)

    print(ans)
else:
    print(0)

Measured memory_bytes: 15020
//標準解答
#include<cstdio>
#include<cctype>

int main(){
  char ch;
    
  while (1) {
    scanf ("%c", &ch);
      if ( isalpha(ch) ){
          if ( islower(ch) ) printf("%c", toupper(ch));
          else printf("%c", tolower(ch));
      }else printf("%c", ch);
    
      if ( ch == '\n' ) break;
  }
    
  return 0;
}


Measured memory_bytes: 2700
N,K=map(int,input().split())
p=list(map(int,input().split()))
su=[0]
for i in range(N):
    p[i]=((p[i]+1)/2)
    su.append(su[i]+p[i])
ans=0
for i in range(K,N+1):
    ans=max(ans,su[i]-su[i-K])
print(ans)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> t(n),a(n);
    rep(i,n) cin>>t[i]>>a[i];
    ll n1=1,n2=1;
    rep(i,n){
      ll x=max((n1+t[i]-1)/t[i],(n2+a[i]-1)/a[i]);
      n1=t[i]*x,n2=a[i]*x;
      //cout<<n1<<' '<<n2<<endl;
    }
    cout<<n1+n2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

#define fs first
#define sc second

int main(){
	int w,h;
	while(cin>>w>>h,w){
		vector<vvi> f(2,vvi(h+2,vi(w+2,1)));
		pair<pii,pii> curr;
		pair<pii,pii> stat;
		for(int i=1;i<=h;i++){
			rep(p,2){
				for(int j=1;j<=w;j++){
					char c; cin>>c;
					if(c=='.'){
						f[p][i][j]=0;
					}else if(c=='%'){
						f[p][i][j]=0;
						if(p==0){
							stat.first={i,j};
						}else{
							stat.second={i,w+1-j};
						}
					}else if(c=='L'){
						f[p][i][j]=0;
						curr.first={i,j};
					}else if(c=='R'){
						f[p][i][j]=0;
						curr.second={i,w+1-j};
					}
				}
			}
			reverse(all(f[1][i]));
		}
		//putii(f[0],"");
		//cout<<endl;
		//putii(f[1],"");
		//cout<<"======="<<endl;
		
		/*幅優先
			・どちらか片方だけ動き、動いた先がゴールでない場合
			・両方動き、かつ少なくともどちらかがそのマスを訪れたことがない場合
			だけ、探索する
		*/
		set<pair<pii,pii>> isVisited;

		queue<pair<pii,pii>> que;
		que.push(curr);
		int y[]={-1,0,1,0};
		int x[]={0,1,0,-1};
		auto step=[f](pii &pos,int lr, int y, int x){
			if(f[lr][pos.fs+y][pos.sc+x]!=1){
				pos.fs+=y;
				pos.sc+=x;
				return true;
			}
			return false;
		};
		bool ok=false;
		while(!que.empty()){
			auto c=que.front();
			que.pop();
			//cout<<c[0][0]<<","<<c[0][1]<<"  "<<c[1][0]<<","<<c[1][1]<<endl;
			if(isVisited.find(c)!=isVisited.end()){
				continue;
			}
			isVisited.insert(c);
			rep(v,4){
				auto next=c;
				bool l=step(next.fs,0,y[v],x[v]);
				bool r=step(next.sc,1,y[v],x[v]);
				if(next==stat){
					ok=true;
					goto fin;
				}

				if(isVisited.find(next)==isVisited.end()){
					if( (!l and r and next.sc!=stat.sc)
						or (l and !r and next.fs!=stat.fs)
						or ( l and r and (next.fs!=stat.fs and next.sc!=stat.sc) )){
						//cout<<" o "<<next[0][0]<<","<<next[0][1]<<"  "<<next[1][0]<<","<<next[1][1]<<endl;
						que.push(next);
					}else{
						//cout<<" x "<<next[0][0]<<","<<next[0][1]<<"  "<<next[1][0]<<","<<next[1][1]<<endl;
					}
				}
			}
		}
		fin:;
		if(ok){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 109324
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int e,d;
double m=10000;
double t=0;
double f;

int main(){
 while(true){
  cin>>d>>e;
  if(d==0&&e==0){
   break;
  }
  for(int i=0;i<d;i++){
    t=sqrt(pow(i,2)+pow(d-i,2));
    if(e>t){
     f=e-t;
    }else{
     f=t-e;
    }
    if(m>f){
     m=f;
    }
      
  }
  cout<<fixed<<setprecision(6)<<m<<endl;
  m=10000;
 }
}

Measured memory_bytes: 3280
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
n,a,b = LI()
ans = [min(a,b),max(0,a+b-n)]
print(ans[0],ans[1])
"""

#B
"""
n = II()
a = S()
b = S()
c = S()
ans = 0
for i in range(n):
    if a[i] == b[i]:
        if b[i] == c[i]:
            continue
        else:
            ans += 1
    else:
        if b[i] == c[i] or c[i] == a[i]:
            ans += 1
        else:
            ans += 2
print(ans)
"""

#C
n = II()
c = LIR(n)
c.sort(key = lambda x:-x[0]-x[1])
ans = 0
i = 0
for i in range(n):
    x,y = c.pop(0)
    if i%2 == 0:
        ans += x
    else:
        ans -= y
print(ans)

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

int main(){
  long long int n;
  cin >> n;
  
  vector<long long int> vec(n);
  
  for(int i = 0;i < n;i ++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  cout << vec.at(n / 2) - vec.at((n / 2) - 1) << endl;
}

Measured memory_bytes: 4032
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

lint par[200500]; //MAX_N
lint ufsize[200050]; //MAX_N

void init(lint x){
  rep(i,x) par[i]=i,ufsize[i]=1;
}

lint root(lint x){
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

bool same(lint x,lint y){
  return root(x)==root(y);
}

void unite(lint x,lint y){
  x=root(x);
  y=root(y);
  if(x==y) return;
  lint s=ufsize[x]+ufsize[y];
  ufsize[x]=s,ufsize[y]=s;
  par[x]=y;
}

lint size(lint x){
  return ufsize[root(x)];
}

int main(void){
    int N,M;
    cin >> N >> M;
    init(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        unite(a,b);
    }
    lint ans=-INF;
    rep(i,N) ans=max(ans,size(i));
    cout << ans << endl;
}

Measured memory_bytes: 12940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n; 
int f[51][51];
char a[60];
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
  	string s;
  	cin>>s;
	for(int j=0;j<s.size();j++)
	{
	   f[i][s[j]-'a'+1]++;
	} 
  }
  for(int i=1;i<=26;i++)
   {
    int minn=123;
	for(int j=1;j<=n;j++)
    {
    	minn=min(minn,f[j][i]);
    }
    if(minn!=0)
    {
    	for(int j=1;j<=minn;j++)
    	  cout<<char(i+96);
    }
   }
  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<int> vs(N); cin >> vs;
  map<int, int> m1, m2;
  rep(i, N / 2) {
    m1[vs[2 * i]]++;
    m2[vs[2 * i + 1]]++;
  }
  vector<pair<int, int>> v1, v2;
  for(auto e: m1) v1.emplace_back(e.second, e.first);
  for(auto e: m2) v2.emplace_back(e.second, e.first);
  sort(v1.rbegin(), v1.rend());
  sort(v2.rbegin(), v2.rend());

  vector<pair<int, int>> w1, w2;
  rep(i, min(2, (int)v1.size())) w1.emplace_back(v1[i].second, v1[i].first);
  rep(i, min(2, (int)v2.size())) w2.emplace_back(v2[i].second, v2[i].first);

  int ans = inf;
  for (auto e: w1) for (auto f: w2) {
    if (e.first == f.first) {
      ans = min(ans, N - max(e.second, f.second));
    }
    else {
      ans = min(ans, N - e.second - f.second);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6520
#include<iostream>
#include<algorithm>

using namespace std;

#define MAX 100005
#define NIL -1

struct Node {
  int p,r,l;
};

Node T[MAX];
int n,D[MAX],H[MAX];

int getSibling(int u);

void print(int u){
  int deg=0;
	if(T[u].r!=NIL){deg++;}
	if(T[u].l!=NIL){deg++;}
	
  cout << "node " << u << ": parent = " << T[u].p << ", sibling = " << getSibling(u) <<", degree = " << deg <<", depth = " << D[u] << ", height = " << H[u]<< ", " ;
  
  if(T[u].p==NIL)cout << "root";
  else if(T[u].l==NIL && T[u].r==NIL) cout << "leaf";
  else cout<<"internal node";
  cout << endl;
}

void setDepth(int u,int p){
  if(u==NIL)return ;
  D[u] = p;
  if(T[u].r != NIL)setDepth(T[u].r,p+1);
  if(T[u].l != NIL)setDepth(T[u].l,p+1);
}

int setHeight(int u){
	int h1=0,h2=0;
	if(T[u].r != NIL){
		h1 = setHeight(T[u].r)+1;
	}
	if(T[u].l != NIL){
		h2 = setHeight(T[u].l)+1;
	}
	
	return H[u]=max(h1,h2);
	
}

int getSibling(int u){
	if(T[u].p==NIL)return NIL;
	if(T[T[u].p].l!=u & T[T[u].p].r!=NIL)return T[T[u].p].l;
	if(T[T[u].p].r!=u & T[T[u].p].l!=NIL)return T[T[u].p].r;
	return NIL;
}

int main(){
  cin>>n;
  for(int i=0;i<n;++i){T[i].p = T[i].l = T[i].r = NIL;}
  
  int v,d,c,l,r;
  for(int i=0;i<n;++i){
    int id;
  	cin >> id;
  	
  	cin >> T[id].l >> T[id].r;
  	
  	
  	if(T[id].l!=NIL){T[T[id].l].p=id;}
  	if(T[id].r!=NIL){T[T[id].r].p=id;}
  }
  
  for(int i=0;i<n;++i){
    if(T[i].p==NIL)r=i;
  }
  
  setDepth(r,0);
setHeight(r);
  
  for(int i=0;i<n;++i)print(i);
  
  return 0;
}



Measured memory_bytes: 3120
# N  個のソースコードがあり、i 個目のソースコードの特徴は Ai1,Ai2,...,AiM の M 個の整数で表されます。
# また、整数 B1,B2,...,BM と 整数 C が与えられます。
# Ai1B1+Ai2B2+...+AiMBM+C>0 のときに限り、i 個目のソースコードはこの問題に正答するソースコードです。
# N 個のソースコードのうち、この問題に正答するソースコードの個数を求めてください。

nmc = gets.chomp.split
n = nmc[0].to_i
m = nmc[1].to_i
c = nmc[2].to_i

b = gets.chomp.split
m.times do |i|
    b[i] = b[i].to_i
end

a = []
n.times do
    input_a = gets.chomp.split
    m.times do |i|
        input_a[i] = input_a[i].to_i
    end
    a << input_a
end

correct_count = 0
n.times do |i|
    sum = 0
    m.times do |j|
        sum += a[i][j] * b[j]
    end
    sum += c
    correct_count += 1 if sum > 0
end

puts correct_count

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,a[100];
    cin>>n;
    int c=100000000;
    int d;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=a[0];i<=a[n-1];i++){
        d=0;
        for(int j=0;j<n;j++){
            d+=(a[j]-i)*(a[j]-i);
        }
        if(c>d)c=d;
    }
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,q;
  int i,j;
  int S[10000],T[10000];
  int awcount=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
 
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	awcount++;
	T[i]=-1;
      }
    }
  }
  
  printf("%d\n",awcount);

  return 0;
}
  

  



Measured memory_bytes: 2076
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;
int main(void){
    int x;
    int r;
    int count;
cin>>x;
    r=x;
    while(r<=500000){
        count=0;
for(int i=2;i<r;i++){
    if(r%i==0){
        count++;
    }
}
if(count==0){
    cout<<r<<endl;
    break;
}
r++;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,str,s1,s2,flag;
	char a[20];
	cin>>a;
	str=strlen(a);
	for(i=0;i<str;i++)
	{
		flag=0;
		s1=0;
		s2=0;
		if(a[i]=='0'||a[i]=='1')
		{
			flag=1;
			if(i==str-1)
		    {
		    	cout<<a[i];
		    	break;
		    }
			for(j=i+1;j<str;j++)
			{
				if(a[j]=='B')
				{
					s1++;
				}
				else 
				{
					s2++;
				} 
				if(s1>s2)
				{
					flag=0;
					break;
				}
			}	
		}
		if(flag==1)cout<<a[i];
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c, k;
  scanf("%d %d %d %d", &a, &b, &c, &k);
  
  if(k <= a){
    printf("%d", k);
  }
  else if(k <= a + b){
    printf("%d", a);
  }
  else if(k <= a + b + c){
    printf("%d", a - (k - (a + b)));
  }
  
  return 0;
}

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

w = {-1: 'W', 1: 'S'}
p = {1:'o', -1:'x'}

for tmp in [[1, 1], [-1, -1], [1, -1], [-1, 1]]:
    for i in range(1,n):
        tmp.append(tmp[i-1] if s[i] == p[tmp[i]] else (tmp[i-1] * -1))
    if tmp[0] == tmp[-1]:
        flag = 1 if s[0] == p[tmp[0]] else -1
        if tmp[-2] == tmp[1] * flag:
            tmp.pop()
            print(''.join(map(w.get, tmp)))
            break
else:
    print(-1)


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

#define UN unsigned
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define pb push_back
//~ #define x first
//~ #define y second
const int N = 2e5 + 5;


void solve(){
	int n;
	cin >> n;
	
	vector<int> a(4, 0);
	while(n--){
		string s;
		cin >> s;

		if(s[0] == char(65)) a[0]++;
		else if(s[0] == char('W')) a[1]++;
		else if(s[0] == char('T')) a[2]++;
		else a[3]++;
	}	

	cout << "AC x " << a[0] << endl;
	cout << "WA x " << a[1] << endl;
	cout << "TLE x " << a[2] << endl;
	cout << "RE x " << a[3] << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	// int T=0;
	// cin >> T;

	// while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  if (n >= 10) {
    cout << m << '\n';
  } else {
    cout << m + 100 * (10 - n) << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 892
#include<stdio.h>
int main()
{
	int n,i,s,m;
	scanf("%d",&n);
	m=n;
	s=0;
	while(n)
	{
		s+=n%10;
		n=n/10;
	}
	if(m%s==0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
ll gcd (ll a,ll b,ll c)
{
        return __gcd(gcd(a,b),c);
}
ll solve (ll n)
{
    ll sum = 0;
        for (int i=1;i<n+1;i++)
        {
            for (int j=1;j<n+1;j++)
            {
                for (int k=1;k<n+1;k++)
                {
                    sum += gcd(i,j,k);
                }
            }
        }
        return sum;
}
int main() {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        // Code Starts... 
        ll n;
        cin>>n;
        cout<<solve(n)<<endl;
        // Code Ends...
        return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 50

ll fib(int n);

ll dp[MAX];

int main(){
    int n; cin >> n;
    for(int i = 0; i < MAX; i++) dp[i] = -1;
    dp[0] = dp[1] = 1;
    cout << fib(n) << endl;
    return 0;
}

ll fib(int n){
    if(dp[n] != -1) return dp[n];

    dp[n] = fib(n-1) + fib(n-2);
    return dp[n];

}


Measured memory_bytes: 3096
n=int(input())
a=list(map(int,input().split()))

cnt1,cnt2=0,0
for i in a:
  if i%4==0:
    cnt1+=1
  elif i%2==0:
    cnt2+=1
if cnt2>0:
  tmp=n-cnt2+1
else:
  tmp=n
if cnt1>=tmp//2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
#include <stdio.h>
int main(){
    int n,k;
    int c,h;
    c=0;
    scanf("%d %d",&n,&k);
    while(n-->0){
        scanf("%d",&h);
        if(h>=k){
            ++c;
        }
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
LL so(LL x,LL y)
{
	if (x<=y) return y-x;
	return LLONG_MAX/3;
}
void solve(long long x, long long y){
	LL ans=min(so(x,y),min(so(-x,y)+1,min(so(x,-y)+1,so(-x,-y)+2)));
	cout<<ans<<endl;

}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long y;
	long long x;
	scanf("%lld",&x);
	scanf("%lld",&y);
	solve(x, y);
	return 0;
}



Measured memory_bytes: 256
"""
N = int(input())
A, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

N = int(input())
A = [int(i)-1 for i in input().split()]
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = sum(B)
for i in range(N-1):
  if A[i] + 1 == A[i+1]:
    ans += C[A[i]]
    #print(i, A[i], C[A[i]])
    
print(ans)

Measured memory_bytes: 3064
n = int(input())
a = list(map(lambda x:int(x),input().split()))
a.sort(reverse=True)
al = 0
bo = 0
if n==1:
  al = a[0]
else:
  for i in range(0,n,2):
    al += a[i]
  for i in range(1,n,2):
    bo += a[i]
print(al-bo)

Measured memory_bytes: 3060
N, *H = map(int, open(0).read().split())
pt = 0
ans = 0
while pt < N:
    cur = pt
    flag = 0
    while cur < N and H[cur]:
        H[cur] -= 1
        cur += 1
        flag = 1
    while pt < N and H[pt] == 0:
        pt += 1
    ans += flag
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void) {
    int n;
    unsigned int sum;
    cin >> n >> sum;

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i + j <= n) {
                unsigned int price = 10000 * i + 5000 * j + 1000 * (n - i - j);
                if (price == sum) {
                    cout << i << " " << j << " " << n - i - j << endl;
                    return 0;
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

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

int main(){
    int i, j;
    cin >> i >> j;
    
    int a[i][j], b[j], result[i] = {0};
    
    for(int x = 0; x < i; x++){
        for(int y = 0; y < j; y++){
            cin >> a[x][y];
        }
    }
    
    for(int x = 0; x < j; x++){
        cin >> b[x];
    }
    
    for(int x = 0; x < i; x++){
        for(int y = 0; y < j; y++){
            result[x] += a[x][y] * b[y];
        }
        cout << result[x] << endl;
    }
}


Measured memory_bytes: 3132
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i;
    cin>>n;
    for(i=0;i<n;i++)
        cout<<"ACL";
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[100];
int b[100];
vector<int> ans;
signed main(){
	int n;
	a[0] = b[0] = 1;
	a[1] = b[1] = -2;
	int tmp = 2;
	repi(i,2,40){
		tmp *= 2;
		if(i%2 == 0)a[i] = a[i-2]+tmp;
		else a[i] = a[i-2]-tmp;
		if(i%2 == 0)b[i] = tmp;
		else b[i] = -tmp;
	}
	//rep(i,10)printf("%lld ", a[i]);
	scanf("%lld", &n);
	
	tmp = n;
	int f = 0;
	drep(i,38,0){
		if(tmp == 0)f = 1;
		if(f){ans.pb(0);continue;}
		if(i%2 == 0 and tmp > 0){
			if(i-2 < 0){ans.pb(1);tmp -= b[i];continue;}
			if(tmp > a[i-2]){ans.pb(1);tmp -= b[i];continue;}
			else{ans.pb(0);continue;}
		}else if(i%2 == 1 and tmp < 0){
			if(i-2 < 0){ans.pb(1);tmp -= b[i];continue;}
			if(tmp < a[i-2]){ans.pb(1);tmp -= b[i];continue;}
			else{ans.pb(0);continue;}
		}else ans.pb(0);
	}
	
	
	int p = -1;
	rep(i,ans.size())if(ans[i] == 1){
		p = i;
		break;
	}
	if(p == -1){printf("0\n");return 0;}
	repi(i,p,ans.size())printf("%lld", ans[i]);
	printf("\n");
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[1];
int size=1;
int m=2;
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)

int main()
{
    fast;
  
   int x,n;
   cin>>x>>n;
   int arr[102];
   f(i,102)arr[i]=0;
   f(i,n){int a;cin>>a;arr[a]=1;}
   int cnt1=0,cnt2=0;
   if(arr[x]==0)
   {cout<<x;return 0;}
   else
   {
       for(int i=x-1;i>=0;i--)
       {   cnt1++;
           if(arr[i]==0)
               break;
       }
       for(int i=x+1;i<=101;i++)
       {
           cnt2++;
           if(arr[i]==0)
               break;
       }
       if(cnt1==cnt2)
           cout<<x-cnt1;
       else if(cnt1>cnt2)
           cout<<x+cnt2;
       else if(cnt1<cnt2)
           cout<<x-cnt1;
   }

}


Measured memory_bytes: 3604
N, Q = gets.split.map(&:to_i)
S = " " + gets.chomp

cums = Array.new(N+1, 0)
2.upto(N) do |i|
  cums[i] = cums[i-1]
  cums[i] += 1 if S[i-1, 2] == "AC"
end

Q.times do
  l, r = gets.split.map(&:to_i)
  res = cums[r] - cums[l-1]
  res -= 1 if S[l-1, 2] == "AC"
  puts(res)
end


Measured memory_bytes: 3452
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()
A.append(0)
Ans = []
keepcount = 0
count = 0
for i in A:
    if keepcount == 0:
        count = 1
        keepcount = i
    elif keepcount == i:
        count += 1
        keepcount = i
    else:
        keepcount = i
        Ans.append(count)
        count = 1


ans = 0
for i in range(len(Ans)):
    if Ans[i] % 2 == 0:
        Ans[i] == 0
    else:
        ans += 1

print(ans)

Measured memory_bytes: 8012
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Polynomial Construction
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_P = 2999;

/* typedef */

typedef long long ll;

/* global variables */

int bs[MAX_P], cs[MAX_P][MAX_P];

/* subroutines */

inline void addmod(int &a, int b, int mod) { a = (a + b) % mod; }

/* main */

int main() {
  int p;
  scanf("%d", &p);

  for (int i = 0; i < p; i++) {
    cs[i][0] = cs[i][i] = 1;
    for (int j = 1; j < i; j++)
      cs[i][j] = (cs[i - 1][j - 1] + cs[i - 1][j]) % p;
  }

  for (int i = 0; i < p; i++) {
    int ai;
    scanf("%d", &ai);
    if (ai) {
      addmod(bs[0], 1, p);
      for (int j = 0, s = -1, ei = 1; j < p; j++) {
	int d = (ll)cs[p - 1][j] * ei % p;
	addmod(bs[p - 1 - j], (s > 0) ? d : p - d, p);
	s = -s;
	ei = (ll)ei * i % p;
      }
    }
  }
  
  for (int i = 0; i < p; i++) {
    if (i) putchar(' ');
    printf("%d", bs[i]);
  }
  putchar('\n');
  return 0;
}


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

int main(){

	char str[201]={};
	char strc[201]={};
	char in[201]={};
	
	scanf("%s",str);
	scanf("%s",in);
	
	strcpy(strc, str);
	strcat(str, strc);
	
	if(strstr(str,in)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	

return 0;
}

Measured memory_bytes: 540
! 2019.12.22
!
      program answer
      implicit none
      integer :: N
      integer,allocatable,dimension(:) :: a
      integer,allocatable,dimension(:) :: coun
      integer :: i
      integer :: ans
      integer :: en_con
      integer :: num
!
      read(*,*) N
      allocate(a(N),coun(N))
      read(*,*) (a(i),i=1,N)
!initialization
      do i=1,N
        coun(i) = 0
      end do
!counting
      do i=1,N
        coun(a(i)) = coun(a(i))+1
      end do
!ans = -1 condition
      if(coun(1) == 0) then
        ans = -1
        goto 9999
      end if
!calculate end condition
      en_con=N
      do i=1,N
        if(coun(i) == 0) then
          en_con=i
          exit
        end if
      end do
!determine ans
      num=1
      i=0
      lp1:do 
        i=i+1
        lp2:do 
          if(num > N) exit lp1
          if(i > en_con) exit lp1
          if(a(num) == i) exit lp2
          num=num+1
        end do lp2
      end do lp1
      ans = N-(i-1)
!output
9999  write(*,*) ans
      end program answer

Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int main() {
    char c[2][3];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 3; j++)
            cin >> c[i][j];
    }

    bool f = true;

    for (int i = 0; i < 3; i++) {
        if (c[0][i] != c[1][2-i])
            f = false;
    }

    if (f)
        cout << "YES" << endl;
    else
    {
            cout << "NO" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
	fast;
	int x,n;
	cin>>x>>n;
	if(n==0)
		{
			cout<<x;
			return 0;
		}
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	set<int> s;
	for(int i=0;i<n;i++)
		s.insert(arr[i]);
	int size=s.size(),old,val1,val2;
	old=size;
	s.insert(x);
	size=s.size();
	if(old!=size)
		{
			cout<<x;
			return 0;
		}
	val1=x+1;
	val2=x-1;
	while(1){
		old=size;
		s.insert(val2);
		size=s.size();
		if(old==size)
		{
			val2--;
		}
		else
		{
			cout<<val2;
			return 0;
		}
		old=size;
		s.insert(val1);
		size=s.size();
		if(old==size)
		{
			val1++;
		}
				else
		{
			cout<<val1;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline void read(int& a){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

signed main(){
    int x=read();
    
    if(x>=400 && x<=599)
        writeln(8);
    if(x>=600 && x<=799)
        writeln(7);
    if(x>=800 && x<=999)
        writeln(6);
    if(x>=1000 && x<=1199)
        writeln(5);
    if(x>=1200 && x<=1399)
        writeln(4);
    if(x>=1400 && x<=1599)
        writeln(3);
    if(x>=1600 && x<=1799)
        writeln(2);
    if(x>=1800 && x<=1999)
        writeln(1);
        
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
char a[104];
int main(){
	int k;
	scanf("%d",&k);
	scanf("%s",a);
	int len=strlen(a);
	if(len<=k)printf("%s\n",a);
	else {
		a[k]='\0';
		printf("%s...\n",a);
	}
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    s = s + "#";
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != s[i + 1]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int k,q;
ll d[5001];
ll n,x,m;
ll a[5005];
ll md[5005];

int main(void){
	scanf("%d%d",&k,&q);
	for(int i=0;i<k;i++){
		scanf("%lld",&d[i]);
	}
	for(int i=0;i<q;i++){
		scanf("%lld%lld%lld",&n,&x,&m);
		a[0]=x%m;
		ll ans=n-1;
		ll sum=a[0];
		for(int j=0;j<k;j++){
			md[j]=d[j]%m;
			int pos=j+1;
			ll cnt=(n-pos+k-1)/k;
			//printf("cnt %lld\n",cnt);
			if(cnt<=0)continue;
			if(md[j]==0){	
				ans-=cnt;
			}
			sum+=(ll)md[j]*cnt;
		}
		ans-=sum/m;
		printf("%lld\n",ans);
	}
	return 0;
}


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

int main(){
  string N;
  cin>>N;

  for(int i=0;i<2;i++)
    if((N.at(i)==N.at(i+1))&&(N.at(i+1)==N.at(i+2))){
      cout<<"Yes";
      return 0;
    }
  cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int INT;
int n,k;
int main()
{
    cin>>n>>k;
    INT ans=0;
    vector<int> h(n);
    for (int i=0;i<n;++i){
        cin>>h.at(i);
    }
    if(n<=k){
        ans=0;
    }
    else{
        sort(h.begin(),h.end(),greater<int>());
        for (int i=0;i<k;i++){
            h.at(i)=0;
        }
        for (int i=0;i<n;i++){
            ans+=h.at(i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4036
d,g = map(int,input().split())
p = [0] * d
c = [0] * d
for i in range(d):
    p[i],c[i] = map(int,input().split())
#
s = [0] * (2**d)
n = [0] * (2**d)
m =[]
for j in range(2**d):
    for k in range(d):
        if 1 & (j>>k):
            s[j] += 100*(d - k)*p[d - k - 1] + c[d - k - 1]
            n[j] += p[d - k - 1]
    for l in range(p[(str(format(j,'b').zfill(d))).rfind('0')]):
        if s[j] < g:
            s[j] += 100 * ((str(format(j,'b').zfill(d))).rfind('0') + 1)
            n[j] += 1
        else:
            break
    if s[j] >= g:
        m.append(n[j])


#
ans = min(m)
print(ans)


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x.at(i);
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        if (x.at(i) * 2 < k)
        {
            res += x.at(i) * 2;
        }
        else
        {
            res += (k - x.at(i)) * 2;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256