akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll B[100000];
int main() {
    init();
    ll N,H;
    cin >> N >> H;

    ll M = 0;
    rep(i, N) {
        ll a;
        cin >> a >> B[i];
        chmax(M, a);
    }
    sort(B, B + N);

    ll iter = lower_bound(B, B + N, M) - B, cnt = 0, rest = H;
    reper(i,iter,N){
        H -= B[i], cnt++;
        if(H<=0){
            cout << cnt << endl;
            return 0;
        }
    }

    cnt += (H + M - 1) / M;
    cout << cnt << endl;
}

Measured memory_bytes: 1024
N = int(input())
num = [int(i) for i in input().split()]

sum = [0]
sum1 = 0
for i in range(N):
    sum.append(num[i] + sum[i])

for x in range(N):
    if((num[x] * sum[x])//(10**9 + 7)>= 1 ):
        sum1 += num[x]*sum[x] - ((num[x] * sum[x])//(10**9 + 7))*(10**9 + 7)
    else:
        sum1 += num[x]*sum[x]

print(sum1 - (sum1//(10**9 + 7))*(10**9 + 7) )


Measured memory_bytes: 31532
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  string s;
  cin>>s;int l=s.length();
  for(int i=0;i<l;i++){
    int k=((int(s[i])+n)%91);
    if(k<65) k=k+65;
  cout<<char(k);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int x; cin >> x;
	cout << (x < 1200 ? "ABC" : "ARC") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int dp[2010];
	int solve(int n){
		if(n==0)return 1;
		if(n==1 and n==2) return 0;
		if(n>=3 and n<=5)return 1;
		if(dp[n]!=-1)return dp[n];
		int ans=0;
		for(int i=3;i<=n;i++){
			if(n-i>=0){
				int temp=(solve(n-i))%mod;
				ans= (ans+temp)%mod;
			}
		}
		return dp[n]=ans;
	}
	int32_t main(){
		IOS;
		int n;
		cin>>n;
		memset(dp,-1,sizeof dp);
		cout<<solve(n)<<endl;
		return 0;
	}


Measured memory_bytes: 3640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
if(Arr[i]==="0")break;
var arr=(Arr[i]+"").split("").map(Number);
var sum=arr.reduce(function(a,b){return a+b;});
console.log(sum);
}

Measured memory_bytes: 8696
//
//  main.cpp
//  ProblemSolving
//
//  Created by Mac mini on 1/7/20.
//  Copyright © 2020 Mac mini. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
using namespace std;
long long int  dp[52][52][3000];
int x[52], n, a;

long long int call(int idx, int cnt, int amount) {
	if(idx >= n) {
		if((double)amount / cnt == a)
			return 1;
		return 0;
	}

	if(dp[idx][cnt][amount] != -1) return dp[idx][cnt][amount];

	long long int  ret1 = 0, ret2 = 0;

	ret1 = call(idx + 1, cnt + 1, amount + x[idx]);
	ret2 = call(idx + 1, cnt, amount);

	dp[idx][cnt][amount] = ret1 + ret2;

	return dp[idx][cnt][amount];
}

int main() {
	cin >> n >> a;

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

	memset(dp, -1, sizeof(dp));

	cout << call(0, 0, 0) << "\n";

}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
}


Measured memory_bytes: 3648
using System;
namespace AtCoder
{
    public class ABC096A
    {
        public static void Main(string[] args)
        {
            string[] lineArgs = Console.ReadLine().Split(' ');
            int A = int.Parse(lineArgs[0]);
            int B = int.Parse(lineArgs[1]);

            int takahashi = A <= B ? A : A - 1;
            Console.WriteLine(takahashi);
        }
    }
}


Measured memory_bytes: 11092
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
//#define inf ll(10e16)
#define mod ll(10e8+7)
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<ll> vec(n+1);
        map<ll,ll> counter;

        for(ll i=1;i<=n;++i)
        {
            cin>>vec[i];
            counter[i-vec[i]]++;
        }
        ll count=0;

        for(ll i=1;i<=n;++i)
        {
            count+=counter[vec[i]+i];
        }
        cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 27436
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  long long k; cin >> k;
  priority_queue<ll> q;
  for (ll i = -1; i >= -9; i--) q.push(i);
  ll ans;
  for (ll i = k; k--;) {
    ans = -q.top();
    q.pop();
    for (ll d = max(0LL, ans%10-1), e = min(9LL, ans%10+1); d <= e; d++) {
      q.push(-(ans*10+d));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2420
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N;
pair<double, double> p[100000];
double f(double x){
	double ret = 10000000;
	for(int i=0; i<N; i++){
		ret = min(ret, sqrt(p[i].second*p[i].second - (x-p[i].first)*(x-p[i].first)));
	}
	return ret;
}
double ternary_search(double l, double r){
	while(r-l > 0.0001 || f(r)-f(l) > 0.0001){
		if(f( (l*2+r)/3 ) > f( (l+r*2)/3 )) r = (l+r*2)/3;
		else l = (l*2+r)/3;
		//cout << l << " " << f(l) << " " << r << " " << f(r) << endl;
	}
	return f((l+r) / 2);
}
int main(){
	cin >> N;
	double l = -3000000;
	double r = 5000000;
	for(int i=0; i<N; i++){
		cin >> p[i].first >> p[i].second;
		l = max(l, p[i].first-p[i].second);
		r = min(r, p[i].first+p[i].second);
	}
	sort(p, p+N);
	cout << setprecision(16) <<  ternary_search(l, r) << endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define int long long
#define pi pair < int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"

const int N = 1e5 + 5;

vector < int > g[N];
int sz[N],sp[N][20];
int n, takashi, auki;
vector < int > leaf;
void dfs(int u, int p) {
	sp[u][0] = p;
	for(int i = 1; i < 20; i++)
		sp[u][i] = sp[sp[u][i - 1]][i - 1];
	sz[u] = sz[p] + 1;
	int child = 0;
	for(int v : g[u]) {
		if(v == p)
			continue;
		child++;
		dfs(v, u);
	}
	if(child == 0)
		leaf[u] = 1;
	if(child == 1 && u == 1)
		leaf[u] = 1;
}

int lca(int u, int v) {
	if(sz[u] < sz[v])
		swap(u, v);
	int diff = sz[u] - sz[v];
	for(int i = 0; i < 20; i++) {
		if(diff & (1 << i))
			u = sp[u][i];
	}
	if(u == v)
		return u;
	for(int i = 19; i >= 0; i--) {
		if(sp[u][i] != sp[v][i]) {
			u = sp[u][i];
			v = sp[v][i];
		}
	}
	return sp[u][0];
}

int dist(int u, int v) {
	return sz[u] + sz[v] - 2 *sz[lca(u,v)];
}

int32_t main(){
	boost;
	cin >> n >> takashi >> auki;
	for(int i = 1, x, y; i < n; i++) {
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	leaf.resize(n + 1, 0);
	dfs(1, 0);
	int ans = 0;
	int la = lca(takashi, auki);
	for(int i = 1; i <= n; i++) {
		if(leaf[i] == 0)
			continue;
		int auki_d = dist(auki, i);
		int takashi_d = dist(takashi, i);
		//debug(i, auki_d, takashi_d);
		if(auki_d == takashi_d)
			ans = max(ans , dist(auki, la));
		else if(auki_d > takashi_d)
			ans = max(ans , auki_d - 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 30008
N = int(input())
l = input().split()
l = [int(s) for s in l]
count = 0
for j in range(N):
    for i in range(N-1):
        if( l[i] > l[i+1]):
            l[i], l[i+1] = l[i+1], l[i]
            count += 1
for i in range(0,len(l)-1):
    print(l[i],end=' ')
print(l[N-1])
print(count)



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

#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
ifstream ifs("in.txt");
ofstream ofs("out.txt");
#define cin ifs
#define cout ofs
//*/

int A, B, C, K;
signed main() {
    cin >> A >> B >> C >> K;
    int bai = 1 << K;
    cout << A + B + C + max(max(A, B), C) * (bai - 1) << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
	var (
      a	string
      count = 0
    )
  fmt.Scan(&a)
  for i := 0; i < len(a); i++ {
    if a[i] == '1' {
      count++
    }
  }
  fmt.Println(count)
}

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

int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if( x == 0 && y == 0){
            break;
        }
        else if(x <= y){
            cout << x << " " << y << endl;
        }
        else if(y < x){
            cout << y << " " << x << endl;
        }
    }
}


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

int main() {
  string S;
  cin>>S;
  sort(S.begin(),S.end());
  if(S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(1)!=S.at(2)){
    cout <<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
}



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


int n,k;
bool Ban[233];

int main(){
	std::cin>>n>>k;
	while(k--){
		int x;
		std::cin >> x;
		Ban[x] = true;
	}
	for(int i = n; i < 1000000; i++){
		bool flag = true;
		int sb = i;
		while(sb > 0){
			int Pos = sb % 10;
			sb /= 10;
			if(Ban[Pos]) flag = false;
		}
		if(flag){
			std::cout<<i;
			break;
		}
	}
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    int max=0;
    int num;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]>max){
            max=a[i];
            num=i;
        }
    }
    cout<<a[num]+b[num]<<endl;

    return 0;
}

Measured memory_bytes: 4372
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int D = sc.nextInt();
	int N = sc.nextInt();
        if(N<=99){
	    System.out.print(N * (int)Math.pow(100,D));
	}else if(N==100){
	    System.out.print(101 * (int)Math.pow(100,D));
	}
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>

using namespace std;

typedef vector<char> vc;

int main() {
	string s;
	cin >> s;
	vc v;
	for (auto c : s) {
		if (c == 'B') {
			if (!v.empty()) v.pop_back();
		} else v.push_back(c);
	}
	for (auto c : v) cout << c;
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

// 全局变量
const int N = 100010 , M = N + N;
int x[N],y[N],id[N],n;

typedef struct ufset *UFset;
struct ufset
{
  int *parent;
  int *root;
};
UFset UFinit(int size)
{
  int e;
  UFset U=(UFset)malloc(sizeof *U);
  U->parent=(int*)malloc((size+1)*sizeof(int));
  U->root=(int*)malloc((size+1)*sizeof(int));
  for(e=1; e<=size; e++)
  {
    U->parent[e]=1;
    U->root[e]=1;
  }
  return U;
}
int UFfind(int e,UFset U)
{
  int i,j = e;
  while(!U->root[j]) j = U->parent[j];
  while(j!=e){
    i = U->parent[e];
    U->parent[e]=j;
    e=i;
  }
  return j;
}
int UFunion(int i,int j,UFset U)
{
  if(U->parent[i]<U->parent[j])
  {
    U->parent[j]+=U->parent[i];
    U->root[i]=0;
    U->parent[i]=j;
    return j;
  }
  else
  {
    U->parent[i]+=U->parent[j];
    U->root[j]=0;
    U->parent[j]=i;
    return i;
  }
}

// 记录优化后的边集数
struct Edge
{
  int u, v, cost;
  bool operator <(const Edge&b) const
  {
    return cost < b.cost;
  }
} edge[M];
int tot;
// 按照X轴排序
bool cmpX(int a, int b)
{
  return x[a] < x[b];
}
// 按照Y轴排序
bool cmpY(int a, int b)
{
  return y[a] < y[b];
}
void add(int c, int a, int b)
{
  edge[tot].cost = c;
  edge[tot].u = a;
  edge[tot++].v = b;
}
void Work()
{
    scanf("%d", &n);
  int i;
  for (i = 1; i <= n; ++i)
  {
    scanf("%d%d", x + i, y + i);
    id[i] = i;
  }
  std::sort(id + 1 , id + n + 1, cmpX);
  for (i = 2; i <= n; ++i)
    add(x[id[i]] - x[id[i - 1]], id[i], id[i - 1]);
  std::sort(id + 1 , id + n + 1, cmpY);
  for (i = 2; i <= n; ++i)
    add(y[id[i]] - y[id[i - 1]], id[i], id[i - 1]);
  UFset UFS = UFinit(n);

  // 按照花费排序
  std::sort(edge, edge + tot);
  long long totcost = 0;
  for (i = 0; i < tot; ++i)
  {
    int u = edge[i].u, v = edge[i].v;
    u = UFfind(u,UFS), v = UFfind(v,UFS);
    if (u != v)
    {
      UFunion(u,v,UFS);
      totcost += edge[i].cost;
    }
  }
  printf("%lld\n", totcost);
}
int main()
{
  Work();
  return 0;
}


Measured memory_bytes: 4608
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
template<typename T>
T extgcd(T a,T b,T &x,T &y){
  if(!b){x=1;y=0;return a;}
  T d=extgcd(b,a%b,y,x);
  y-=(a/b)*x;
  return d;
}
//ax+by=gcd(a,b)を満たすx,y 返り値はgcd
 
template<typename T>
pair<T,T> ChineseRem(const vector<T> &b,const vector<T> &m){
  T r=0,M=1;
  for(int i=0;i<(int)m.size();++i){
    T p,q;
    T g=extgcd(M,m[i],p,q);
    if((b[i]-r)%g)return {0,-1};
    r+=M*(((b[i]-r)/g*p)%(m[i]/g));
    M*=m[i]/g;
  }
  return {(r%M+M)%M,M};
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,m;cin>>n>>m;
     vector<ll> b(n),mo(n);
     rep(i,0,n){
       cin>>mo[i];
       b[i]=mo[i]/2;
     }
     Pll ans=ChineseRem(b,mo);
    
     if(ans.se<0){
       cout<<0<<endl;
       return 0;
     }
    ll cnt=m/ans.se;
    if(ans.fi!=0 && ans.fi<=m%ans.se)cnt++;
    cout<<cnt<<Endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
        int c[] = new int[n];
        int s[] = new int[n];
        int f[] = new int[n];
        for(int i = 0; i < n-1; i++){
          c[i] = sc.nextInt();
          s[i] = sc.nextInt();
          f[i] = sc.nextInt();
        }
        
        for(int i = 0; i < n;i++){
          int t = 0;
          for(int j = i; j < n - 1;j++){
            if(t < s[j]){
              t = s[j];
            }else if(t % f[j] == 0){
            }else{
              t += f[j] - (t % f[j]);
            }
            t += c[j];
          }
          System.out.println(t);
        }
    }
}

Measured memory_bytes: 39492
N = int(input())
W = [input() for i in range(N)]
s_W = list(set(W))

if len(W) != len(s_W):
    print('No')
    exit()

last = W[0][-1]
for i in range(1,N):
    if W[i][0] != last:
        print('No')
        exit()
  
    last = W[i][-1]
  
print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int n,a[5010],sum,max;
	int i,j,k,l;

	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0; i<n; i++){
			scanf("%d",&a[i]);
		}
		sum=0;
		for(i=0; i<n; i++){
			for(j=i; j<n; j++){
				for(k=i; k<=j; k++){
					sum+=a[k];
					if(sum<0)break;
				}
				if(i==0&&j==0)max=sum;
				if(max<sum)max=sum;
				sum=0;
			}
		}
		printf("%d\n", max);
	}


	return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if (a+b>=10)
        cout<<"error\n";
    else
        cout<<a+b<<endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
            }

            for (int i = 0; i < N; i++) {
                if (a[i] <= 399) {
                    a[i] = 1;
                } else if (a[i] <= 799) {
                    a[i] = 2;
                } else if (a[i] <= 1199) {
                    a[i] = 3;
                } else if (a[i] <= 1599) {
                    a[i] = 4;
                } else if (a[i] <= 1999) {
                    a[i] = 5;
                } else if (a[i] <= 2399) {
                    a[i] = 6;
                } else if (a[i] <= 2799) {
                    a[i] = 7;
                } else if (a[i] <= 3199) {
                    a[i] = 8;
                } else {
                    a[i] = 0;
                }
            }

            HashSet<Integer> colors = new HashSet<>();
            int count0s = 0;
            for (int i = 0; i < N; i++) {
                if (a[i] > 0) {
                    colors.add(a[i]);
                } else {
                    count0s++;
                }
            }

            int min = colors.size() > 0 ? colors.size() : count0s > 0 ? 1 : 0;
            int max = colors.size() + count0s;
            System.out.println(min + " " + max);
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 131072
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

int n;
ll dat[MAX*2], add[MAX*2];
void init(int m){
	n = 1;
	while(n < m)n *= 2;
}

void lazy_update(int k){
	if(k < n-1){
		add[k*2+1] += add[k];
		add[k*2+2] += add[k];
	}
	add[k] = 0;
}

void update(int a, int b, int x, int k, int l, int r){
	if(r <= a || b <= l)return;
	if(a <= l && r <= b){
		add[k] += x;
		dat[k] += add[k]*(r-l);
		lazy_update(k);
		return;
	}
	lazy_update(k);
	update(a, b, x, k*2+1, l, (l+r)/2);
	update(a, b, x, k*2+2, (l+r)/2, r);
	int m = ((l+r)/2-l);
	dat[k] = dat[k*2+1]+dat[k*2+2]+add[k*2+1]*m+add[k*2+2]*m;
	return;
}

ll find(int a, int b, int k, int l, int r){
	if(r <= a || b <= l)return 0;
	if(a <= l && r <= b){
		dat[k] += add[k]*(r-l);
		lazy_update(k);
		return dat[k];
	}
	lazy_update(k);
	ll vl = find(a, b, k*2+1, l, (l+r)/2);
	ll vr = find(a, b, k*2+2, (l+r)/2, r);
	int m = ((l+r)/2-l);
	dat[k] = dat[k*2+1]+dat[k*2+2]+add[k*2+1]*m+add[k*2+2]*m;
	return vl+vr;
}

int main(){
	int m, q, c, s, t, x;
	scanf("%d%d", &m, &q);
	init(m);
	while(q--){
		scanf("%d", &c);
		if(c == 0){
			scanf("%d%d%d", &s, &t, &x);
			update(s-1, t, x, 0, 0, n);
		}else{
			scanf("%d%d", &s, &t);
			ll ans = find(s-1, t, 0, 0, n);
			printf("%lld\n", ans);
		}
	}
	return 0;
}



Measured memory_bytes: 6264
#include <stdio.h>
int main(void) {
	int a;
	scanf("%d",&a);
	if(a<40) a=40;
	int b;
	scanf("%d",&b);
	if(b<40) b=40;
	int c;
	scanf("%d",&c);
	if(c<40) c=40;
	int d;
	scanf("%d",&d);
	if(d<40) d=40;
	int e;
	scanf("%d",&e);
	if(e<40) e=40;
	int s;
	s= a+b+c+d+e;
	printf("%d\n",s/5);	
	return 0;
}


Measured memory_bytes: 2144
function main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split(' ');
  count = 0;

  for (i = 1; i <= input[0]; i++) {
    if (i % 2 == 1) {
      count++;
    }
  }
  console.log((count / input[0]).toFixed(10));

}

//  * この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11468
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class BIT{
	public:
	//[1,i]
	int n;
	vi bit;
//	int bit[MAZ_N+1];
	BIT(int size){
		n=size;
		bit=vi(n+1);
	}
	int query(int i){//sum
		int s=0;
		while(i>0){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(int i,int x){
		while(i<=n){
			bit[i]+=x;
			i+=i&-i;
		}
	}
};
int main(){
	ll n,m;
	cin>>n>>m;
	vi in(n+1);
	ll sum=0;
	rep(i,n){
		int a;cin>>a;
		sum+=a;
		in[i+1]=sum-(i+1)*m;
	}
	vi t=in;
	sort(all(t));
	t.erase(unique(all(t)),t.end());
	rep(i,n+1)in[i]=lower_bound(all(t),in[i])-t.begin();
	
	ll out=0;
	BIT bit(n+2);
	rep(i,n+1){
		int t=in[i];
		out+=bit.query(t+1);
		bit.add(t+1,1);
	}
	cout<<out<<endl;
}




Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;

    ll ans=100000000000000;
    ll tmp = 100000000000000;

    for(ll i=1; i<sqrt(n)+1; i++){
        if(n%i == 0){
            tmp = i-1 + n/i - 1;
        }

        if(ans >= tmp){
                ans = tmp;
            }else{
                break;
            }
    }

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll out = 0;
    if(N<10) out = N;
    else if(N<100) out = 9;
    else if(N<1000) out = N-99+9;
    else if(N<10000) out = 909;
    else if(N<100000) out = N-9999+909;
    else out = 90909;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long n;
	unsigned long long sum=0;
	cin>>n;
	if(n==1)
	cout<<"0";
	else
	{
		for(int i=1;i<=n-1;i++)
	    sum=sum+i;
	    cout<<sum;
	}
}

Measured memory_bytes: 256
n, p_ = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

ne = 0
no = 0
a.each do |i|
  if i.even? then
    ne += 1
  else
    no += 1
  end
end

if no == 0 then
  if p_ == 0
    puts 2 ** n
  else
    puts 0
  end
else
  puts 2 ** (n - 1)
end


Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;
typedef long long LL;
const int NICO = 1000000 + 10;
const LL MOD = 1000000000 + 7;
LL n, m;
int main() 
{
    cin >> n >> m;
    LL res = (n>(m/2))?(m/2):n;
    if(n<=m/2)res += abs(n-m/2)/2;
    cout << res << endl;
}


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

public class Main {
  private static String solve(char[] cs) {
    char cFirst = cs[0];
    char cLast = cs[cs.length - 1];
    return (cFirst == cLast) == (cs.length % 2 != 0) ? "Second" : "First";
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] cs = reader.nextCharArray();
    out.println(solve(cs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 24916
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();
            long left = S.Length;
            var ans = 0L;
            for (var i = 0; i < S.Length; ++i)
                if (S[i] == 'B')
                {
                    left = i;
                    break;
                }
            for (var i = left + 1; i < S.Length; ++i)
            {
                if (S[(int)i] == 'W')
                {
                    ans += i - left;
                    ++left;
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13112
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
int a[200005];
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

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

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string st;
typedef vector<int> vi;
#define all(v) ((v).begin()),((v).end())
#define allr(v) v.rbegin(),v.rend()
#define repi(n)  for(int i = 0; i < (int)(n); ++i)
#define repj(n)  for(int j = 0; j < (int)(n); ++j)
#define endl "\n"
#define sz(n) n.size()
#define RT(v) return cout<<v,0
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
void run() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
void Ahmed_Meky()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main()
{

	Ahmed_Meky();  		   /*█▀▀▄░░░░░░░░░░░▄▀▀█
							░█░░░▀▄░▄▄▄▄▄░▄▀░░░█  
							░░▀▄░░░▀░░░░░▀░░░▄▀
							░░░░▌░▄▄░░░▄▄░▐▀▀
							░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
							░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
							▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
							█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
							░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
							░░░█░░░░░░░░░░░▄▀▄░▀▄
							░░░█░░░░░░░░░▄▀█░░█░░█
							░░░█░░░░░░░░░░░█▄█░░▄▀
							░░░█░░░░░░░░░░░████▀
							░░░▀█▄▄▄▀▀▀▀▄▄▄█▀*/

	st s;
	cin >> s;
	bool b = 0;
	repi(sz(s)){
		if (s[i] == '7')b = true;
	}
	if (b)cout << "Yes";
	else cout << "No";
	
    //system("pause");
	return 0;

}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main() {
    int K, sum_ = 0;
    cin >> K;
    for (int i = 1; i < K + 1; i++){
        for (int j = 1; j < K + 1; j++){
            for (int k = 1; k < K + 1; k++){
                int tmp = gcd(i, j);
                sum_ += gcd(tmp, k);
            }
        }
    }
    cout << sum_ << endl;
}

Measured memory_bytes: 3624
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
a=lnii()
a.sort()

mod=10**9+7

MAX_N = n+5
fac = [1,1] + [0]*MAX_N
finv = [1,1] + [0]*MAX_N
inv = [0,1] + [0]*MAX_N
for i in range(2,MAX_N):
  fac[i] = fac[i-1] * i % mod
  inv[i] = mod - inv[mod % i] * (mod // i) % mod
  finv[i] = finv[i-1] * inv[i] % mod

def nCk(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod

min_X=0
for i in range(n-k+1):
  min_X+=a[i]*nCk(n-i-1,k-1)
  min_X%=mod

max_X=0
for i in range(k-1,n):
  max_X+=a[i]*nCk(i,k-1)
  max_X%=mod

ans=max_X-min_X
ans%=mod
print(ans)

Measured memory_bytes: 25512
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n;

int main() {
	cout << fixed << setprecision(18);
	cin>>n;
	while(n!=0){
		long long int x,y,mp[25][25]={},capture=0,nowx=10,nowy=10;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			mp[x][y]=1;
		}
		long long int m,l;
		cin>>m;
		char ch;
		for(int i=0;i<m;i++){
			cin>>ch>>l;

			while(l>0){
				if(ch=='N'){
					nowy++;
				}else if(ch=='S'){
					nowy--;
				}else if(ch=='E'){
					nowx++;
				}else{nowx--;}
				
				
				if(mp[nowx][nowy]==1){
					mp[nowx][nowy]=0;
					capture++;
				}
				l--;
			}
			//cout<<nowx<<" "<<nowy<<endl;
		}
		if(capture==n){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
		cin>>n;
	}
} 


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

signed main () {
	int n, t;
	cin >> n;
	vector < bool > a(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		cin >> t;
		a[i] = bool(t);
	}
	set < int > put;
	for (int i = n; i; --i) {
		bool seen = 0;
		for (int j = i; j <= n; j += i) {
			if (put.find(j) != put.end())
				seen ^= 1;
		}
		if (seen != a[i]) 
			put.insert(i);
	}
	cout << int(put.size()) << '\n';
	for (int x: put)
		cout << x << ' ';
	cout << '\n';
}


Measured memory_bytes: 7168
#include <stdio.h>

int main(void){

	int A;
	int B;
	int C;
	int X;


/*
	if(scanf("%d",&A) == 1);
	if(scanf("%d",&B) == 1);
	if(scanf("%d",&C) == 1);
	if(scanf("%d",&X) == 1);
*/

	scanf("%d\n%d\n%d\n%d",&A,&B,&C,&X);

	int a, b, c, count=0;
	for (a = 0; a <= A; a++) {
		for (b = 0; b <= B; b++) {
			for (c = 0; c <= C; c++) {
				if(a * 500 + b * 100 + c * 50 == X) {
					count++;
				}
			}
		}
	}

	printf("%d", count);

	return 0;

}

Measured memory_bytes: 128
N=int(input())
import sys
input=sys.stdin.readline
A=[[int(j) for j in input().split()] for _ in range(N)]

ans=0
bridge=[[False]*(N) for i in range(N)]
for k in range(N):
  for i in range(N):
    for j in range(N):
      if i>=j: continue
      if A[i][j]>A[i][k]+A[k][j]:
        print(-1)
        exit(0)

for i in range(N):
  for j in range(N):
    if i >=j :continue
    if all(A[i][j]<A[i][k]+A[k][j] for k in range(N) if k!=i and k!=j):
 
          if not bridge[i][j]:
            ans+=A[i][j] 
            bridge[i][j]=True
print(ans)

Measured memory_bytes: 48476
import math

def main():
    X = input().split(' ')
    a = int(X[0])
    b = int(X[1])
    x = int(X[2])

    if x >= a*a*b/2:
        '''
        y = 2*(b-x/a/a) # 2*(a*a*b-x)/a/a
        m = y/a
        '''
        print(math.degrees(math.atan(2*(b/a-x/a/a/a))))
    else:
        '''
        y = 2*x/b/a
        m = y/b
        '''
        print(90-math.degrees(math.atan(2*x/b/b/a)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, a, b;
vector<ll> h;

bool calc(ll mid) {
  ll count = 0;
  REP(i, n) {
    ll d = h[i] - (mid * b);
    if(d > 0) {
      if(d % (a - b) == 0) count += d / (a - b);
      else count += d / (a - b) + 1;
    }
    if(count > mid) return false;
  }

  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  REP(i, n) {
    ll c;
    cin >> c;
    h.push_back(c);
  }

  ll l = 0, r = INF;
  ll mid = (l + r) / 2;
  ll ans = 1e14;
  while(r - l > 1) {
    if(calc(mid)) r = mid, ans = min(ans, mid);
    else l = mid;
    mid = (l + r) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    long long int a, n, mini = 1e+16;

    cin >> n;
    for (int i=0; i<5; i++) {
        cin >> a;
        mini = min(mini, a);
    }

    long long int ans = 4 + n / mini;
    if (n % mini) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    aa = list(map(int,input().split()))
    S = aa[0]
    for a in aa[1::]:
        S ^= a
    ans = []
    for a in aa:
        ans.append(str(S ^ a))
    print(" ".join(ans))

if __name__ == '__main__':
    main()


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

int main(){
    int N; cin >> N;
    vector<int> prime;
    for(int i = 2; i <= 55555; i++){
        bool flag = true;
        for(int j = 0; j < prime.size() && pow(prime[j],2) <= i; j++){
            if(i % prime[j] == 0){
                flag = false;
                break;
            }
        }
        if(flag) prime.push_back(i);
    }
    int cnt = 0;
    for(auto p : prime){
        if(p % 5 == 1){
            if(cnt != 0) cout << " ";
            cout << p ;
            cnt++;
        }
        if(cnt == N) break;
    }
    /* if(N % 2 == 1){ // 奇素数を出力
        for(int i = 0; i < N; i++){
            if(i != 0) cout << " ";
            cout << prime[i];
        }
    }else{
        for(int i = 1; i <= N; i++){
            if(i != 1) cout << " ";
            cout << prime[i];
        }
    } */
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n;
	cin >> n;
	ll H, A, D, S;
	cin >> H >> A >> D >> S;
	ll ans = 0;
	vector<pii> v;
	REP(i, n)
	{
		ll h, a, d, s;
		cin >> h >> a >> d >> s;
		ll dmg = max(0ll, a - D);
		if (S > s)
		{
			H += dmg;
			ans -= dmg;
		}
		ll gdmg = max(0ll, A - d);
		if (dmg > 0 && gdmg == 0)
		{
			cout << -1 << endl;
			return 0;
		}
		if (dmg == 0) continue;
		v.emplace_back((h + gdmg - 1) / gdmg, dmg);
	}
	sort(ALL(v), [](const pii& a, const pii& b) {return (ld)a.first / a.second < (ld)b.first / b.second; });
	ll sum = 0;
	REP(i, v.size())
	{
		sum += v[i].first;
		ans += sum * v[i].second;
		if (ans >= H)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  string s; cin >> s;
  if(s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

}
























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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K; cin>>N>>K;
	if (K>(N-1)*(N-2)/2) {
		cout<<-1<<"\n";
		return 0;
	}
	int ret=N*(N-1)/2-K;
	cout<<ret<<"\n";
	for (int i=1; i<N&&ret; i++)
		for (int j=i+1; j<=N&&ret; j++,ret--)
			cout<<i<<" "<<j<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=305;
int n;
ll z;
string s;
ll f[N];
ll dp[N][N];
ll pf[N][N];
ll pf2[N][N];
void buildpf(){
	for(int j=0; j<=n ;j++){
		for(int k=0; k<=n ;k++){
			pf[j][k]=pf2[j][k]=dp[j][k];
			if(j>0) pf[j][k]=(pf[j][k]+pf[j-1][k])%mod;
			if(j>0 && k>0) pf2[j][k]=(pf2[j][k]+pf2[j-1][k-1])%mod;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	int c=0;
	cin >> s;n=s.size();s='?'+s;
	cin >> z;
	for(int i=1; i<=n ;i++){
		if(s[i]=='0') c++;
		else f[c]++;
	}
	dp[0][0]=1;
	buildpf();
	int sum=0;
	for(int i=0; i<=c ;i++){
		sum+=f[i];
		for(int j=n-c; j>=0 ;j--){
			for(int y=0; y<=n ;y++){
				if(j<sum){
					dp[j][y]=0;continue;
				}
				ll res=0;
				res=res+pf2[j-f[i]][y]+pf[j][y]-pf[j-f[i]][y];
				dp[j][y]=(res%mod+mod)%mod;
			}
		}
		buildpf();
	}
	ll ans=0;
	for(int i=0; i<=min((ll)n,z) ;i++) ans=(ans+dp[n-c][i])%mod;
	cout << ans << endl;
}

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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	bool cnt = 0;
	int min = 100001;
	ll ans = 0;
	rep(i, n){
		if(a[i] < 0) cnt ^= 1;
		if(abs(a[i]) < min) min = abs(a[i]);
		ans += abs(a[i]);
	}
	if(cnt == 0){
		cout << ans << endl;
	}else{
		cout << ans - min*2 << endl;
	}
	
	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int>kane(n);
  for(int i=0;i<n;i++)
    cin >> kane.at(i);
  sort(kane.begin(),kane.end());
  int su=0;
  for(int i=0;i<k;i++)
    su+=kane.at(i);
  cout << su << endl;
  return 0;
}

Measured memory_bytes: 3568
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, A, B = MI()
    a = N % (A + B)
    b = N // (A + B)

    print(b * A + min(a, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38764
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] v = new int[n + 1];
		for (int i = 1; i < n + 1; i++)
			v[i] = sc.nextInt();
		sc.close();

		Arrays.sort(v);
		double ans = v[1];

		for (int i = 2; i < n + 1; i++)
			ans = (ans + v[i]) / 2;

		System.out.print(ans);

	}
}

Measured memory_bytes: 23892