akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int minX = Integer.MAX_VALUE;
        int maxX = Integer.MIN_VALUE;
        int minY = Integer.MAX_VALUE;
        int maxY = Integer.MIN_VALUE;
        for (int i=0; i<N; i++) {
          int w = reader.nextInt();
          int h = reader.nextInt();
          minX = Math.min(minX, w-h);
          maxX = Math.max(maxX, w-h);
          minY = Math.min(minY, w+h);
          maxY = Math.max(maxY, w+h);
        }

        System.out.println(Math.max(maxX-minX, maxY-minY));
    }

    public static void solver() {
        // write logic
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}


Measured memory_bytes: 36680
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define fi first
#define se second
//#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
typedef pair<int,int> P;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define abs(x) ((x)>0?(x):-(x))
#define y1 hhf
#define mp make_pair
const int mod=1e9+7;
const int maxn = 55;
int n;
ll a[maxn];
ll ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	while(1){
		int id=max_element(a, a+n)-a;
		if(a[id]<n) break;
		for(int i=0;i<n;i++){
			if(i!=id){
				a[i]+=a[id]/n;
			}
		}
		ans += a[id]/n;
		a[id]%=n;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define int long long
const int INF = 1e18 + 239;

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

    int a, b, c;
    cin >> a >> b >> c;
    int n = a + b + c;
    int add = 0;
    vector<vector<int>> v(n, vector<int> (3));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> v[i][j];
        }
        int sb = v[i][2];
        add += sb;
        for (int j = 0; j < 3; j++) {
            v[i][j] -= sb;
        }
    }
    sort(v.rbegin(), v.rend(), [&](vector<int> x, vector<int> y) {
        return x[0] - x[1] < y[0] - y[1];
    });
    // for (int i = 0; i < n; i++) {
    //     cerr << v[i][0] << ' ' << v[i][1] << ' ' << v[i][0] - v[i][1] << endl;
    // }
    vector<int> pref(n, -INF);
    vector<int> suff(n, -INF);
    {
        multiset<int> cur;
        int sm = 0;
        auto ins = [&](int x) {
            cur.insert(x);
            sm += x;
        };
        auto pp = [&]() {
            sm -= *cur.begin();
            cur.erase(cur.begin());
        };
        for (int i = 0; i < n; i++) {
            ins(v[i][0]);
            while ((int)cur.size() > a) pp();
            if ((int)cur.size() == a) pref[i] = sm;
        }
        cur.clear();
        sm = 0;
        for (int i = n - 1; i >= 0; i--) {
            ins(v[i][1]);
            while ((int)cur.size() > b) pp();
            if ((int)cur.size() == b) suff[i] = sm; 
        }
    }
    int cans = 0;
    for (int i = 1; i < n; i++) {
        cans = max(cans, pref[i - 1] + suff[i] + add);
    }
    cout << cans << endl;
}   


Measured memory_bytes: 11648
#include<stdio.h>
int main(){
	int n,q;
	int A[100000],T[50000];
    int i,count=0;
	int left,right,mid;

	scanf("%d",&n);

	for(i=0 ; i<n ; i++){
		scanf("%d",&A[i]);
	}

	scanf("%d",&q);

	for(i=0 ; i<q ; i++){
		scanf("%d",&T[i]);
	}

	for(i=0 ; i<q ; i++){
		right = n;
		left = 0;
	while(left < right){
	mid = (left + right)/2;
	if(T[i] == A[mid]){
		count++;
		break;
	}

	else if(T[i] > A[mid])left = mid+1;
	else right = mid;
		     }
  
					
		}

	printf("%d\n",count);

	return 0;
	}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll h,n;cin>>h>>n;
  ll sum=0;
  rep(i,0,n){
    ll x;cin>>x;
    sum+=x;
  }

  if(sum<h){
    cout<<"No"<<ENDL;
  }else{
    cout<<"Yes"<<ENDL;
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
/**
 * AOJ #1186: Integral Rectangles (ICPC Domestic 2013)
 */

#include <stdio.h>

#define MAX_HW 150
#define DIAG2(h, w) ((h) * (h) + (w) * (w))
#define LT(h1, w1, h2, w2) (DIAG2((h1), (w1)) < DIAG2((h2), (w2)) || \
                           (DIAG2((h1), (w1)) == DIAG2((h2), (w2)) && \
                           (h1) < (h2)))

/**
 * Print the smallest wide integral rectangle bigger than the given one.
 */
void solve(int h, int w)
{
  int h1, w1, minh, minw;
  minh = minw = MAX_HW;
  for (h1 = 1; h1 <= MAX_HW; h1++) {
    for (w1 = h1 + 1; w1 <= MAX_HW; w1++) {
      if (LT(h, w, h1, w1)) {
        if (LT(h1, w1, minh, minw)) {
          minh = h1;
          minw = w1;
        }
      }
    }
  }
  printf("%d %d\n", minh, minw);
}

int main()
{
  int h, w;
  for (;;) {
    scanf("%d%d", &h, &w);
    if (h == 0 && w == 0) break;
    solve(h, w);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	ll n, x, q, y;
	cin >> n;
	ll arr[100002] = {0};
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		cin >> x;
		arr[x]++;
		ans += x;
	}
	cin >> q;
	while (q--)
	{
		cin >> x >> y;
		ans += y * arr[x];
		ans -= arr[x] * x;
		arr[y] += arr[x];
		arr[x] = 0;
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 4440
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    while(1) {
        int n, x;
        cin >> n >> x;
        if(n==0 && x==0) break;

        int ans = 0;
        for(int i=1; i<=n; ++i)
            for(int j=i+1; j<=n; ++j)
                for(int k=j+1; k<=n; ++k)
                    if(i+j+k == x) ans++;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
import sys

def solve(N, A, B):
    ans = 0
    for i in range(N):
        if A[i] != 0:
            d = min(A[i], B[i])
            A[i] -= d
            B[i] -= d
            ans += d

        if A[i+1] != 0 and B[i] != 0:
            d = min(A[i+1], B[i])
            A[i+1] -= d
            B[i] -= d
            ans += d
    
    return ans

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    print(solve(N, A, B))

if __name__ == "__main__":
    main()

Measured memory_bytes: 19000
n, l = map(int, input().split())
sum_ = int(n * (2 * l + (n - 1)) / 2)
min_ = l
max_ = l + n - 1
if min_ * max_ < 0:
  eaten = 0
else:
  eaten = min_ if abs(min_) < abs(max_) else max_
print(sum_ - eaten)

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

#define long long int

const int D = 365;
vector<int> C(26), ans(D, 0);
vector<vector<int>> S(D, vector<int>(26));

void debug1()
{
    //rep(i,26) cout << C[i] << " "; cout << endl;
    rep(i,D){
        rep(j,26)cout << S[i][j] << " ";
        cout << endl;
    }
}
void rand_init()
{
    rep(i,26) C[i] = rand() % 100;
    rep(i,D) rep(j,26) S[i][j] = rand() % 20000;
}
void input()
{
    int tmp;
    cin >> tmp;
    if(tmp == 0)
    {
      rand_init();
      return;
    }
    rep(i,26) cin >> C[i];
    rep(i,D)rep(j,26) cin >> S[i][j];
    rep(i,D) cin >> ans[i]; rep(i,D) ans[i]--; //B,C問題用
}
void output()
{
    for(auto x : ans)
        cout << x+1 << "\n";
}
int calc(vector<int> &vec)
{
    int score = 0;
    vector<int> last(26, -1);
    rep(i,D) score += S[i][ans[i]];
    rep(i,D)
    {
        int cur = vec[i];
        last[cur] = i;
        rep(j,26)
        {
            score -= C[j] * (i - last[j]);
        }
        //cout << score << endl;
    }
    return score;
}
bool is_increase(vector<int> &old, vector<int> &cur, int d, int q)
{
    int a = S[d][q] - S[d][old[d]];
    int p = old[d], b = 0, c = 0, last = -1;
    rep(i,D)
    {
      if(cur[i] == p) last = i;
      else b += C[p] * (i - last);
    }
    last = -1;
    rep(i,D)
    {
      if(cur[i] == q) last = i;
      else c += C[p] * (i - last);
    }
    return (a + b - c > 0);
}
    
void greedy()
{
    rep(i,D) rep(j,26)
        if(S[i][j] > S[i][ans[i]])
            ans[i] = j;
}
void rand_ans()
{
  rep(i,D) ans[i] = rand() % 26;
}
void incremental()
{
    rep(t, 100000)
    {
        int d = rand() % D, q = rand() % 26;
        vector<int> old = ans;
        ans[d] = q;
        if(calc(ans) < calc(old))
            ans = old;
    }
}
void solve()
{
  //greedy();
  rand_ans();
  incremental();
}
void rand_test(int r)
{
    rep(q,r)
    {
        rand_init();
        solve();
        cout << 1000000 + calc(ans) << endl;
    }
}
int main()
{
    input();
    //rand_test(10);
    solve();
    output();
    //cout << calc(ans) << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 3e3 + 5;
int N, T;
int dp[2 * MN];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> T;
    vector<pii> v;
    for (int i = 1; i <= N; i++) {
        int a, b; cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(all(v));
    for (int i = 1; i <= N; i++) {
        int a = v[i - 1].first, b = v[i - 1].second;
        for (int j = T - 1; j >= 0; j--) {
            dp[j + a] = max(dp[j + a], dp[j] + b);
        }
    }
    cout << *max_element(dp, dp + 2 * MN) << '\n';
    return 0;
}

Measured memory_bytes: 3704
#include<stdio.h>

int main(void){
    
    int i,j,max=0,rec=-1;
    int h[10];
    
    for(i=0;i<10;i++){
        scanf("%d",&h[i]);
    }
    for(i=0;i<3;i++){
        max=0;
        for(j=0;j<10;j++){
            if(h[j]>max){
                max = h[j];
                rec=j;
            }
        }
        printf("%d\n",max);
        h[rec] = 0;
        rec=-1;
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,m;
int main(){
	n=read(),m=read();
	for(int i=m-n+1;i<m+n;i++)
	printf("%d ",i);
	return 0;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
num = []
for i in range(1, x+1):
    num.append(i+n-1)
if 0 in num:
    print(sum(num))
else:
    ma = max(num)
    mi = min(num)
    if ma < 0:
        print(sum(num)-ma)
    else:
        print(sum(num)-mi)

Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<unordered_set>
#include<queue>
using namespace std;

bool is_connected(vector<vector<int>> &graph, pair<int, int> &e_rm)
{
	queue<int> q;
	unordered_set<int> visited;
	q.push(0);
	while (!q.empty())
	{
		int from = q.front();
		q.pop();
		if (visited.count(from))
		{
			continue;
		}
		visited.insert(from);
		for (auto const &to : graph[from])
		{
			bool ng = ((from == e_rm.first&&to == e_rm.second) || (from == e_rm.second&&to == e_rm.first));
			if (!ng)
			{
				q.push(to);
			}
		}
	}



	return visited.size() == graph.size();
}

int main()
{
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>>edges;
	vector<vector<int>>graph(N);
	for (int i = 0; i < M; i++)
	{
		int a, b;
		//a--; b--;
		cin >> a >> b;
		a--; b--;
		edges.push_back(make_pair(a,b));
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	int count = 0;
	for (int i = 0; i < M; i++)
	{
		bool conn = is_connected(graph, edges[i]);
		if (!conn)
		{
			count++;
		}
		
	}
	cout << count << endl;



}

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

int main(){
    int N;
    cin >> N;
    map<int, int> M;
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        M[x]++;
    }
    int count = 0;
    for(auto m:M) {
        if(m.second % 2 == 1) {
            count++;
        }
    }
    cout << count << endl;
}

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

int main() {
	string s;
     cin>>s;
    int a=s.length();
    int count=0;
    int max=count;
    int k=0;
     for(int i=0;i<a;i++)
     {   if((s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T')&&(s[i+1]=='A'||s[i+1]=='G'||s[i+1]=='C'||s[i+1]=='T'))
           {
             count++;
             if(count>max)
                 max=count;
            }
          else
            count=0;     
      }  
       for(int i=0;i<a;i++)
         { if((s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'))
            k=1;} 
           if(k==1)
            cout<<max+1;
            if(k==0)
            cout<<0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){

  int n,k;
  cin >> n >> k;
  int ans = 0;
  rep(i,0,n){
    int y;
    cin >> y;
    ans += min(y*2,abs((y-k)*2));
  }

  P(ans);
  
  return  0;
}


Measured memory_bytes: 384
/*
https://creep06.hatenablog.com/entry/20181031/1540979249
参考にさせて頂きました。
i write my code with looking this url's blog.
 */


#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;

ll n;
ll p[200005];

int main(){
    cin >> n;
    rep(i, n) cin >> p[i];
    vll bef(n+1, 0);
    rep(i,n){
        if (p[i]==1)
            bef[p[i]] = 1;
        else {
            if (bef[p[i]-1]>0)
                bef[p[i]] = bef[p[i] - 1] + 1;
            else
                bef[p[i]] = 1;
        }
    }
    ll ans = 0;
    rep(i, n + 1) ans = max(bef[i], ans);
    cout << n - ans << endl;
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 100010
int n,k;
int tab[MAXSIZE];
int dp[MAXSIZE];

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>k;
	FOR(i,1,n)
		cin>>tab[i];
	
	
	FOR(i,2,n){
		dp[i]=INF;
		FOR(j,1,k){
			if(i-j>=1)
				dp[i]=min(dp[i],dp[i-j]+abs(tab[i-j]-tab[i]));
		}
	}
	
	cout<<dp[n];
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
bool f(string s){
    int len = s.length();
    for(int i=0;i<len/2;i++){
        if(s[i] != s[len-1-i]) return false;
    }
    return true;
}
int main(void){
    string s;
    cin >> s;
    int n = s.length();
    if(f(s)){
        if(f(s.substr(0, (n-1)/2))){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


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

using namespace std;

#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;

struct info { ll x, y, g; };

//Solve ax + by = (a, b)
info ext_gcd(ll a, ll b)
{
	ll a0 = 1, a1 = 0, b0 = 0, b1 = 1, t;
	while (b != 0)
	{
		t = a0 - a / b * a1; a0 = a1; a1 = t;
		t = b0 - a / b * b1; b0 = b1; b1 = t;
		swap(a %= b, b);
	}
	if (a < 0)
	{
		a0 = -a0; b0 = -b0; a = -a;
	}
	return {a0, b0, a};
}


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

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

	info ans = ext_gcd(a, b);

	cout << ans.x << " " << ans.y << endl;

	return 0;
}

Measured memory_bytes: 1192
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

	int p = pow(100, d);
	for (int i = p; ; i += p)
	{
		int p2 = pow(100, d + 1);
		if (i % p2 != 0)
		{
			n--;
			if (n == 0)
			{
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 512
#include <iostream>

#define DIVISOR 1000000007
#define N_MAX 1000000

long pow10n[N_MAX], pow8n[N_MAX], pow9n[N_MAX];

int main(void) {
    long N, n, m;
    long remain_10 = 1, remain_8 = 1, remain_9 = 1, remain_10_9 = 0, remain_9_8 = 0;
    long remain;
    
    std::cin >> N;
    
    for(n = 0; n < N; n++) {
        pow10n[n] = remain_10;
        pow8n[n] = remain_8;
        pow9n[n] = remain_9;
        
        remain_10 = (remain_10 * 10) % DIVISOR;
        remain_8 = (remain_8 * 8) % DIVISOR;
        remain_9 = (remain_9 * 9) % DIVISOR;
    }
    
    for(n = 0; n < N; n++) {
        remain_10 = pow10n[N - n - 1];
        remain_8 = pow8n[N - n - 1];
        remain_9 = pow9n[n];
        
        remain_10_9 = (remain_10_9 + (remain_10 * remain_9) % DIVISOR) % DIVISOR;
        remain_9_8 = (remain_9_8 + (remain_9 * remain_8) % DIVISOR) % DIVISOR;
    }
    
    remain = (remain_10_9 + DIVISOR - remain_9_8) % DIVISOR;
    
    std::cout << remain << std::endl;
    
    return 0;
}

Measured memory_bytes: 26828
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int x; cin>>x;
    int ans=0;
    ans+=x/500*1000;
    x%=500;
    ans+=x/5*5;
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

VI g[100010];
int n, m, color[100010], d = 0;
bool e = true;

void dfs(int v, int c) {
  color[v] = c;
  d++;
  for(int i: g[v]) {
    if(color[i] == 0)
      dfs(i, -c);
    if(color[i] == c)
      e = false;
  }
}

signed main(void)
{
  cin >> n >> m;
  REP(i, m) {
    int u, v;
    cin >> u >> v;
    g[u-1].push_back(v-1);
    g[v-1].push_back(u-1);
  }

  ll a = 0, b = 0, c = 0;
  REP(i, n) {
    d = 0; e = true;
    if(color[i] == 0) {
      dfs(i, 1);
      if(d == 1) a++;
      else if(e) b++;
      else c++;
    }
  }
  //cout << a << " " << b << " " << c << endl;
  cout << 2*b*b + 2*b*c + c*c + a*a + 2*a*(n-a) << endl;
  return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 1003;

int n;
char mp[_][_]={0};

#define item(i,j) (mp[(i)+(x)][(j)+(y)])
#define puth(i,j,k) (item(i,j)=item(i+1,j)=*(#k))
#define putv(i,j,k) (item(i,j)=item(i,j+1)=*(#k))

inline void put3s(int x,int y)
{
	putv(0,0,a),puth(1,2,b);
}
inline void put3d(int x,int y)
{
	putv(0,0,a);
	puth(1,2,b);
	puth(2,0,c);
	putv(3,1,d);
}

inline void put4t(int x,int y)
{
	putv(0,0,a),putv(1,0,b);
	puth(0,2,c),puth(0,3,d);
	puth(2,0,e),puth(2,1,f);
	putv(2,2,g),putv(3,2,h);
}

inline void put5t(int x,int y)
{
	putv(0,0,a),puth(0,2,b),puth(0,3,c);
	puth(1,4,d);
	puth(2,0,e),putv(2,1,f);
	puth(3,2,g),putv(3,3,h);
	putv(4,0,i),putv(4,3,j);
}

inline void put6s(int x,int y)
{
	putv(0,0,a),puth(1,2,b),putv(3,3,c),puth(4,5,d);
}

inline void put6t(int x,int y)
{
	putv(0,0,a),puth(0,2,b),putv(0,3,c);
	puth(1,0,d),puth(1,5,e);
	putv(2,1,f);
	putv(3,0,g),putv(3,3,h),puth(3,5,i);
	puth(4,2,j),puth(4,3,k);
	putv(5,4,l);
}

inline void put7t(int x,int y)
{
	putv(0,0,a),putv(0,2,b),puth(0,4,c);
	puth(1,0,d),putv(1,5,e);
	puth(2,2,f),putv(2,3,g);
	putv(3,0,h),puth(3,4,i);
	puth(4,1,j),putv(4,5,k);
	puth(5,5,l),puth(5,6,m);
	putv(6,2,n);
}

#undef item
#undef puth
#undef putv

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);
	
	n=ty();
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)mp[i][j]='.';

	if(n<=2){cout<<-1<<lf;return 0;}
	
	if(n==3)put3s(1,1);
	else
	{
		int now=n%4+4;
		if(now==4)put4t(1,1);
		if(now==5)put5t(1,1);
		if(now==6)put6t(1,1);
		if(now==7)put7t(1,1);
		now++;
		while(now<=n)put4t(now,now),now+=4;
	}

	for(int i=1;i<=n;i++)cout<<mp[i]+1<<lf;
	
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct Data {
    int r, g, b, cnt;

    Data() {
        r = g = b = cnt = 0;
    }

    Data(int _r, int _g, int _b, int _c) {
        r = _r;
        g = _g;
        b = _b;
        cnt = _c;
    }
};

int red, green, blue, k;

bool brute() {
    queue<Data> q;
    q.push(Data(red, green, blue, 0));
    while (!q.empty()) {
        Data x = q.front();
        q.pop();
        if (x.g > x.r && x.b > x.g) {
            return true;
        }
        if (x.cnt == k) {
            continue;
        }
        q.push(Data(x.r * 2, x.g, x.b, x.cnt + 1));
        q.push(Data(x.r, x.g * 2, x.b, x.cnt + 1));
        q.push(Data(x.r, x.g, x.b * 2, x.cnt + 1));
    }
    return false;
}

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    cin >> red >> green >> blue >> k;
    cout << (brute() ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3628
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	var A = input[0];
  var B = input[1];
  if(A == 1 && B == 1){
     console.log("Draw");
  }else if(A == 1 && B != 1){
     console.log("Alice");
  }else if(A != 1 && B == 1){
     console.log("Bob");
  }else if(A > B){
     console.log("Alice");
  }else if(A < B){
     console.log("Bob");      
  }else{
     console.log("Draw");
  }
}

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


Measured memory_bytes: 7372
#include <cstdio>

int abs(int d){
    return (d>=0)? d:-d;
}

int main(){
    int H,W,D,Q,A,L,R;

    scanf("%d %d %d",&H,&W,&D);
    int *mp = new int[H*W];
    int *x = new int[H*W]; 
    int *y = new int[H*W];

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf("%d", &A);
            x[A]=j;
            y[A]=i;
        }
    }

    for(int i=D+1;i<=H*W;i++){
        mp[i]=mp[i-D]+abs(x[i]-x[i-D])+abs(y[i]-y[i-D]);
    }

    scanf("%d",&Q);
    for(int i=0;i<Q;i++){
        scanf("%d %d",&L,&R);
        printf("%d\n",mp[R]-mp[L]);
    }
    
    return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>

const int MAXN = 3e5 + 1, Mod = 1e9 + 7;

namespace Mathscalc {
    inline int Add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
    inline int Sub(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
    inline int Mul(int a, int b) { return 1LL * a * b % Mod; }
} using namespace Mathscalc;

int n, m, k;

int jc[MAXN << 2], inv[MAXN << 2], invj[MAXN << 2], p[MAXN << 2];
void GetNeed() {
    p[0] = 1; for (int i = 1; i <= MAXN * 3; ++i) p[i] = Mul(p[i - 1], 3);
    jc[0] = 1; for (int i = 1; i <= MAXN * 3; ++i) jc[i] = Mul(jc[i - 1], i);
    inv[1] = 1; for (int i = 2; i <= MAXN * 3; ++i) inv[i] = Mul(Sub(Mod, Mod / i), inv[Mod % i]);
    invj[0] = 1; for (int i = 1; i <= MAXN * 3; ++i) invj[i] = Mul(invj[i - 1], inv[i]);
}

inline int C(int n, int m) { return Mul(jc[n], Mul(invj[m], invj[n - m])); }

int main() {
    scanf("%d%d%d", &n, &m, &k);
    GetNeed();
    if (m < k) std :: swap(m, k); --n;
    int ans = 0, x = 1;
    for (int i = 0; i <= m + k; ++i) {
        ans = Add(ans, Mul(C(n + i, n), Mul(p[m + k - i], x)));
        if (i < k) x = Mul(x, 2);
        else if (i < m) x = Sub(Mul(x, 2), C(i, k));
        else x = Sub(Mul(x, 2), Add(C(i, m), C(i, k)));
    }
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 18688
#include<cstdio>
#include<vector>


using namespace std;

using vi=vector<int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi c(n), s(n), f(n), ans(n);

		for(int i=0;i<n-1;i++)
		{
			scanf("%d%d%d", &c[i], &s[i], &f[i]);
		}

		for(int i=0;i<n-1;i++)
		{
			for(int j=0;j<=i;j++)
			{
				ans[j]=max((ans[j]+f[i]-1)/f[i]*f[i], s[i])+c[i];
			}
		}

		for(auto t:ans)
		{
			printf("%d\n", t);
		}
	}

	return 0;
}


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

using namespace std;

int hoge(int n, int m, vector<vector<int>> &vec, vector<int> &ps,
         vector<int> pattern = {}) {
  if (static_cast<int>(pattern.size()) == n) {
    int ret = 1;
    for (int i = 0; i < m; ++i) {
      int cnt = 0;
      for (auto &v : vec[i])
        cnt += pattern[v - 1];
      if (cnt % 2 != ps[i])
        ret = 0;
    }
    return ret;
  }

  vector<int> pattern1 = pattern;
  vector<int> pattern2 = pattern;
  pattern1.push_back(0);
  pattern2.push_back(1);
  int ret = hoge(n, m, vec, ps, pattern1);
  ret += hoge(n, m, vec, ps, pattern2);
  return ret;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vec(m);
  for (auto &v : vec) {
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int tmp;
      cin >> tmp;
      v.push_back(tmp);
    }
  }

  vector<int> ps(m);
  for (auto &v : ps)
    cin >> v;

  int ans = hoge(n, m, vec, ps);
  cout << ans << endl;
}

Measured memory_bytes: 3628
package main

import (
  "fmt"
  "bufio"
  "strings"
  "strconv"
  "os"
  "unsafe"
)

func main() {
  rd := bufio.NewReaderSize(os.Stdin, 100000)
  num_string := make([]byte, 0, 100000)

  for {
    l, p, _ := rd.ReadLine()
    num_string = append(num_string, l...)
    if !p {
      break
    }
  }

  nums := strings.Split(*(*string)(unsafe.Pointer(&num_string)), " ")
  n, _ := strconv.Atoi(nums[0])
  k, _ := strconv.Atoi(nums[1])

  s := make([]byte, 0, 100000)

  for {
    l, p, _ := rd.ReadLine()
    s = append(s, l...)
    if !p {
      break
    }
  }

  var count [100003]int

  var prev_value byte = '1'
  arr_num := 1
  for i := 0; i < n; i++ {
    if s[i] != prev_value {
      count[arr_num] = i
      arr_num++
      prev_value = s[i]
    }
  }

  count[arr_num] = n
  arr_num++
  if prev_value == '0' {
    count[arr_num] = n
    arr_num++
  }

  num := 2 * k + 1
  max := 0

  for i := 1;; i += 2 {
    if i + num > arr_num {
      sum := count[arr_num - 1] - count[i - 1]
      if sum > max {
        fmt.Println(sum)
      } else {
        fmt.Println(max)
      }
      break
    }
    sum := count[i + num - 1] - count[i - 1]
    if sum > max {
      max = sum
    }
  }
}


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

bool is_even(int n) {
  return n % 2 == 0;
}

int get_times_div2(int n) {
  int times = 0;
  while (is_even(n)) {
    n /= 2;
    times++;
  }
  return times;
}

void answer1(vector<int> a) {
  // 工夫した実装
  int mi = INT_MAX;
  //cout << INT_MAX << endl;
  for (int a_i: a) {
    int a_i_count = get_times_div2(a_i);
    mi = min(mi, a_i_count);
  }
  cout << mi << endl;
}

void answer2(std::vector<int> a) {
  // 素朴な実装
  int count = 0;
  bool can_continue = true;
  while (can_continue) {
    for (int& a_i: a) {
      if (is_even(a_i)) {
        a_i /= 2;
      } else {
        can_continue = false;
        break;
      }
    }
    if (can_continue) {
      count++;
    }
  }
  std::cout << count << '\n';
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int& a_i: a) {
    cin >> a_i;
  }
  answer1(a);
  //answer2(a);
}


Measured memory_bytes: 256
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

w, h, n = na()
l = 0
r = w
u = h
d = 0
for i in range(n):
    x, y, a = na()
    if a == 1:
        l = max(l, x)
    if a == 2:
        r = min(r, x)
    if a == 3:
        d = max(d, y)
    if a == 4:
        u = min(u, y)
print(max(0, r - l) * max(0, u - d))

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

int main() {
	long long n;
	long long p;
	long long answer = 1;
	static bool a[1000000];

	for (int i = 0; i < 1000000; i++) {
		a[i] = 1;
	}

	for (int i = 2; i < 1000000; i++) {
		if (a[i] == 1) {
			for (int j = 2 * i; j < 1000000; j += i) {
				a[j] = 0;
			}
		}
	}

	cin >> n >> p;
	long long i = 2;

	if (n == 1) {
		answer = p;
	}
	else {
		while (1) {
			if (i >= 1000000) { break; }
			if (a[i] == 1) {
				if (long(pow(i, n)) > p) {
					break;
				}
				else if (p % long(pow(i, n)) == 0) {
					answer *= i;
					p /= long(pow(i, n));

				}
				else {
					i++;
				}
			}
			else {
				i++;
			}
		}
	}
	

	cout << answer << endl;
}

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

signed main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  string ans="No";
  if(abs(A-C)<=D)ans="Yes";
  if(abs(A-B)<=D&&abs(B-C)<=D)ans="Yes";
  cout<<ans<<endl;
}

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

int main() {
  vector<int> bs = {0x0, 0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f}; // two based
  int n;
  while(cin >> n, n >= 0) {
    int lastnum = -1;
    for(int i = 0; i < n; ++i) {
      int num;
      cin >> num;
      cout << static_cast<bitset<7> >(bs[num + 1] ^ bs[lastnum + 1]) << endl;
      lastnum = num;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray = br.readLine().split(" ");
		
		int t = Integer.parseInt(tmpArray[0]);
		int a = Integer.parseInt(tmpArray[1]);
		
		double temper[] = new double[n];
		
		tmpArray = br.readLine().split(" ");
		double dt = Double.MAX_VALUE;
		int index = -1;
				
		for(int i = 0; i < n; i++){
			int h = Integer.parseInt(tmpArray[i]);
			
			temper[i] = t - 0.006*h;
			
			if(dt > Math.abs(temper[i] - a)){
				dt = Math.abs(temper[i] - a);
				index = i;
			}
		}
		
		System.out.println(index + 1);
	}

}


Measured memory_bytes: 21204
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////
#define int long long


void solve(){

	int n;
	cin>>n;
	int a[n];
	int x = 0;
	for(int i = 0 ; i < n ; ++i){
		cin>>a[i];
		x^=a[i];
	}

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

		cout<<(x^a[i])<<" ";
	}
	cout<<endl;


}

signed main(){

	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<ll> a(n), b(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  for(int i=0;i<n;++i) {
    cin >> b[i];
  }
  priority_queue<P> pq;
  for(int i=0;i<n;++i) {
    pq.push({b[i], i});
  }
  ll ans = 0;
  while(!pq.empty()) {
    P p = pq.top(); pq.pop();
    ll now = p.first, idx = p.second;
    if(now != b[idx]) continue;
    ll idx1 = (idx + n - 1) % n, idx2 = (idx + 1) % n;
    if((now - a[idx]) % (b[idx1] + b[idx2]) == 0) {
      if(now - a[idx] == 0) continue;
      ans += (now - a[idx]) / (b[idx1] + b[idx2]);
      b[idx] = a[idx];
      pq.push({b[idx], idx});
    } else {
      ll tmp = b[idx1] + b[idx2];
      if(tmp == 0) continue;
      ll cnt = (now - tmp - 1) / tmp + 1;
      ans += cnt;
      b[idx] -= cnt * tmp;
      if(b[idx] < 0) {
        cout << -1 << endl;
        return 0;
      }
      pq.push({b[idx], idx});
    }
  }
  bool ok = true;
  for(int i=0;i<n;++i) {
    ok &= a[i] == b[i];
  }
  cout << (ok ? ans : -1) << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

int main() {
    cin >> n;
    vl h;
    NREP() {
        IPT(ll, h);
    }

    ans = 0;
    cnt = 0;
    REP(i, n-1) {
        if (h.at(i) >= h.at(i+1)) {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    MSG(ans)
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  ll k = gcd(n,m);
  auto s = prime_factorize(k);
  cout << s.size()+1 << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<bitset>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n,k;
char s[2010][10010];
bitset<MAXN> dp[2010];
pair<int,int> qr[2][2010];
int val[2010];
int main(){
	SF("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		SF("%s",s[i]);
		val[i]=strlen(s[i]);
	}
	dp[n+1][0]=1;
	for(int i=n;i>0;i--)
		for(int j=0;j<=k;j++)
			if(dp[i+1][j]==1){
				dp[i][j]=1;
				if(j+val[i]<=k)
					dp[i][j+val[i]]=1;
			}
	int now=0,cnt=0;
	for(int i=1;i<=n;i++)
		if(dp[i+1][k-val[i]]==1)
			qr[now][++cnt]=make_pair(i,0);
	while(k--){
		char minc='z';
		int cntn=0,minid=n+1;
		
		for(int i=1;i<=cnt;i++){
			int id=qr[now][i].first;
			int num=qr[now][i].second;
			minc=min(minc,s[id][num]);
		}
		PF("%c",minc);
		for(int i=1;i<=cnt;i++){
			int id=qr[now][i].first;
			int num=qr[now][i].second;
			if(s[id][num]!=minc)
				continue;
			if(num+1==val[id])
				minid=min(minid,id);
			else
				qr[now^1][++cntn]=make_pair(id,num+1);
		}
		for(int i=minid+1;i<=n;i++)
			if(val[i]<=k&&dp[i+1][k-val[i]]==1)
				qr[now^1][++cntn]=make_pair(i,0);
		now^=1;
		cnt=cntn;
	}
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    vector<int> colors = {a, b, c};
    sort(colors.begin(), colors.end());
    colors.erase(unique(colors.begin(), colors.end()), colors.end());
    cout << colors.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a[5];
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	long sum=0;
	while(a[1]!=a[3])
	{
		sum++;
		if(a[2]==a[3]||a[3]-a[1]>1)
		{
			a[1]+=2;
		}else{
			a[1]++;a[2]++;
		}
		sort(a+1,a+4);
	}
	cout<<sum<<endl;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    vector< vector<int> > lcs(s.length()+1,vector<int>(t.length()+1,0));
    for(int i=1;i<=s.length();i++)
    {
        //cout<<"1"<<endl;
        for(int j=1;j<=t.length();j++)
        {
            //cout<<"2"<<endl;
            if(s[i-1]==t[j-1])
            {
                //cout<<s[i-1];
                lcs[i][j]=lcs[i-1][j-1]+1;
            }
            else
            {
                //cout<<endl<<"ELSE: "<<s[i-1]<<" "<<t[j-1]<<endl;
                lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);

            }
        }
    }
    int i=s.length(),j=t.length(),c=lcs[i][j];
    char l[lcs[i][j]+1];
    l[lcs[i][j]]='\0';
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            l[c-1]=s[i-1];
            i--;j--;c--;
        }
        else if(lcs[i-1][j]>lcs[i][j-1])
            i--;
        else
            j--;
    }
    cout<<l;
}


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

int main(){
  	string S,T;
    cin >> S;
    cin >> T;
    int len = S.size();
    int len2 = T.size();
    int flag = 0;
    int ans;
    ans = 0;
    for(int i=0;i<len;i++){
    	if(S[i]!=T[i]){
            ans += 1;
        }
    }
  	if(ans == 0){
      	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 3636