akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,k,ze=0;
vector<ll> a,b;
ll num(ll x)
{
	ll i,ret=0;
	if(x==0)
	{
		return a.size()*b.size()+ze*(a.size()+b.size())+ze*(ze-1)/2;
	}
	if(x>=0)
	{
		ret=ze*(a.size()+b.size())*2+ze*(ze-1);
	}
	for(i=0;i<a.size();i++)
	{
		if(a[i]*a[i]<=x)
		{
			ret--;
		}
		if(x>=0)
		{
			ret+=upper_bound(a.begin(),a.end(),x/a[i])-a.begin();
		}
		ret+=upper_bound(b.begin(),b.end(),(x-a[i]+1)/a[i])-b.begin();
	}
	for(i=0;i<b.size();i++)
	{
		if(b[i]*b[i]<=x)
		{
			ret--;
		}
		if(x<=0)
		{
			ret+=a.size()-(upper_bound(a.begin(),a.end(),(x+1)/b[i])-a.begin());
		}
		else
		{
			ret+=a.size()-(upper_bound(a.begin(),a.end(),(x-1)/b[i])-a.begin());
		}
		if(x>=0)
		{
			ret+=b.size()-(lower_bound(b.begin(),b.end(),x/b[i])-b.begin());
		}
	}
	return ret/2;
}
int main(){
	//freopen("D.in","r",stdin);
	//freopen("D.out","w",stdout);
	ll i,l,r,mid,x;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>x;
		if(x==0)
		{
			ze++;
		}
		else if(x>0)
		{
			a.push_back(x);
		}
		else				
		{
			b.push_back(x);
		}
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	l=-LINF;
	r=LINF;
	while(l<=r)
	{
		mid=(l+r)/2;
		//cout<<mid<<" "<<num(mid)<<endl;
		if(num(mid)>=k)
		{
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int K = scanner.nextInt();
			String S = scanner.next();

			if (S.length() <=K)  {
				System.out.print(S);
			} else {
				System.out.print(S.substring(0, K) + "...");
			}

		}
	}
}

Measured memory_bytes: 38504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (a % 2 == 1) {
        for (int i = 0; i < b; i++) {
            cout << i + 1 << " " << a - (i + 1) << endl;
        }
    }
    else {
        int count = b;
        for (int i = 0; i < (a / 2) / 2; i++) {
            if (count != 0) {
                cout << i + 1 << " " << a - i << endl;
                count--;
            }
        }
        for (int i = 0; i < a; i++) {
            if (count != 0) {
                cout << a / 2 - i << " " << a / 2 + 2 + i << endl;
                count--;
            }
        }
    }
}

Measured memory_bytes: 3640
N,M=gets.split.map(&:to_i)
as=gets.split.map{|e|e.to_i/2}
def hlcm(a,b)
    gc=a.gcd(b)
    pa=a/gc
    pb=b/gc
    if pa.even? || pb.even?
        return 0
    else
        return gc*pa*pb
    end
end
h=as[0]
as.each do |e|
    h=hlcm(e,h)
    if h>M
        puts 0
        exit
    end
end
if h==0
    puts 0   
else
    puts (M/h+1)/2
end


Measured memory_bytes: 8580
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] li = new int[n+1];
        for(int i = 1; i <= n; i++){
            int a = sc.nextInt();
            li[i] += a + li[i-1];
        }
        int ans = li[n];
        for(int i = 1; i < n; i++){
            ans = Math.min(ans,Math.abs((li[n]-li[i])-li[i]));
        }
        System.out.println(ans);
    }
}


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: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

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

int main() {
    ll N;
    cin >> N;
    vector<Pll> A(N);
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        A[i]=Pll(b,a);
    }
    sort(A.begin(),A.end());
    ll now=0;
    rep(i,N){
        now+=A[i].second;
        if (now>A[i].first){
            cout << "No" << endl;
          	return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
fun main(args: Array<String>) {
    val text = readLine()!!
    val keyWords = listOf("dream", "dreamer", "erase", "eraser")
    var result = "NO"
    var sb = StringBuilder(text)
    do {
        var sholdContine = false
        for (keyWord in keyWords) {
            if (sb.endsWith(keyWord)) {
                sb.delete(sb.length - keyWord.length, sb.length)
                sholdContine = true
                break
            }
        }
        if (sb.isEmpty()) {
            result = "YES"
            break
        }
    } while (sholdContine)
    print(result)
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> A(n, vector<int>(n-1));
  rep(i, n) {
    rep(j, n-1) {
      cin >> A[i][j];
      --A[i][j];
    }
    reverse(A[i].begin(), A[i].end());
  }

  vector<Pair> P;
  
  auto check = [&](int i) {
    if (A[i].size() == 0) return;
    int j = A[i].back();
    Pair p(i, j);
    if (A[j].back() == i) {
      if (i > j) swap(p.first, p.second);
      P.push_back(p);
    }
  };

  rep(i, n) {
    check(i);
  }

  int day, count;
  day = count = 0;
  while (P.size() > 0) {
    ++day;
    sort(P.begin(), P.end());
    P.erase(unique(P.begin(), P.end()), P.end());
    vector<Pair> Q;
    swap(P, Q);

    for (Pair p : Q) {
      ++count;
      int i, j;
      i = p.first; j = p.second;
      A[i].pop_back(); A[j].pop_back();
      check(i); check(j);
    }
  }
  
  if (count < n*(n-1)/2) day = -1;
  cout << day << endl;
  return 0;
}

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

int main() {
    int n;
    long long ans=0;
    cin >> n;

    int a[n+1], b;
    for (int i=0; i<=n; ++i) cin >> a[i];

    for (int i=0; i<n; ++i) {
        cin >> b;
        if(a[i] + a[i+1] > b) {
          ans += b;
          a[i+1] -= (b>a[i]? (b-a[i]) : 0);
        } else {
           ans += a[i] + a[i+1];
           a[i+1] = 0;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
import sys
for s in sys.stdin:
  hand = sorted(map(int, s.split(',')))
  kind = len(set(hand))
  ma = max([hand.count(i) for i in hand])
  
  ans = 'null'
  if kind == 4:
    ans = 'one pair'
  elif kind == 3:
    if ma == 2:
      ans = 'two pair'
    else:
      ans = 'three card'
  elif kind == 2:
    if ma==4:
      ans = 'four card'
    else:
      ans = 'full house'
  else:
    if hand == [1,10,11,12,13] or (hand[4] - hand[0]) == 4:
      ans = 'straight'
  print ans       

Measured memory_bytes: 4228
X,Y,Z,K = map(int,input().split())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
A = A[0:K]
B.sort(reverse=True)
B = B[0:K]
AB = [a+b for a in A for b in B]

AB.sort(reverse=True)

AB = AB[0:K]

C.sort(reverse=True)
C=C[0:K]
ABC = [ab+c for ab in AB for c in C]

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

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

main()
{
	char str[20];
	char copy_str[20];
	int len;
	int i = 0;
	
	scanf("%s", str);
	
	len = strlen(str);
	
	while (str[i] != '\0'){
		copy_str[i] = str[len - 1];
		i++;
		len--;
	}
	copy_str[i] = '\0';
	
	printf("%s\n", copy_str);
	
	return (0);
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    int A[100];
    for (int i=0; i < M; i++) {
      cin >> A[i];
    }
    int cnt = 0;
    for (int i=0; i < M; i++) {
      if (A[i] > X) {
        cnt++;
      }
    }
    if (cnt > M - cnt) {
      cnt = M - cnt;
    }
    cout << cnt << endl;
    return 0;
}

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

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


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,L;
  cin >> N >> L;
  vector<string> str(N);
  for (int i=0;i<N;i++){
  cin >> str[i];
  }
  sort(str.begin(),str.end());
  for (int i=0;i<N;i++){
  cout << str[i];
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
 
 
const ll INF = 1e18;
const ll N =(300+5);
const ll MOD = 1e9+7;
ll ptr[N];
char a[N][N];
// ll dp[N][N];
// ll cst[N][N];
void solve(){
    ll n,m;
    cin >> n >> m;
    for(int i = 1;i<=n;i++){
        for(int  j = 1;j<=m;j++){
            cin >> a[i-1][j-1];
        }
    }
    ll ans = 0;
    for(int i =0;i<m-1;i++){
        char arr[n+1],arr2[n+1];
        for(int j = 0;j<n;j++) {
            arr[j] = a[j][i];
            arr2[j] = a[j][i+1];
        }
        // dp[i][j] = if we have pushed i rows from 1st col. and j rows from 2nd col.
                vector<vector<int>> cst(n + 3, vector<int>(n + 3));

        for(int x =0;x<n;x++){
            for(int y = 0;y<n;y++){
                cst[x+1][y+1] = cst[x][y] + (arr[x] == arr2[y]);
            }
        }
         vector<vector<int>> dp(n + 1, vector<int>(n + 1, INF));
        // for(int x = 0;x<=n;x++){
        //     for(int y = 0;y<=n;y++)
        //         dp[x][y] = INF;
        // }
        for(int x =0;x<=n;x++){
            dp[x][0] = 0;
            dp[0][x] = 0; 
        }
        for(int x = 1;x<=n;x++){
            for(int y = 1;y<=n;y++){
                dp[x][y] = min(dp[x][y],dp[x-1][y] + cst[x][y]);
                dp[x][y] = min(dp[x][y],dp[x][y-1] + cst[x][y]); 
            }
        }
        ans += dp[n][n];
    }
    cout<<ans;
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    

 
     ll tt=1;   
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 4848
#include <cstdio>
#include <cctype>

int main() {
	char ch;

	while (1) {
		scanf("%c", &ch);
		if (isalpha(ch)) {
			if (islower(ch)) printf("%c", toupper(ch));
			else printf("%c", tolower(ch));
		}
		else printf("%c", ch);

		if (ch == '\n') {
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 2608
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
long long n, cnt;
void dfs(long long x, int f) {
    if (x > n) return;
    if (f == 7) cnt++;
    dfs(x * 10 + 3, f | 1);
    dfs(x * 10 + 5, f | 2);
    dfs(x * 10 + 7, f | 4);
}
void solve() {
    cin >> n;
    dfs(0, 0);
    cout << cnt << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = A; i <= min(B, A + K - 1); i++) cout << i << endl;
  for (int i = max(B - K + 1, A + K); i <= B; i++) cout << i << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
  ll d;cin >> d;
  vl c(26);rep(i,26)cin >> c[i];
  vvl s(d,vl(26));rep(i,d)rep(j,26)cin >> s[i][j];
  vector<set<ll>> ch(26);rep(i,26)ch[i].ins(-1),ch[i].ins(d);
  vl days(d);
  ll pre=0;
  vl last(26,-1);
  rep(i,d){
    ll t=0;
    ll maxi=-INF;
    rep(j,26){
        ll p=s[i][j];
        rep(k,26){
            if(k==j)continue;
            p-=c[k]*(i-last[k]);
        }
        if(chmax(maxi,p))t=j;
      }
      days[i]=t;
      last[t]=i;
  }
  rep(i,d){
    ll t=days[i];
    pre+=s[i][t];
    ch[t].ins(i);
    days[i]=t;
  }
  ll score=pre; 
  rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      score-=c[i]*mini;
  }
  //rep(i,d)cout << days[i] <<endl;

  ll q=45000;
  while(q--){
    ll x=-1,sz=inf;
    rep(i,26){
      if(chmin(sz,(ll)ch[i].size()))x=i;
    }
    ll y=rand()%26;
    //cout << x <<" " << y <<endl;
    ll old=days[x];
    pre-=s[x][days[x]];
    ch[days[x]].erase(x);
    days[x]=y;
    pre+=s[x][y];
    ch[y].ins(x);
    ll p=0;
    rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      p+=c[i]*mini;
    }
    //if(q>299990)cout << score <<endl;
    if(pre-p>=score){
      score=pre-p;
    }
    else{
      ch[y].erase(x);
      pre-=s[x][y];
      days[x]=old;
      ch[days[x]].ins(x);
      pre+=s[x][old];
    }
  }
  rep(i,d)cout << days[i]+1 <<endl;
}   

Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF=(1LL<<60);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
	init();
	ll N,M;cin>>N>>M;
	vector<pair<ll,ll>>baseG;
	for(int i=0;i<M;i++){
		ll a,b;cin>>a>>b;
		a--;b--;
		baseG.push_back(make_pair(a,b));
	}
	
	ll ans=0;
	for(int k=0;k<M;k++){
		//delete baseG[k]
		vector<ll>G[N];
		for(int i=0;i<M;i++){
			if(i==k)continue;
			ll a=baseG[i].first;
			ll b=baseG[i].second;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		
		vector<ll>color(N,-1);
		queue<ll>que;
		que.push(0);
		color[0]=0;
		while(!que.empty()){
			ll u=que.front();
			que.pop();
			for(int i=0;i<G[u].size();i++){
				ll next=G[u][i];
				if(color[next]!=-1)continue;
				color[next]=0;
				que.push(next);
			}
		}
		
		ll num=0;
		//cout<<"delete.."<<k<<endl;
		for(int i=0;i<N;i++){
			if(color[i]==-1)num++;
		}
		if(num!=0)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class UnionFind{
    int[] index;
    public UnionFind(int n){
        index = new int[n];
        for(int i=0; i<n; i++)
            index[i] = i;
    }
    int find(int x){
        if(index[x]==x)
            return x;
        else
            return find(index[x]);
    }
    boolean same(int x, int y){
        return find(x) == find(y);
    }
    void union(int x, int y){
        int rootx = find(x);
        int rooty = find(y);
        if(rootx == rooty)
            return;
        else
            index[rooty] = rootx;
    }
    void printIndex(){
        for(int i=0; i<index.length; i++)
            System.out.print(" " + index[i]);
        System.out.println("");
    }

}
public class Main {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        UnionFind unionFind = new UnionFind(scanner.nextInt());
        int m = scanner.nextInt();
        //unionFind.printIndex();
        for(int i=0; i<m ; i++){
            unionFind.union(scanner.nextInt(), scanner.nextInt());
        //    unionFind.printIndex();
        }
   
/*         for(int k=0; k<group.length ;k++)
             System.out.print(group[k].id+" ");
         System.out.println("");*/
        int q = scanner.nextInt();
        for (int i = 0; i < q; i++){
            int s = scanner.nextInt();
            int t = scanner.nextInt();
            if (unionFind.same(s,t))
                System.out.println("yes");
            else
                System.out.println("no");
            //unionFind.printIndex();
        }
    }
 

}

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

int main(){
  int n,m,sum=0;
  cin >>n >> m;
  
  vector<int> vec(m);
  for (int i = 0; i < m; i++) 
    cin >> vec.at(i);
  
  for (int i=0;i<m;i++)
    sum=sum+vec.at(i);
  
  if(n>=sum)
    cout << n-sum << endl;
  else
    cout << -1 << endl;
}


Measured memory_bytes: 3668
S = input()

sum = 0

for n in range(1<<(len(S)-1)): #全通り
  i_before = 0
  for i in range(len(S)-1): #各桁
    if n & (1<<i): #bitチェック
      sum += int(S[i_before:i+1])
      i_before = i+1
  sum += int(S[i_before:]) #最後の桁

print(sum)

Measured memory_bytes: 66940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000000000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

/*vector<bool> seen;
void dfs(const Graph& G, int v, int count) {
    seen[v] = true;
    count = 0;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        if (count > 2) continue;
        count++;
        cout << count << ":" << next_v << endl;
        dfs(G, next_v, count);
    }
}*/

int main() {
    long long N, M;
    cin >> N >> M;
    if (N == 1 || M == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (N % 2 == 0 && M % 2 == 0) cout << M * (N / 2) << endl;
    else if(N %2 == 1 && M % 2 == 0) cout << M * (N / 2) + (M / 2) << endl;
    else if (M % 2 == 1 && N % 2 == 1) {
        cout << M * (N / 2) + (M / 2) + 1 << endl;
    }
    else if (M % 2 == 1 && N % 2 == 0) cout << M * (N / 2) << endl;
}


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

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

    long num = a * b;

    long tmp = 0;
    if ( a < b  ) {
        tmp = a;
        a = b;
        b = tmp;
    }

    long r = 0;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    cout << num / b << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

bool era[100010];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  rep(i, 100010) era[i] = true;
  era[0] = era[1] = false;
  repi(i, 2, 100001) {
    for (int j = i * 2; j <= 100000; j += i) era[j] = false;
  }
  vi32 lst(100010, 0), sums(100010);
  for (int i = 1; i <= 100000; i += 2) {
    if (era[i] && era[(i + 1) / 2]) lst[i] = 1;
  }
  partial_sum(all(lst), sums.begin() + 1);
  i32 q; cin >> q;
  rep(i, q) {
    i32 l, r;
    cin >> l >> r;
    cout << sums[r + 1] - sums[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1536
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            boolean[][] map = new boolean[4][4];

            List<List<Integer>> list = getPermutations(3);
            for (int i = 0; i < 3; i++) {
                int a = in.nextInt();
                int b = in.nextInt();

                map[a - 1][b - 1] = true;
                map[b - 1][a - 1] = true;
            }

            boolean ans = false;

            for (List<Integer> element : list) {
                if (map[element.get(0)][element.get(1)] &&
                        map[element.get(1)][element.get(2)] &&
                        map[element.get(2)][element.get(3)]) {
                    ans = true;
                }
            }

            if (ans) {
                out.print("YES");
            } else {
                out.print("NO");
            }
        }

        private static List<List<Integer>> getPermutations(Integer n) {

            List<List<Integer>> results = new ArrayList<List<Integer>>();

            if (n == 0) {
                results.add(new ArrayList<Integer>(Arrays.asList(0)));
                return results;
            }

            List<List<Integer>> prevResults = getPermutations(n - 1);

            for (List<Integer> permutation : prevResults) {
                for (int i = 0; i <= n; ++i) {
                    permutation.add(i, n);
                    results.add(new ArrayList<Integer>(permutation));
                    permutation.remove(n);
                }
                permutation.clear();
            }
            prevResults.clear();

            return results;
        }

    }
}



Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			int n=scan.nextInt();
			int a=scan.nextInt();
			int sum=0,count=0;
			for(int i=1;i<=n;i++) {
				for(int j=2;j<=n;j++) {
					for(int k=3;k<=n;k++) {
						if(i == j || j == k || i == k) {
						}else {
							sum = i+j+k;
						if (sum == a && i<j && j<k) {
							count += 1;
						}
						}
					}
				}
			}
			if(n==0 && a==0) {
				break;
			}
			System.out.println(count);
}
		scan.close();
}
}


Measured memory_bytes: 26524
N = int(input())
As = list(map(int, input().split()))

cnt = [0]*(N+1)
tmp = 0

for a in As:
  cnt[a] += 1

for a in cnt:
  tmp += a*(a-1)//2

for a in As:
  if cnt[a] < 2:
    print(tmp)
  else:
    print(tmp - cnt[a] + 1)

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

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	if(a >= 13) {
		cout << b;
	} else if(a >= 6 && a <= 12) {
		cout << b / 2;
	} else {
		cout << 0;
	}
}


Measured memory_bytes: 256
N = int(input())
L = sorted(map(int,input().split()))
cnt = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        if a == b:
            continue
        for k in range(j+1,N):
            c = L[k]
            if a==c or b==c:
                continue
            if a+b > c:
                cnt += 1
print(cnt)

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

const double pi = acos(-1);

int main()
{
    double h,m;
    double a,b;
    scanf("%lf",&a);
    scanf("%lf",&b);
    scanf("%lf",&h);
    scanf("%lf",&m);

    double hdeg , mdeg ;
    hdeg = h*30;
    hdeg += (m/2);
    mdeg = m*6;
    double diff = abs(hdeg-mdeg);
    double di = (pi*diff)/180.0;
    double calc;
    calc = a*a + b*b ;
    calc = calc - 2*a*b*cos(di);
    calc = sqrt(calc) ;
    printf("%.18f\n",calc);

    
    
    return 0;
}

Measured memory_bytes: 4252
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N;
const int MAX_N = 100;
ll a[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> a[i];
  int prv = 0, ans = 0;
  REP(i, N) {
    if(a[i] == prv) {
      ans++;
      prv = 0;
    } else {
      prv = a[i];
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
n = gets.to_i

if n % 2 == 0 || n % 5 == 0
  puts -1
  return
end

n = n / 7 if n % 7 == 0

x = 0
count = 0
n.times do
  x = (x * 10 + 1) % n
  count += 1
  break if x == 0
end

puts x == 0 ? count : -1


Measured memory_bytes: 14380
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

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

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<string> s(n);
  for(int i=0; i<n; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());

  vector<string> ans;
  int max = 0;
  int count = 1;
  for(int i=1; i<n; i++) {
    if(s[i] == s[i - 1]) {
      count++;
    }
    else{
      if(max < count) {
        max = count;
        ans.clear();
        ans.push_back(s[i - 1]);
      }
      else if(max == count) {
        ans.push_back(s[i - 1]);
      }
      count = 1;
    }
  }
  if(max < count) {
    max = count;
    ans.clear();
    ans.push_back(s[n - 1]);
  }
  else if(max == count) {
    ans.push_back(s[n - 1]);
  }

  for(int i=0; i<ans.size(); i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 17816
//x = human*y + (human+1)*z
#include <stdio.h>

int main()
{
    int x, y, z, human = 1, total = 0;

    scanf( "%d %d %d", &x, &y, &z);

    while(total < x )
    {
        total = human * y + (human + 1) * z;
        if( total > x ) break;
        human++;
        if( total == x ) break;
    }
    printf("%d\n", human-1);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define all(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
typedef long long ll;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
int main()
{
    IOS;
    int n;
    string s,t,x,y;
    cin>>s;
    n = s.size();
    t = s;
    bool b1 = false,b2=false,b3=false;
   reverse(s.begin(),s.end());
   //cout<<"t="<<t<<endl;
    if(t==s)
    {
            b1 = true;
            x = s.substr(0,((n-1)/2));
            y = x;
            //cout<<"y="<<y<<endl;
            reverse(all(x));
            //cout<<"x="<<x<<endl;
            if(y==x)
            {
                b2 = true;
            }
            else{
                b2 = false;
            }
            x = s.substr(((n+3)/2)-1, n-1);
            y = x;
            //cout<<"y="<<y<<endl;
            reverse(all(x));
            //cout<<"x="<<x<<endl;
            if(y==x){
                b3 = true;
            }
            else b3 = false;
    }
    else b1 = false;
    if(b1 && b2 && b3)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ) {
        cout << "vowel";
    } else {
        cout << "consonant";
    }

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()
split_list = [0]
section_list = [0]
for i in range(1, N):
    if S[i-1] != S[i]:
        section_list.append(i - split_list[-1])
        split_list.append(i)
split_list.append(N)
section_list.append(split_list[-1] - split_list[-2])
del split_list[0]
del section_list[0]
answer = 0
if len(section_list) <= 2 * K:
    answer= N
else:
    total = sum(section_list[:2 * K + 1])
    if S[0] == '0':
        for i in range(len(section_list) - 2 * K - 1):
            total = total - section_list[i] + section_list[i+2*K+1]
            if i % 2 == 0:
                if total >= answer:
                    answer = total
    if S[0] == '1':
        answer = total
        for i in range(len(section_list) - 2 * K - 1):
            total = total - section_list[i] + section_list[i+2*K+1]
            if i % 2 == 1:
                if total >= answer:
                    answer = total
    # 0から始まるパターン
    total = sum(section_list[:2 * K])
    if total > answer:
        answer = total
    #0で終わるパターン
    total = sum(section_list[- 2 * K:])
    if total > answer:
        answer = total
print(answer)

Measured memory_bytes: 8516
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

void fread(int &x){
    char c; x=0;
    while((c=getchar())<'0' || c>'9');
    while('0'<=c && c<='9'){
        x = x*10 + c-'0';
        c = getchar();
    }
    return;
}

int main(){
    int a,b,c; fread(a); fread(b); fread(c);
    printf("%s\n",b-a == c-b  ?  "YES"  :  "NO");
    return 0;
}

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

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

long long MOD = 10000000000 + 7;

template<class T>
using MaxHeap = std::priority_queue<T>;

int main(){
  cout << setprecision(10);
  int X,Y,a,b,c;
  cin >> X >> Y >> a >> b >> c;

  MaxHeap<pli> pq;

  for(int i = 0; i < a; i++){
    ll tmp; cin >> tmp;
    pq.push(make_pair(tmp, 0));
  }
  for(int i = 0; i < b; i++){
    ll tmp; cin >> tmp;
    pq.push(make_pair(tmp, 1));
  }
  for(int i = 0; i < c; i++){
    ll tmp; cin >> tmp;
    pq.push(make_pair(tmp, 2));
  }

  ll ans = 0;
  int x=0,y=0,z = 0;
  while(x + y + z < X+Y){
    auto now = pq.top();
    int col = now.second;
    ll val = now.first;
    // cerr << col << " " << val << endl;
    pq.pop();

    if(col==0 && x < X){
      ans += val;
      x++;
    }
    if(col==1 && y < Y){
      ans += val;
      y++;
    }

    if(col==2){
      ans += val;
      z++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 11668
if __name__ == "__main__":
    n, x = map(int, input().split())
    aaa = list(map(int, input().split()))
    ans = 0
    
    for a in sorted(aaa):
        if x < a:
            break
        ans += 1
        x -= a
    else:
        if x > 0:
            ans -= 1
    print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

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

Node *root,*NIL;

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

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

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

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

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

void inorder(Node *u){
  if( u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

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

  scanf("%d", &n);

  for(i=0;i<n;i++){
    cin >> com;
    if( com[0] == 'f' ){
      scanf("%d", &x);
      Node *t = find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    } else if (com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 20004
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int i,n;
  cin >> n;
  int a[n],b[n];
  for(i=0;i<n;i++){
    scanf(" %d",&a[i]);
  }
  for(i=0;i<n;i++){
    scanf(" %d",&b[i]);
  }

  long long ans=0;
  for(i=28;i>=0;i--){
    long long tmp=0;
    long long t=1LL<<i;
    for(int j=0;j<n;j++){
      a[j]=a[j]%(2*t);
      b[j]=b[j]%(2*t);
    }
    sort(b,b+n);
    for(int j=0;j<n;j++){
      tmp+=lower_bound(b,b+n,2*t-a[j])-lower_bound(b,b+n,t-a[j]);
      tmp+=lower_bound(b,b+n,4*t-a[j])-lower_bound(b,b+n,3*t-a[j]);
    }
    ans+=(tmp%2)*t;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0])) 
using namespace std;
int main(){
  
  int n,a;
  cin >> n;
  int cnt[100001]={};
  while(cin>>a){
    cnt[a]++;
    cnt[a+1]++;
    cnt[a+2]++;
  }
  cnt[0]=0;
  int *mx = max_element(cnt, cnt+SIZE(cnt)); 
  cout << *mx;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
using namespace std;
 
#define ll long long
 
int main() {
	ll n, a, b, max, min;
	cin >> n >> a >> b;
	if (n == 1 && b - a == 0)cout << 1 << endl;
	else if (n == 1 && b - a != 0)cout << 0 << endl;
	else if (b - a < 0)cout << 0 << endl;
	else if (n == 2)cout << 1 << endl;
	else {
		max = b * (n - 2);
		min = a * (n - 2);
		cout << max - min + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = input().split()
alist = []
count = 0

for i in range(N):
    a = int(A[i])
    alist.append(a)

for ii in range(N - 1):
    if alist[int(ii)] + alist[int(ii) + 1] <= x:
        pass
    else:
        while alist[int(ii)] + alist[int(ii) + 1] > x:
            if alist[int(ii) + 1] > 0:
                k = alist[int(ii)] + alist[int(ii) + 1] - x
                if k <= alist[int(ii) + 1]:
                    alist[int(ii) + 1] -= k
                    count += k
                else:
                    alist[int(ii)] -= k - alist[int(ii) + 1]
                    alist[int(ii) + 1] = 0
                    count += k
            
print(count)

Measured memory_bytes: 14544
module Main where
    import Data.List
    import Control.Monad
    
    main = do
        inputs<-getInputs
        let a = inputs!!0
        let b = inputs!!1
        putStrLn $ getAttr a b
        

    getAttr:: Integer->Integer->String
    getAttr a b 
        |(a*b <=0) = "Zero"
        |0<a = "Positive"
        |(mod (abs(a-b)) 2==0) ="Negative"
        |otherwise = "Positive"


        
    read' s = read s ::Integer

    getInputs = do
        line <- getLine
        let inputs = map read' (words line)
        return inputs

    getLines n = do
        lines <- (replicateM n getLine)
        return lines

    getGCD::Integer->Integer->Integer
    getGCD m n 
        | m < n = (getGCD n m)
        | n == 0 = m
        | otherwise = getGCD (mod m n) n

    getLCM::Integer->Integer->Integer
    getLCM m n = div (m * n) (getGCD m n)
   

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

int main() {
  int64_t n, y;
  cin >> n >> y;
  int a = -1, b = -1, c = -1;
  int i=0, j=0, k;
  for (i = 0; i <= n; i++) {
    for (j = 0; j+i <= n; j++) {
      k = n - i - j;
      if ((10000*i + 5000*j + 1000*k) == y) {
        a = i; b = j; c = k;
      }
    }
    
  }
  cout << a << " " << b << " " << c << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL H, W; cin >> H >> W;
		UL h, w; cin >> h >> w;
		H -= h; W -= w;
		cout << (H * W) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  int ans = 0;
  for (int i=0; i<n; i++) cin >> d[i];
  for (int i=0; i<n-1; i++) {
    for (int j=i+1; j<n; j++) {
      ans += (d[i]*d[j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define PI acos(-1)

int main(void)
{
  int a, b, c;
  double s, l, h;

  scanf("%d %d %d", &a, &b, &c);

  s = a * b * sin(c * PI / 180) / 2;
  l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * PI / 180));
  h = b * sin(c * PI / 180);

  printf("%lf\n%lf\n%lf\n", s, l, h);

  return (0);
}

Measured memory_bytes: 660
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)				(x).begin(),(x).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(ll)1e18
#define EPS					(double)1e-9
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/(n)))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/(n))*(n))	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N;
	cin >> N;
	vector<P> robot(N);
	REP(i, N) {
		int x, l;
		cin >> x >> l;
		robot[i].first = x - l;
		robot[i].second = x + l;
	}
	sort(ALL(robot));

	ll ans = 0;
	ll prevEnd = robot[0].second;
	REPN(i, 1, N) {
		auto &nowOne = robot[i];
		if (nowOne.first < prevEnd) {
			prevEnd = min(nowOne.second, prevEnd);
			ans++;
		} else {
			prevEnd = nowOne.second;
		}
	}

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



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int a[4];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]!=a[2]||a[1]==a[2]&&a[0]!=a[1])
	cout<<"Yes";
	else cout<<"No";
	return 0;
 } 

Measured memory_bytes: 256