akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int N, int M, vector<long long> X, vector<long long> Y,
           vector<long long> Z) {
  long long ans = 0;
  vector<vector<int>> uo = {{1, 1, 1},  {1, 1, -1},  {1, -1, 1},  {1, -1, -1},
                            {-1, 1, 1}, {-1, 1, -1}, {-1, -1, 1}, {-1, -1, -1}};
  for (auto o : uo) {
    long long temp = 0;
    vector<long long> s(N);
    for (int i = 0; i < N; i++) {
      s[i] = o[0] * X[i] + o[1] * Y[i] + o[2] * Z[i];
    }
    sort(s.begin(), s.end());
    for (int i = N - 1; i >= N - M; i--) {
      temp += s[i];
    }
    ans = max(ans, temp);
  }

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> X(N), Y(N), Z(N);
  for (int i = 0; i < N; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    X[i] = x;
    Y[i] = y;
    Z[i] = z;
  }
  solve(N, M, X, Y, Z);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;

	int t;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1) {
				a--;
			}

			t = a /= 2;
			b += t;
		}
		else {
			if (b % 2 == 1) {
				b--;
			}

			t = b /= 2;
			a += t;
		}
	}
	printf("%d %d\n", a, b);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {

    int n, F[45], i;

    cin >> n;

    F[0] = 1;
    F[1] = 1;

    for (i = 2; i <= n; i++) {

        F[i] = F[i - 1] + F[i - 2];

    }

    cout << F[n] << endl;

    return 0;

}

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

int n,m;
int d[15][15],maze[205][205];

void Floyd()
{
    for(int k=0;k<10;k++)
        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

void input()
{
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            scanf("%d",&d[i][j]);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%d",&maze[i][j]);
        }
    }
}

void solve()
{
    int sum=0;
    Floyd();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(maze[i][j]!=-1){
                sum+=d[maze[i][j]][1];
            }
        }
    }
    printf("%d\n",sum);
}

int main()
{
    scanf("%d%d",&n,&m);
    input();
    solve();
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stack>
#define NUM 1000
using namespace std;
int main(){
    int n, q, query, x, t;
    stack<int> s[NUM];
    scanf("%d %d", &n, &q);
    for(int i = 0; i < q; i++){
        scanf("%d %d", &query, &t);
        switch(query){
            case(0):
                scanf("%d", &x);
                s[t].push(x);
                break;
            case(1):
                if(!s[t].empty()) printf("%d\n", s[t].top());
                break;
            case(2):
                if(!s[t].empty()) s[t].pop();
                break;
        }
    }
}


Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  lint n;
  lint r=0;
  lint g=0;
  lint b=0;
  lint count=0;
  string s;
  cin>>n>>s;
  for(lint i=0;i<s.size();i++){
    if(s[i]=='R'){
      r++;
    }
    else if(s[i]=='G'){
      g++;
    }
    else {
      b++;
    }
  }
  count=r*g*b;
  lint loop=n/2;
  lint num=2;
  for(lint e=1;e<=loop;e++){
    for(lint i=0;i<s.size()-num;i++){
      if(s[i]==s[i+e]||s[i]==s[(i+e*2)]||s[i+e]==s[(i+e*2)]){
      }
      else{
        count--;
      }
    }
    num+=2;
  }
  log(count);
  
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int d[400][400];
const int INF = 12345678;

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> v(h);
  rep(i,h) cin>>v[i];

  auto id = [&](int x, int y){
    return x*w + y;
  };

  int n = h*w;
  rep(i,n) rep(j,n) d[i][j] = INF;
  rep(i,n) d[i][i] = 0;

  const int ki[] = {-1,1,0,0};
  const int kj[] = {0,0,-1,1};
  rep(i,h)rep(j,w)if(v[i][j]=='.'){
    rep(k,4){
      int ni = i+ki[k], nj = j+kj[k];
      if(ni<0 || ni>=h || nj<0 || nj >= w) continue;
      if(v[ni][nj] == '#') continue;
      d[id(i,j)][id(ni,nj)] = 1;
    }
  }

  rep(_,3) rep(k,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  int ans = 0;
  rep(i,n)  rep(j,n) if(d[i][j] < INF) ans = max(ans, d[i][j]);

  cout << ans << endl;

  return 0;
}


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

int main() {
  int X , Y , Z ; 
  
  cin >> X >> Y >> Z ;
  
  swap(X , Y) ;
  swap(X , Z) ;
  
  
  cout << X << " " << Y << " " << Z << endl ; 
  
  
  
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
const ld pi = 3.14159265358979323846;
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;
ll mul(ll x,ll y){
    return (1ll* (x%mod1)*(y%mod1));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ld a,b;
    cin>>a>>b;
    ld ans = a*b;
    cout<<(ll)ans<<"\n";
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unordered_set<int> uset;

int main( int argc, char* argv[] ){
  string s;
  int K;
  cin >> s >> K;
  int L=s.size();
  set<string> v;
  for( int i=0; i<L; ++i ){
    for( int l=1; l<=L-i; ++l ){
      string x = s.substr(i,l);
      if( v.size() == K && *(v.rbegin()) < x ){ continue; } 
      v.insert(x);
      if( v.size() > K ) v.erase( *(v.rbegin()) ); 
      // for( auto a : v ) cerr << " " << a ; cerr << endl;
    }
  }
  cout << *(v.rbegin()) << endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define repr(i, n) for(int i = n;i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    int n;
    cin >> n;
    long long a[n];
    a[0] = 2;
    a[1] = 1;

    for(int i = 2; i <= n; ++i){
        a[i] = a[i - 2] + a[i - 1];
    }

    cout << a[n] << "\n";
    
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
cnt = [0]*(10**5+1)
for i in range(n): cnt[a[i]] += 1
q = int(input())
s = sum(a)
for _ in range(q):
    b,c = map(int,input().split())
    s += (-b+c)*cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(s)

Measured memory_bytes: 84588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp43 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').ToArray();
            string a = st[0];
            string b = st[1];

            if (a == "H") {
                Console.WriteLine(b);
            } else {
                if (b == "H") {
                    Console.WriteLine("D");
                } else {
                    Console.WriteLine("H");
                }
            }
        }

    }
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll h,w;
	cin >> h >> w;
	vs s(h);
	rep(i,h) cin >> s[i];
	vvll dp(h,vll(w,0));
	rep(i,h){
		rep(j,w){
			if(i==0 && j==0){
				if(s[0][0]=='#') dp[i][j]=1;
				else dp[i][j]=0;
			}
			else if(i==0){
				if(s[i][j]!=s[i][j-1]) dp[i][j]=dp[i][j-1]+1;
				else dp[i][j]=dp[i][j-1];
			}
			else if(w==0){
				if(s[i][j]!=s[i-1][j]) dp[i][j]=dp[i-1][j]+1;
				else dp[i][j]=dp[i-1][j];
			}
			else{
				ll a=(s[i][j]!=s[i-1][j]?dp[i-1][j]+1:dp[i-1][j]);
				ll b=(s[i][j]!=s[i][j-1]?dp[i][j-1]+1:dp[i][j-1]);
				dp[i][j]=min(a,b);
			}
		}
	}
	cout << (dp[h-1][w-1]+1)/2 << endl;
	return 0;
}

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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN1(n)
    vector<int> a(100001,0),b(100001,0);
    rep(i,n){
        CIN1(v)
        if(i&1){
            a[v]++;
        }else{
            b[v]++;
        }
    }
    int ans;
    auto tmp_a = max_element(a.begin(),a.end()),tmp_b = max_element(b.begin(),b.end());
    if(distance(a.begin(),tmp_a)==distance(b.begin(),tmp_b)){
        int tmp_tmp_a = *tmp_a,tmp_tmp_b = *tmp_b;
        *tmp_a=0;*tmp_b=0;
        tmp_a = max_element(a.begin(),a.end()),tmp_b = max_element(b.begin(),b.end());
        if(*tmp_a>=*tmp_b){
            ans = n - *tmp_a - tmp_tmp_b;
        }else{
            ans = n - tmp_tmp_a - *tmp_b;
        }
    }else{
        ans = n - *tmp_a - *tmp_b; 
    }
    cout << ans << endl;
}

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

using namespace std;


int main()
{
  int N, A[100000];

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


  auto check = [&](int size)
  {
    int left = 0, right = size - 1;
    int flag = -1;
    for(int i = 1; i < N; i++) {
      if(A[i - 1] < A[i]) {
        ++left;
        ++right;
        right = size - 1;
      } else if(A[i] < A[i - 1]) {
        left = 0;
        --right;
      }
      if(left > right) return (false);
    }
    return (true);
  };

  int ok = 1 << 30, ng = 0;
  while(ok - ng > 1) {
    int mid = (ok + ng) >> 1;
    if(check(mid)) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;
}

Measured memory_bytes: 3448
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        double t = sc.nextDouble();
        double x = sc.nextDouble();
        System.out.println(t/x);

        sc.close();

    }

    public static void intArrayScan(int[] array) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        sc.close();
    }

    public static void intArrayPrint(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }

    public static void intSquareArrayScan(int[][] array, int h, int w) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                array[i][j] = sc.nextInt();
            }
        }
        sc.close();
    }

    public static void intArrayListScan(List<Integer> list, int n) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        sc.close();
    }

    public static void intArrayListPrint(List<Integer> list) {
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));  
        }
    }
}


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

int main(){
	int n,m,s,i,j,k,l;
	static int t[100];
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>k;
		for(j=0;j<k;j++){
			cin>>l;
			t[l]+=1;
		}
	}
	s=0;
	for(i=1;i<=m;i++){
		if(t[i]==n){
			s+=1;
		}
	}
	cout<<s;
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan2, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    li = LIST()
    A = defaultdict(int)
    for i in li:
        A[i] += 1
    cnt = 0
    for i in A.keys():
        if i < A[i]:
            cnt += A[i]-i
        elif i > A[i]:
            cnt += A[i]

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
string s; 
int i=0;
int main()
{    
    getline(cin,s); 
    while(i<s.length())
    {
        if(s[i]!='0'&&s[i]!='1') 
        {
         if(i>0) s.erase(i-1,2),i--;
           else s.erase(i,1);
    }
    else i++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 9;
const int INF = 2e9 + 239;
const int K = 20;

int f[N];
int up[K][N];

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	a.push_back(INF);
	int L;
	cin >> L;
	for (int i = 0; i < n; i++) {
		int last = upper_bound(a.begin(), a.end(), a[i] + L) - a.begin();
		last--;
		f[i] = last;
		// cerr << f[i] << ' ';
	}
	// cerr << endl;
	for (int i = 0; i < n; i++) {
		assert(i <= f[i]);
		up[0][i] = f[i];
	}
	for (int i = 0; i + 1 < K; i++) {
		for (int j = 0; j < n; j++) {
			up[i + 1][j] = up[i][up[i][j]];
		}
	}
	auto jump = [&](int a, int cnt) {
		for (int i = 0; i < K; i++) {
			if ((cnt >> i) & 1) a = up[i][a];
		}
		return a;
	};
	auto solve = [&](int i, int j) {
		int l = 0;
		int r = n;
		while (r - l > 1) {
			int m = (r + l) >> 1;
			if (jump(i, m) >= j) {
				r = m;
			} else {
				l = m;
			}
		}
		return r;
	};
	int q;
	cin >> q;
	while (q--) {
		int i, j;
		cin >> i >> j;
		i--;
		j--;
		if (i > j) swap(i, j);
		cout << solve(i, j) << '\n';
	}
	// cout << f[f[4]] << endl;

}


Measured memory_bytes: 9464
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t H, W;

    std::cin >> H >> W;

    if (H == 1 || W == 1) {
        std::cout << 1 << std::endl;
        return 0;
    }

    int64_t w = W;
    int64_t h = H/2;

    int64_t ans = w * h;

    if (H%2 == 1) {
        ans += W/2;
        if (W%2 == 1) ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main() {
	
	int S[10005];
	int T[505];
	
	int n;
	int q;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>S[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>T[i];
	}
	
	int count=0;
	for(int i=0;i<q;i++){
		for(int j=0;j<n;j++){
			if(S[j]==T[i]){
				count++;
				break;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <int> v(n);

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

    int m;
    cin >> m;

    for(i = 0; i < m; i ++)
    {
    	int p, x;
    	cin >> p >> x;

    	p --;
    	int ans = sum - (v[p] - x);
    	cout << ans << endl;
    }

}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

	int k, s;
	cin >> k >> s;

	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (0 <= z && z <= k) {
				ans++;
			}
		}
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long M){
  if (M ==N) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
ta, ao = 0, 0
if c % b == 0:
    ta = c // b
else:
    ta = c // b + 1
if a % d == 0:
    ao = a // d
else:
    ao = a // d + 1
if ta > ao:
    print("No")
else:
    print("Yes")

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    ans = (n-1)*n/2;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define isuck ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}

int main()
{
    isuck;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i) cin>>a[i];
    sort(a,a+n);
    int l = a[n/2] , r = a[n/2-1];
    cout<<max(0,l-r);
}


Measured memory_bytes: 640
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N,K = map(int,readline().split())
A = [int(x)-1 for x in readline().split()]

desc_edge = [set() for _ in range(N)]
parent = [0] * N
for i,x in enumerate(A[1:],1):
    # 根から葉に向かう向きに辺を持つ
    desc_edge[x].add(i)
    parent[i]=x

depth = [None] * N
q = [0]
depth[0]=0
while q:
    x = q.pop()
    for y in desc_edge[x]:
        q.append(y)
        depth[y] = depth[x]+1

V = set(range(N))

q=[]
depth_to_v = [[] for _ in range(N)]
for v,x in enumerate(depth):
    depth_to_v[x].append(v)
for d in range(N-1,-1,-1):
    q += depth_to_v[d]

q

answer = 0
for x in q:
    if x == 0:
        break
    if x not in V:
        continue
    if depth[x] <= K:
        break
    answer += 1
    y=x
    for _ in range(K-1):
        y = parent[y]
    # yの転送先を0に変更する、yの部分木は捨てる
    qq = [y]
    while qq:
        z = qq.pop()
        V.remove(z)
        for w in desc_edge[z]:
            if w in V:
                qq.append(w)

if A[0] != 0:
    answer += 1
print(answer)

Measured memory_bytes: 60832
n, m = map(int, input().split())
res = [[] for i in range(m)]
val = [0] * m
for i in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    for j in range(len(c)):
        res[i].append(c[j])
    val[i] = a



# i番目まで鍵を見たときにbit_stateの状態になっているときの最小値
INF = 10**9 + 7
dp  = [[INF]*(2**n) for i in range(m + 1)]
dp[0][0] = 0
for i in range(m):
    mask = 0
    for j in res[i]:
        mask += 2**(j-1)
    for bit_state in range(2**n):
        # i番目の鍵を使わない時
        dp[i+1][bit_state] = min(dp[i+1][bit_state], dp[i][bit_state])
        # i番目の鍵を使う時
        dp[i+1][bit_state | mask] = min(dp[i+1][bit_state | mask], dp[i][bit_state] + val[i])
if dp[-1][-1] == 10**9 + 7:
    print(-1)
else:
    print(dp[-1][-1])

Measured memory_bytes: 79320
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int h[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &h[i]);
  }
  long long int cost=h[0];
  for (size_t i = 1; i < N; i++) {
    if (h[i-1]<h[i]) {cost=cost+h[i]-h[i-1];}
  }
  printf("%lld", cost);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<string>
using namespace std;
string s;
int a=0,b=0,o=0,ab=0;
int main() {
	while(cin>>s){
	if(*(s.end()-1)=='A'){	
	a++;}else
	if(*(s.end()-2)=='A'){	
	ab++;}else
	if(*(s.end()-1)=='O'){	
	o++;}else b++;
	}
	cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;
	return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    while(cin >> n >> l)
    {
        string s[n];
        for(int i = 0;i < n;i ++)
        cin >> s[i];
        sort(s,s + n);
        for(int i = 0;i < n;i ++)
        cout << s[i];
        cout << endl;
    }
    return 0;
}


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

#define ll long long

using namespace std;

int main(){
	ll n, i, j, mini, x, p;
	vector < char > b[10];
	
	cin>>n;

	vector < string > a(n+1), c(n+1);
		
	for(i=0;i<n;i++){
		cin>>a[i];
		c[i]=a[i];
		x=a[i][1]-'0';
		b[x].push_back(a[i][0]);
	}
	
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(a[j][1]<a[j-1][1]){
				swap(a[j],a[j-1]);
			}
		}
	}
	
	for(i=0;i<n-1;i++){
		cout<<a[i]<<" ";
	}
	cout<<a[n-1]<<"\n";
	
	cout<<"Stable\n";
	
	for(i=0;i<n;i++){
		mini=i;
		for(j=i+1;j<n;j++){
			if(c[j][1]<c[mini][1]) mini=j;
		}
		swap(c[mini],c[i]);
	}
	
	for(i=0;i<n-1;i++){
		cout<<c[i]<<" ";
	}
	
	cout<<c[n-1]<<"\n";
	
	x=0;
	p=0;
	for(i=1;i<=9;i++){
		for(j=0;j<b[i].size();j++){
			if(c[x][0]!=b[i][j]) j=b[i].size(), i=10, p=1;
			x++;
		}
	}
	if(p==0) cout<<"Stable\n";
		else cout<<"Not stable\n";
}


Measured memory_bytes: 3192
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 10000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	string s;
	cin>>s;
	int n;
	cin>>n;
	
	vector<string>sub;
	
	REP(i,min(n,(int)s.size())){
		REP(j,s.size()-i){
			sub.push_back(s.substr(j,i+1));
		}
	}
	std::sort(sub.begin(),sub.end());
	std::unique(sub.begin(),sub.end());
	
	//	REP(i,sub.size())cout<<sub[i]<<endl;
	cout<<sub[n-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 1660
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    auto d = ReadVec1<int>(N);
    ll ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++) { 
            ans += d[i] * d[j]; 
        }
    }
    cout << ans << endl;
}

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

int S[100000];

bool binaryS(int key, int n);

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }
  
  int q, sum = 0;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int key;
    cin >> key;
    if (binaryS(key, n)) { sum++; }
  }
  
  cout << sum << endl;
  return 0;
}

bool binaryS(int key, int n) {
  
  int l = 0;
  int t = n;
  
  while (l <= t) {
    int s = (l + t) / 2;
    if (S[s] == key) { return true; }
    else if (S[s] < key) { l = s + 1; }
    else if (S[s] > key) { t = s - 1; }
  }
  
  return false;
}

Measured memory_bytes: 1548
N,K = map(int,input().split())

h = []
for _ in range(N):
    h.append(int(input()))

h.sort()
minimum = h[N - 1]- h[0]

for i in range(N - K + 1):
    minimum = min(minimum, h[i + K - 1] - h[i])
print(minimum)

Measured memory_bytes: 7484
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

const int N = 1010;
const int M = 201010;
int n;
int a[N], b[N], c[N], d[N];
vector<int> graph[N];
int vis[N], mp[N];

int dfs(int v)
{
    if (vis[v]) return 0;
    vis[v] = 1;
    for (auto u : graph[v])
    {
        if (mp[u] == -1 || dfs(mp[u]))
        {
            mp[u] = v;
            return 1;
        }
    }
    return 0;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i] >> d[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i] < c[j] && b[i] < d[j]) graph[i].push_back(j + 100);
        }
    }
    fill(mp, mp + 200, -1);
    for (int i = 0; i < n; i++)
    {
        fill(vis, vis + 200, 0);
        ans += dfs(i);
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
x=a[0]
y=sum(a)-a[0]
mini=float('inf')
if n==2:
    print(abs(a[0]-a[1]))
    exit()
for i in range(1,n-1):
    x+=a[i]
    y-=a[i]
    mini=min(mini,abs(x-y))
print(mini)

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

int main() {
  int N; cin >> N;
  map<int, int> A;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (A.count(a)) A[a]++;
    else A[a] = 1;
  }
  int ans = 0;
  for (auto a : A) {
    if (a.first == a.second) continue;
    if (a.first < a.second) ans += a.second - a.first;
    if (a.first > a.second) ans += a.second;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var a = 0
    var b = 0
    var aabb = 0
    var ab = 0
    for (i in 0 until n) {
        val text = readLine()!!.toString()
        for (j in 0 until text.length - 1) {
            if (text[j] == 'A' && text[j + 1] == 'B') ab++
        }
        if (text[0] == 'B' && text[text.length - 1] != 'A') b++
        else if (text[0] != 'B' && text[text.length - 1] == 'A') a++
        else if (text[0] == 'B' && text[text.length - 1] == 'A') aabb++
    }
    if (aabb >= 1) {
        if (a == b && a > 0) {
            println(ab + a + aabb)
        } else {
            println(ab + Math.max(Math.min(a + aabb, b + aabb - 1), Math.min(a + aabb - 1, b + aabb)))
        }
    } else {
        println(ab + Math.min(a, b))
    }
}


Measured memory_bytes: 35404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N>>M;
  
  vector<int>point(M);
  
  for(int i=0;i<N;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int l;
      cin>>l;
      point.at(l-1)++;
    }
  }
  int res=0;
  for(int i=0;i<M;i++){
    if(point.at(i)==N)
      res++;
  }
  cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k;
	ll ans=1,num=1;
	cin>>n>>k;
	while(1){
		if(num<=n&&n<num*k){
			cout<<ans;
			return 0;
		}
		ans++;
		num*=k;
	}
	return 0;
}



Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)
xs.sort!
diff = []
m.times do |i|
  break if xs[i+1].nil?
  diff << xs[i+1] - xs[i]
end

diff.sort!
(n-1).times do
  diff.pop
end
ans = diff.reduce(0){|a,e| a+=e}

puts ans

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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 50 + 7;
string A[MAX];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int n, m;
queue<PII> q;
int D[MAX][MAX];

bool inside(int x, int y)
{
	return x >= 0 && x < n && y >= 0 && y < m;
}

int bfs()
{
	FOR(i, 0, n)
	{
		FOR(j, 0, m) D[i][j] = INF;
	}

	q.push(MP(0, 0));
	D[0][0] = 0;
	while (!q.empty())
	{
		int x = q.front().first;
		int y = q.front().second;
		q.pop();

		FOR(k, 0, 4)
		{
			int x1 = x + dx[k];
			int y1 = y + dy[k];
			if (!inside(x1, y1) || A[x1][y1] == '#') continue;

			if (D[x1][y1] > D[x][y] + 1)
			{
				D[x1][y1] = D[x][y] + 1;
				q.push(MP(x1, y1));
			}
		}
	}

	return D[n -1][m - 1];
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	FOR(i,0,n) cin >> A[i];
	int len = bfs();
	if (len == INF)
	{
		cout << -1 << endl;
		return 0;
	}

	int cnt = 0;
	FOR(i,0,n)
	{
		FOR(j, 0, m) cnt += A[i][j] == '.';
	}

	cout << cnt - len - 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
    int t;
   // cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,min1=10000000000000,max2=-100;
 // char c;
  
  cin>>n;
  long long int a[n];
  
  //p=n;
  for(i=0;i<n;i++)
  {cin>>a[i];
  p=(p^a[i]);
  }
  for(i=0;i<n;i++)
  {
    cout<<(a[i]^p)<<" ";       
  }

    }
 return 0;
}


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

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007


 
int32_t main(){

     IOS
     int x,a;
     cin>>x>>a;
     if(x<a)
        cout<<"0";
    else
        cout<<"10";
return 0;
}

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

using namespace std;

int n;

map <int,int> cnt;

int main () {
    cin >> n;
    for (int i = 0, x;i < n;i ++) {
        cin >> x;
        if (cnt[x]) {
            cout << "NO";
            exit (0);
        }
        cnt[x] ++;
    }cout << "YES";
}


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


int main(void){
    long long a, b, k;
    cin >> a >> b >> k;
    
    //no1
    long long m1 = min(a, k);
    a -= m1;
    k -= m1;
    
    long long m2 = min(b, k);
    b -= m2;
    k -= m2;
    
    cout << a << " " << b << endl;
    
}

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

long long int  a[100000],b[100000];
vector<long long int> v;
map<long long int,int> m;
int cnt[100001];
long long int pre[100001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		v.emplace_back(a[i]);
	}
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
	for(int i=0;i<v.size();i++)
		m[v[i]]=i;
	for(int i=0;i<n;i++)
		b[i]=m[a[i]];
	for(int i=0;i<n;i++)
		cnt[m[a[i]]]++;
	long long int tmp=n;
	pre[0]=tmp*v[0];
	for(int i=1;i<v.size();i++){
		tmp-=cnt[i-1];
		pre[i]=pre[i-1]+tmp*(v[i]-v[i-1]);
	}
	long long int now=-1;
	for(int i=0;i<n;i++){
		if(now==-1){
			cout<<pre[b[i]]<<'\n';
			now=b[i];
		}
		else if(b[i]>now){
			cout<<pre[b[i]]-pre[now]<<'\n';
			now=b[i];
		}
		else
			cout<<0<<'\n';
	}
}

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

typedef long long ll;
const int MOD = 1e9 + 7;

int main()
{
    int n, x, k = 0;
    ll ans = 1;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &x);
        k++;
        if(x < 2 * k - 1)
        {
            ans = ans * k % MOD;
            k--;
        }
    }
    for(int i = 2; i <= k; i++)
        ans = ans * i % MOD;
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll d[15][2005], dp[2005][2005];

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

	vector<int> id, v[2005];

	rep(i, n) {
		int a, b;
		cin >> a >> b;

		id.push_back(b-1);
		v[b-1].push_back(a);
	}

	sort(id.begin(), id.end());
	id.erase(unique(id.begin(),id.end()),id.end());

	rep(i, id.size()) {
		int j = id[i];
		sort(v[j].begin(), v[j].end(), greater<int>() );
	}

	memset(d, 0, sizeof(d));

	rep(i, id.size()) {
		int j = id[i];

		REP(k, 1, v[j].size()+1) {
			d[j][k] += d[j][k-1] + v[j][k-1] + (k-1) * 2;
		}
	}

	memset(dp, 0, sizeof(dp));

	rep(i, id.size()) {
		rep(j, K + 1) {
			ll res = dp[i][j];
			rep(k, v[id[i]].size() + 1) {
				if(j >= k) {
					res	= max(res, dp[i][j - k] + d[id[i]][k]);
				}
			}

			dp[i+1][j] = res;
		}
	}

	cout << dp[ id.size()][K] << endl;

	return 0;
}

Measured memory_bytes: 32932
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int has[1000001];
signed main()
{
  int n,ans=0;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      has[arr[i]]++;
  }
   for(int j=0;j<n;j++)
   {
       int k=arr[j];
       for(int i=1;i<=sqrt(k);i++)
       {
           if(k%i==0)
           {
               int a,b;
               a=i;
               b=k/i;
               if(a!=k && has[a]!=0)
               {
                   ans++;
                   break;
               }
               else if(has[a]>1)
               {
                   ans++;
                   break;
               }

               if(b!=k && has[b]!=0)
               {
                   ans++;
                   break;
               }
               else if(has[b]>1)
               {
                   ans++;
                   break;
               }
           }
       }

   }
   cout<<n-ans<<endl;
}




Measured memory_bytes: 12816
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int MaxN = 100;
char s[MaxN + 5];

int main(){
	while(~scanf("%s", s + 1)){
		int len = strlen(s + 1);
		int ans = 1 << 30;
		for(char c = 'a'; c <= 'z'; c++){
			int tot = 0;
			int cnt = 0;
			for(int i = len; i >= 1; i--){
				if(s[i] == c){
					tot = max(tot, cnt);
					cnt = 0;
				}
				else cnt++;
			}
			tot = max(tot, cnt);
			ans = min(ans, tot);
		}
		printf("%d\n", ans);
	}
	return 0;
}
					


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

int main() {
	long long int A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;

	if (A < B) {
		if (W * T + B <= V * T + A) {
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}else{
		if (-(W * T) + B >= -(V * T) + A) {
			cout << "YES" << endl;
		}else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main() {
    int k,n;
    cin >> k >> n;
    cout << (k*500>=n?"Yes":"No") << endl;
}

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

string y ="YYMM";
string m ="MMYY";
string both ="AMBIGUOUS";
string no ="NA";

int main(){
    string s,s1,s2;
    cin >> s;
    int yymm = false,mmyy = false;
    s1 = s.substr(0,2);
    s2 = s.substr(2,2);
    //cout << s1 << " " << s2 << endl;
    int n1,n2;
    n1 = atoi(s1.c_str());
    n2 = atoi(s2.c_str());
    //cout << n1 << " " << n2 << endl;
    if(n2<=12&&n2>0){
        yymm = true;
    }
    if(n1<=12&&n1>0){
        mmyy = true;
    }

    if(yymm&&mmyy){
        cout << both << endl;
        return 0;
    }else if(yymm){
        cout << y << endl;
        return 0;
    }else if(mmyy){
        cout << m << endl;
    }else{
        cout << no << endl;
    }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[55],sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			sum+=a[i]*a[j];
	printf("%d\n",sum);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, k, x, y;
  scanf("%d %d %d %d", &n, &k, &x, &y);
  if(n <= k){
    printf("%d\n", x * n);
  }else{
    printf("%d\n", x*k + y*(n-k));
  }
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int f(int x) {
	cout << x << endl;
	string s; cin >> s;
	if (s[0] == 'V') {
		exit(0);
		return 2;
	}
	else if (s[0] == 'M') {
		return 0;
	}
	else {
		return 1;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	string s;
	int l = 0, r = N - 1;
	int nl = f(0);

	while (r - l > 2) {
		int m = (r + l) / 2;
		int d = m - l;
		dump(l, m, r);
		int nm = f(m);
		if (d % 2 == 0) {
			if (nl == nm) {
				l = m;
				nl = nm;
			}
			else {
				r = m - 1;
			}
		}
		else {
			if (nl == nm) {
				r = m - 1;
			}
			else {
				l = m;
				nl = nm;
			}
		}
	}
	f(l + 1);
	f(l + 2);

	return 0;
}

Measured memory_bytes: 852