akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <iostream>
using namespace std;


int main(){
    char map[6][5] = {
	{'a', 'b', 'c', 'd', 'e'},
	{'f', 'g', 'h', 'i', 'j'},
	{'k', 'l', 'm', 'n', 'o'},
	{'p', 'q', 'r', 's', 't'},
	{'u', 'v', 'w', 'x', 'y'},
	{'z', '.', '?', '!', ' '}};

    string s;
    while (cin >> s){
	bool err = false;
	for (int i = 0; i < s.size(); i++){
	    if (i % 2 && (s[i] > '5' || s[i] < '1')) err = true;
	    else if (i % 2 == 0 && (s[i] > '6' || s[i] < '1')) err = true;
	}
	if (s.size() % 2 || err) cout << "NA" << endl;

	else {
	    for (int i = 0; i < s.size(); i+=2){
		cout << map[s[i]-'0'-1][s[i+1]-'0'-1];
	    }
	    cout << endl;
	}
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;

inline void chk_max(int &a,int b){ if(a<b) a=b;}

char s[MAXN];
int pre[MAXN],suf[MAXN];
ll dif[MAXN];
inline void update(int l,int r){ ++dif[l]; --dif[r+1];}

int main(void)
{
	int n,d,c;
	scanf("%d%d%d%s",&n,&d,&c,s+1);
	
	for(int i=1; i<=n; ++i)
	{
		pre[i] = pre[i-1];
		if(s[i]=='x') continue;
		chk_max(pre[i],1);
		if(i-c-1 >= 1) chk_max(pre[i], pre[i-c-1]+1);
	}
	for(int i=n; i>=1; --i)
	{
		suf[i] = suf[i+1];
		if(s[i]=='x') continue;
		chk_max(suf[i],1);
		if(i+c+1 <= n) chk_max(suf[i], suf[i+c+1]+1);
	}
	
	//for(int i=1; i<=n; ++i) printf("%d %d\n",pre[i],suf[i]);
	
	for(int i=1; i<=n; ++i)
		if(pre[i-1]+suf[i+1] < d)
			printf("%d\n",i);
	
//	for(int i=1; i<=n; ++i)
//	{
//		if(pre[i-1]>=d || suf[i+1]>=d)
//			update(i,i);
//	}
//	for(int i=1; i+c-1<=n; ++i)
//	{
//		int j = i+c-1;
//		if(pre[i-1] + suf[j+1] >= d)
//			update(i,j);
//	}
//	for(int i=1; i<=n; ++i) dif[i] += dif[i-1];
//	
//	for(int i=1; i<=n; ++i)
//		if(s[i]=='o' && !dif[i])
//			printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 3200
n = int(input())
A = list(map(int,input().split()))

def partition(A,p,r):
  x = A[r]
  i = p-1
  for j in range(p,r):
    if A[j] <= x:
      i += 1
      A[i],A[j] = A[j],A[i]
  A[i+1],A[r] = A[r],A[i+1]
  return i+1


pat = partition(A,0,len(A)-1)

for i in range(len(A)):
  if i == pat:
    print("[%d]" %(A[i]),end="")
  else:
    print(A[i],end = "")
  if i != len(A)-1:
    print(" ",end="")

print()



Measured memory_bytes: 16392
#include "stdio.h"
#include "stdlib.h"
int main(void){
int i,n,a,b;
int suma,sumb;
do{
n=suma=sumb=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&a,&b);
if(a==b){
suma+=a;
sumb+=b;
}else if(a>b){
suma+=(a+b);
}else{
sumb+=(a+b);
}
}
if(n)
printf("%d %d\n",suma,sumb);
else
break;
}while(1);
return 0;
}

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

int main() {
  vector<int> A(3);
  for(int i = 0; i < A.size(); i++) cin >> A.at(i);
  accumulate(A.begin(), A.end(), 0) < 22 ? cout << "win" << endl : cout << "bust" <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,taro_point = 0,hanako_point = 0,j;
    char taro_card[101],hanako_card[101];
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%s %s",taro_card,hanako_card);
        for(j = 0; taro_card[j] != '\0' && hanako_card[j] != '\0' && taro_card[j] == hanako_card[j];j++);
        if(taro_card[j] == '\0'){
            if(hanako_card[j] == '\0'){
                taro_point += 1;
                hanako_point += 1;
            }else{
                hanako_point += 3;
            }
        }else if(hanako_card[j] == '\0'){
            taro_point += 3;
        }else if(hanako_card[j] > taro_card[j]){
            hanako_point += 3;
        }else{
            taro_point += 3;
        }
    }
    printf("%d %d\n",taro_point,hanako_point);
}


Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

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

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

	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}	
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char a[11],b[11],c[11];
  int i;
  scanf("%s %s %s",a,b,c);
  for(i=0;a[i]!=0;i++){}
  if(a[i-1]==b[0]){
    for(i=0;b[i]!=0;i++){}
    if(b[i-1]==c[0]) puts("YES");
    else puts("NO");
  }
  else puts("NO");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;


int main(){
	int n,t;cin >> n >> t;
	vector<int> a(n),mx(n);
	int prof = 0;
	int ans = 0;
	rep(i,n) cin >> a[i];
	for(int i = n-1;i >= 0;i--) {
		if(i == n-1) mx[i] = a[i];
		else mx[i] = max(mx[i+1],a[i]);
	}
	rep(i,n) prof = max(prof,mx[i]-a[i]);
	rep(i,n) if(mx[i]-a[i] == prof) ans++;
	// rep(i,n) cout << mx[i] << endl;
	// cout << prof << endl;
	cout << ans << endl;
} 


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	cin>>N;
	int prev=-1;
	int up=0;
	int ans=0;
	rep(i,N){
		int x;
		cin>>x;
		if(prev==-1){
			prev=x;
			up=0;
		}else{
			if(prev==x){
				continue;
			}else{
				if(prev<x){
					if(up==-1){
						ans++;
						prev=x;
						up=0;
					}else{
						prev=x;
						up=1;
					}
				}else{
					if(up==1){
						ans++;
						prev=x;
						up=0;
					}else{
						prev=x;
						up=-1;
					}
				}
			}
		}
	}
	cout<<ans+1<<endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> bar(n);
    for (int i = 0; i < n; i++) {
        cin >> bar.at(i);
    }
    ll sum = accumulate(bar.begin(), bar.end(), 0LL);
    ll acc = 0; ll min_p = sum;

    for (int i = 0; i < n; i++) {
        acc += bar.at(i);
        min_p = min(min_p, abs(acc-(sum-acc)));
    }
    cout << min_p << endl;
    return 0;
}

Measured memory_bytes: 4836
from math import factorial
 
s = int(input())
 
ans = 0
for i in range(s // 3):
    box = i + 1  # 箱の数
    ball = s - 3 * box # あらかじめ箱に３こずつ入れたあとの残りの玉の数
    
    # 箱の入れ方が何通りあるか計算。
    # 割り算を // ではなく / とするとfloat型の計算となりオーバーフローする可能性がある。
    # factorial(s_ + i) // (factorial(s_) * factorial(i))ではなくfactorial(s_ + i) // (factorial(s_) // factorial(i))としても同様にオーバーフローする可能性がある。
    ans_ = factorial(ball + box - 1) // (factorial(ball) * factorial(box - 1))
    ans += ans_
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b; cin >> a >> b;
  if(a*b%2==0){
   	cout << "No"  << endl;
  }
  else cout << "Yes" << endl;
  
  return 0;
}

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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
  while (u != NIL && k != u->key) {
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, x;
  string com;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> com;
    if (com[0] == 'f') {
      cin >> x;
      Node *t = find(root, x);
      if (t != NIL) cout << "yes" << endl;
      else cout << "no" << endl;
    } else if (com == "insert") {
      cin >> x;
      insert(x);
    } else if (com == "print") {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }

  return 0;

}


Measured memory_bytes: 21824
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    string s;
    int kukan=0;
    cin >> s;
    int st=0;
    char left=s[0];
    while(st<s.size()){
        if(s[st]==left){
            kukan++;
            while(st<s.size()&&s[st]==left) st++;
        }
        else{
            kukan++;
            while(st<s.size()&&s[st]!=left) st++;
        }
    }
    cout << kukan-1 <<endl;
    return 0;
}



Measured memory_bytes: 512
#include<iostream> 
#include<string>

using namespace std;

int main(){
    int a,b;
    int ans=0;
    cin>>a>>b;

    for(int i=1;i<a;i++){
        ans++;
    }
    for(int i=1;i<=b;i++){
        if(a==i){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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

	ll x;
	scanf("%lld", &x);
	printf("%lld\n", (x - 1) / 2);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d,c,i;
  cin>>n;
  vector<int> a(100);
  for (i=0;i<n;i++) {
    cin>>d;
    a.at(d-1)=1;
  }
  c=0;
  for (i=0;i<a.size();i++) {
    c+=a.at(i);
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
//##MohK..
//22/05/2020   ...   5,07
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a,b;
    cin>>a>>b;
    b.pop_back();
    if(b==a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    /*ll a;
    cin>>a;
    ll c=a%10;
    if(c==2||c==4||c==5||c==7||c==9)cout<<"hon"<<endl;
    else if(c==0||c==1||c==8||c==6)cout<<"pon"<<endl;
    else if(c==3)cout<<"bon"<<endl;*/

    return 0;
}



Measured memory_bytes: 3572
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    I vec;
    REP(a,N){
        CIN(b);
        vec.pb(b);
    }
    LL ans1 = 0,ans2 = 0,n1=0,n2=0;
    for(int a = 0;a < N;a++){
        n1+=vec.at(a);
        n2+=vec.at(a);
        if(a%2==0){
            if(n1>=0){
                ans1+=abs(n1-(-1));
                n1 -= abs(n1-(-1));
            }
            if(n2<=0){
                ans2+=abs(n2-1);
                n2 += abs(n2-1);
            }
        }else{
            if(n2>=0){
                ans2+=abs(n2-(-1));
                n2 -= abs(n2-(-1));
            }
            if(n1<=0){
                ans1+=abs(n1-1);
                n1 += abs(n1-1);
            }
        }
    }
    COUT(min(ans1,ans2));
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

//-------------------ここから回答する-----------------------

void solve(void)
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    deque<char> da, db, dc;
    for (auto i : sa)
        da.emplace_back(i);
    for (auto i : sb)
        db.emplace_back(i);
    for (auto i : sc)
        dc.emplace_back(i);

    char st = 'a';

    while (true)
    {

        if (st == 'a')
        {
            if (da.size() == 0)
            {
                cout << "A" << endl;
                return;
            }
            st = da.front(), da.pop_front();
        }
        else if (st == 'b')
        {
            if (db.size() == 0)
            {
                cout << "B" << endl;
                return;
            }
            st = db.front(), db.pop_front();
        }
        else if (st == 'c')
        {
            if (dc.size() == 0)
            {
                cout << "C" << endl;
                return;
            }
            st = dc.front(), dc.pop_front();
        }
    }
}
int main(void)
{
    solve();
}


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

// nCk mod p
// O(N)
// ttps://drken1215.hatenablog.com/entry/2018/06/08/210000
// ttps://algo-logic.info/combination/
const int MAX = 2000;
const ll MOD = 1000000007;
ll fact[MAX], fact_inv[MAX], inv[MAX];
void comb_mod_init() {
  fact[0] = fact[1] = 1;          // 0,1の階乗は1
  fact_inv[0] = fact_inv[1] = 1;  // 1の逆元は1
  inv[1] = 1;                     // 1の逆元は1
  for (int i = 2; i < MAX; i++) {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }
}
ll comb_mod(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main() {
  int s;
  cin >> s;
  comb_mod_init();
  ll ans = 0;
  for (int n = 1; n <= (s / 3); n++) {
    // s-3n+n-1 C n-1 の総和
    ans += comb_mod(s - 2 * n - 1, n - 1);
    ans %= MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int time = scan.nextInt();

		int hour = time / (60 * 60);
		int min = (time - hour * 60 * 60) / 60;
		int sec = time - hour * 60 * 60 - min * 60;

		System.out.println(hour + ":" + min + ":" + sec);
	}

}


Measured memory_bytes: 26408
// https://atcoder.jp/contests/abc133/tasks/abc133_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

class DisjointSet{
public:
    vector<int> p,r;

    DisjointSet(int s){
        p.resize(s,0);
        r.resize(s,0);
        int i;
        for(i=0;i<s;i++){makeset(i);}
    }

    void makeset(int i){
        p[i]=i;
        r[i]=0;
    }

    bool same(int a,int b){
        if(findset(a)==findset(b))return true;
        else return false;
    }

    void link(int a,int b){
        int pa=findset(a);
        int pb=findset(b);
        if(r[pa]>r[pb])p[pb]=pa;
        else{
            p[pa]=pb;
            if(r[pa]==r[pb])r[pb]+=1;
        }
    }

    int findset(int a){
        if(a!=p[a]){
            p[a]=findset(p[a]);
        }
        return p[a];
    }
};

int main()
{
    int n,q,t,a,b;
    cin>>n>>q;
    DisjointSet ds=DisjointSet(n);
    int i;
    for(i=0;i<q;i++){
        cin>>t>>a>>b;
        if(t==0)ds.link(a,b);
        if(t==1){
            if(ds.same(a,b))cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[n], b[n];
  pair<int, int> ab[n];

  for (int i=0; i<n; i++) {
    cin>>a[i]>>b[i];
    ab[i] = {a[i] + b[i], i};
  }
  sort(ab, ab + n);
  reverse(ab, ab + n);
  long long ans = 0;
  for (int i=0; i<n; i++) {
    if (i % 2 == 0) {
      ans += a[ab[i].second];
    } else {
      ans -= b[ab[i].second];
    }
  }
  cout<<ans<<endl;
}

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

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

    int n = s.size();
    vector<int> arr;
    if(s[n-1]!='0'){
        cout<<-1;
        return 0;
    }
    if (s[0] != '1') {
        cout<<-1;
        return 0;
    }
    for(int i = 0; i < n-1; i++){
        if(s[i]=='1') arr.push_back(i+1);
        if(s[i] == '1' && s[i]!=s[n-i-2]){
            cout<<-1;
            return 0;
        }
    }

    int cur = 1;
    int prv = 0;
    int pnod = 0;
    vector<pair<int,int>> e;
    for(int i = 0; i < (int)arr.size(); i++){
        if(i!=0) e.push_back({pnod,cur});
        int sz = arr[i] - prv;
        pnod = cur;
        if(i != (int)arr.size()-1){
            sz--;
        }
        for(int j = 0; j < sz; j++){
            e.push_back({cur,cur+j+1});
        }
        cur+=sz+1;
        prv=cur-1;
    }
    if(prv<n){
        e.push_back({pnod,cur});
        for(int i = 0; i < n - prv; i++) e.push_back({cur,cur+i+1});
    }

    for(auto i : e) cout<<i.first<<" "<<i.second<<endl;
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    printf("%d\n",a[n/2+1]-a[n/2]);
    return 0;
}

Measured memory_bytes: 640
# AOJ 0072: Carden Lanternl
# Python3 2018.6.28 bal4u

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

while True:
	n = int(input())
	if n == 0: break
	u = UnionSet(n)
	m = int(input())
	tbl = []
	for i in range(m):
		a, b, d = map(int, input().split(','))
		tbl.append((d//100-1, a, b))
	tbl.sort()
	ans = 0;
	for x in tbl:
		d, a, b = x
		if not u.connected(a, b):
			u.unite(a, b)
			ans += d
	print(ans)


Measured memory_bytes: 5776
// AOJ Volume 0 Problem 0050

#include <stdio.h>
#include <string.h>

int main(void)
{
    char str_in[2000];
    char str_out[2000];
    char *p_in, *p_out;
    
    fgets(str_in, 2000, stdin);

    str_out[0] = '\0';
    p_in = str_in;
    p_out = str_out;

    while (*p_in != '\0'){
        if (strncmp(p_in, "apple", strlen("apple")) == 0){
            strcat(p_out, "peach");
            p_out += 5;
            p_in += 5;
        }
        else if (strncmp(p_in, "peach", strlen("peach")) == 0){
            strcat(p_out, "apple");
            p_out += 5;
            p_in += 5;
        }
        else {
            *p_out++ = *p_in++;
        }
    }
    *p_out = '\0';

    printf("%s", str_out);

	return (0);
}

Measured memory_bytes: 0
const main = i => console.log(
  i.split(' ')
    .map(n => parseInt(n))
    .map((n, i, arr) => Math.abs(arr[(i + 1) % arr.length] - n))
    .sort((a,b)=>a-b)
    .slice(0, 2)
    .reduce((prev, curr) => prev + curr, 0)
)

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int X;
    cin >> X;
    if(X == 7 or X == 5 or X == 3)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3636
#include <iostream>

typedef struct _player {
    std::string s;
    int  idx;
    char name;
    _player( char n ) : idx(0), name(n) {}
} player;

player A('A'), B('B'), C('C');

char calc( char turn ) {
    char next_turn;
    switch( turn ) {
        case 'a':
            if ( A.idx == A.s.size() ) return A.name;
            next_turn = A.s[A.idx++];
            break;
        case 'b':
            if ( B.idx == B.s.size() ) return B.name;
            next_turn = B.s[B.idx++];
            break;
        case 'c':
            if ( C.idx == C.s.size() ) return C.name;
            next_turn = C.s[C.idx++];
            break;
        default:
            break;
    }
    return calc( next_turn );
}

void solve() {
    std::cout << calc( 'a' ) << std::endl;
}

int main() {
    std::cin >> A.s >> B.s >> C.s;
    solve();
    return 0;
}

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

int main(){
	int n,m,l,A[100][100],B[100][100];
	long long int C[100][100]={};
	cin>>n>>m>>l;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>A[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++){
			cin>>B[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int k=0;k<m;k++){
			for(int j=0;j<l;j++){
				C[i][j]+=A[i][k]*B[k][j];
			}
			
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			cout<<C[i][j];
			if(j!=l-1)cout<<" ";
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3232
# -*- coding: utf-8 -*-
import sys

N,K = list(map(int, input().rstrip().split()))
A_list = list(map(int, input().rstrip().split()))
#-----

visited_list = [1]
visited_set = set([1])
idx = 0


while True:
    next_idx = A_list[idx] - 1
    
    if (next_idx+1) in visited_set:
        break
    else:
        visited_list.append(next_idx+1)
        visited_set.add(next_idx+1)
        idx = next_idx

    if len(visited_list) == (K+1):
        print(visited_list[K])
        sys.exit()


cycle_start = visited_list.index(next_idx+1)  # 0-index
cycle_length = len(visited_list) - cycle_start

remain = (K - cycle_start) % cycle_length  # 0-index
idx = cycle_start + remain

print(visited_list[idx])


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

long long ck_mandis(vector<long long> p1, vector<long long>p2);

int main(){
    long long N, X, Y, ans, w, z;
    long long w_min, w_max, z_min, z_max;
    long long X_min, i_x_min = 0, X_max, i_x_max = 0;
    std::cin >> N;
    vector<vector<long long>> points(N);

    for(long long i = 0; i < N; i++){
        std::cin >> X >> Y;
        w = X + Y;
        z = X - Y;
        if(i == 0){
            w_max = w;
            w_min = w;
            z_max = z;
            z_min = z;
        }

        if(z < z_min){
            z_min = z;
        }else if(z > z_max){
            z_max = z;
        }
        if(w < w_min){
            w_min = w;
        }else if(w > w_max){
            w_max = w;
        }
    }
    if(z_max - z_min > w_max - w_min){
        ans = z_max - z_min;
    }else{
        ans = w_max - w_min;
    }

    std::cout << ans;

}

long long ck_mandis(vector<long long> p1, vector<long long>p2){
    long long ans;
    // std::cout << "ck\n";
    // std::cout << p1[0] << " " << p1[1] << "\n"; 
    // std::cout << p2[0] << " " << p2[1] << "\n";
    ans = labs(p1[0]-p2[0]) + labs(p1[1] - p2[1]);
    // std::cout << ans << "\n";
    return ans;

}

Measured memory_bytes: 8004
n = gets.chomp.to_i
a,b = gets.chomp.split(/\s/).map{|x| x.to_i}
pn = gets.chomp.split(/\s/).map{|x| x.to_i}

cnt = 0

for i in 1..n/3
    found = false
    for j in 0..(pn.length-1)
        if pn[j] <= a
            found = true
            pn.delete_at(j)
            break
        end
    end
    break unless found
    break if pn.length == 0

    found = false
    for j in 0..(pn.length-1)
        if (a+1) <= pn[j] and pn[j] <= b
            found = true
            pn.delete_at(j)
            break
        end
    end
    break unless found
    break if pn.length == 0

    found = false
    for j in 0..(pn.length-1)
        if b+1 <= pn[j]
            found = true
            pn.delete_at(j)
            break
        end
    end
    break unless found

    cnt += 1
    break if pn.length == 0
end

puts cnt

Measured memory_bytes: 1788
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
	if(m>=n%500)cout<<"Yes";
	else cout<<"No";
	cout<<endl;
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int count[N]={0};
    for (int i=0; i<M;i++){
        int A, B;
        cin >> A >> B;
        count[A-1]++;
        count[B-1]++;
    }
    for (int i=0; i<N; i++) cout << count[i] << endl;
}


Measured memory_bytes: 256
n,q=map(int,input().split())
s=list(input())
p=[tuple(input().split())for i in range(q)]
def judge_l(x):
    for(k,v)in p:
        if k==s[x]:
            if v=="L":
                x-=1
            else:
                x+=1
        if x==-1:
            return True
        elif x==n:
            return False
    return False

def judge_r(x):
    for(k,v)in p:
        if k==s[x]:
            if v=="L":
                x-=1
            else:
                x+=1
        if x==-1:
            return False
        elif x==n:
            return True
    return False

ok=-1
ng=n

while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if judge_l(mid):
        ok=mid
    else:
        ng=mid
l=ok+1

ok=n
ng=-1

while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if judge_r(mid):
        ok=mid
    else:
        ng=mid
r=n-ok
#print(l,r)
print(max(n-l-r,0))


Measured memory_bytes: 18932
def solve():
    N = int(input())
    h = list(map(int, input().split()))

    dp = [float('inf')] * N
    dp[0] = 0
    for i in range(1, N):
        if i >= 2:
            dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], dp[i])
            dp[i] = min(abs(h[i] - h[i-2]) + dp[i-2], dp[i])
        else:
            dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1],dp[i])
    
    print(dp[N-1])

if __name__ == '__main__':
    solve()


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

void solve() {
	string s;
	cin >> s;
	vector<int>l(s.length(), 0), r(s.length(), 0), ans(s.length(), 0);
	for (int i = 1; i < s.length(); i++) {
		if (s[i] == 'L')l[i] = l[i - 1] + 1;
		if (s[s.length() - i - 1] == 'R')
			r[s.length() - i - 1] = r[s.length() - i] + 1;
	}
	for (int i = 0; i < s.length(); i++)
		if (r[i]) {
			if (r[i] % 2 == 0)ans[i + r[i]] += 1;
			else ans[i + r[i] - 1] += 1;
		}
	for (int i = s.length() - 1; 0 <= i; i--)
		if (l[i]) {
			if (l[i] % 2 == 0)ans[i - l[i]] += 1;
			else ans[i - l[i] + 1] += 1;
		}
	for (int i = 0; i < s.length(); i++) {
		cout << ans[i];
		if (i != s.length() - 1)cout << " ";
	}
	cout << endl;
}

int main() {
	solve();
}

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

int main(){
    int d,g;
    cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    for(int i=0; i<d; i++){
        cin >> p.at(i);
        cin >> c.at(i);
    }
    int score = 0;
    int snum = 0;
    int com_snum = INT_MAX;
    for(int i=0; i<(1<<d); i++){
        bitset<11> bit(i);
        //cout << bit << endl;
    
        for(int j=0; j<d; j++){
            if(bit.test(j)){
                score += c.at(j);
                score += p.at(j) * 100*(j+1);
                snum += p.at(j);
            }
        }
        //cout << score << endl;
        //cout << snum << endl;
        if(score >= g){
            //cout << snum << endl;
        }
        else{
            for(int k=d-1; k>=0; k--){
                if(!bit.test(k) && score < g){
                    for(int l=1; l<=p.at(k); l++){
                        if(score+l*(k+1)*100 >= g){
                            snum += l;
                            score += l*(k+1)*100;
                            //cout << score << endl;
                            break;
                        }
                        if(l==p.at(k)){
                            snum += p.at(k)-1;
                            score += (p.at(k)-1)*(k+1)*100;
                        }
                    }
                }
            }
        }
        //cout << score << endl;
        //cout << snum << endl;
        if(com_snum > snum && score >= g){
            com_snum = snum;
        }
        score = 0;
        snum = 0;
    }
    //cout << "最小回数=" << com_snum << endl;
    cout << com_snum << endl;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
#ifndef LOCAL_PROJECT
#define cerr if(0)cerr
#endif
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef __int128 lll;
const lll ONE=1;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int mn=2e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=1e9+7;

int h;
int p[mn];
ll val[mn];
ll ans=0;
void hail(vector<int>&o,int l,int r,bool b,int par){
    int mid=(l+r)>>1;
    vector<pll>v;
    for(int i=l;i;i>>=1)v.push_back({i,0});
    reverse(v.begin(),v.end());
    for(int i:o){
        for(int j=p[i];j!=v.back().first;j>>=1){
            v[v.size()-2].second+=v.back().first*v.back().second%mod;
            v[v.size()-2].second%=mod;
            v.pop_back();
        }
        for(int j=h-1;j>=0;j--)if(p[i]>>j>v.back().first)v.push_back({p[i]>>j,0});
        if((i<=mid)^b){
            v.back().second+=val[i];
            v.back().second%=mod;
        }
        else{
            ll ad=val[i]*par%mod;
            for(int j=v.size()-1;j>=0;j--){
                ad*=v[j].first,ad%=mod;
                ans+=ad*v[j].second%mod,ans%=mod;
            }
        }
    }
}
void solve(int l,int r,int par){
    if(l==r)return;
    int mid=(l+r)>>1;
    for(int i=l;i<=r;i++){
        val[i]=1;
        for(int j=i;j>par;j>>=1)val[i]*=j,val[i]%=mod;
    }
    vector<int>o(r-l+1);
    iota(o.begin(),o.end(),l);
    sort(o.begin(),o.end(),[](int a,int b){return p[a]<p[b];});
    hail(o,l,r,0,par);
    hail(o,l,r,1,par);
    solve(l,mid,par*2);
    solve(mid+1,r,par*2+1);
}
int main(){
#ifdef LOCAL_PROJECT
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
#else
    cin.tie(0);
    cin.sync_with_stdio(0);
#endif
    cin>>h;
    for(int i=1<<h-1;i<1<<h;i++){
        cin>>p[i];
        p[i]+=(1<<h-1)-1;
    }
    solve(1<<h-1,(1<<h)-1,1);
    printf("%lld",ans);
}





Measured memory_bytes: 5828
def f(s):

	return tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)])
		
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(f(raw_input()))))]

Measured memory_bytes: 27884
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int main(int n) {
    cin >> n;
    int number[n];
    int a;
    for (int i = n-1; i >= 0; i--) {
        cin >> a;
        number[i] = a;
    }
    for (int j = 0; j < n; j++) {
        if (j > 0) cout << " ";
        cout << number[j];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>

int main(int argc, char **argv)
{
    int w,h,x,y,r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if ((x >= r) && (x <= w - r) &&              
        (y >= r) && (y <= h - r)) {              
        printf("Yes\n");
    } else printf("No\n");

    return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

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


int main(){
    string s; cin >> s;
    int n = s.size();
    cout << s[0] << n-2 << s[n-1] << endl;
}
    



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

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

//queue<pair<int,int>> que;
char a[1002][1002];
int cost[1002][1002];
bool used[1002][1002];

int return_cost(pair<int,int> S,pair<int,int> G){
	//while(!que.empty())que.pop();
	queue<pair<int,int>> que;
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++){ cost[i][j]=INF; used[i][j]=false; }
	que.push(S);
	cost[S.first][S.second]=0;
	while(!que.empty()){
		pair<int,int> p=que.front(); que.pop();
		if(p==G)break;
		int x=p.first,y=p.second;
		if(!used[x][y]){
			for(int i=0;i<4;i++){
				int nx=x+muki[i][0],ny=y+muki[i][1];
				if(a[nx][ny]!='X'&&cost[nx][ny]>cost[x][y]+1){
					cost[nx][ny]=cost[x][y]+1;
					que.push(pair<int,int>(nx,ny));
				}
			}
			used[x][y]=true;
		}
	}
	return cost[G.first][G.second];
}

int main(){
	int h,w,n;
	pair<int,int> p[12];
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++)a[i][j]='X';

	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=h;i++){
scanf("\n");
	for(int j=1;j<=w;j++){
		scanf("%c",&a[i][j]);
		if(a[i][j]=='S'){
			p[0]=pair<int,int>(i,j);
		}
		else if('1'<=a[i][j]&&a[i][j]<='9'){
			p[a[i][j]-'1'+1]=pair<int,int>(i,j);
		}
	}
	}

	int ret=0;
	for(int i=0;i<n;i++){
		ret+=return_cost(p[i],p[i+1]);
	}

	printf("%d\n",ret);
}

Measured memory_bytes: 7076
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vector<double> p(n);
    rep(i,n)cin >> p[i];
    vector<vector<double>> dp(n+1,vector<double>(n+1));
    dp[0][0]=1.0;
    rep(i,n)rep(j,i+1){
        dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
        dp[i+1][j+1]+=dp[i][j]*p[i];
    }
    double ans=0.0;
    rep2(i,(n+1)/2,n+1)ans+=dp[n][i];
    cout << ans << endl;
}

Measured memory_bytes: 73732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

const int A = 1e6 + 5;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(A);
    rep(i, n){
        cin >> a.at(i);
        c.at(a.at(i))++;
    }
    bool pairwise = true;
    mrep(i, 2, A){
        int cnt = 0;
        for(int j = i; j < A; j += i){
            cnt += c.at(j);
        }
        if(cnt > 1) pairwise = false;
    }
    if(pairwise){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int g = 0;
    rep(i, n) g = gcd(g, a.at(i));
    if(g == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;

int bottom(int n){
    int res = 1;
    while(res * 10 <= n){
        res *= 10;
    }
    return res;
}

int slow(int A, int B, int P){
    map<int, int> dp;
    map<int, int> sum[12];
    int ans = 0;
    for(int i = A; i <= B; i++){
        dp[i] = 1;
        dp[i] = (dp[i] + sum[ to_string(i).size() ][i - 1]) % P;
        for(int k = i / 10; k > 0; k /= 10){
            dp[i] = (dp[i] + sum[to_string(k).size()][k]) % P;
        }
        sum[to_string(i).size()][i] = (sum[ to_string(i).size() ][i - 1] + dp[i]) % P;
        ans = (ans + dp[i]) % P;
    }
    return ans;
}
int main(){
    LL A, B, P;
    while(cin >> A >> B >> P && A > 0){
        const int N = B - A + 1;
        // [A, border - 1], [border, border * 10 - 1], ... [border * 10^n, B] 
        LL border = 10;
        while(border - 1 < A){
            border *= 10;
        }
        if(border > B){
            LL ans = 1;
            REP(i, N) ans = ans * 2 % P;
            cout << (ans + P - 1) % P << endl;
        }else if(B < 10 * A){
            const int N1 = border - A;
            const int N2 = B - border + 1;
            LL ans1 = 1, ans2 = 1;
            REP(i, N1) ans1 = ans1 * 2 % P;
            REP(i, N2) ans2 = ans2 * 2 % P;
            cout << (ans1 + ans2 + P - 2) % P << endl;
        }else{
            cout << slow(A, B, P) << endl;
        }
    }
    return 0;
}

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

int main() {
	int a[4];
	for (int b = 0; b < 4; b++) {
		scanf("%d", &a[b]);
	}
	sort(a, a + 4);
	int sum = a[1] + a[2] + a[3];
	int p, q;
	cin >> p >> q;
	sum += max(p, q);
	cout << sum << endl;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

map<int,int> mp;
 
signed main(){
	
	int n;cin>>n;
	int ans=0;
	rep(i,n)
	{
		int a;cin>>a;
		if(mp[a])
		{
			mp[a] = 0;
			ans--;
		}
		else
		{
			mp[a]++;
			ans++;
		}


	}
	

	cout << ans << endl;
	
}
 

Measured memory_bytes: 6528
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }

int main() {
  int N;
  ll Z, W;
  cin >> N >> Z >> W;
  vector<ll> a(N);
  for(int i=0; i<N; ++i) {
    cin >> a[i];
  }
  
  if(N == 1) {
    cout << abs(W-a.back()) << endl;
  } else {
    cout << max(abs(W - a.back()), abs(a.back() - a[a.size()-2])) << endl;
  }
}

Measured memory_bytes: 256
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x
import math
A, B, C, D = (int(a) for a in input().split())
lcm = gcd(C, D)
a = B - A + 1
b = abs(B // C - (A - 1) // C)
c = abs(B // D - (A - 1) // D)
d = abs(B // ((C * D) // lcm) - (A - 1) // ((C * D) // lcm))
print(a - (b + c - d))

Measured memory_bytes: 3064
n, a, b, c, d = map(int, input().split())
a, b = 0, b - a
segs = [[-d * (n - 1), -c * (n - 1)]]
for _ in range(n - 1):
	segs.append([segs[-1][0] + c + d, segs[-1][1] + c + d])
ok = False
for i in range(n):
	if segs[i][0] <= b <= segs[i][1]:
		ok = True
if ok:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 89844
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    ll k;
    cin >> k;
    cout << (k >= 30 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;


int main(){
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] ||s[2]==s[3]){
		cout << "Bad" << endl;
	}else{
		cout << "Good" << endl;
	}

		return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const double PI=3.14159265358979323846;

ll gcd(ll x, ll y) {
    if(x%y==0) return y;
    else return gcd(y,x%y);
}

vector <pair<ll, ll>> prime_factorize(ll n) {
    vector <pair<ll, ll>> res;
    for(ll i=2;i*i<n;++i) {
        if(n%i!=0) continue;
        ll num=0;
        while(n%i==0) {
            ++num;
            n/=i;
        }
        res.push_back(make_pair(i,num));
    }
    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}

int main() {
    ll a,b;
    cin >> a >> b;
    ll x=gcd(a,b);
    auto pf=prime_factorize(x);
    cout << pf.size()+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = (mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value)) % mod_value;
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0) return 0;
		if (n < r) return 0;
		if (n == r) return 1;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_combination<long long> fc(N, MOD);
//long long result = fc.process(n, r);

const int MOD = 1e9 + 7;

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

	fast_combination<long long> fc(3e6, MOD);

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	long long result = fc.process(r2 + 1 + c2 + 1, r2 + 1);
	result = (result + (MOD - fc.process(r2 + 1 + c1, c1))) % MOD;
	result = (result + (MOD - fc.process(r1 + c2 + 1, c2 + 1))) % MOD;
	result = (result + fc.process(r1 + c1, c1)) % MOD;
	cout << result;

	return 0;
}


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

int main() {
  int A,B;
  cin>>A>>B;
  int ans=0;
  if(A>=B){
    ans += A;
    A=A-1;
  }
  else{
    ans += B;
    B=B-1;
  }
  if(A>=B){
    ans += A;
  }
  else{
    ans+=B;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n=1<<18;L[1<<18],p;F[1<<18],X[1<<18];i;long D[1<<20],Z[1<<20],A[1<<18],x,z;long f(a,k,l,r){D[k]+=z=Z[k];Z[2*k]+=z;Z[2*k+1]+=z;Z[k]=0;return a<=l&r<i+2?D[k]+(Z[k]=x):l<=i&a<r?D[k]=fmax(f(a,2*k,l,l+r>>1),f(a,2*k+1,l+r>>1,r)):D[k];}main(j){for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];for(;p?:(p=F[++i],f(i,1,0,n),n/i);p=X[p])x=A[p],x=f(L[p],1,0,n);printf("%ld",x);}

Measured memory_bytes: 19200