akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) ((a).begin(),(a).end())
using namespace std;
typedef vector<int> vi;

vi toVec(string s){
  rep(i,s.size()){
    if(s[i] == '/')s[i] = ' ';
  }
  stringstream ss(s);
  vi res;
  int tmp;
  while(ss >> tmp){
    res.push_back(tmp);
  }
  return res;
}


int main(){
  vi start = toVec("0000/00/00");
  vi last = toVec("9999/99/99");

  int n,q;
  cin >> n;
  vector<string> bn(n),ba(n),bd(n);
  vector<vi> bv(n);

  rep(i,n){
    cin >> bn[i] >> ba[i] >> bd[i];
    bv[i] = toVec(bd[i]);
  }

  cin >> q;
  rep(i,q){
    string qn,qa,qf,qt;
    vi qvf,qvt;
    cin >> qn >> qa >> qf >> qt;
    
    rep(j,n){
      bool f = true;
      if(qn!="*"){
	f &= (bn[j].find(qn)!=string::npos);
      }

      if(qa!="*"){
	f &= (ba[j].find(qa)!=string::npos);
      }

      if(qf!="*")qvf = toVec(qf);
      else qvf = start;
      if(qt!="*")qvt = toVec(qt);
      else qvt = last;
      f &= (qvf <= bv[j] && bv[j] <= qvt);
      
      if(f)cout << bn[j] << endl;
    }
    if(i<q-1)cout << endl;
  }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> data(N);
  for (int i = 0; i < N; i++){
    cin >> data.at(i);
    }//for input
  
  // output
  int sum = 0;
  for (int i = 0;i < N; i++){
    if ( data.at(i) * 2 < (K - data.at(i)) *2){
      sum += data.at(i) *2;
      }
    else {
      sum += (K - data.at(i)) * 2;
      }
  }// for output
  cout << sum << endl;
  }//main
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
int n;
int arr[MAXN],dp[MAXN];
/*
   int solve(int i){
        if(i>=n) {
                return 1e9;
        }
        if(i==n-1) {
                return 0;
        }
        int cost1=abs(arr[i+1]-arr[i]);

        int cost2=abs(arr[i+2]-arr[i]);
        if(dp[i]!=-1) return dp[i];
        return dp[i]=min(cost1+solve(i+1),cost2+solve(i+2));
   }
 */
int main()
{
	std::ios::sync_with_stdio(false);

	cin>>n;

	for(int i=0; i<n; i++) cin>>arr[i];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2; i<n; i++) {
		dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


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

int main(void) {
	int i, len;
	char str[32];
	scanf ("%s", str);
	len = strlen (str);
	for (i=0; i<len; i++) printf ("%c", str[len-i-1]);
	printf ("\n");
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

if __name__=='__main__':
  n = int(input())
  a = list(map(int, input().strip().split()))
  current_number = 0
  for i in range(n):
    if a[i] == current_number+1:
      current_number+=1
  if current_number == 0:
    print(-1)
  else:
    print(n - current_number)

Measured memory_bytes: 24872
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  vector<ll> S(N+1,0);
  map<ll,ll> mp;
  for(int i=0; i<N; i++){
    S[i+1] = S[i] + A[i];
    mp[S[i+1]%M]++;
  }
  ll ans=0;
  for(auto m: mp){
    if(m.first == 0){
      ans += (m.second*(m.second+1))/2;
    }else{
      ans += ((m.second-1)*m.second)/2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if(a%3==0||b%3==0||(a+b)%3==0)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int main() {
    int k; cin >> k;
    while (k--) {
        cout << "ACL";
    }
    cout << endl;
}



Measured memory_bytes: 3632
#include <stdio.h>
int main() {
	int n, a[100], ans = 0, cnt = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			cnt++;
		} else {
			ans += cnt / 2;
			cnt = 1;
		}
	}
	ans += cnt / 2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = INF;
  // ll n;
  // cin >> n;
  ll l, r;
  cin >> l >> r;
  // ll n, m, k;
  // cin >> n >> m >> k;
  if(r - l >= 2019) {
    cout << "0\n";
    return 0;
  }
  r %= 2019;
  l %= 2019;
  if(r < l) r += 2019;
  fi(l, r)
    fj(i + 1, r + 1)
      chmin(ans, (ll)(i * j) % 2019);
  cout << ans << endl;
  return 0;
}



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

int main(){
    int n; cin >> n;
    vector<long long> numbers(n); for (int i=0;i<n;i++){cin >> numbers[i];}
    vector<long long> sorted_numbers = numbers;
    sort(sorted_numbers.begin(), sorted_numbers.end());
    long long one_before, one_after;
    one_before = sorted_numbers[n/2 - 1];
    one_after = sorted_numbers[n/2];

    for (auto k : numbers){
        if (k <= one_before){
            cout << one_after << endl;
        } else {
            cout << one_before << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

struct S{
    int A;
    int B;
    double v;

    S(int A, int B){
        this->A = A;
        this->B = B;
    }

    bool operator<(const S &l) const{
        return static_cast<double>(B)/A < static_cast<double>(l.B)/l.A;
    };
};

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

    if(S=="SUN") cout << 7 << endl;
    else if(S=="MON") cout << 6 << endl;
    else if(S=="TUE") cout << 5 << endl;
    else if(S=="WED") cout << 4 << endl;
    else if(S=="THU") cout << 3 << endl;
    else if(S=="FRI") cout << 2 << endl;
    else if(S=="SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
// failed to generate code

#include <bits/stdc++.h>
using namespace std;


int dp[2010][2010];
vector<int> g[2010];
int N,K;
	
int dfs(int x,int p=-1){
	
	dp[x][0] = 1;
	for( auto e : g[x] ){
		if( e == p ) continue;
		dfs(e,x);
		dp[x][0] += dp[e][0];
	}
	dp[x][1] = dp[x][0] - 1;
	
	
	int sum[2010] = {};
	for(int i = 0 ; i <= K ; i++){
		for(auto j : g[x] ){
			if(j == p ) continue;
			sum[i] += dp[j][i];
		}
	}
	for( auto i : g[x] ){
		if( i == p ) continue;
		for(int j = 0 ; j <= K ; j++)
			dp[x][j+1] = min(dp[x][j+1],dp[i][j] + sum[min(j,K-j)] - dp[i][min(j,K-j)]);
	}
	
	for(int i = 1 ; i <= K + 1 ; i++){
		dp[x][i] = min(dp[x][i],dp[x][i-1]);
	}
	
	
	
	
}

int main(){
	for(int i = 0 ; i < 2010 ; i++)
		for(int j = 0 ; j < 2010 ; j++)
			dp[i][j] = 1e9;
	
	cin >> N >> K;
	
	for(int i = 0 ; i < N - 1 ; i++){
		int a,b;
		cin >> a >> b;
		--a,--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	int ans = 1e9;
	for(int i = 0 ; i < N ; i++){
		for(int j = 0 ; j <=  K+1 ; j++){ 
			ans = min(ans,dp[i][j] + N - dp[i][0]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 28672
struct B{int v,w,s;}A[1111];n,i;long p[22222],s;c(a,b)struct B*a,*b;{s=a->w+a->s-b->w-b->s;}main(j){for(scanf("%*d");~scanf("%d%d%d",j+4,j+8,j=A+n);n++);for(qsort(A,n,12,c);i<n;i++)for(j=A[i].s;~j;)s=fmax(s,p[j+A[i].w]=fmax(p[j--+A[i].w],p[j]+A[i].v));printf("%ld",s);}

Measured memory_bytes: 380
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        long mod=1000000007;
        long[] x=new long[n];
        for(int i=0;i<n;i++){
            x[i]=sc.nextLong();
        }
        long[] y=new long[m];
        for(int i=0;i<m;i++){
            y[i]=sc.nextLong();
        }
        long sumx=0;
        for(int i=0;i<n/2+1;i++){
            sumx+=Math.max((x[n-1-i]-x[i])*Math.abs(n-1-i*2),0);
            sumx%=mod;
        }
        long sumy=0;
        for(int i=0;i<m/2+1;i++){
            sumy+=Math.max((y[m-1-i]-y[i])*Math.abs(m-1-i*2),0);
            sumy%=mod;
        }
        System.out.println(sumx*sumy%mod);
    }
 
    
}

Measured memory_bytes: 64660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
// vector<vector<int>> A(3, vector<int>(4));
int main() {
   string S;
   cin>>S;
   int ans=S.size();
   int cnt=0;
    bool T=false;
    rep(i,S.size()){
        if(S[i]=='A'){
            ans=min(ans,i);
        }
        else if(S[i]=='Z'){
            cnt=max(cnt,i);
        }
}
cout<<cnt-ans+1<<endl;
}




Measured memory_bytes: 3736
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,w,h;
int main(){
	cin>>n>>w>>h;
	cout<<(n-w+1)*(n-h+1);
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=1010, M=4;

struct Matrix{
	ll A[M][M];
	Matrix(){
		memset(A, 0, sizeof(A));
	}
	ll* operator [](int i){
		return A[i];
	}
};
Matrix operator *(Matrix A, Matrix B){
	Matrix C;
	for (int i=0; i<M; i++) for (int k=0; k<M; k++) for (int j=0; j<M; j++)
		C[i][j]=(C[i][j] + A[i][k]*B[k][j])%mod;
	return C;
}
Matrix operator ^(Matrix A, ll k){
	Matrix B;
	for (int i=0; i<M; i++) B[i][i]=1;
	for (; k; k>>=1, A=A*A) if (k&1) B=B*A;
	return B;
}

ll n, m, k, u, v, x, y, t, a, b, c, ans, cnt;
char A[MAXN][MAXN];
Matrix T;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>k;
	for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cin>>A[i][j];
	for (int i=1; i<=n; i++) if (A[i][1]=='#' && A[i][m]=='#') a++;
	for (int i=1; i<=m; i++) if (A[1][i]=='#' && A[n][i]=='#') b++;
	for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cnt+=(A[i][j]=='#');
	if (a && b) kill(1)
	if (!a && !b){
		T[0][0]=cnt;
		T=T^(k-1);
		kill(T[0][0])
	}
	if (b){
		for (int i=1; i<MAXN; i++) for (int j=1; j<i; j++) swap(A[i][j], A[j][i]);
		swap(n, m);
		swap(a, b);
	}
	T[0][0]=cnt;
	for (int i=1; i<=n; i++) for (int j=1; j<m; j++)
		T[0][1]-=(A[i][j]=='#' && A[i][j+1]=='#');
	T[1][1]=a;
	T=T^(k-1);
	ans=(T[0][0] + T[0][1])%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 4624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

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

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main() {
    int n,m; cin >> n >> m;
    vector<vector<string>> v;v.assign(n,vector<string>());
    for(int i = 0;i < m;i++){
        int x; string s; cin >> x >> s;
        v[x-1].push_back(s);
    }
    ll correct = 0,incorrect = 0;
    for(int i = 0;i < n;i++){
        int n = 0;
        for(int j = 0;j < v[i].size();j++){
            if(v[i][j] == "WA"){
                n++;
            }else{
                correct++;
                incorrect+=n;
                break;
            }
        }
    }
    cout << correct << " " << incorrect;
}


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


int main() {
  int N,L;
  cin>>N>>L;
  vector<string> vec(N);
  rep(i,N){cin >> vec.at(i);}
  sort(vec.begin(), vec.end());
  
  rep(i,N){cout<<vec.at(i);}
  cout<<endl;
}

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


int main() {
    int r, g, b;
    cin >> r >> g >> b;

    int num = 100 * r + 10 * g + b;
    if (num % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, K; cin >> N >> K;
    vector<int> V(N);
    rep(i, 0, N) cin >> V[i];

    ll res = 0;
    const int maxTake = min(N, K);
    for(int i_A = 0; i_A <= maxTake; ++i_A) {
        for(int i_B = 0; i_B <= maxTake-i_A; ++i_B) {
            ll score = 0;
            vector<int> toBack;

            rep(i, 0, N) {
                if (i < i_A or i >= N-i_B) { // 左からi_A個、右からi_B個
                    score += V[i];
                    if (V[i] < 0) toBack.push_back(V[i]);
                }
            }

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

            const int maxBack = min(K-i_A-i_B, (int)toBack.size());
            rep(i, 0, maxBack) score -= toBack[i];

            if (score > res) {
                res = score;
                //printf("i_A = %d i_B = %d score = %lld\n", i_A, i_B, score);
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String);
    let ss: Vec<usize> = (&s).split(&"/").map(|x| x.parse().unwrap()).collect();

    let ans = if ss[0] <= 2019 && ss[1] <= 4 && ss[2] <= 30 {
        "Heisei"
    } else {
        "TBD"
    };

    println!("{}", ans);
}


Measured memory_bytes: 2100
# 2019/08/14

x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))

if (x<0 and y<0) or (x>0 and y>0):
    if x>y :ans+=2
elif x!=0 and y!=0:
    ans+=1
else:
    if y<=0 and x>y:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,k,ng=1;

main(){
	cin>>n>>k;
	set<int> d;
	rep(i,k){
		int t;
		cin>>t;
		d.ins(t);
	}
	while(1){
		int cn=n;
		int flg=1;
		while(cn){
			int t=cn%10;
			cn/=10;
			if(d.count(t)){
				flg=0;
				break;
			}
		}
		if(flg)break;
		n++;
	}
	dump(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)

int main() {
    cin.sync_with_stdio(0);
    ll n; cin >> n;
    ll d; cin >> d;
    ll out = 0;

    FOR(i, 0, n) {
        ll a, b; cin >> a >> b;
        if(a*a + b*b <= d*d) out++;
    }
    cout << out << endl;
}

Measured memory_bytes: 3616
N = int(input())

dic = {}

for i in range(2,10**6+10):

    if N == 1:
        break
    while N % i == 0:

        if i not in dic:
            dic[i] = 1
        else:
            dic[i] += 1
        N //= i

if N != 1:
    if N not in dic:
        dic[N] = 1
    else:
        dic[N] += 1

ans = 0

for i in dic:

    l = 1
    r = 10**12

    while r-l != 1:

        m = (l+r)//2

        now = (1+m)*m//2

        if now <= dic[i]:
            l = m
        else:
            r = m

    ans += l

print (ans)


Measured memory_bytes: 63088
#include <iostream>

using namespace std;

int main() {
    int a,b,c,d,x=0;
    cin>>a>>b>>c>>d;
    if(a>=d){
        x=d;
    }else{
        x+=a;
        d-=a;
        if(d>b){
            d-=b;
            if(d>0){
                x-=d;
            }
        }
    }
    cout<<x;
}

Measured memory_bytes: 3628
/*
 * c.cc: 
 */

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

using namespace std;

/* constant */

const int MAX_N = 10000;
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

vpii nbrs[MAX_N];
int dists[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v, c;
      cin >> v >> c;
      nbrs[u].push_back(pii(v, c));
    }
  }

  for (int i = 0; i < n; i++) dists[i] = INF;
  dists[0] = 0;

  priority_queue<pii> q;
  q.push(pii(0, 0));

  while (! q.empty()) {
    pii u = q.top(); q.pop();
    int ud = -u.first, &ui = u.second;
    if (dists[ui] != ud) continue;

    vpii& nbru = nbrs[ui];
    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &vi = vit->first, vd = ud + vit->second;
      if (dists[vi] > vd) {
	dists[vi] = vd;
	q.push(pii(-vd, vi));
      }
    }
  }

  for (int i = 0; i < n; i++) printf("%d %d\n", i, dists[i]);

  return 0;
}

Measured memory_bytes: 6276
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100010;
int n,a[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(a[n]-a[1]>1)printf("No");
	else if(a[n]==a[1])printf(n==a[1]+1||n>=(a[1]<<1)?"Yes":"No");
	else{
		int p=0,q=0;
		for(int i=1;i<=n;i++)(a[i]==a[1]?p:q)++;
		if(a[1]<p)printf("No");
		else printf(n-p>=((a[1]-p+1)<<1)?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 512
H,W,K = [int(i) for i in input().split()]

DP = [[0 for i in range(W)]for j in range(2)]

t = [0 for i in range(W+10)]
t[0]  = 1
t[1] = 1
t[2] = 2
for i in range(2,W+8):
    t[i+1] = t[i] + t[i-1]

#print(t)
n = 0
DP[0][0] = 1
for i in range(H):
    if W == 1:
        break
    DP[not(n)][0] = (DP[n][0] * t[W-1] + DP[n][1] * t[W-2]) % 1000000007
    for i in range(1,W-1):
        DP[not(n)][i] =( DP[n][i-1] *(t[W-i-1] * t[i-1]) + DP[n][i] * (t[i] * t[W-i-1]) + DP[n][i+1]*(t[W-i-2] * t[i])) % 1000000007
    
    DP[not(n)][W-1] = (DP[n][W-2]*t[W-2] + DP[n][W-1] * t[W-1]) % 1000000007
    n = not(n)
print(DP[n][K-1])


Measured memory_bytes: 3192
/*input
5
2 5 2
2 3 10
1 3 8
3 4 2
*/
#include "bits/stdc++.h"
using namespace std;
vector<pair<long long,long long>> v[100005];
int a[100005];
void dfs(int u, int dad, int c){
	a[u] = c;
	for(auto i:v[u]) if(i.first!=dad){
		dfs(i.first,u,c^(i.second&1));
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	for(int i=n-1,x,y,p;i--;){
		cin>>x>>y>>p;
		v[x].push_back({y,p});
		v[y].push_back({x,p});
	}
	dfs(1,0,0);
	for(int i=1;i<=n;cout<<a[i++]<<'\n');
}

Measured memory_bytes: 9856
N = int(input())
As = list(map(int, input().split()))
all_factor = [0 for _ in range(N)]

#%%
from math import gcd
from_right = [0 for _ in range(N)]
from_left = [0 for _ in range(N)]

from_right[-1] = As[-1]
from_left[0] = As[0]

for i in range(N-1):
    from_left[i+1] = gcd(from_left[i], As[i+1])
for i in list(range(N-1))[::-1]:
    from_right[i] = gcd(from_right[i+1], As[i])

answer = 1
for i in range(N):
    if i == 0:
        temp = from_right[1]
    elif i == N-1:
        temp = from_left[N-2]
    else:
        temp = gcd(from_left[i-1],from_right[i+1])
    
    if temp > answer:
        answer = temp
print(answer)

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int main() {
	string s, t;
	cin >> s >> t;
	if(s.size() + 1 != t.size()) {
		cout << "No" << endl;
	} else {
		for(int i=0;i<s.size();i++) {
			if(s[i] != t[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}


	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < n; ++i)

using namespace std;

int main() {
    int n;
    cin >> n;
    int fib1 ,fib2 ,fib3;
    fib1 = fib2 = fib3 = 1;
    rep(i,n-1) {
        fib3 = fib1 + fib2;
        fib1 = fib2;
        fib2 = fib3;
    }
    cout << fib3 << endl;
    return 0;
}


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

int H, W, N;
long long int ans[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
vector< pair<int, int> > colored;

int main(){
    cin >> H >> W >> N;
    ans[0] = (H - (long long int)2) * (W - (long long int)2);
    //cout << "all 3x3 " << ans[0] << endl;
    int a, b;
    for(int i = 0; i < N; i++){
        scanf("%d %d", &a, &b);
        colored.push_back(make_pair(a, b));
    }
    sort(colored.begin(), colored.end());
    bool iscol[5][5];
    int xx, yy;
    vector<pair<int, int> >::iterator ite = colored.begin();
    //for(int ii = 0; ii < colored.size(); ii++){
    while(ite != colored.end()){
        for(int i = 0; i < 5; i++){
            for(int j = 0; j < 5; j++){
                iscol[i][j] = false;
            }
        }
        xx = (*ite).first;
        yy = (*ite).second;
        for(int i = -2; i <= 0; i++){
            vector<pair<int, int> >::iterator beg = upper_bound(colored.begin(), ite + 1, make_pair(xx + i, yy - 3));
            vector<pair<int, int> >::iterator edn = upper_bound(colored.begin(), ite + 1, make_pair(xx + i, yy + 2));
            //cout << (*beg).first << " " << (*beg).second << " " << (*edn).first << " " << (*edn).second << endl;
            while(beg != edn){
                //cout << "(" << (*beg).first - xx + 2 << ", " << (*beg).second - yy + 2 << ") ";
                iscol[(*beg).first - xx + 2][(*beg).second - yy + 2] = true;
                beg++;
            }
            //cout << endl;
        }
        //for(int i = 0; i <5; i++){
        //    for(int j = 0; j < 5; j++){
        //        if(iscol[i][j]){
        //            cout << "# ";
        //        }else{
        //            cout << ". ";
        //        }
        //    }
        //    cout << endl;
        //}
        //cout << endl;
        for(int i = max(0, 3 - xx); i < min(3, H - xx + 1); i++){
            for(int j = max(0, 3 - yy); j < min(3, W - yy + 1); j++){
                int aa = 0;
                for(int k = 0; k < 3; k++){
                    for(int l = 0; l < 3; l++){
                        if(iscol[i + k][j + l]){
                            aa++;
                        }
                    }
                }
                //cout << xx << " " << yy << " " << i << " " << j << " " << aa << endl;
                ans[aa - 1]--;
                ans[aa]++;
            }
        }
        ite++;
        //for(int i = 0; i < 10; i++){
        //    cout << ans[i] << " ";
        //}
        //cout << endl;
        //cout << endl;
    }
    for(int i = 0; i < 10; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 1400
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = input()

hand = {'r':p, 's':r, 'p':s}
ans = 0

for i in range(k):
    last = ''
    j = i
    while j < n:
        aite = t[j]
        if aite != last: # 相手の手がk回前と違ったら、勝ちの手を出せる
            ans += hand[aite]
            last = aite
        else: # 相手の手がk回前と同じなら、勝ちの手は出せない（正確には、k回後に勝てるような手を出しておいた方が良い）
            last = '' # k回後に勝てるような手を出す前提で、nullにしておく（k回後に勝つ手によって変わる値）
        j += k

print(ans)

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

using namespace std;
 
 // Combination Table
long long C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
    for(int i=0;i<=N;++i){
        for(int j=0;j<=i;++j){
            if(j==0 or j==i){
                C[i][j]=1LL;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}
 
int main(void){
    int N,A,B;
    cin >> N >> A >> B;

    const int NMAX=50;
    long long v[NMAX];
 
    for(int i=0;i<N;++i){
    cin >> v[i];
    }
 
    comb_table(N);
    sort(v,v+N);
    reverse(v,v+N);
 
    double max_average=0.0;
    for(int i=0;i<A;++i){
    max_average+=v[i];
    }

    max_average/=A;
 
    int a_th_val_num=0,a_th_val_pos=0;
    for(int i=0;i<N;++i){
        if(v[i]==v[A-1]){
            a_th_val_num++;
            if(i<A){
                a_th_val_pos++;
            }
        }
    }
 
    long long cnt=0LL;
    if(a_th_val_pos==A){
        for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
            cnt+=C[a_th_val_num][a_th_val_pos];
        }
    }else{
        cnt+=C[a_th_val_num][a_th_val_pos];
    }
 
    cout.precision(20);
    cout << fixed << max_average << endl;
    cout << cnt << endl;
 
    return 0;
 }

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

long long inv(long long a){
  long long c,r,mod=1000000007,pow=1000000005;
  c=a; r=1;
  while(pow>0){
    if(pow%2==1){
      r=(r*c)%mod;
    }
    c=(c*c)%mod;
    pow/=2;
    
  }
  return r;
}

int main(){
  long long n,i,j,cur,ans,mod=1000000007,one=1;
  cin >> n;
  vector<long long> a(n),b(n),p(1000001,0);
  
  
  for(i=0; i<n; i++){
    cin >> a[i];
    b[i]=a[i];
  }
  // factor
  for(i=0; i<n; i++){
    for(j=2; j*j<=b[i]; j++){
      if(b[i]%j==0){
        cur=0;
        while(b[i]%j==0){
          cur++;
          b[i]/=j;
        }
        p[j]=max(p[j],cur);
      }
    }
    if(b[i]>1){
      p[b[i]]=max(p[b[i]],one);
    }
  }
  
  
  // max calc
  cur=1;
  for(i=2; i<1000001; i++){
    for(j=0; j<p[i]; j++){
      cur=(cur*i)%mod;
    }
  }
  //cout << cur  << ' ';
  
  //bi calc
  ans=0;
  for(i=0; i<n; i++){
    //cout << (cur*inv(a[i]))%mod << ' ';
    ans+=(cur*inv(a[i]))%mod;
    ans%=mod;
  }
  cout << ans;
  
  
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

long Max2(long a,long b){
if(a>b){
    return a;
}else{
    return b;
}
}

long Min2(long a,long b){
if(a>b){
    return b;
}else{
    return a;
}
}


string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {

long N;
cin>>N;
vector<long> A(N);
vector<long> B(N);
for(long i=0;i<N;i++){
cin>>A.at(i);
B.at(A.at(i)-1)=i;
}
for(long i=0;i<N;i++){
cout<<B.at(i)+1<<endl;
}



}



Measured memory_bytes: 239240
n = int(input())
lw = [input() for _ in range(n)]

cond = True
used = set()
last = lw[0][0]
for w in lw:
    if w in used or last != w[0]:
        cond = False
        break
    used.add(w)
    last = w[-1]

print("Yes" if cond else "No")


Measured memory_bytes: 8952
from collections import Counter
N=int(input())
L=list(map(int,input().split()))
s=[(i+1)+L[i] for i in range(N)]
s=Counter(s)
d=[(i+1)-L[i] for i in range(N)]
d=Counter(d)
ans=0
for i in s:
  if i in d:
    ans+=s[i]*d[i]
print(ans)

Measured memory_bytes: 168840
import java.util.*;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String w=sc.next();
        int cnt=0;
        char c;
        String str;
        String[] str2;
        int i;
        while(true){
            str=sc.next();
            if(str.equals("END_OF_TEXT"))break;
            c=getSymbolInString(str);
            str2=null;
            if(c!='a'){
                str2=str.split(Pattern.quote(String.valueOf(c)),0);
            }else{
                str2=new String[1];
                str2[0]=str;
            }
            for(i=0;i<str2.length;i++){
                if(str2[i].toLowerCase().equals(w))cnt++;
            }
        }
        System.out.println(cnt);
    }
    
    static char getSymbolInString(String s){
        char c;
        int i;
        for(i=0;i<s.length();i++){
            c=s.toLowerCase().charAt(i);
            if(c<'a'||c>'z')return c;
        }
        return 'a';
    }
}


Measured memory_bytes: 26872
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FUnfairNim {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<lint> A(N);
        lint xsum = 0;
        for(auto& a : A) in>>a, xsum ^= a;
        lint sum = A[0] + A[1];
        xsum ^= A[0] ^ A[1];
        sum -= xsum;
        lint a = 0, b = 0;
        for(int i=43;i;--i){
            if(sum>>i&1){
                a += 1ll << (i-1);
                b += 1ll << (i-1);
            }
        }
        for(int i=40;0<=i;--i){
            if(xsum>>i&1){
                if(a>>i&1){
                    out<<"-1\n";
                    return;
                }
                if(a+(1ll<<i)<=A[0]) a += (1ll<<i);
                else b += (1ll<<i);
            }
        }
        if(a+b!=sum+xsum or a==0 or a>A[0]) out<<"-1\n";
        else out<<A[0]-a<<'\n';
    }
};


int main() {
	FUnfairNim solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
typedef  long long ll;
using namespace std;

int main(void) {
	string x;
	map<char, int> alp;

	while (cin >> x)
	{
		for (int i = 0; i < x.length(); i++)
		{
			if ( isalpha(x[i])) alp[tolower(x[i])]++;
		}
	}

	for (int i = 0; i < 26; i++)
	{
		cout << char(i + 'a') << " : " << alp[char(i + 'a')] << endl;
	}

	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}
 
int main() {
  int n;
  cin >> n;
  
  vb x(n+1,false);
  x[1]=true;
  REPD(i,2,n) {
    int j=i*i;
    while(j<=n) {
      x[j]=true;
      j*=i;
    }
  }
  REP(i,n){
    if(x[n-i]) {
      cout << n-i << endl;
      return 0;
    } 
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long long int d;
    cin>>d;
    long long int p,q;
    int count=0;
    for (int i=0;i<n;i++) {
        cin>>p>>q;
        if (p*p+q*q<=d*d) {
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3628
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int main(){
	int A,B;cin>>A>>B;
	rep(i,1,1000000){
		int a=i*0.08;
		int b=i*0.1;
		if(a==A && b==B){
			cout<<i<<endl;
			return 0;
		}
	}cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin >> n >> k;

    for (int i=0; i<k; i++) {
        int x,y;
        cin >> x >> y;
        int ans = min(min(x-1, y-1), min(n-x, n-y));
        cout << ans % 3 + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2272

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    H, W = map(int, input().split(' '))
    data = []
    for i in range(H):
        data.append([int(x) for x in list(input().strip('\n'))])


    dp = [[0] * W for _ in range(H)]

    for i in range(1, H):
        dp[i][0] = dp[i-1][0] + data[i][0]
    for j in range(1, W):
        dp[0][j] = dp[0][j-1] + data[0][j]

    for i in range(1, H):
        for j in range(1, W):
            dp[i][j] = data[i][j] + min(dp[i-1][j], dp[i][j-1])

    print(dp[-1][-1])




if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7832
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
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.0);
const LL INF = 1000 * 1000 *1000 + 7;
const LL LINF = INF * (LL)INF;


int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	int c = 0;
	LL res = 0;
	FOR (i, 0, n)
	{
		int x;
		scanf("%d", &x);

		if (x)
		{
			if (c) res++, x--;
		}

		c = x % 2;
		res += x / 2;
	}

	cout<<res<<endl;


}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		List<String> array=new ArrayList<>();
		

		Scanner sc=new Scanner(System.in);
		int kuzi=sc.nextInt();
		
		for(int i=0;i<kuzi;i++) {
			array.add(sc.next());
			
		}
		
		List<String> result=new ArrayList<>(new HashSet<>(array));
		
		System.out.println(result.size());

	}
}

Measured memory_bytes: 73640