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

#define endl '\n'

#define abs(a) ((a) < 0? -(a): (a))

// #if defined _WIN32 && !defined ONLINE_JUDGE
// #include <windows.h> //only works on windows
// long TimeBegin = GetTickCount();
// void timer() {cout<<endl<<"*** Execution time: "<<(GetTickCount()-TimeBegin)<<"ms ***"<<endl;}
// #endif

#define s(x) scanf("%d",&x)
#define s2(x,y) scanf("%d %d",&x,&y)
#define sd(x) scanf("%lf",&x)

#define fr(i,s) for(int i=0;i<(s);i++)
#define frl(i,s) for(long long i=0;i<(s);i++)
#define sarr(x,s) for(int i=0;i<(s);i++) scanf("%d",&x[i])

#define pb(x) push_back(x)
#define ppb() pop_back()
#define pf(x) push_front(x)
#define ppf() pop_front()
#define ff first
#define ss second

#ifndef ONLINE_JUDGE  //debugging
#define debug(x) cout<<(#x)<<" = "<<(x)<<endl
void test() {cout<<"meaow"<<endl;}
template <class T1> void test(T1 e) {cout<<"meaow\t"<<e<<endl;}
template <class T1,class T2> void test(T1 e1,T2 e2) {cout<<"meaow\t"<<e1<<"\t"<<e2<<endl;}
template <class T1,class T2,class T3> void test(T1 e1,T2 e2,T3 e3) {cout<<"meaow\t"<<e1<<"\t"<<e2<<"\t"<<e3<<endl;}
template <class T1,class T2,class T3,class T4> void test(T1 e1,T2 e2,T3 e3,T4 e4) {cout<<"meaow\t"<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<endl;}
template <class T1,class T2,class T3,class T4,class T5> void test(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5) {cout<<"meaow\t"<<e1<<"\t"<<e2<<"\t"<<e3<<"\t"<<e4<<"\t"<<e5<<endl;}
#define parr(x,s) for(int i=0;i<(s);i++) {cout<<x[i]<<"\t";} cout<<endl //tab separated
#else
#define debug(x)
void test() {}
template <class T1> void test(T1 e) {}
template <class T1,class T2> void test(T1 e1,T2 e2) {}
template <class T1,class T2,class T3> void test(T1 e1,T2 e2,T3 e3) {}
template <class T1,class T2,class T3,class T4> void test(T1 e1,T2 e2,T3 e3,T4 e4) {}
template <class T1,class T2,class T3,class T4,class T5> void test(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5) {}
#define parr(x, s)
#endif

const int MAX = (int) 1e5 + 5;
const double pi = 3.141592653589793;
const long long inf = std :: numeric_limits <long long> :: max() - 1;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // //freopen("out.txt", "w", stdout);
    // #endif

    int n1, n2;
    bool ans = true;
    char a[200], b[200];
    cin >> a >> b;
    n1 = strlen(a);
    n2 = strlen(b);
    sort(a, a+n1);
    sort(b, b+n2, [](char a, char b){return a > b;});
    for (int i = 0; ; i++)
    {
        if (!b[i] || a[i] > b[i]) {ans = false; break;}
        else if (!a[i] || a[i] < b[i]) {ans = true; break;}
    }
    cout << (ans? "Yes": "No") << endl;

    // #if defined _WIN32 && !defined ONLINE_JUDGE
    // timer();
    // #endif
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	int a=0,n,maxi=0;
	char s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=='I')a++;
		else if(s=='D')a--;
		maxi=max(maxi,a);
	}
	cout<<maxi<<endl;
	return 0;
}

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

int main(){
	
	int n;
	while(cin>>n){
		if(n!=0){
			int ice[10]={0};
			int a;
			for(int i=0;i<n;i++){
				cin>>a;
			ice[a]++;
			}
			for(int i=0;i<10;i++){
			if(ice[i]==0)
				cout<<"-";
			else{
			for(int j=0;j<ice[i];j++)
				cout<<"*";
			}
				cout<<endl;
		}
	}
		else
			break;
	}
}

Measured memory_bytes: 1152
// AOJ CGL_3_A: Area
// 2018.5.2 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG, LINE;

#define INF			1e8
#define EPS			1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)
#define PPeQ(a,b)	(EQ(a.x,b.x)&&EQ(a.y,b.y))

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return hypot(p1.x-p2.x, p1.y-p2.y); };
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }
PP dir(SEG s) { return vsub(s.e, s.s); }

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

double calc_area(int n, PP *pp)
{
   int i;
   double s;

   if (n < 3) return 0;
   for (s = 0, i = 0; i < n; i++) {
      s += (pp[i].x-pp[i+1].x) * (pp[i].y+pp[i+1].y);
   }
   return fabs(s)/2;
}

PP p[103];

int main()
{
	int n, i;

	n = in();
	for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in();
	p[n] = p[0];
	printf("%.1lf\n", calc_area(n, p));
	return 0;
}



Measured memory_bytes: 2128
using System;
using System.Collections.Generic;
using System.Linq;

namespace A
{
    class Program
    {
        class IJ
        {
            public int I { get; set; }
            public int J { get; set; }
        }
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var H = HW[0];
            var W = HW[1];

            var blackList = new List<IJ>();
            var AList = Enumerable.Range(0, H)
                .Select(i =>
                {
                    return Console.ReadLine()
                        .Select((A, j) =>
                        {
                            if (A == '#')
                            {
                                blackList.Add(new IJ() { I = i, J = j });
                            }
                            return A == '#' ? 0 : int.MaxValue;
                        })
                        .ToArray();
                })
                .ToArray();

            var output = 0;
            while (blackList.Any())
            {
                var blackList2 = new List<IJ>();

                foreach (var ij in blackList)
                {
                    var i = ij.I;
                    var j = ij.J;

                    if (i - 1 >= 0 && AList[i - 1][j] > output + 1)
                    {
                        AList[i - 1][j] = output + 1;
                        blackList2.Add(new IJ() { I = i - 1, J = j });
                    }
                    if (i + 1 < H && AList[i + 1][j] > output + 1)
                    {
                        AList[i + 1][j] = output + 1;
                        blackList2.Add(new IJ() { I = i + 1, J = j });
                    }
                    if (j - 1 >= 0 && AList[i][j - 1] > output + 1)
                    {
                        AList[i][j - 1] = output + 1;
                        blackList2.Add(new IJ() { I = i, J = j - 1 });
                    }
                    if (j + 1 < W && AList[i][j + 1] > output + 1)
                    {
                        AList[i][j + 1] = output + 1;
                        blackList2.Add(new IJ() { I = i, J = j + 1 });
                    }
                }

                blackList = new List<IJ>(blackList2);

                output++;
            }

            output--;

            Console.WriteLine(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 58716
S = list(input())

max_len = 0

for i in range(len(S)):
    for j in range(i, len(S)):
        if S[i:j+1][-1] not in ["A", "C", "G", "T"]:
            break
        else:
            max_len = max(max_len, len(S[i:j+1]))
            
print(max_len)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main() {
	ll n, w;
	cin >> n >> w;
	vector<vector<ll>> dp(n + 1, vector<ll> (3 * n + 1,0));
	vector<vector<ll>> qdp;
	ll mo;
	cin >> mo;
	ll v;
	cin >> v;
	dp[1][0] = v;
	for (int i = 2; i <= n; i++) {
		qdp = dp;
		ll we;
		cin >> we>>v;
		we -= mo;
		for (int j = 0; j < i; j++) {
			for (int k = 0; k <= 3 * n-we; k++) {
				dp[j + 1][k + we] = max(dp[j + 1][k + we], qdp[j][k] + v);
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= 3 * n; j++) {
			if (i*mo + j <= w) {
				ans = max(ans, dp[i][j]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int ans = B;
		if(A<6) {
			ans = 0;
		}else if(A<13){
			ans = B/2;
		}
		System.out.println(ans);
		sc.close();
		
	}
}

Measured memory_bytes: 23892
from collections import deque
 
n,m = list(map(int, input().split()))
put = [1]*(n+1)
 
ab = [[] for i in range(n+1)]
for i in range(m):
	a,b = map(int, input().split())
	ab[a].append(b)
	ab[b].append(a)

q = deque([1])
flg = [-1]*n
flg[0] = 0

while q:
	item = q.popleft()
	for i in ab[item]:
		if put[i]:
			flg[i-1]=item
			q.append(i)
			put[i]=0
 
if -1 in flg:
	print("No")
	exit()
 
print("Yes")
for i in range(1,len(flg)):
	print(flg[i])

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

using namespace std;

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b, k;
    cin >> a>> b >> k;

    vector<int> m;
    for (int i = 1; i <= min(a, b); i++){
        if (a % i == 0 && b % i == 0)
            m.push_back(i);
    }
    cout << m[m.size()-k] <<  endl;

    return 0;
}

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

vector<vector<int>> g;
vector<int> dp;

int rec(int node){
  if(dp[node]!=-1) return dp[node];
  if(g[node].size()==0) return 0;
  int maxdis = -1;
  for(int next:g[node]){
    maxdis = max(maxdis,rec(next)+1);
  }
  return dp[node] = maxdis;
}

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

  g.assign(n,vector<int>());
  dp.assign(n,-1);

  for (int i = 0; i < m; i++)
  {
    int x,y;
    cin >> x >> y;
    x--,y--;
    g[x].push_back(y);
  }

  for (int i = 0; i < n; i++)
  {
    rec(i);
  }

  int ans = -1;
  for (int i = 0; i < n; i++)
  {
    ans = max(ans,dp[i]);
  }
  cout << ans << endl;  
}

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

using namespace std;

int main(void) {
    int n, k;

    cin >> n >> k;

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

    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    for (int i = 2; i < n; i++) {
        int menor = INT_MAX;
        for (int j = k; j >= 0; j--) {
            if (i - j >= 0) {
                menor = min(menor, abs(v[i] - v[i - j]) + dp[i - j]);
            }
        }
        dp[i] = menor;
    }

    cout << dp[n - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
  char s[3];
  
  scanf("%s",s);
  
  int i;
  for(i=0;i<3;i++)
  {
    if(s[i]=='7')
    {
      printf("Yes\n");
      return 0;
    }
  }
  
  printf("No\n");
 
  return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<long long> a(n);
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];

  std::priority_queue<long long> pque;
  for (auto v : a)
    pque.push(v);

  for (int j = 0; j < m; ++j) {
    long long val = pque.top();
    pque.pop();
    pque.push(val / 2);
  }

  long long res = 0;
  while (!pque.empty()) {
    res += pque.top();
    pque.pop();
  }

  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 2168
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;

	bool x[26];
	bool y[26];

	int ans = 0;
	for(int i = 1;i <= n-1;i++){
		for(int j = 1;j <= n-1;j++){
			if(i + j > n)continue;
			//cout << i << " " << j << endl;
			for(int k = 0;k < 26;k++){
				x[k] = false;
				y[k] = false;
			}
			for(int k = 0;k < i;k++){
				x[s[k]-'a'] = true;
			}
			for(int k = 0;k < j;k++){
				y[s[n-1-k] - 'a'] = true;
			}
			int cnt = 0;
			for(int k = 0;k < 26;k++){
				if(x[k] == true  && y[k] == true)cnt++;
			}
			//cout << cnt << endl;
			ans = max(ans,cnt);
		}
	}

	cout << ans << endl;
}


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

int main(){
  long long h,w;cin>>h>>w;
  if(h==1||w==1){
    cout<<1<<endl;
    return 0;
  }
  cout<<(h>>1)*(w>>1)+((h+1LL)>>1)*((w+1LL)>>1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n ;
    cin >> n ; 
    cout << 180 * (n-2) << el ; 
    ro ;  
}































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

int main(void){
  string s; cin >> s;
  int fa=0, fb=0, fc=0;
  for(int i=0; i<3; i++){
    if(s.at(i) == 'a') fa = 1;
    if(s.at(i) == 'b') fb = 1;
    if(s.at(i) == 'c') fc = 1;
  }
  if(fa == 1 && fb == 1 && fc == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;             
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <list>
#include <iterator>
#include <unordered_map>	

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long long> vl;

typedef pair<int,int> pi;
typedef pair<double,double> pd;

#define pb push_back
#define pf push_front
#define mp make_pair

#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int uint;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

ll INF = 1e10;
ll MOD = 1e9+7;

ll fast_power(ll base, ll power){
    ll result = 1;
    while(power > 0){
        if(power % 2 == 1)
            result = (result*base) % MOD;
        base = (base * base) % MOD;
        power = power / 2;
    }
    return result;
}

int main(){
	fastio();
	int n;
	cin>>n;
	if (n%2==0)
		cout<<n/2;
	else
		cout<<n/2+1;
	return 0;
}


Measured memory_bytes: 256
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

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

const std::uint_fast64_t MOD = 1e9 + 7;

modint<MOD> factorial(int n) {
  modint<MOD> x(1);
  for (int i = 1; i <= n; i++) {
    x *= modint<MOD>(i);
  }
  return x;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int X, Y;
    cin >> X >> Y;
    int M = 2 * Y - X; int N = 2 * X - Y;
    if (M % 3 != 0 || N % 3 != 0 || M < 0 || N < 0) {
      cout << 0 << endl;
      return 0;
    }
    M /= 3; N /= 3;
    cout << (factorial(N + M) / factorial(N) / factorial(M)).a << endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())
lis = input().split(" ")
# print(lis)

n = 0
G = 0
Y = 0
W = 0
P = 0
for n in range(len(lis)):
    if lis[n] == "G":
        G = 1
    if lis[n] == "Y":
        Y = 1
    if lis[n] == "W":
        W = 1
    if lis[n] == "P":
        P = 1
    n += 1

su = G + Y + W + P
if su == 3:
    print("Three")
else:
    print("Four")


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC157
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            var nm = ReadIntArray();
            var n = nm[0];
            var m = nm[1];

            var digit = Enumerable.Repeat(-1, n).ToArray();

            for (int i = 0; i < m; i++)
            {
                var sc = ReadIntArray();
                var s = sc[0] - 1;
                var c = sc[1];

                if (digit[s] == -1)
                {
                    digit[s] = c;
                    continue;
                }
                else if(digit[s] != c)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            if (n > 1 && digit[0] == 0)
            {
                Console.WriteLine(-1);
                return;
            }

            if (n==1 && digit[0] < 0)
            {
                Console.WriteLine(0);
                return;
            }

            var result = 0;
            if (digit[0] < 0)
            {
                result = 1;
            }
            else
            {
                result = digit[0];
            }
            for (int i = 1; i < n; i++)
            {
                if (digit[i] < 0) digit[i] = 0;
                result = result * 10 + digit[i];
            }
            Console.WriteLine(result);
        }

        #region Console
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
int W, a, b;
 
int main (){
	cin >> W >> a >> b;
	if(a+W<b){
		cout << b-(a+W) << endl;
	}
	else if(b+W<a){
		cout << a-(b+W) << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    int n, m;
    void Solve() {
        //input
        n = io.Int;
        m = io.Int;
        //cal
        var ans = (n - 1) * (m - 1);
        //ret
        WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 11092
import math
A, B, H, M = map(int, input().split())
pi = math.pi

ta = 30*H + 0.5*M
tb = 6*M

t = math.fabs( ta - tb )

if t > 180.0:
    t = 360.0 - t

#print(t)

t = (t*pi)/180.0

ans = A*A + B*B - 2*A*B*math.cos(t)

print("{:.9f}".format(math.sqrt(ans)))







Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  double N, M;
  vector<int> A(100);
  
  cin >> N >> M;
  for (int i = 0; i < 100; i++) {
    cin >> A.at(i);
  }
  
  int Asum = 0;
  for (int i = 0; i < A.size(); i++) {
    Asum += A.at(i);
  }
  
  int n = 0;
  for (int i = 0; i < A.size(); i++) {
    if ( A.at(i) >= Asum / (4 * M) ) {
      n++;
    }
  }
  
  //cout << n << endl;
  
  if (M <= n) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# coding:utf-8
import sys
def main():
    n = int(input())
    h = list(map(int, input().split()))
    count = 0
    loop = 0

    #各数字が偶数であるかを判定する
    while True:
        if h[loop] % 2 != 0:
            print(count)
            sys.exit()
        loop = loop + 1
        #最後の数を判定したら
        if loop == len(h):
            h = list(map( lambda x:x/2, h))
            count = count + 1
            loop = 0

if __name__ == '__main__' :
    main()

Measured memory_bytes: 3060
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
 
 
 
int main()
{
 
    int  N;
    int  N0, N1,N2,N3;
   int f0=0,f1=0,f2=0;
   int ans[8];
   char op0,op1,op2;
   int flag;
  int i;
  // 整数の入力
    scanf("%d", &N);
     N0 = N % 10;
     N1 = (N/10 % 10);
     N2 = (N/100)% 10;
     N3 = N/1000;
 
   ans[0]=N3+N2+N1+N0;
   ans[1]=N3+N2+N1-N0;
   ans[2]=N3+N2-N1+N0;
   ans[3]=N3-N2+N1+N0;
   ans[4]=N3+N2-N1-N0;
   ans[5]=N3-N2-N1+N0;
   ans[6]=N3-N2+N1-N0;
   ans[7]=N3-N2-N1-N0;
  
   for(i=0;i<7;i++)
   {
     if(7 == ans[i]){
       flag = i;
       break;
     }
   }
//        printf("%d\n",flag);
  switch (flag) {
	case 0:
		op0='+';
		op1='+';
		op2='+';
        break;
	case 1:
		op0='+';
		op1='+';
		op2='-';
        break;
	case 2:
		op0='+';
		op1='-';
		op2='+';
        break;
	case 3:
		op0='-';
		op1='+';
		op2='+';
        break;
	case 4:
		op0='+';
		op1='-';
		op2='-';
        break;
	case 5:
		op0='-';
		op1='-';
		op2='+';
        break;
	case 6:
		op0='-';
		op1='+';
		op2='-';
        break;
    case 7:
		op0='-';
		op1='-';
		op2='-';
        break;
	default:
		//printf("others\n");
		break;
}
  
     printf("%d%c%d%c%d%c%d=7\n",N3,op0,N2,op1,N1,op2,N0);
//   if ((f0&f1)||(f1&f2)){
//     printf("Yes\n");
//  }else {
//printf("No\n");
//}
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
//#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL a;
    LL b;
    LL c;
    LL d;
    bool is_ok=false;
    cin >> a >> b >> c >> d;
    LL diff_ab = labs(a-b);
    LL diff_bc = labs(b-c);
    LL diff_ac = labs(a-c);
    if(diff_ac<=d){
        is_ok=true;
    }else if(diff_ab<=d && diff_bc<=d){
        is_ok=true;
    }

    if(is_ok==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
using System;
class Program
{
  static void Main(string[] args)
  {
    // 入力値を取得
    int n = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    
    double sum = 0.0;
    for (int i = 0; i < n; i++) {
      sum += 1 / double.Parse(input[i]);
    }
    Console.WriteLine(1 / sum);
  }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
    int n, r, i;
    scanf("%d", &n);
    for(i = 1; i <= 3; i++){
        r = n % 10;
        n = n / 10;
        if(r == 7){
            printf("Yes");
            break;
        }
        if(i == 3){
            printf("No");
        }
    }

    return 0;
}

Measured memory_bytes: 1732
#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>;

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      ret.push_back(i);
      if(i != 1 && i*i != n) {
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

bool isprime(ll x) {
  ll i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> vec = enum_div(n);
  vec.push_back(n);
  ll ans = LLONG_MAX;
  rep(i, vec.size()) {
    ll m = vec.at(i) + n/vec.at(i) - 2;
    ans = min(ans, m);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
a = list(map(int, input()))

n = len(a)
o_odd = 0
o_even = 0
for i in range(n):
    if i % 2 == 0 and a[i] == 1:
        o_odd += 1
    elif i % 2 == 1 and a[i] == 1:
        o_even += 1

z_even = int(n / 2 - o_even)
z_odd = round(n / 2 - o_odd + 0.1)

f_o = z_odd + o_even
f_z = z_even + o_odd

print(min(f_o, f_z))

Measured memory_bytes: 3956
#include <stdio.h>

int main(void) {
  int n,i;
  double x[10];
  char y[10][4];
  double ans=0;

  scanf("%d",&n );

  for ( i = 0; i < n; i++) {
    scanf("%lf %s" ,&x[i],y[i] );
  }
  

  for ( i = 0; i<n; i++) {
    if (y[i][0]=='J'&&y[i][1]=='P'&&y[i][2]=='Y') {
      ans=ans+x[i];
    }
    if (y[i][0]=='B'&&y[i][1]=='T'&&y[i][2]=='C') {
      ans=ans+(x[i]*380000);
    }
  
  }


printf("%f\n",ans );

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

const int N = int(2e5) + 10;

ll n, x, d;
ll pref[N], suff[N];
map<ll, ll> series_from;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	cin >> n >> x >> d;

	if (d == 0) {
		if (x == 0) cout << 1 << endl;
		else cout << n + 1 << endl;
		return 0;
	}

	if (d < 0) {
		x += d * (n - 1);
		d *= -1;
	}

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

	vector<pair<ll, ll>> seriesv(n + 1);

	for (int i = 0; i <= n; i++) {
		ll add = x * (i - (n - i));
		ll L = d * (pref[i] - suff[n - i]);
		ll R = d * (suff[i] - pref[n - i]);

		seriesv[i] = make_pair(add + L, add + R);
	}

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

	ll ans = 0LL;
	d *= 2;

	for (pair<ll, ll> p : seriesv) {
		ll l = p.x, r = p.y;
		ll rem = (l % d + d) % d;

		ll R = LLONG_MIN;
		if (series_from.find(rem) != series_from.end()) {
			R = series_from[rem];
		}

		if (R < r) {
			l = max(l, R + d);
			ans += (r - l + d) / d;
			series_from[rem] = r;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

bool comp(pair<int,int> a, pair<int, int> b)
{
	return a.second<b.second;
}

void solve()
{
	int n;
	cin>>n;
	vector<pair<int,int>> a(n), b(n);
	for (int i=0; i<n; i++) {
		cin>>a[i].first >> a[i].second;
		b[i].first = a[i].first;
		b[i].second = a[i].second;
	}	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end(), comp);
	int l,r;
	if (n&1) {
		l = a[n/2].first;
		r = b[n/2].second;
	}
	else {
		l = a[n/2-1].first + a[n/2].first;
		r = b[n/2-1].second + b[n/2].second;
	}
	cout << r-l+1 << "\n";
}

int main()
{
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6324
n = int(input())
s = input()
MOD = 10 ** 9 + 7
a = ord('a')
rec = [0] * 26
for i in range(n):
    rec[ord(s[i]) - a] += 1

num = 1
for i in range(26):
    if rec[i] != 0:
        num *= rec[i] + 1
        num %= MOD

print(num - 1)

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n > k) {
        cout << x * k + y * (n - k) << endl;
    } else {
        cout << x * n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int cnt[10] = {
  3, 5, 5, 5, 5, 5, 5, 5, 3, 5
};

int dp[10][100 * 1000 + 1];
char buff[100* 1000 + 10];
const int mod = 100000007;

int main(){
  REP(i,10){
    dp[i][0] = 1;
    REP(j,100 * 1000 + 1){
      dp[i][j+1] = dp[i][j] * 2;
      if(j + 1 > cnt[i]) dp[i][j+1] += mod - dp[i][j-cnt[i]];
      dp[i][j+1] %= mod;
    }
  }

  while(scanf("%s", buff), buff[0] != '#'){
    long long ans = 1;
    int i = 0;
    while(isdigit(buff[i])){
      char now = buff[i]; 
      int cc = 0;
      while(buff[i] == now){ cc++; i++; }
      // printf("cc: %d now: %c\n", cc, now);
      ans = (ans * dp[now - '0'][cc - 1]) % mod;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4900
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sqr(a) ((a) * (a))
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define co() cout.precision(10);
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<endl;
#define nec cout<<endl;continue;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define test int t;cin>>t;while(t--)
//memset(arr, 0, sizeof arr);
typedef long long li;
typedef long double ld;
 
const li mod = 1000000007;
 
int main()
{ 
io();
string s;
cin>>s;
if(s[s.length()-1]=='s')
s+="es";
else
s+="s";
cout<<s;
}

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

string S;
int N;
int out[100005];

int main() {
  cin >> S;
  N = S.size();
  int cnt=1;
  char pre='R';
  int l_st;
  for(int i=1; i<N; i++) {
    if(S[i] == pre) cnt++;
    else{
      if(S[i]=='R') {
        out[l_st] += (cnt+1)/2;
        out[l_st-1] += cnt/2;
      } else {
        out[i-1] += (cnt+1)/2;
        out[i] += cnt/2;
        l_st = i;
      }
      cnt=1;
    }
    pre = S[i];
  }
  out[l_st] += (cnt+1)/2;
  out[l_st-1] += cnt/2;
  rep(i, N){
    printf("%d ", out[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 1024
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}

const int maxN = 3005;
int n, m;
int tp[maxN];
int mx[maxN];
int l[maxN], r[maxN];
int inv[maxN], fact[maxN], invfact[maxN];

void init() {
    fact[0] = fact[1] = invfact[0] = invfact[1] = inv[1] = 1;
    for (int i = 2; i < maxN; i++) {
        fact[i] = mult(fact[i - 1], i);
        inv[i] = mult(inv[mod % i], mod - mod / i);
        invfact[i] = mult(invfact[i - 1], inv[i]);
    }
}

int cnk(int a, int b) {
    if (a < b || b < 0) return 0;
    return mult(fact[a], mult(invfact[a - b], invfact[b]));
}

int dp[maxN][maxN];
int pref[maxN];

int ones(int l, int r) {
    return pref[r] - pref[l - 1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    init();
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        char c;
        cin >> c;
        tp[i] = c - '0';
    }
    for (int i = 1; i <= m; i++) {
        cin >> l[i] >> r[i];
        mx[l[i]] = max(mx[l[i]], r[i]);
    }
    int cur_max = 0;
    for (int i = 1; i <= n; i++) {
        if (cur_max >= mx[i]) {
            mx[i] = 0;
        }
        cur_max = max(cur_max, mx[i]);
    }
    m = 0;
    for (int i = 1; i <= n; i++) {
        if (mx[i] != 0) {
            m++;
            l[m] = i;
            r[m] = mx[i];
        }
    }
    assert(m != 0);
    for (int i = 1; i <= n; i++) {
        pref[i] = pref[i - 1] + tp[i];
    }
    dp[1][ones(l[1], r[1])] = 1;
    /*for (int i = 0; i <= n; i++) {
        cout << dp[1][i] << " ";
    }
    cout << endl;*/
    for (int i = 1; i + 1 <= m; i++) {
        if (l[i + 1] > r[i]) {
            int will = ones(l[i + 1], r[i + 1]);
            int tot = r[i] - l[i] + 1;
            for (int j = 0; j <= tot; j++) {
                dp[i + 1][will] = sum(dp[i + 1][will], mult(dp[i][j], cnk(tot, j)));
            }
        }
        else {
            int tot = r[i] - l[i] + 1;
            for (int j = 0; j <= tot; j++) {
                if (dp[i][j] == 0) continue;
                for (int ones_here = 0; ones_here <= l[i + 1] - l[i] && ones_here <= j; ones_here++) {
                    int coef = cnk(l[i + 1] - l[i], ones_here);
                    int will_ones = ones(r[i] + 1, r[i + 1]);
                    if (j - ones_here > r[i] - l[i + 1] + 1) continue;
                    dp[i + 1][j - ones_here + will_ones] = sum(dp[i + 1][j - ones_here + will_ones], mult(dp[i][j], coef));
                }
            }
        }
    }
    int tot = 0;
    for (int i = 0; i <= n; i++) {
        tot = sum(tot, mult(dp[m][i], cnk(r[m] - l[m] + 1, i)));
    }
    cout << tot;
    return 0;
}

Measured memory_bytes: 15360
import sys
H, W = map(int, input().split())
s = ['.'*(W+2)]
for i in range(H):
    s.append('.' + input() + '.')
s.append('.'*(W+2))
for i, x in enumerate(s):
    for j, y in enumerate(x):
        if s[i][j] == '#':
            if s[i+1][j] == '#' or s[i-1][j] == '#' or s[i][j+1] == '#' or s[i][j-1] == '#':
                continue
            else:
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n, k;
long int s;
int main() {
    cin >> n >> k >> s;
    int a[n];
    if (s != 1000000000) {
        for (int i = 0; i < n; i++) {
            if (i < k) {
                a[i] = s;
            } else {
                a[i] = s + 1;
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (i < k) {
                a[i] = s;
            } else {
                a[i] = 1;
            }
        }
    }
    string s;
    for (int i = 0; i < n; i++) {
        s += to_string(a[i]);
        s += ' ';
    }
    cout << s << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  vector<int64_t> A(n);
  for(int i=0;i<n;++i)cin>>A[i];
  int64_t res=0,sum=A[0]+A[1];
  for(int i=2;i<n;++i)res^=A[i];
  if(sum<res){
    cout<<-1;
    return 0;
  }
  sum-=res;
  if(sum&1ll){
    cout<<-1;
    return 0;
  }
  sum/=2;
  if(sum>A[0]){
    cout<<-1;
    return 0;
  }
  for(int i=0;i<60;++i)if((res>>i&1ll)&&(sum>>i&1ll)){
    cout<<-1;
    return 0;
  }
  for(int i=60;i>=0;--i)if(res>>i&1ll){
    if(sum+(1ll<<i)<=A[0]){
      sum+=(1ll<<i);
    }
  }
  if(sum==0){
    cout<<-1;
    return 0;
  }
  cout<<A[0]-sum<<'\n';
  
  
  return 0;
}
//2020.06.27 21:02:02


Measured memory_bytes: 3576
#include <iostream>

using namespace std;

int main(){

	int a,b;

	cin >> a >> b;

	int sum = a + b;
	int mul = a * b;
	int sub = a - b;

	if(sum >= mul && sum >= sub){
		cout << sum << endl;
	}
	else if(mul >= sum && mul >= sub){
		cout << mul << endl;
	}
	else if(sub >= sum && sub >= mul){
		cout << sub << endl;
	}
	else{
		cout << mul << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
main=print.solve=<<B.getLine
solve=(\(_,_,_,c)->c).B.foldl f(1,0,0,0)
f(r,a,b,c)v=case v of
  'A'->(r, g$a+r, b, c)
  'B'->(r, a, g$b+a, c)
  'C'->(r, a, b, g$c+b)
  '?'->(g$r*3, g$a*3+r, g$b*3+a, g$c*3+b)
g x=x`mod`(10^9+7)

Measured memory_bytes: 34248
n,m = map(int, input().split())
ab= [list(map(int, input().split())) for i in range(m)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):

        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 

        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y

            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def Output(self):
        return [i for i in self.root if i < 0]

uf = UnionFind(n)
for i in ab:
    uf.Unite(i[0],i[1])

a = [-1 * i for i in uf.Output()]
del a[0]
print(max(a))

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

int main() {
  long long x;
  cin >> x;
  long long mon = 100;
  long long r;
  int y = 0;
  while ( mon < x ) {
    y++;
    r = mon/100;
    mon += r;
  }
  cout << y << endl;
  return 0;
}


Measured memory_bytes: 3612
import numpy as np

N = int(input())
numbers = [int(input()) for _ in range(N)]

M = 998244353
count_all = (3 ** N - 3 * (2 ** N - 2) - 3) % M

S = sum(numbers)
count3 = np.zeros((N, S + 1), dtype=np.int64)
count3[0, 0] = 2
count3[0, numbers[0]] = 1
count2 = np.zeros((N, S + 1), dtype=np.int64)
count2[0, 0] = 1
count2[0, numbers[0]] = 1

for i in range(1, N):
    count3[i, numbers[i]:] += count3[i - 1, :-numbers[i]]
    count3[i, :] += 2 * count3[i - 1, :]
    count3[i, :] %= M
    count2[i, numbers[i]:] += count2[i - 1, :-numbers[i]]
    count2[i, :] += count2[i - 1, :]
    count2[i, :] %= M

invalid_from = S // 2 + 1
if (S % 2 == 0):
  invalid_from = S // 2
count_invalid = np.sum(count3[N - 1, invalid_from:-1]) - 2 * np.sum(count2[N - 1, invalid_from:-1])
count_invalid %= M

print((count_all - 3 * count_invalid) % M)


Measured memory_bytes: 432316
#include<stdio.h>

int n,a,i,l,r,ans;

int main(){
  scanf("%d",&n);
  while(n>0){
    n--;
    
    l=0;
    r=0;
    ans=0;
    for(i=0;i<10;i++){
      scanf("%d",&a);
      if(l<a)l=a;
      else if(r<a)r=a;
      else ans=1;
    }

    if(ans==0)printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 580
import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        long[] arr = new long[n];
        long t = 0;

        for (int i=0; i<n; i++) {
            arr[i] = sc.nextLong();
            t ^= arr[i];
        }

//        long[] res = new long[n];
//
//        for (int i=0; i<n-1; i++) {
//            res[i+1] = arr[i];
//        }
//        res[0] = arr[n-1];

        for (int i=0; i<n; i++) System.out.print((arr[i]^t) + " ");

//        System.out.println(t);

//        System.out.print(11 ^ 9 ^ 24);

    }
}


Measured memory_bytes: 63024