akhauriyash/Code-Regression huggingface dataset:
for i in range(10**5):
    s = input().split()
    if s[1] == "?":
        break
    else:
        if s[1] == "+":
            S = int(s[0])+int(s[2])
        elif s[1] == "-":
            S = int(s[0])-int(s[2])
        elif s[1] == "*":
            S = int(s[0])*int(s[2])
        elif s[1] == "/":
            S = int(s[0])//int(s[2])
        print(S)


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100000,vector<ll>(3,0));
ll ans[100000];
int main(){
  string s;
  cin >> s;
  ll n=s.size();
  ll tmp=0;
  memset(ans,0,sizeof(ans));
  // MSG(n);
  rep(i,n){
    if(s[i] == 'R'){
      tmp++;
    }else{
      ans[i] += tmp/2;
      ans[i-1] += tmp/2+tmp%2;
      tmp=0;
    }
  }
  // rep(i,n){
  //   cout << ans[i] << " ";
  // }
  // cout << endl;
  tmp=0;
  rep(i,n){
    if(s[n-1-i] == 'L'){
      tmp++;
    }else{
      ans[n-1-i] += tmp/2;
      ans[n-i] += tmp/2+tmp%2;
      tmp=0;
    }
  }
  rep(i,n){
    cout << ans[i] << " ";
  }
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		if(A<10 && B<10) {
			System.out.println(A*B);
		}else {
			System.out.println(-1);
		}
	}

}

Measured memory_bytes: 23764
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
int main()
{
  int x,y;
  scanf("%d %d",&x,&y);
  x += y;
  if((x&1)==1){ x++; }
  printf("%d\n",(x/2));
  return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  int n, m;
  vector<long> a, b, c, d;
  cin >> n >> m ;
  for(int i = 0; i < n; i++) {
    long tmp_a, tmp_b;
    cin >> tmp_a >> tmp_b;
    a.push_back(tmp_a);
    b.push_back(tmp_b);
  }

  for(int j = 0; j < m; j++) {
    long tmp_c, tmp_d;
    cin >> tmp_c >> tmp_d;
    c.push_back(tmp_c);
    d.push_back(tmp_d);
  }

  for(int i = 0; i < n; i++) {
    long min_diff = abs(a[i]-c[0]) + abs(b[i]-d[0]);
    int check_point = 0;
    for(int j = 1; j < m; j++) {
      long next_check_point = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(next_check_point < min_diff) {
        min_diff = next_check_point;
        check_point = j;
      }
    }
    cout << check_point + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	std::string s = to_string(n);
	int b = s.size();
	string t;
	for (int i = 0;i < b-2;i++) {
		t = t + "0";
	}
	string x = "1" + t;
	int a = stoi(x);
	int c = n - a;
	string h = to_string(a);
	string j = to_string(c);
	int y = h.size();
	int u = j.size();
	int count1 = 0, count2 = 0;
	for (int f = 0;f < y;f++) {
		count1 = a % 10 + count1;
		a = a / 10;
	}
	for (int e = 0;e < u;e++) {
		count2 = c%10 + count2;
		c = c / 10;
	}
	cout << count1+count2;
}


Measured memory_bytes: 256
pos = [0,0]
deg = 90
until (n = gets.chomp.split(',').map(&:to_i)) == [0,0]
    pos[0] = pos[0] + Math.sin(Math::PI*deg/180) * n[0]
    pos[1] = pos[1] + Math.cos(Math::PI*deg/180) * n[0]

    deg -= n[1]
end

puts pos[1].to_i, pos[0].to_i

Measured memory_bytes: 6168
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int re=0;
  for(int i=0;i<n;i++)
  {
    re=10*re+7;
    re=re%n;
    if(re==0)
    {
      cout<<i+1;
      return 0;
    }
}
  cout<<-1;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n;

  cin >> n;

  vector<int> a(n+1);

  for (int i = 1; i < (n+1); i++) { 
scanf("%d", &a[i]);
  }

  vector<int> b(n+1);
  bool ok = true;

  int cnt = 0;
  for(int i = n; i>=1; i--) {
    int sm = 0;
    for(int j = i*2; j <= n; j+=i) {
      sm += b[j];
    }
    if(a[i]%2 != sm%2) {
      b[i] = 1;
      cnt++;
    }
  }

  cout << cnt << endl;
  rep(i, n+1) {
    if(b[i]) {
      cout << i;
      cnt--;
      if (cnt) {
        cout << " ";
      } else {
        cout << endl;
      }
    }
  } 
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
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;}

const int INF=INT_MAX-1;
int N;
int X[222222],Y[222222];

int acc[555555];
signed main(){
    cin>>N;
    rep(i,N)cin>>X[i]>>Y[i];
    rep(i,N)if(X[i]>Y[i])swap(X[i],Y[i]);

    int latte=*max_element(X,X+N)-*min_element(X,X+N);
    int malta=*max_element(Y,Y+N)-*min_element(Y,Y+N);

    int ans=latte*malta;
    vint lis;
    rep(i,N){
        lis.pb(X[i]);
        lis.pb(Y[i]);
    }
    sort(all(lis));lis.erase(unique(all(lis)),lis.end());

    latte=max(*max_element(X,X+N),*max_element(Y,Y+N));
    malta=min(*min_element(X,X+N),*min_element(Y,Y+N));

    rep(i,N){
        int x=lower_bound(all(lis),X[i]+1)-lis.begin();
        int y=lower_bound(all(lis),Y[i]+1)-lis.begin();
        chmax(acc[0],X[i]);
        chmax(acc[x],Y[i]);
        chmax(acc[y],INF);
    }
    rep(i,lis.size())chmax(acc[i+1],acc[i]);
    rep(i,lis.size())chmin(ans,(acc[i]-lis[i])*(latte-malta));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12012
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
using P = pair<int, int>;

int main(){
    int h1, w1, m;
    cin >> h1 >> w1 >> m;
    vector<int> h(m), w(m);
    for(int i = 0; i < m; i++) cin >> h[i] >> w[i];

    vector<P> memoh(h1+1), memow(w1+1);
    for(int i = 0; i <= h1; i++) memoh[i] = make_pair(0, i);
    for(int i = 0; i <= w1; i++) memow[i] = make_pair(0, i);
    vector<map<int, int>> memoh2(h1+1), memow2(w1+1);
    for(int i = 0; i < m; i++){
        memoh[h[i]].first++;
        memoh2[h[i]][w[i]] = 1;
        memow[w[i]].first++;
        memow2[w[i]][h[i]] = 1;
    }

    sort(memoh.begin(), memoh.end(), greater<P>());
    sort(memow.begin(), memow.end(), greater<P>());
    int ans = -1;
    int maxhnum = memoh[0].first;
    int maxwnum = memow[0].first;

    vector<int> maxh_ind, maxw_ind;
    for(int i = 0; i < h1; i++){
        if(memoh[i].first != maxhnum) break;
        maxh_ind.push_back(memoh[i].second);
    }
    for(int i = 0; i < w1; i++){
        if(memow[i].first != maxwnum) break;
        maxw_ind.push_back(memow[i].second);
    }

    for(int i = 0; i < maxh_ind.size(); i++){
        for(int j = 0; j < maxw_ind.size(); j++){
            if(!(memoh2[maxh_ind[i]].count(maxw_ind[j])
            && memow2[maxw_ind[j]].count(maxh_ind[i]))){
                ans = maxhnum+maxwnum;
                break;
            }
        }
    }
    if(ans == -1) ans = maxhnum+maxwnum-1;
    cout << ans << endl;
    return 0;
}

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

int main(void){
    long n,ans,a,r,c,h,m;
    a = r = c = h = m = 0;
    string b;
    cin >> n;
    for(int i = 0;i < n;i ++){
        cin >> b;
        if(b[0] == 'A')a ++;
        else if(b[0]=='R')r ++;
        else if(b[0]=='C')c ++;
        else if(b[0]=='M')m ++;
        else if(b[0]=='H')h ++;
    }

    cout << a*r*c + a*r*m + a*r*h + a*c*m + a*c*h + a*m*h + r*c*m +r*c*h + r*m*h + c*m*h << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static boolean[] prime = new boolean[1000001];
	static int n;
	public static void main(String[] args) {
		eratosthenes();
		while(read()){
			solve();
		}
	}
	
	static void eratosthenes(){
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		
		for(int i = 2; i < prime.length; i++){
			if(prime[i]){
				for(int j = 2*i; j < prime.length; j += i){
					prime[j] = false;
				}
			}
		}
	}
	
	static boolean read(){
		if(!sc.hasNextInt())return false;
		
		n = sc.nextInt();
		return true;
	}
	
	static void solve(){
		int res = 0;
		for(int i = 2; i <= n; i++){
			if(prime[i])res++;
		}
		System.out.println(res);
	}

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
vector<int> g[MAXN];
int val[MAXN];
inline void dfs(int pos,int prev)
{
	for(int i=0;i<g[pos].size();i++)
	{
		if(g[pos][i]!=prev)
		{
			dfs(g[pos][i],pos);
		}
	}
	int nval=0;
	for(int i=0;i<g[pos].size();i++)
	{
		if(g[pos][i]!=prev)
		{
			nval=nval^(val[g[pos][i]]+1);
		}
	}
	val[pos]=nval;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1,0);
	if(g[1].size()==1)
	{
		cout<<"Alice\n";
	}
	else
	{
		if(val[1])
		{
			cout<<"Alice\n";
		}
		else
		{
			cout<<"Bob\n";
		}
	}
	// for(int i=1;i<=n;i++)
	// {
	// 	cout<<val[i]<<"\n";
	// }
}

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

int h, w;
char ch[100 + 2][100 + 2];

int main(){
	cin >> h >> w;
	for(int i = 0; i < h + 2; i++){
		for(int j = 0; j < w + 2; j++){
			ch[i][j] = '#';
		}
	}

	for(int i = 1; i < h + 1; i++){
		for(int j = 1; j < w + 1; j++){
			char input;
			cin >> input;
			ch[i][j] = input;
		}
	}

	for(int i = 0; i < h + 2; i++){
		for(int j = 0; j < w + 2; j++){
			cout << ch[i][j];
			if(j == w + 1) cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

string s;

int convert(string x){
    return 10*(x[0]-'0')+(x[1]-'0');
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> s;
    int a = convert(s.substr(0, 2));
    int b = convert(s.substr(2, 2));
    bool valid1=false;
    bool valid2=false;
    if(a >= 1 && a <= 12){
        if(b >= 1 && b <= 12){
            cout << "AMBIGUOUS" << el;
        } else {
            cout << "MMYY" << el;
        }
    } else {
        if(b >= 1 && b <= 12){
            cout << "YYMM" << el;
        } else {
            cout << "NA" << el;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define FOR(x,y) for(int i=x; i<y; ++i)
#define FORR(x,y) for(int i=y-1; i>=x; i--)

using namespace std;

int main() {
    long long n; cin >> n;
    vector<long long> arr(n),b(n);
    FOR(0,n){
        cin >> arr[i];
        b[i] = arr[i] - (i+1);
    }
    
    
    sort(b.begin(),b.end());
    long long s = b[n/2];
    long long sumS = 0;
    
    FOR(0,n){
        sumS += abs(arr[i] - (s + i + 1));
    }
    cout << sumS << endl;
  return 0;
}


Measured memory_bytes: 6408
use std::io;

fn get_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

fn main() {
    let hoge = get_line();
    let fuga = get_line();
    let nk: Vec<usize> = hoge.trim().split(" ").map(|x| x.parse().unwrap()).collect();
    let mut ls: Vec<u32> = fuga.trim().split(" ").map(|x| x.parse().unwrap()).collect();
    ls.sort_by(|a, b| b.cmp(a));
    println!("{}", ls[0..nk[1]].iter().sum::<u32>());
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main() {
  int N;
  cin >> N;
  int P[200010];
  rep(i,N) cin >> P[i];
  
  priority_queue<int, vector<int>, greater<int>> que;
  
  int ans =0;
  
  rep(i,N){
    que.push(P[i]);
    if(que.top()>=P[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2168
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] list = new int[n];
		int tmp;
		int minj = 0;
		int count = 0;
		for(int i = 0;i<n;i++){
			list[i] = sc.nextInt();
		}
		for(int i = 0;i<n;i++){
			minj = i;
			for(int j = i;j<n;j++){
				if(list[j] < list[minj]){
					minj = j;
					
				}
			}
			if(list[i] != list[minj]){
				tmp = list[i];
				list[i] = list[minj];
				list[minj] = tmp;
				count += 1;
			}
			
		}
		for(int i = 0;i < n;i++){
			System.out.print(list[i]);
			if(i != (n-1)){
				System.out.print(" ");
			}else{
				System.out.println();
			}
		}
		System.out.println(count);
	
	}
}


Measured memory_bytes: 26468
import sys
input = sys.stdin.readline
params = list(map(int, input().split()))
result_parse = lambda x:[int(x[0]),x[1]]
results = [result_parse(input().split()) for i in range(params[1])]
fails = [0]*params[0]
suceeds = [False]*params[0]
for result in results:
    index = result[0]-1
    if result[1] == 'AC':
        suceeds[index] = True
    elif suceeds[index] is False:
        fails[index] += 1
fails = sum(fails[i]*suceeds[i] for i in range(params[0]))
print(str(sum(suceeds)) + ' ' + str(fails))

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> mat(H,vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> mat.at(i).at(j);
    }
  }
  for(int i=0; i<H; i++){
    bool color = 0;
    for(int j=0; j<W;j++){
      if(mat.at(i).at(j) == '#'){
        color = 1;
      }
    }
    if(!color){
      for(int k=i; k<H-1; k++){
        for(int j=0; j<W; j++){
          mat.at(k).at(j) = mat.at(k+1).at(j);
        }
      }
      H--;
      i--;
    }
  }

  for(int j=0; j<W; j++){
    bool color = 0;
    for(int i=0; i<H; i++){
      if(mat.at(i).at(j) == '#'){
        color = 1;
      }
    }
    if(!color){
      for(int k=j; k<W-1; k++){
        for(int i=0; i<H; i++){
          mat.at(i).at(k) = mat.at(i).at(k+1);
        }
      }
      W--;
      j--;
    }
  }
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W-1; j++){
      cout << mat.at(i).at(j);
    }
    cout << mat.at(i).at(W-1) << endl;
  }
}

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

int main() {
	string s;
	cin>>s;
	int a=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(s[j]==s[i])
			a++;
		}
	}
	if(a==8)
	cout<<"Yes";
	else 
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		Arrays.sort(a);
		for(int i=0;i<n-1;i++) {
			if(a[i+1]==a[i]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 51368
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll x;
    cin >> x;
    ll num = 100;
    ll cnt = 0;
    while(1) {
        if ( num >= x ) {
            cout << cnt << endl;
            return 0;
        }
        num += num / 100;
        ++cnt;
    }
    return 0;
}


Measured memory_bytes: 3596
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

a,b,c=MI()
ans=a*b//2
print(ans)
    
        


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,P;
  cin >> N >> P;

  vector<long long> A(N),num(6000,0);
  long long s = 0;
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
    s += A.at(i);
  }

  num.at(0) = 1;
  for(int i = 0;i < N;i++) {
    for(int j = s;j >= 0;j--) {
      if(j < A.at(i)) break;
      if(num.at(j-A.at(i))) num.at(j) += num.at(j-A.at(i));
    }
  }

  long long sum = 0;
  for(int i = 0;i <= s;i++) {
    if(i%2==P) sum += num.at(i);
  }

  cout << sum << endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;


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

  string S; cin >> S;

  int64_t ans = -inf;
  int64_t k = 0;

  rep(i, (int)S.size()) {
    if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') k++;
    else k = 0;
    ans = max(ans, k);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int mx[]={-1,0,1,0};
int my[]={0,-1,0,1};

int main(){
	int N;
	while(cin>>N,N){
		vector<pair<int,int>>v(N);
		v[0]=make_pair(0,0);
		for(int i=1;i<N;++i){
			int n,d;
			cin>>n>>d;
			v[i]=make_pair(v[n].first+mx[d],v[n].second+my[d]);
		}
		int min_x=1e9,max_x=-1e9;
		int min_y=1e9,max_y=-1e9;
		for(int i=0;i<N;++i){
			max_x=max(v[i].first,max_x);
			min_x=min(v[i].first,min_x);
			max_y=max(v[i].second,max_y);
			min_y=min(v[i].second,min_y);
		}
		cout<<max_x-min_x+1<<" "<<max_y-min_y+1<<endl;
	}
}

Measured memory_bytes: 2992
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
typedef long long LL;
const int MAXN = 200000;
const LL INF = 1LL << 50;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, a[MAXN + 5];
LL pre[MAXN + 5];

void init() {
  //enableFileIO();

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

LL getSum(int x, int y) {
  return pre[y] - pre[x - 1];
}
LL fabs(LL x) {
  return x > 0 ? x : -x;
}

int main() {
  init();

  int l = 1, r = 3;
  LL ans = INF;
  for (int i = 2; i < n - 1; ++i) {
    while (l + 1 < i && fabs(getSum(l + 2, i) - pre[l + 1]) < 
           fabs(getSum(l + 1, i) - pre[l])) ++l;
    while (r + 1 < n && fabs(getSum(r + 2, n) - getSum(i + 1, r + 1)) < 
           fabs(getSum(r + 1, n) - getSum(i + 1, r))) ++r;

    LL sum1 = pre[l], sum2 = getSum(l + 1, i);
    LL sum3 = getSum(i + 1, r), sum4 = getSum(r + 1, n);
    LL mx = max(max(sum1, sum2), max(sum3, sum4));
    LL mn = min(min(sum1, sum2), min(sum3, sum4));
    ans = min(ans, fabs(mx - mn));
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
const LL MOD = 1000000007LL;
LL comb[1001][1001];
LL inv_fact[1001];
LL dp[1001][1001];
LL mod_pow(LL a, LL n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		LL b = mod_pow(a, n / 2);
		return (b*b) % MOD;
	}
	return (a*mod_pow(a, n - 1)) % MOD;
}
int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	comb[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < N; j++) {
			comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
		}
	}
	inv_fact[0] = 1;
	for (int i = 1; i <= N; i++) {
		inv_fact[i] = inv_fact[i - 1];
		(inv_fact[i] *= mod_pow(i, MOD - 2)) %= MOD;
	}
	dp[A - 1][0] = 1;
	for (int k = A; k <= B; k++) {
		for (int n = 0; n <= N; n++) {
			LL y = 1;
			for (int x = 0; x <= n / k; x++) {
				if (x > 0) (y *= comb[n - k*(x - 1)][k]) %= MOD;
				if (x == 0 || (C <= x && x <= D)) {
					LL add = y;
					(add *= dp[k - 1][n - k*x]) %= MOD;
					(add *= inv_fact[x]) %= MOD;
					(dp[k][n] += add) %= MOD;
				}
			}
		}
	}
	cout << dp[B][N] << endl;
}

Measured memory_bytes: 15872
using System;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] H = new int[N];
        for (int i = 0; i < N; i++)
            H[i] = int.Parse(input[i]);
        int Max = 0;
        int c = 0;
        for (int i = 0; i < N; i++)
        {
            if (H[i] >= Max)
            {
                Max = H[i];
                c++;
            }
        }
        Console.WriteLine(c);
    }
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n, k;

int main() {
	read(n), read(k);
	if (k == 1) {
		print(0);
	} else {
		print(n - k);
	}
}


Measured memory_bytes: 3608
N ,A,B  =list(map(int,input().split(" ")))
N - 2
ab = A+B

if  A > B : #異常値
    print(0)

elif N == 1 :
    if A==B:
        print(1)
    else:
        print(0)
elif N==2:
    print(1)
else:
    minsum = (N-2) * A + ab
    maxsum = (N-2) * B + ab

    print(maxsum - minsum + 1)

Measured memory_bytes: 38256
n=int(input())
x=list(map(int,input().split()))



min_i = [x[0]]

for i in range(1,n):
    min_i.append(min(min_i[i-1],x[i]))

count=0
for i in range(1,n):
    if min_i[i-1] < x[i]:
        count=count+1
#  if x[i-1]>=x[i]:
#    count=count+1
    
#if min(x)==x[n-1]:
#  count=count+1
print(n-count)


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

int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;
  int sum = 0;
  for(int i = 0; i < S.size(); i++) {
      if(S[i] == '1') sum++;
      else break;
  }

  if(sum >= K) cout << "1";
  else cout << S[sum];

  
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, const char* argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    int X;
    cin >> X;
    if (X < 30) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

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

    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,w,a,b;
    cin>> h>>w >> a >>b;
    cout << (h-a)*(w-b);
    

    return 0;
}

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

int main() {
  long long int n,k;
  cin>>n>>k;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n-k;i++){
    if(a[i]<a[i+k]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  
}


Measured memory_bytes: 5192
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
 
using namespace std;
 
int32_t main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	string s;
	cin>>s;
	int len=s.length();

	int sum=0;
	for(int i=0;i<len;i++){
		sum=sum + (s[i]-'0');
	}
	sum=sum%3;
	if(sum)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

	return 0;
}


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

using modint = atcoder::modint998244353;

vector<modint> p10, p10s;

struct S{
	modint val;
	int l, r;
	S(){}
	S(modint val, int l, int r):val(val), l(l), r(r){}
};
using F = int;
S op(S a, S b){ return S(a.val+b.val, min(a.l, b.l), max(a.r, b.r)); }
S e(){ return S(0, 1e9, -1e9); }
S mapping(F f, S x){
	if(f) x.val = f * (p10s[x.r] - p10s[x.l]);
	return x;
}
F composition(F f, F g){ return f ? f : g; }
F id(){ return 0; }

int main(){
	int N, Q;
	cin >> N >> Q;
	p10.resize(N, 1);
	p10s.resize(N+1);
	for(int i=N-2; i>=0; i--) p10[i] = p10[i+1] * 10;
	for(int i=0; i<N; i++) p10s[i+1] = p10[i] + p10s[i];

	vector<S> init(N);
	for(int i=0; i<N; i++) init[i] = S(p10[i], i, i+1);
	atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(init);
	while(Q--){
		int l, r, d;
		cin >> l >> r >> d;
		seg.apply(l-1, r, d);
		cout << seg.all_prod().val.val() << endl;
	}
}


Measured memory_bytes: 14320
from collections import namedtuple


Point = namedtuple('Point', ['x', 'y'])


def sort(li):
    """Sort a list of Point(x, y) ascending order

    >>> sort([Point(x=2, y=1), Point(x=1, y=0)])
    [Point(x=1, y=0), Point(x=2, y=1)]
    >>> sort([Point(x=1, y=4), Point(x=1, y=3)])
    [Point(x=1, y=3), Point(x=1, y=4)]
    """
    li = sorted(li, key=lambda p: p.y)
    return sorted(li, key=lambda p: p.x)


def run():
    n = int(input())
    ps = []
    for _ in range(n):
        x, y = [int(i) for i in input().split()]
        ps.append(Point(x, y))

    for p in sort(ps):
        print("{} {}".format(p.x, p.y))


if __name__ == '__main__':
    run()



Measured memory_bytes: 23292
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

char s[50][50];
int dist[50][50];
int moveX[]{-1,0,1,0};
int moveY[]{ 0,-1,0,1 };

int main() {
	int H,W;
	cin >> H >> W;
	int whiteCount = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> s[i][j];
			dist[i][j] = 10000;
			if (s[i][j] == '.')whiteCount++;
		}
	}
	dist[0][0] = 0;

	queue<P>qu;
	qu.push(make_pair(0,0));
	while (!qu.empty()) {
		P pos = qu.front(); qu.pop();
		int currentDist = dist[pos.first][pos.second];
		for (int i = 0; i < 4;++i) {
			int nextX = pos.first + moveX[i];
			int nextY = pos.second + moveY[i];
			if (nextX < 0 || H <= nextX || nextY < 0 || W <= nextY || s[nextX][nextY] == '#') continue;
			if (currentDist + 1 < dist[nextX][nextY]) {
				dist[nextX][nextY] = currentDist + 1;
				qu.push(make_pair(nextX, nextY));
			}
		}
	}

	int ans = -1;
	if (dist[H - 1][W - 1] != 10000) {
		ans = whiteCount - (dist[H - 1][W - 1] + 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

int a, b;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	cout << (b % a == 0 ? a + b : b - a) << endl;
	return 0;
}



Measured memory_bytes: 256
'use strict'
function Main(input){
  const N=input.trim()-0;
  if(N===1){
    console.log(0);
    return;
  }
  if(N===2){
    console.log(0);
    return;
  }
  const M=Math.floor(Math.sqrt(N))+1;
  const isPrime=[];
  for(let i=0;i<M;i++){
    isPrime[i]=true;
  }
  isPrime[0]=isPrime[1]=false;
  for(let i=0;i<M;i++){
    if(!isPrime[i])continue;
    for(let j=2;i*j<=M;j++){
      isPrime[i*j]=false;
    }
  }
  const primes=[];
  for(let i=0;i<=M;i++){
    if(isPrime[i])primes.push(i);
  }
  const factorized=[];
  for(let i=0;i<=primes.length;i++){
    factorized[i]=0;
  }
  var n=1;
  let i=0;
  while(n<N){
    while(N%(n*primes[i])===0){
      factorized[i]++;
      n*=primes[i];
    }
    i++;
    if(i===primes.length)break;
  }
  const concentrated=[];
  factorized.forEach(function(e,i){
    if(e>=1)
      concentrated.push([primes[i],e]);
  });
  if(concentrated.length===0)concentrated.push([N,1]);
  //console.log(concentrated);
  var ans=0;
  const factor=[];
  const L=concentrated.reduce((acc,cur)=>acc*(cur[1]+1), 1);
  //console.log(concentrated);
  for(let l=0;l<L;l++){
    let m=l;
    concentrated.forEach(function(cur,i){
      let p=cur[0];
      let e=cur[1];
      factor[i]=[p,m%(e+1)];
      m=(m-m%(e+1))/(e+1);
    });
    //console.log(factor);
    let r=factor.reduce((acc,cur)=>acc*(Math.pow(cur[0],cur[1])),1);
    //console.log(r);
    if(N/r-1>r)ans+=N/r-1;
  }
  console.log(ans);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));


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

int n, A, B, C, l[9], INF = 1e9;
void chmin(int &a, int b)
{
    if (a > b)
        a = b;
}

int rec(int i, int a, int b, int c)
{
    if (i == n)
    {
        if (a == 0 || b == 0 || c == 0)
            return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }

    int res = rec(i + 1, a, b, c);

    chmin(res, rec(i + 1, a + l[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i + 1, a, b + l[i], c) + (b ? 10 : 0));
    chmin(res, rec(i + 1, a, b, c + l[i]) + (c ? 10 : 0));

    return res;
}

int main()
{
    cin >> n >> A >> B >> C;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    cout << rec(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int x,a,n,max,min;
    long long int s = 0;
    scanf("%d",&n);
    for(a = 1;a <= n;a++){
        scanf("%d",&x);
        if(a == 1){
            max = x;
            min = x;
        }
        if(max < x) max = x;
        if(min > x) min = x;
        s += x;
    }
    printf("%d %d %lld\n",min,max,s);
    return 0;
}


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

void ask_conti(int a, int n, int dis){
    cout << '?';
    for(int i = 0; i <= n; i++){
        if((a + i) % (n * 2) != dis) cout << ' ' << (a + i) % (n * 2) + 1;
    }
    cout << endl;
}

int main()
{
    int n;
    cin >> n;
    int right = n, left = 0;
    string p, curr;
    ask_conti(0, n, n);
    cin >> p;
    while(right - left > 1){
        int mid = (right + left) / 2;
        ask_conti(mid, n, mid + n);
        cin >> curr;
        if(p == curr) left = mid;
        else right = mid;
    }
    int f = left;
    char c[202];
    string s;
    for(int i = f; i < f + n; i++){
        ask_conti(f, n, i);
        cin >> s;
        if(s == "Red") c[i] = 'B';
        else c[i] = 'R';
    }
    for(int i = f + n; i < f + n * 2; i++){
        ask_conti(f + n, n, i % (n * 2));
        cin >> s;
        if(s == "Red") c[i % (n * 2)] = 'B';
        else c[i % (n * 2)] = 'R';
    }
    cout << "! ";
    for(int i = 0; i < n * 2; i++) cout << c[i];
    cout << endl;
}


Measured memory_bytes: 724
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    char x,y;
    cin>>x>>y;
    if(x>y) cout<<">"<<endl;
    else if(x<y) cout<<"<"<<endl;
    else cout<<"="<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int al = 0;
  int bo = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      al += a[i];
    else
      bo += a[i];
  }
  cout << al - bo << endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    map<int, int> mp;
    rep(i, n) {
        cin >> a[i];
        sum ^= a[i];
        mp[(a[i] ^ (a[i] - 1))] ++;
    }
    int ans = 0;
    for(int bit = 32; bit >= 0; -- bit) {
        int mask = (1LL<<bit);
        int co = 0;
        if(sum & mask) {
            if(ans % 2 == 0) co = 1;
        } else {
            if(ans % 2 == 1) co = 1;
        }
        if(mp[(mask << 1) - 1] < co) {
            cout << -1 << endl;
            return;
        }
        ans += co;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 4000
import sys
input = sys.stdin.buffer.readline
import numpy as np

D = int(input())
c = np.array(input().split(), dtype=np.int32)
s = np.array([input().split() for _ in range(D)], dtype=np.int32)
last = np.zeros(26, dtype=np.int32)
# print(s)
# print(s.shape)

ans = []
point = 0
for i in range(D):
    down = (i+1-last)*c
    loss = down * 2 + s[i,:]
    idx = np.argmax(loss)
    ans.append(idx+1)
    point += s[i, idx] - down.sum()
    last[idx] = i+1
    # print(loss)

for i in range(D):
    print(ans[i])

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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = a+b+c-max({a,b,c});
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int H, W, K, sum1d[15][1005], sum2d[15][1005];
int count(vector<int> cutp) {
  int cnt = cutp.size()-1; bool end = false;
  for(int l = 0, r = 1; r <= W && !end; ++r) {
    int u = 0, b = 0;
    for(int i = 0; i < cutp.size(); ++i) {
      u = b, b = cutp[i];
      if((sum2d[b][r]-sum2d[u][r])-(sum2d[b][l]-sum2d[u][l]) <= K) continue;
      end = (r-l <= 1);
      l = --r, ++cnt;
      break;
    }
    if(end) cnt = 1e9;
  }
  return cnt;
}
int main() {
  cin >> H >> W >> K;
  string S[15];
  for(int i = 1; i <= H; ++i) cin >> S[i];
  for(int i = 1; i <= H; ++i) {
    for(int j = 1; j <= W; ++j) {
      sum1d[i][j] = sum1d[i][j-1]+(S[i].at(j-1)-'0');
      sum2d[i][j] = sum1d[i][j]+sum2d[i-1][j];
    }
  }
  int ans = 1e9;
  for(int i = 0; i < (1<<(H-1)); ++i) {
    vector<int> cutp;
    for(int j = 0; j < (H-1); ++j) {
      if(i & (1<<j)) cutp.push_back(j+1);
    }
    cutp.push_back(H);
    ans = min(ans, count(cutp));
  }
  cout << ans << endl;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,k,c; string s;
	cin >> n >> k >> c >> s;
	c++;
	vector<int>left,right;
	int cur=0,cnt=0;
	while(cnt<k){
		if(s[cur]=='o'){
			left.pb(cur);
			cur+=c;
			cnt++;
		}else cur++;
	}
	cnt = 0; cur = n-1;
	while(cnt<k){
		if(s[cur]=='o'){
			right.pb(cur);
			cur-=c;
			cnt++;
		}else cur--;
	}
	reverse(right.begin(),right.end());
	vi ans;
	for(int i=0; i<k; i++){
		if(left[i]==right[i])ans.pb(left[i]+1);
	}
	for(auto x:ans)cout << x << endl;
	cout << endl;
}	


Measured memory_bytes: 4236
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    int n, res = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    for (int i = 0; i < n; i++)
    {
        int k = i;
        for (int j = i + 1; j < n; j++)
        {
            while (k < n && a[k] < a[i] + a[j]) k++;
            res += k - (j + 1);
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int n;
	int a, b;
	int a_s, b_s;
	
	while (scanf("%d", &n), n != 0){
		a_s = b_s = 0;
		
		while (n != 0){
		scanf("%d %d", &a, &b);
		
		if (a > b) a_s += a + b;
		else if (a < b) b_s += b + a;
		else {
			a_s += a;
			b_s += b;
		}
		n--;
		}
		
		printf("%d %d\n", a_s, b_s);
	}
}

Measured memory_bytes: 1028
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				System.out.printf("%dx%d=%d\n", i, j, i*j);
			}
		}
	}

}

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

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

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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	int cnt = 0;
	rep(i, n) {
		while (i + 1 < n && a[i] == a[i + 1]) i++;

		if (i + 1 < n && a[i] < a[i + 1]) {
			while (i + 1 < n && a[i] <= a[i + 1]) i++;
		}
		else if(i + 1 < n && a[i] > a[i + 1]) {
			while (i + 1 < n && a[i] >= a[i + 1]) i++;
		}

		cnt++;
	}

	out(cnt);

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char s[107];
int main(){
    int n;
    cin>>n;
    scanf("%s",s+1);
    int cntr=0,cntb=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='R')
            cntr++;
        else if(s[i]=='B')
            cntb++;
    }
    if(cntr>cntb)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> x(n, 0);
    size_t y = 0;
    for (size_t i = 0; i < n; ++i) {
        cin >> x[i];
        y = max(y, x[i]);
    }
    size_t a = numeric_limits<size_t>::max();
    for (size_t i = 0; i < y; ++i) {
        auto p = i + 1;
        size_t b = 0;
        for (size_t j = 0; j < n; ++j) {
            auto c = x[j] - p;
            b += c * c;
        }
        a = min(a, b);
    }
    cout << a << endl;
    return 0;
}


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

lld N;
lld A[81];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    A[N] = 0;
    lld nowp = 1000;
    lld minp = A[0];
    lld cnt = 0;
    for (int i = 1; i < N+1; i++) {
        if(A[i-1] < A[i]){
            cnt++;
        } else if(A[i-1] > A[i]){
            if(cnt > 0){
                lld buyk = nowp/minp;
                nowp += buyk * (A[i-1]-minp);
                cnt = 0;
            }
            minp = A[i];
        }
    }
    cout << nowp << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int a, b, k; cin >> a >> b >> k;
    set<int> s;
    for(int i = a; i < a + k && i <= b; i++) s.insert(i);
    for(int i = b; i > b - k && i >= a; i--) s.insert(i);
    for(auto x : s) cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int N;
	cin >> N;
	while(1){
		if(N % 10 == (N / 10) % 10 && N % 10 == N / 100){
			cout << N << endl;
			break;
		}
		N ++;
	}
	
	return 0;
}

Measured memory_bytes: 256