akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    vl A(N), B(N); REP(i, N) cin >> A[i] >> B[i];
    vector<pair<ll, ll>> C(N); REP(i, N) C[i] = make_pair(A[i]+B[i], i);
    sort(ALL(C), greater<>());
    ll t = 0, a = 0;
    for(int i = 0; i < N; i+=2) t += A[C[i].second];
    for(int i = 1; i < N; i+=2) a += B[C[i].second];
    cout << t - a << endl;
}

Measured memory_bytes: 3456
// C - Reconciled?
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

ll factorial_mod(ll n){//階乗％MOD
	ll ans = n;
	while(n>1) ans = ans * --n % MOD;
	return ans;
}

int main(){
	ll N,M; cin>>N>>M;

	if(abs(N - M) > 1){
		cout<< 0 <<endl;
		return 0;
	}

	ll ans =  factorial_mod(N) * factorial_mod(M) % MOD;
	if(N == M) ans = ans * 2 % MOD;
	cout<< ans <<endl;
}

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

int main() {
    int n;cin>>n;
    pair<int,int> a[n];
    for (int i=0;i<n;i++) {
        int x,y;cin>>x>>y;
        a[i]={x,y};
    }
    sort(a,a+n);
    double ans=0;
    do {
        for (int i=1;i<n;i++)
            ans+=hypot(a[i].first-a[i-1].first,a[i].second-a[i-1].second);
    } while (next_permutation(a,a+n));
    for (int i=2;i<=n;i++)
        ans/=i;
    cout<<fixed<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//2020.1.6
//s1270188 xxxmk2
//alds1_07a

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

//struct
typedef struct {
  int p, l, r;
}node;

//prototype
int depth(int);

//global
node *data;

int main(){
  int i, j, a, b, c, d, num;

  //input
  scanf("%d",&num);
  data=(node *)malloc(sizeof(node)*num);
  for(i=0;i<num;i++) data[i].p=data[i].l=data[i].r=-1;
  
  for(i=0;i<num;i++){
    scanf("%d %d",&a,&b);

    for(j=0;j<b;j++){
      scanf("%d",&c);
      if(j==0) data[a].l=c;
      else data[d].r=c;
      d=c;
      data[c].p=a;
    }  
  }

  //output
  for(i=0;i<num;i++){
    printf("node %d: parent = %d, depth = %d, ",i,data[i].p,depth(i));

    if(data[i].p==-1) printf("root, [");
    else if(data[i].l==-1) printf("leaf, [");
    else printf("internal node, [");

    for(j=data[i].l;j!=-1;j=data[j].r){
      if(data[j].r==-1) printf("%d",j);
      else printf("%d, ",j);
    }
    printf("]\n");
    
  }

  free(data);
  return 0;
}

int depth(int n){
  int depth=0;

  for(;data[n].p!=-1;n=data[n].p) depth++;

  return depth;
}



Measured memory_bytes: 2532
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int ans[10005];

int main() {
    int n;
    cin >> n;
    for (int x = 1; x * x < n; x++) {
        for (int y = 1; y * y < n; y++) {
            for (int z = 1; z * z < n; z++) {
                int v = x*x + y*y + z*z + x*y + y*z + x*z;
                if (v <= n) {
                    ans[v]++;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3656
a, b, c, d = map(int, input())
l = [a+b+c+d, a+b+c-d, a+b-c+d, a+b-c-d, a-b+c+d, a-b+c-d, a-b-c+d, a-b-c-d]

if l.index(7) == 0:
    print(a, '+', b, '+', c, '+', d, '=7', sep='')
elif l.index(7) == 1:
    print(a, '+', b, '+', c, '-', d, '=7', sep='')
elif l.index(7) == 2:
    print(a, '+', b, '-', c, '+', d, '=7', sep='')
elif l.index(7) == 3:
    print(a, '+', b, '-', c, '-', d, '=7', sep='')
elif l.index(7) == 4:
    print(a, '-', b, '+', c, '+', d, '=7', sep='')
elif l.index(7) == 5:
    print(a, '-', b, '+', c, '-', d, '=7', sep='')
elif l.index(7) == 6:
    print(a, '-', b, '-', c, '+', d, '=7', sep='')
elif l.index(7) == 7:
    print(a, '-', b, '-', c, '-', d, '=7', sep='')

Measured memory_bytes: 3064
if __name__ == '__main__':
    N = 15
    line = input()
    nums = line.split(' ')
    a, b = [int(i.strip()) for i in nums]
    assert 1 <= a <= 15
    assert 1 <= b <= 15
    if N - a == b:
        print('+')
    elif N / a == b:
        print('*')
    else:
        print('x')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

string S;
ll dp[112345][4]; // [i][j] i文字目(1-indexed)時点でABCの状態がjであるときの場合の数

int main() {
	cin >> S;
	
	dp[0][0] = 1;
	REP(i, S.size()) {
		char c[3] = {'A', 'B', 'C'};
		
		REP(j, 4) {
			ll cur = dp[i][j];
			
			if (S[i] == '?') {
				if (j < 3) (dp[i + 1][j + 1] += cur) %= MOD;
				(dp[i + 1][j] += cur * 3) %= MOD;
			}
			else {
				if (j < 3 && S[i] == c[j]) (dp[i + 1][j + 1] += cur) %= MOD;
				(dp[i + 1][j] += cur) %= MOD;
			}
		}
	}
	cout << dp[S.size()][3] << endl;
	
	return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h, w;
		while(true){
			h = sc.nextInt();
			w = sc.nextInt();
			if(h==0 && w==0)break;
			if(h<=300 && w<=300){
				for(int i=0; i<h; i++){
					for(int j=0; j<w; j++){
						if(i==0 || (i+1)==h || j==0 || (j+1)==w){
							System.out.print("#");
						} else{
							System.out.print(".");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 24668
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if (N==2) {
    cout << A[0] << endl;
    return 0;
  }
  ll res = A[0];
  if (N%2!=0) {
    for (int i=1; i<(N-1)/2; i++) res += 2*A[i];
    res += A[(N-1)/2];
  }
  else for (int i=1; i<N/2; i++) res += 2*A[i];
  cout << res << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
  	int x = N % 10;
    if( x == 3 ) printf("bon");
    else if(x == 0 or x == 1 or x==6 or x== 8) printf("pon");
    else printf("hon");
    return 0;
}

Measured memory_bytes: 3760
def solve():
  n = int(input())
  f = []
  ans = -1000000000
  for i in range(n):
    tmp = list(int(i) for i in input().split())
    f.append(tmp)
  p = []
  for i in range(n):
    tmp = list(int(i) for i in input().split())
    p.append(tmp)
  for bit in range(1,2**10):
    benefit = 0
    ope = 0
    query = [0]*n
    for j in range(10):
      if (bit>>j)&1 == 1:
        for i in range(n):
          if f[i][j]:
            query[i] += 1

    for i in range(n):
      benefit += p[i][query[i]]
    ans = max(ans,benefit)
  print(ans)
        
        
      
solve()

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    ll x, res = 0; 
    cin >> x;
    res += x / 500 * 1000;
    x %= 500;
    res += x / 5 * 5;
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 256
(defparameter *s* (coerce (read-line) 'list))
(defparameter *t* (coerce (read-line) 'list))

(defparameter *alphabet* (coerce "abcdefghijklmnopqrstuvwxyz" 'list))

(defun f (str)
  (mapcar (lambda (x) (count x str)) *alphabet*))

(defun g (str1 str2)
  (if (equal (sort (remove 0 (f str1)) #'<)
             (sort (remove 0 (f str2)) #'<))
      "Yes"
      "No"))

(princ (g *s* *t*))

Measured memory_bytes: 16612
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,n)       for(int i=0; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}





int32_t main()
{
    //zeus();

    int n; cin >> n;
    int k; cin >> k;

    if (k >= n) {
        k = n - 1;
    }

    int h[n];

    forn(i, n) {
        cin >> h[i];
    }

    int x[n];

    x[0] = 0;
    x[1] = abs(h[1] - h[0]);

    for (int i = 2; i < k; i++) {
        int mini = INT_MAX;
        for (int j = i; j > 0; j--) {
            mini = min(mini, x[i - j] + abs(h[i] - h[i - j]));

        }
        x[i] = mini;
        //cout << x[i] << endl;
    }

    for (int i = k; i < n; i++) {
        int mini = INT_MAX;

        for (int j = k; j > 0; j--) {
            mini = min(mini, x[i - j] + abs(h[i] - h[i - j]));
        }
        x[i] = mini;
        //cout << x[i] << endl;
    }

    cout << x[n - 1] << endl;

    //cout << INT_MAX;



}


Measured memory_bytes: 1792
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

def bsearch(mn, mx, func):
    #func(i)=True を満たす最大のi (mn<=i<mx)
    idx = (mx + mn)//2
    while mx-mn>1:
        if func(idx):
            idx, mn = (idx + mx)//2, idx
            continue
        idx, mx = (idx + mn)//2, idx
    return idx

import sys;input=sys.stdin.readline
Q, = map(int, input().split())
qs = []
c = 0
j = 0
for _ in range(Q):
    q = input().split()
    if len(q) == 1:
        c += 1
    else:
        a, b = int(q[1]), int(q[2])
        qs.append((a, b, c, j))
        c = 0
        j+=1
if c:
    qs.append((a, b, c, j))

m = j
qqs = sorted(qs, key=lambda x:x[0])
j2i = dict()
i2a = dict()
for i, (a, b, c, j) in enumerate(qqs):
    j2i[j] = i+1
    i2a[i+1] = a

m = len(j2i)
st = Bit(m)
st_sum = Bit(m)
asum=bsum=0
#print(i2a)
#print(j2i)
for a, b, c, i in qs:
    if c:
        j = bsearch(0, m+1, lambda x: st.sum(x)<ci)
#        print(st_sum.sum(j+1))
        for _ in range(c):
            if not i%2:
                print(i2a[j+1], -2*st_sum.sum(j+1)+asum+bsum)
            else:
                print(i2a[j+1], -st_sum.sum(j)+(asum-st_sum.sum(j+1))+bsum)
    asum += a
    bsum += b
    st.add(j2i[i], 1)
    st_sum.add(j2i[i], a)
    ci = -(-(i+1)//2)


Measured memory_bytes: 110940
import math

def calc(x,k,n):
    m = math.ceil(math.log2(k/x))
    y = 2**m
    if x >= k:
        return 1
    else:
        return 1/y
n,k = map(int,input().split())
ans = 0.0
for x in range(1,n+1):
    tmp = calc(x,k,n)
    ans += tmp
print(ans/n)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int ans = 0;
  for(int a = 0 ; a <= A ; a++){
    for(int b = 0 ; b <= B ; b++){
      for(int c = 0 ; c <= C ; c++){
        if(500 * a + 100 * b + 50 * c == X){
          ans++;
        }
  	  }
  	}
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int dp[10000][10000];

string s,t;
int main(){
  cin>>s>>t;

  int N = s.length();
  int M = t.length();

  string ans = "";

  memset(dp, 0, sizeof(dp));

  rep(i,N)
    rep(j,M){
      if(s.at(i) == t.at(j)){
        dp[i+1][j+1] = max(dp[i][j]+1, max(dp[i][j+1], dp[i+1][j]));
      }else{
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }


  int n = N;
  int m = M;
  while(n>0 && m>0){
    if(dp[n][m] == dp[n-1][m]){
      n--;
    }else if(dp[n][m] == dp[n][m-1]){
      m--;
    }else{
      ans = s[n-1] + ans;
      n--;m--;
    }
  }

  cout<< ans << endl;
}

Measured memory_bytes: 390912
#include <iostream>

using namespace std;

int n, maxim, r, sum, a[101], minim;

int main()
{
  cin >> n;
  minim = 101;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    maxim = max (maxim, a[i]);
    minim = min (minim, a[i]);
  }
  r = 2000000;
  for (int i = minim; i <= maxim; i++) {
    sum = 0;
    for (int j = 1; j <= n; j++)
      sum += (a[j] - i) * (a[j] - i);
    r = min (r, sum);
    //cout << sum << ' ';
  }
  cout << r;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        for (int i = Math.min(a, b); 1 <= i; i--) {
            if (a % i == 0 && b % i == 0) {
                k--;
                if (k==0) {
                    System.out.println(i);
                }
            }
        }
    }
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3


int main(){
    cin.sync_with_stdio(false);
    int n, q, k;
    cin >> n;
    vector<P> edge[n];
    rep(i, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edge[a].pb(P(c, b)), edge[b].pb(P(c, a));
    }
    cin >> q >> k; k--;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, k));
    bool visited[n] = {};
    ll cost[n] = {};
    while(que.size()) {
        P p = que.top(); que.pop();
        if (visited[p.se]) continue;
        visited[p.se] = true;
        cost[p.se] = p.fi;
        rep(i, edge[p.se].size()) {
            int u = edge[p.se][i].se, c = edge[p.se][i].fi;
            if (!visited[u]) que.push(P(p.fi + c, u));
        }
    }
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        cout << cost[x - 1] + cost[y - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 11248
# -*- coding: utf-8 -*-                                                                              

N = int(input())
T, A = map(int, input().split())

import numpy as	np

ans = (T-A) / 0.006

h = np.abs(np.array(list(map(int, input().split()))) - ans)

print(np.argmin(h) + 1)
	


Measured memory_bytes: 12488
#include <iostream>
#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ld n ; cin >> n ;
	n /= 3 ;
	cout << fixed << setprecision(15) << n*n*n << endl ;
}


Measured memory_bytes: 256
# 横軸:重さ
def knapsack(W,weight,value):
    n = len(weight)#or len(value)
    dp = [[0]*(W+1) for _ in range(n+1)]
    # 初期化
    for j in range(W):
        dp[0][j] = 0
    for i in range(n):
        for j in range(W+1):
            if weight[i] <= j:
                dp[i+1][j] = max(dp[i][j-weight[i]]+value[i],dp[i][j])
            else:
                dp[i+1][j] = dp[i][j]
    sol = dp[-1][-1]
    return dp,sol

# Wが大きい時
# 横軸:価値
# 価値が小さい必要がある
# https://qiita.com/drken/items/dc53c683d6de8aeacf5a#e-%E5%95%8F%E9%A1%8C---knapsack-2
def knapsack2(W,weight,value):
    n = len(weight)
    max_v = n*max(value)
    dp = [[0 for j in range(max_v)] for i in range(n)]
    
    for i in range(max_v):
        if i+1 > value[0]:
            dp[0][i] = float('inf')
        else:
            dp[0][i] = weight[0]
    
    for i in range(1,n):
        for j in range(max_v):
            if j+1 > value[i]:
                dp[i][j] = min(dp[i-1][j], weight[i]+dp[i-1][j-value[i]])
            else:
                dp[i][j] = min(dp[i-1][j], weight[i])
    for i in range(1,max_v+1)[::-1]:
        if dp[-1][i-1] <= W:
            sol = i
            break
    return dp,sol

N,W = map(int,input().split())
values, weights = [],[]
for _ in range(N):
    ｗ,ｖ = map(int,input().split())
    values.append(v)
    weights.append(w)

W = min(W,sum(weights))
dp,sol = knapsack2(W,weights,values)
print(sol)


Measured memory_bytes: 278792
def energy_drink_collector(n,m,dic):
    count = 0
    v = 0
    stores = sorted(dic.keys())

    for i in range(n):
        c = stores[i]
        s = dic[c]
        v += s

        if v >= m:
            _s = s - (v - m)
            count += c * _s
            break
        else:
            count += c * s

    return count

if __name__ == '__main__':
    n,m = map(int,raw_input().split())
    a = [0]*n
    b = [0]*n
    dic = {}
    for i in range(n):
        a[i],b[i] = map(int,raw_input().split())
        dic[a[i]] = 0

    for i in range(n):
        dic[a[i]] = dic[a[i]] + b[i]

    print energy_drink_collector(n,m,dic)

Measured memory_bytes: 21928
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  cin>>A;
  ll x=0;
  for(auto &I:A){x^=I;}
  for(auto &I:A){cout<<(x^I)<<endl;}
  


  return 0;
}


Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int s, w;
    cin >> s >> w;
    if(s <= w)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3636
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int m[200008];
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	 int n,k;cin>>n>>k;for(int i=0;i<n;i++) 
	 {
	 	int a;cin>>a;
	 	m[a]++; 
	 }sort(m+1,m+n+1);reverse(m+1,m+n+1);int ans=0;
	 for(int i=k+1;i<=n;i++) ans+=m[i];cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
S = input()
N = len(S)
S2 = S[:((N - 1) // 2)]
S3 = S[((N + 1) // 2):]

S_rev1 = S[::-1]
S_rev2 = S2[::-1]
S_rev3 = S3[::-1]

if S == S_rev1 and S2 == S_rev2 and S3 == S_rev3 :
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <cstdio>
 
int main(int argc, const char * argv[]) {
    
    int n,k;
    
    scanf("%d %d",&n,&k);
    
    for(int i=1,tmp;i<=n;i++){
        scanf("%d",&tmp);
    }
    int ans = 0;
    
    int tmp = n;
    for(int i=0;i<n;i++){
        if(tmp>1){
            tmp-=(k-1);
            ans++;
        }else break;
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        A: usize,
        B: usize,
    }
    for x in 1..10000 {
        if (x as f64 * 0.08).floor() as usize == A && (x as f64 * 0.1).floor() as usize == B {
            println!("{}", x);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#define _USE_MATH_DEFINES
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}

ll n, a,b, p2[200005] = {0}, M = 1000000007, ans = 1;
map<pair<ll,ll>, int> mp, vis;
ll mul(ll a, ll b){
    return (a*b)%M;
}
ll add(ll a, ll b){
    a+=b;
    if (a>=M) a-=M;
    if (a<0) a+=M;
    return a;
}
int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin>>n;
    p2[0] = 1;
    for (int i = 1; i <= n; i++){
        p2[i] = mul(p2[i-1],(ll)2);
    }
    for (int i = 0; i < n; i++){
        cin>>a>>b;
        ll g = gcd(abs(a),abs(b));
        if (g){
            a/=g;
            b/=g;
        }
        if (a<0){
            a*=-1;
            b*=-1;
        }
        if ((a==0) && (b!=0)){
            b=1;
        }
        else if ((a!=0) && (b==0)){
            a=1;
        }
        mp[make_pair(a,b)]++;
    }

    for (map<pair<ll,ll>, int>::iterator it = mp.begin(); it != mp.end(); ++it){
        if ((!vis[it->first]) && (it->first!=make_pair((ll)0,(ll)0))){
            ll a = (it->first).first, b = (it->first).second;
            ll aa = -b, bb = a;
            ll g = gcd(abs(aa),abs(bb));
            if (g){
                aa/=g;
                bb/=g;
            }
            if (aa<0){
                aa*=-1;
                bb*=-1;
            }
            if ((aa==0) && (bb!=0)){
                bb=1;
            }
            else if ((aa!=0) && (bb==0)){
                aa=1;
            }
            pair<ll, ll> p = make_pair(aa,bb);

            int n1 = it->second, n2 = (mp.find(p)==mp.end()) ? 0 : mp[p];
            ans = mul(ans, add(p2[n1],add(p2[n2],(ll)-1)));
            vis[it->first]++;
            vis[p]++;
        }
    }
    ans = add(ans,(ll)-1);
    ans = add(ans,mp[make_pair((ll)0,(ll)0)]);
    cout<<ans<<"\n";

    return 0;
}
 

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

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

int main(){
    int n;
    cin >> n;
    string st;
    cin >> st;
    vector<char> alp(26);
    rep(i, 26) alp.at(i) = 'A'+i;
    rep(i, st.size()){
        st.at(i) += n;
        if(st.at(i) > 'A'+25) st.at(i) -= 26;
    }
    cout << st << endl;
    return 0;
}

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

int main(){
  
	int k, l;
  	cin >> k >> l;
  
  	int total = k * l;
  
  	if( k > 9 || l > 9){
      cout << -1 << endl;
    }else{
      cout << total << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
    ll x, time, d;
    cin >> x >> time >> d;
    x = abs(x);
    ll get = abs(x) / d;
    if (time <= get) {
        cout << x - time * d;
    } else {
        if ((time - get) & 1) {
            cout << (get + 1) * d - x;
        } else {
            cout << x - get * d;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;
 
#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 FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
 
struct UnionFind {
   vector<int> node;
   UnionFind(int n) : node(n,-1) {}
   bool unite(int x, int y) {
      x = root(x); 
      y = root(y);
      if (x != y) {
         if (node[y] < node[x]) swap(x, y);
         node[x] += node[y]; 
         node[y] = x;
      }
      return x != y;
   }
   bool is_same(int x, int y) {
      return root(x) == root(y);
   }
   int root(int x) {
      return node[x] < 0 ? x : node[x] = root(node[x]);
   }
   int size(int x) {
      return -node[root(x)];
   }
};
 
int main(){
 
    int N,K,L; cin>>N>>K>>L;
    UnionFind inst1(200010);
    UnionFind inst2(200010);
    REP(i,K){
        int p,q; cin>>p>>q;
        inst1.unite(p,q);
    }
    REP(i,L){
        int r,s; cin>>r>>s;
        inst2.unite(r,s);
    }
    
    map<int,vector<int> > same_g;
    for(int i=1;i<=N;i++){
        same_g[inst1.root(i)].push_back(i);
    }
    
    int ans[200010]={};
    FOREACH(i,same_g){
        vector<int> t=i->second;
        map<int,int> root;
        REP(j,t.size()){
            int r=inst2.root(t[j]);
            if(root.find(r)==root.end())root[r]=1;
            else root[r]++;
        }
        REP(j,t.size())ans[t[j]]=root[inst2.root(t[j])];
    }
    
    for(int i=1;i<N;i++){
        cout<<ans[i]<<" ";
    }
    cout<<ans[N]<<endl;
    
    return 0;
}

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

ll n;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read();
	printf("%.14f\n", 2 * n * 3.14159265358979);
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    int A, B;
    cin >> A >> B;
    if ((A * B) % 2 == 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())

ans = 0
for i in range(1, n+1):
    ans += (n-1) // i

print(ans)



Measured memory_bytes: 67880
N,M = map(int,input().split())
L = [[] for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    L[A-1].append(B-1)
    L[B-1].append(A-1)
ans = [0] * N
visit = [0] * N
visit[0] = 1
from queue import Queue
q = Queue()
q.put(0)
while not q.empty():
    current = q.get()
    for a in L[current]:
        if visit[a] == 0:
            visit[a] = visit[current] + 1
            ans[a] = current + 1
            q.put(a)
        else:
            if visit[a] > visit[current] + 1:
                visit[a] = visit[current] + 1
                ans[a] = current + 1
flag = True
for i in range(1,N):
    if ans[i] == 0:
        flag = False
        print('No')
        break
if flag == True:
    print('Yes')
    for i in range(N-1):
        print(ans[i+1])

Measured memory_bytes: 37780
#include <iostream>
#include <vector>
int main() {
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	for (auto &v : vec)std::cin >> v;
	int q; std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		int b, e, k;
		std::cin >> b >> e >> k;
		int count = 0;
		for (auto j = b; j < e; ++j) {
			if (vec[j] == k) ++count;
		}
		std::cout << count << std::endl;
	}
}


Measured memory_bytes: 3096
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;

	long N, K; cin >> N >> K;
	string S; cin >> S;

	long turn0 = 0, turn1 = 0;

	long c0[100009] = {}, c1[100009] = {}; //0のまとまり //1のまとまり
	long count0 = 0, count1 = 0;
	for (int i = 1; i <= N; i++) {

		if (turn0 == 0 && S[i - 1] == '0') turn0 = 1;
		if (S[i - 1] == '0') count0++;
		if (S[i - 1] == '1' && i >= 2) if (S[i - 2] == '0') { c0[turn0] = count0; turn0++; count0 = 0; }
		if (i == N && S[N - 1] == '0') c0[turn0] = count0;
		if (i == N && S[N - 1] == '1') turn0--;

		if (turn1 == 0 && S[i - 1] == '1') turn1 = 1;
		if (S[i - 1] == '1') count1++;
		if (S[i - 1] == '0' && i >= 2) if (S[i - 2] == '1') { c1[turn1] = count1; turn1++; count1 = 0; }
		if (i == N && S[N - 1] == '1') c1[turn1] = count1;
		if (i == N && S[N - 1] == '0') turn1--;

	}

	if (turn0 <= K) { cout << N << endl; return 0; }

	//turn0 は 0 のまとまりの数。c0はれんぞくする0の数それぞれturn0個とturn1個
	//最初が0のとき
	long Kwa[100009] = {};
	c0[0] = 0;
	c1[0] = 0;
	c0[turn0 + 1] = 0;
	c1[turn1 + 1] = 0;
	long f, l;
	if (S[0] == '0') f = 0; else f = 1;
	if (S[N - 1] == '0') l = 0; else l = 1;

	if (f == l) {
		for (int i = 1; i <= turn0; i++) {
			for (int j = 1; j <= K; j++) {
				Kwa[i] += c0[i + j - 1] + c1[i + j - 1 - l];
			}
			Kwa[i] += c1[i - 1 + f];
		}
	}
	if(f == 0 && l == 1){
		for (int i = 1; i <= turn0; i++) {
			for (int j = 1; j <= K; j++) {
				Kwa[i] += c0[i + j - 1] + c1[i + j - 1];
			}
			Kwa[i] += c1[i - 1];
		}
	}

	if (f == 1 && l == 0) {
		for (int i = 1; i <= turn0; i++) {
			for (int j = 1; j <= K; j++) {
				Kwa[i] += c0[i + j - 1] + c1[i + j ];
			}
			Kwa[i] += c1[i];
		}
	}




	sort(Kwa + 1, Kwa + turn0 + 1);

	res = Kwa[turn0];

	cout << res << endl;
}

Measured memory_bytes: 2816
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int[] d = new int[N];
		for(int i=0; i<N; i++)d[i] = sc.nextInt();
		Arrays.sort(d);
		out.println(d[N/2] - d[N/2-1]);

		out.flush();
	}
}


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

int L[500010];
int R[500010];
int INF = 1000000007;

long long merge (int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INF;
  R[n2] = INF;
  int i = 0;
  int j = 0;
  long long cnt = 0;
  for (int k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

long long mergeSort (int A[], int n, int left, int right) {
  long long v1, v2, v3;
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    v1 = mergeSort(A, n, left, mid);
    v2 = mergeSort(A, n, mid, right);
    v3 = merge(A, n, left, mid, right);
    return v1 + v2 + v3;
  } else {
    return 0;
  }
}

int main() {

  int A[500010];
  int n;
  cin >> n;

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

  long long answer = mergeSort(A, n, 0, n);

  cout << answer << endl;

  return 0;

}


Measured memory_bytes: 4660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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);
        lcsDpContest solver = new lcsDpContest();
        solver.solve(1, in, out);
        out.close();
    }

    static class lcsDpContest {
        char[] s;
        char[] t;
        int[][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            s = sc.next().toCharArray();
            t = sc.next().toCharArray();
            memo = new int[s.length][t.length];
            for (int[] x : memo)
                Arrays.fill(x, -1);
            pw.println(trace(0, 0));
        }

        private String trace(int i, int j) {
            if (i == s.length || j == t.length)
                return "";
            if (s[i] == t[j])
                return s[i] + trace(i + 1, j + 1);
            int optimal = dp(i, j);
            if (optimal == dp(i, j + 1))
                return trace(i, j + 1);
            return trace(i + 1, j);
        }

        private int dp(int i, int j) {
            if (i == s.length || j == t.length)
                return 0;
            if (memo[i][j] != -1)
                return memo[i][j];
            if (s[i] == t[j])
                return 1 + dp(i + 1, j + 1);
            int ii = dp(i, j + 1);
            int jj = dp(i + 1, j);
            return memo[i][j] = Math.max(ii, jj);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

    }
}



Measured memory_bytes: 86356
#include <stdio.h>
typedef long long int lli;

int main(void){
    lli nums, numc;
    scanf("%lld %lld", &nums, &numc);

    lli ans = 0;
    if(numc >= 2 * nums){
        ans += nums;
        numc -= 2 * nums;
        ans += numc / 4;
    }else{
        ans += numc / 2;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(int argc, char const* argv[])
{
    long int n;
    std::cin >> n;
    long int max_diff = -20000000000;
    long int min_val;

    std::cin >> min_val;

    for (int i = 1; i < n; i++) {
        long int cur_val;
        std::cin >> cur_val;
        max_diff = max_diff > (cur_val - min_val)? max_diff: (cur_val - min_val);
        min_val = cur_val > min_val? min_val: cur_val;
    }
    std::cout << max_diff << std::endl;
    return 0;
}

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

int main(){
 int q,a,b;
 string str,com,rep;
 char temp;

 cin >> str >> q;

 for(int i = 0; i < q; i++){
  cin >> com >> a >> b;

  if(com == "print"){
   cout << str.substr(a, b-a+1) << endl;
  } else if(com == "reverse") {
   while(a < b){
    temp = str[a];
    str[a] = str[b];
    str[b] = temp;
   
    a++;
    b--;
   }
  } else if(com == "replace"){
   cin >> rep;

   str = str.replace(a, b-a+1, rep);
  }
 }

 return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, k;
    cin >> n >> k;
    vector<long> l(n);
    vector<long> lb(n, -1);
    vector<long> m;
    for(long i = 0; i < n; i++){
        cin >> l[i];
    }
    long cnt = 0, next = 0;
    while(lb[next] == -1 && cnt <= k){
        lb[next] = cnt;
        m.push_back(next+1);
        next = l[next]-1;
        cnt++;
    }
    
    m.erase(m.begin(), m.begin()+lb[next]);
    long remain = k - lb[next], hoge = remain % (cnt - lb[next]);
    cout << m[hoge] << endl;
    return 0;
}

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

int main(){
    int N,i;
    int result=0;
    cin>>N;
    vector<int> P(N);
    for(i=0;i<N;i++)cin>>P[i];
    sort(P.begin(),P.end(),greater<int>());

    for(i=0;i<N;i++){
        if(P[i]>=i+1)result=i+1;
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<string>
using namespace std;
int main(){
    int a,b,c;
    cin >> a;
    if (a%1000==0){
        cout << 0;
    }else{
        b=(a+1000)%1000;
        c=1000-b;
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  if (N%2==0)
	  cout << fixed << setprecision(10) << (long double)(N/2)/(long double)(N) << endl;
  else
  	cout << fixed << setprecision(10) << (long double)(N/2+1.0)/(long double)(N) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

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 n;
  cin >> n;
  vector<int> a(n + 1);
  map<int, int> mp;
  REP(i, n + 1) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int t;
  for (auto x : mp) {
    if (x.second == 2) t = x.first;
  }
  bool f = true;
  int l, r;
  REP(i, n + 1) {
    if (a[i] == t) {
      if (f) {
        l = i;
        f = false;
      } else {
        r = n - i;
      }
    }
  }

  COMinit();
  FOR(i, 1, n + 2) {
    int ans = COM(n + 1, i) - COM(l + r, i - 1);
    cout << (ans + MOD) % MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 18304
#include <stdio.h>

int minn(int a[], int n)
{
  int max = 10;
  int i;
  for (i = 0; i < n; i++)
    if (a[i]%10 < max && a[i]%10!=0)
      max = a[i]%10;
  return max;
}

int main(void)
{
  int a[5];
  for (int i = 0; i < 5; i++)
    scanf("%d", &a[i]);
  int max = 10 - minn(a, 5);

  for (int i = 0; i < 5; i++) {
    if (a[i] % 10 == 0);
    else a[i] = (a[i] / 10 + 1) * 10;
  }
  int ans = a[0] + a[1] + a[2] + a[3] + a[4]-max;
  printf("%d\n", ans);
  return 0;
}

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


int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i],
  sort(p.rbegin(),p.rend());
  int sum = p[0]/2;
  for(int i = 1; i < n; ++i){
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int c[3][3],i,j,sum[3][2] = {0};

    for (i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            scanf("%d",&c[i][j]);
        }
    }
    for (i = 0; i < 3; i++)
    {
        for (j = 0; j < 3; j++)
        {
            sum[i][0] += c[j][(j + i) % 3];
            sum[i][1] += c[j][2 - (j + i) % 3];
        }
    }
    for (i = 0; i < 6; i++)
    {
        if(sum[i % 3][i % 2] != sum[(i + 1) % 3][(i + 1) % 2])break;
    }
    printf("%s\n",i == 6 ? "Yes" : "No");
}

Measured memory_bytes: 128
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();
        int[] H = new int[N];
        for(int i = 0; i < N; i++){
            H[i] = sc.nextInt();
        }
        sc.close();

        int diff = (T-A)*1000/6;
        int index = 0;
        int min = Math.abs(H[0] - diff);
        for(int i = 1; i < N; i++){
            if(min > Math.abs(H[i]-diff)){
                min = Math.abs(H[i]-diff);
                index = i;
            }   
        }
        System.out.println(index+1);
    }
}

Measured memory_bytes: 24276
#include <iostream>
#include <vector>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> v(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j * i <= n; j++) v[j * i]++;
    }

    i64 ret = 0;
    for (int i = 1; i <= n; i++) ret += v[i] * i;

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 81340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ld pie=3.1415926535;
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,cnt=0; cin>>n;
    string s; cin>>s;
    vector<string> c={"SS","SW","WS","WW"};
    for(auto st:c){
        string ans=s;
        ans[0]=st[0]; ans[1]=st[1];
        for(int i=2;i<n;i++){
            if(ans[i-2]=='S' && ans[i-1]=='S' && s[i-1]=='o')
            ans[i]='S';
            if(ans[i-2]=='S' && ans[i-1]=='S' && s[i-1]=='x')
            ans[i]='W';
            if(ans[i-2]=='S' && ans[i-1]=='W' && s[i-1]=='o')
            ans[i]='W';
            if(ans[i-2]=='S' && ans[i-1]=='W' && s[i-1]=='x')
            ans[i]='S';
            if(ans[i-2]=='W' && ans[i-1]=='S' && s[i-1]=='o')
            ans[i]='W';
            if(ans[i-2]=='W' && ans[i-1]=='S' && s[i-1]=='x')
            ans[i]='S';
            if(ans[i-2]=='W' && ans[i-1]=='W' && s[i-1]=='o')
            ans[i]='S';
            if(ans[i-2]=='W' && ans[i-1]=='W' && s[i-1]=='x')
            ans[i]='W';
        }
        if(ans[n-1]=='S'){
            if((ans[n-2]==ans[0] && s[n-1]=='o') ||
               (ans[n-2]!=ans[0] && s[n-1]=='x')){
               if(ans[0]=='S'){
                   if((ans[n-1]==ans[1] && s[0]=='o') ||
               (ans[n-1]!=ans[1] && s[0]=='x')){
                   cout<<ans<<endl;
                   break;
               }
               }
               else{
                   if((ans[n-1]==ans[1] && s[0]=='x') ||
               (ans[n-1]!=ans[1] && s[0]=='o')){
                   cout<<ans<<endl;
                   break;
               }
               }
               }
        }
        else{
            if((ans[n-2]==ans[0] && s[n-1]=='x') ||
               (ans[n-2]!=ans[0] && s[n-1]=='o')){
               if(ans[0]=='S'){
                   if((ans[n-1]==ans[1] && s[0]=='o') ||
               (ans[n-1]!=ans[1] && s[0]=='x')){
                   cout<<ans<<endl;
                   break;
               }
               }
               else{
                   if((ans[n-1]==ans[1] && s[0]=='x') ||
               (ans[n-1]!=ans[1] && s[0]=='o')){
                   cout<<ans<<endl;
                   break;
               }
               }
               }
        }
        cnt++;
        if(cnt==4) cout<<-1<<endl;
    }
}

Measured memory_bytes: 512