akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int N = 10050;
const int mod = 1000000007;
typedef long long  ll;

char str[N];
int d,len;
int dp[N][105][2][2][2];

int rec(int p,int md,int srt,int sm,int f)
{
    if(p==len) return (md==0 && f==1);
    int &ret=dp[p][md][srt][sm][f];
    if(ret!=-1) return ret;
    ret=0;
    int lo=0,hi=str[p]-'0';
    if(srt) lo=1;
    if(sm) hi=9;
    int v=str[p]-'0';
    if(srt) ret+=rec(p+1,md,srt,1,f);
    ret%=mod;
    for(int i=lo; i<=hi; i++)
    {
        ret+=rec(p+1,(md+i)%d,0,sm|i<v,1);
        ret%=mod;
    }
    return ret;
}

int main()
{
   scanf("%s %d",str,&d);
   len=strlen(str);
    memset(dp,-1,sizeof dp);
    printf("%d\n",rec(0,0,1,0,0));



}


Measured memory_bytes: 34432
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
#include<cmath>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
#define MAX_V 2*100000+10

using namespace std;



bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli k, n, m, e;


int main() {
	lli x, y, z=0;
	cin >> x;
	rep1(i, x)if ((y = (int)log10(i)) % 2==0)z++;

	cout << z;

}




Measured memory_bytes: 512
n = int(input())
h = list(map(int,input().split()))
prev = 10**9+1
stair = "Yes"
hlen = len(h)
for i in range(n):
  hgt = h[hlen-1-i]
  if hgt>prev+1:
    stair = "No"
    break
  elif hgt==prev+1:
    prev = hgt-1
  else:
    prev = hgt
print(stair)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a, v, b, w, t, i, j, c = 0;
    cin >> a >> v >> b >> w >> t;
    if (a == b)
    {
        cout << "YES" << endl;
        return 0;
    }
    if (a>b) {
        b=a+(a-b);
       }
        for (i = 1; i <= t; i++)
        {
            a += v;
            b += w;
            if (a >= b)
            {
                cout << "YES" << endl;
                return 0;
            }

        }
        cout << "NO" << endl;
        return 0;
    // }else
    // {
    //      for (i = 1; i <= t; i++)
    //     {
    //         a -= v;
    //         b -= w;
    //         if (a <= b)
    //         {
    //             cout << "YES" << endl;
    //             return 0;
    //         }

    //     }
    //     cout << "NO" << endl;
    //     return 0; 
    // }
}


Measured memory_bytes: 3620
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

def score(t):
    if t == "r": return p
    if t == "s": return r
    if t == "p": return s

hist = [False] * n

ans = 0
for i in range(n):
    if i < k or (t[i] != t[i-k] or not hist[i-k]): 
        ans += score(t[i])
        hist[i] = True

print(ans)

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define PI 3.14159265358979323846
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();++i)
    {
        cout<< (char)( (s[i]-'A' + n)%26 + 'A' );
    }
}


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

using namespace std;

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

	string str;
	cin >> str;

	vector<int> kazu1(n + 2, 0); /*左側の数*/
	vector<int> kazu2(n + 2, 0); /*右側の数*/
	int counter1 = 0;
	int counter2 = 0;
	for (int i = 1; i < str.size(); i++) {
		if (str[i-1] == 'A' && str[i] == 'C') {
			counter1++;
			kazu1[i] = counter1;
		}
		else {
			kazu1[i] = counter1;
		}

		if (str[str.size()-1-i] == 'A' && str[str.size()-i] == 'C') {
			counter2++;
			kazu2[str.size()-i-1] = counter2;
		}
		else {
			kazu2[str.size() - i - 1] = counter2;
		}
	}
	int sousu = kazu1[str.size() - 1];

	int l, r;
	int sousuu = sousu;
	for (int i = 0; i < q; i++) {
		cin >> l >> r;

		sousuu = sousu;
		if (l != 1){
			sousuu = sousuu - kazu1[l - 1 - 1] - kazu2[r + 1 - 1];
		}
		else {
			sousuu = sousuu  - kazu2[r + 1 - 1];
		}
		if (l >= 2) {
			if (str[l - 1] == 'C' && str[l - 2] == 'A') {
				sousuu--;
			}
		}
		if (r != str.size()) {
			if (str[r - 1] == 'A' && str[r] == 'C') {
				sousuu--;
			}
		}
		cout << sousuu << endl;
	}


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    cin >> A;
    sort(A.begin(), A.end());
    int idx = 0;
    ll sum = 0;
    for (int i = 0; i + 1 < N; i++) {
        sum += A[i];
        if (sum * 2 < A[i + 1]) idx = i + 1;
    }
    cout << N - idx << endl;
}

Measured memory_bytes: 1024
n = int(input())
score = []
for i in range(n):
    score.append(list(map(int, input().split())))

p = 0
A = []
B = []
for n in score:
    A.append(n[0])
    B.append(n[1])

aida = max(A) - min(A) + 1
one_to_a = (1 - min(A)) * -1
p = aida + one_to_a + min(B)
print(p)


Measured memory_bytes: 29144
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<=1000;i++)
    {
        if(i*a%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

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

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

int main(){

  long long N, KB, t, i;
  cin>>N;
  cin>>KB;
  for(i=0;i<N-1;i++){
    cin>>t;
    KB=KB*(t/GCD(KB,t));
  }
  cout<<KB<<endl;
  return 0;
}

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

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> re(a);
  vector<int> oh(b);
  for(int i = 0; i < a; i++) cin >> re.at(i);
  for(int i = 0; i < b; i++) cin >> oh.at(i);
  vector<int> x(m);
  vector<int> y(m);
  vector<int> c(m);
  for(int i = 0; i < m; i++) cin >> x.at(i) >> y.at(i) >> c.at(i);
  
  int ans = 50000000;
  for(int i = 0; i < m; i++){
    int k = re.at(x.at(i)-1) + oh.at(y.at(i)-1) - c.at(i);
    ans = min(ans, k);
  }
  sort(re.begin(), re.end());
  sort(oh.begin(), oh.end());
  ans = min(ans, re.at(0) + oh.at(0));
  
  cout << ans << endl;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}
 
LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b&&a==c)cout << 1 << endl;
  else if(a==b || a==c || c==b)cout << 2 << endl;
  else cout << 3 << endl;
  
  return 0;
}
  


Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        long[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
        boolean even = Arrays.stream(a).filter(x -> x < 0).count() % 2 == 0;
        long total = Arrays.stream(a).map(Math::abs).sum();
        long min = Arrays.stream(a).map(Math::abs).min().orElse(0);
        System.out.println(even ? total : total - 2 * min);
    }
}


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

using namespace std;

int main()
{
    int w, h;
    
    while (scanf("%d %d", &w, &h) && w){
        int a[21] = {0}, b[21] = {0};
        
        for (int i = 0; i < w; i++){
            int x;
            scanf("%d", &x);
            a[x]++;
        }
        for (int j = 0; j < h; j++){
            int x;
            scanf("%d", &x);
            b[x]++;
        }
        
        int r = 0;
        for (int i = 1; i <= 20; i++){
            r += i * max(a[i], b[i]);
        }
        
        printf("%d\n", r);
    }
    
    return (0);
}

Measured memory_bytes: 1188
# -*- coding: utf-8 -*-
N, L = map(int, str(input()).split())

# リンゴの味のリストを作成
Apple_taste = [ i + L for i in range(N)]

# Lが正の値の時、最小値を引く
# Lが負の値かつabs(L)>=Nのとき、最大値を引く
# それ以外は0を含むので、総和と一致する
if L >= 0:
    Output = sum(Apple_taste) - min(Apple_taste)
elif abs(L) >= N:
    Output = sum(Apple_taste) - max(Apple_taste)
else :
    Output = sum(Apple_taste)

print(Output)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1000000007;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

void solve(){
    ll n,k;
    cin >> n >> k;
    ll v[n];
    forn(i,n){
    	cin >> v[i];
    }
    ll ans=0;
    forn(a1,n+1){
    	forn(a2,n+1){
    		forn(b,n+1){
    			if(a1+a2<=n && a1+a2-b>0 && a1+a2+b<=k){
    				vector<ll> v1;
    				forn(i,a1){
    					v1.pb(v[i]);
    				}
    				forsn(i,n-a2,n){
    					v1.pb(v[i]);
    				}
    				sort(v1.begin(),v1.end());
    				ll nans=0;
    				forsn(i,b,(ll)v1.size()){
    					nans+=v1[i];
    				}
    				ans = max(ans,nans);
    			}
    		}
    	}
    }
    cout << ans << ln;
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve();
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto A=vecin(N),B=vecin(N),C=vecin(N);
	sort(ALL(A));
	sort(ALL(B));
	sort(ALL(C));

	ll S=0;
	REP(i,N){
		int center = B[i];
		auto resA = lower_bound(ALL(A),B[i]);
		auto resC = lower_bound(ALL(C),B[i]+1);

		ll AN=0,CN=0;
		AN=distance(A.begin(),resA);
		CN=distance(resC,C.end());
		S += AN*CN;
	}

	out(S);
	return 0;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    vector<int> a;
    rep(i,n){
        int num; cin >> num;
        a.push_back(num);
    }
    
    vector<double> b;
    rep(i,n) b.push_back((double)1/a[i]);

    double sum = 0;
    rep(i,n) sum += b[i];
    double ans = 1/sum;
    
    cout << setprecision(14) << ans <<ln;
    return 0;
}

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

std::string solve(int x, int y)
{
  for (int i = 0; i <= x; ++i) {
    if (2 * i + 4 * (x - i) == y) return "Yes";
  }
  return "No";
}

int main()
{
  int x, y;
  std::cin >> x >> y;

  std::cout << std::setprecision(20);
  std::cout << solve(x, y) << std::endl;
}


Measured memory_bytes: 3632
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	c := map[string]int{}
	for i := 0; i < n; i++ {
		s := scanString()
		c[s]++
	}

	fmt.Fprintln(wr, "AC x", c["AC"])
	fmt.Fprintln(wr, "WA x", c["WA"])
	fmt.Fprintln(wr, "TLE x", c["TLE"])
	fmt.Fprintln(wr, "RE x", c["RE"])
}


Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}
//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(9);
    }
} All_init;


int main()
{
    ll n,m,ans=0;
    cin>>n>>m;
    ans=min(n,m/2);
    m-=ans*2;
    ans+=m/4;
    cout<<ans<<endl;

    
}


Measured memory_bytes: 256
package main

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

type road struct {
	a int
	b int
}

func main() {
	n := getInt()
	m := getInt()

	roads := make([]road, m)
	for i := range roads {
		roads[i].a = getInt()
		roads[i].b = getInt()
	}

	counts := make([]int, n)
	for _, r := range roads {
		counts[r.a-1]++
		counts[r.b-1]++
	}

	for _, c := range counts {
		fmt.Println(c)
	}
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    S=[input().rstrip() for _ in range(N)]
    from collections import Counter,defaultdict
    from string import ascii_lowercase
    d=defaultdict(int)
    for s in S:
        C=Counter(s)
        t=0
        for i,a in enumerate(ascii_lowercase):
            t+=C[a]*(11**i)
        d[t]+=1
    ans=0
    for v in d.values():
        ans+=v*(v-1)//2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 76380
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a, b =f()
    if a>=13:
        print(b)
    elif a>=6:
        print(b//2)
    else:
        print(0)

solve()

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, k;
	int p[10000];

	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> p[i];

	sort(p, p + n);

	
	int sum = 0;
	for (int i = 0; i < k; i++)
		sum += p[i];

	cout << sum;
	
	return 0;
}

Measured memory_bytes: 3640
//プライオリティーキュー
#include "bits/stdc++.h"
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける



int main()
{
  int n;
  int b;
  cin>>n;
  vector<int> xnum(n);//xnum(x)は縦になんこあるか
  vector<int> ynum(n);//ynum(y)は横になんこあるか

  REP(i,n){
    cin>>b;
    b--;
    xnum[b]++;//iカードが何枚あるか
  }
  sort(xnum.begin(), xnum.end(),greater<int>());

  int t=xnum[0];
  REP(i,n){
    if (xnum[i]<t){
      for(int j=xnum[i];j<t;j++){
        ynum[j]=i;
      }
      t=xnum[i];
    }
  }
  
  if (0<t){
    for(int j=0;j<t;j++){
      ynum[j]=n;
    }
  }


  vector<int> ans(n);
  int leftuse=0;//穴埋めに自由に使える面積
  int h=0;//答えとなる高さ
  int s=0;//顕さんに使う面積
  for (int i = n-1; i >=0; i--)
  {
    for(;;){
      if (h==n){
        break;
      }

      if ( (i+1)*h <= s+leftuse ){
        s+=min(ynum[h],i+1);
        h++;
      }else{
        break;
      }
    }

    ans[i]=h-1;

    s-=min(xnum[i],h);
    leftuse+=xnum[i];
  }
  ans[0]=n;
  REP(i,n){
    cout<<ans[i]<<endl;
  }
  return 0;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  int n; cin >> n;
  vector<vpi> a(n);

  rep(i, n) {
    int num; cin >> num;
    while (num --> 0) {
      int x, y; cin >> x >> y;
      a[i].eb(x, y);
    }
  }

  int ans = 0;
  rep(bit, 1<<n) {
    bool ok = true;
    int cnt = __builtin_popcount(bit);

    rep(i, n) {
      if (bit & (1<<i)) {
        rep(j, si(a[i])) {
          if (bit & (1<<(a[i][j].fi-1))) {
            if (a[i][j].se == 0) ok = false;
          } else {
            if (a[i][j].se == 1) ok = false;
          }
        }
      }
    }

    if (ok) chmax(ans, cnt);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>

using namespace std;

bool check(double X1,double Y1,double X2,double Y2,double X3,double Y3,double X4,double Y4)
{
	return((X1 - X2) * (Y3 - Y1) - (Y1 - Y2) * (X3 - X1)) * ((X1 - X2) *(Y4 - Y1) - (Y1 - Y2) * (X4 - X1)) > 0.0;
}

void solve()
{
	double xa, ya, xb, yb, xc, yc, xd, yd;
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) )
	if(check(xa,ya,xc,yc,xb,yb,xd,yd) || check(xb,yb,xd,yd,xa,ya,xc,yc))
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}
}

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

Measured memory_bytes: 1224
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long H, W, K;
long long X[1 << 18], Y[1 << 18], C[1 << 18];
long long V[3009][3009];
long long dp[3009][3009][5];

int main() {
	// 入力
	cin >> H >> W >> K;
	for (int i = 1; i <= K; i++) cin >> X[i] >> Y[i] >> C[i];
	for (int i = 1; i <= K; i++) V[X[i]][Y[i]] = C[i];

	// 初期化
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			for (int k = 0; k <= 4; k++) dp[i][j][k] = -(1LL << 60);
		}
	}

	// DP の遷移
	dp[1][1][0] = 0;
	dp[1][1][1] = V[1][1];
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			for (int k = 0; k <= 3; k++) {
				if (dp[i][j][k] == -(1LL << 60)) continue;

				if (i != H) {
					dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + V[i + 1][j]);
				}
				if (j != W) {
					dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
					if (k <= 2) dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + V[i][j + 1]);
				}
			}
		}
	}

	// 出力
	long long Answer = 0;
	for (int i = 0; i <= 3; i++) Answer = max(Answer, dp[H][W][i]);
	cout << Answer << endl;
	return 0;
}

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

int main(){
	long long  a,b,c;
	long long min,temp;
	cin >> a >> b >> c;
	
	
	min=abs(a-b)+abs(b-c);
	temp=abs(a-c)+abs(c-b);
	if(temp<min)min = temp;
	temp=abs(a-c)+abs(a-b);
	if(temp<min)min = temp;
	
	cout << min <<endl;
	return 0;
}

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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
 
  int n, m; cin >> n >> m;
  vi v(m + 5, 0);
  rep(i, n){
    int k; cin >> k;
    rep(j, k){
      int a; cin >> a;
      ++v[a];
    }
  }

  int ans = 0;

  rep(i, m + 5){
    if(v[i] == n){
      ans++;
    }
  }

  pr(ans);

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long bsearch(long n, long[] hs) {
    if (hs[0] >= n) return -1;
    long l, r = hs.length.to!long;
    while (l+1 < r) {
        auto m = (l+r)/2;
        if (hs[m] < n) {
            l = m;
        } else {
            r = m;
        }
    }
    return l;
}

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(long[]);
    auto bs = readln.split.to!(long[]);

    ulong res;
    foreach (i; 0..30) {
        long[] BS;
        foreach (b; bs) BS ~= b % (1L<<(i+1));
        sort(BS);
        long c;
        foreach (aa; as) {
            auto a = aa % (1L<<(i+1));
            auto s = bsearch((1L<<i) - a, BS);
            auto t = bsearch((1L<<i)*2 - a, BS);
            auto u = bsearch((1L<<i)*3 - a, BS);
            auto v = bsearch((1L<<i)*4 - a, BS);
            c += t-s + v-u;
        }
        if (c%2 == 1) res |= 1L<<i;
    }
    writeln(res);
}

Measured memory_bytes: 24932
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{

    char s[101];
    int k,i,j;
    scanf("%d %s",&k,&s);
    if(strlen(s)<=k){

printf("%s",s);
    }
    else{
        for(i=0;i<k;i++){
            printf("%c",s[i]);

        }
        printf("...");
    }
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  string str = "";
  str += (a[0]-'a'+'A');
  str += (b[0]-'a'+'A');
  str += (c[0]-'a'+'A');
  cout << str << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int a,b,h; cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i,N){
    cin >> h[i];
  }
  int max = h[0];
  int cnt = 1;
  for(int i=1;i<N;i++){
    if(max<=h[i]){
      max = h[i];
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int y,n;

  cin >> n >> y;

  FOR(i, 0, n+1){
    FOR(j, 0, n+1){
      if(i+j>n){
        continue;
      }
      else{
        if(i*10000 + j*5000 + (n-i-j)*1000 == y){
          cout << i << " " << j << " " << n-i-j << endl;
          return 0;
        }
      }
    }
  }
  cout << "-1 -1 -1" << endl;


  return 0;
}


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

#define int long long

signed main(){
    int n, k, q, x;
    cin >> n >> k >> q;
    
    int data[n+5] = {0};
    
    for(int i = 1; i <= q; i++){
        cin >> x;
        data[x]++;
    }
    
    for(int i = 1; i <= n; i++){
        data[i] = (-q+data[i] + k);
        if(data[i] > 0){
            cout << "Yes\n";
            continue;
        }
        cout << "No\n";
    }
    
}




Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
    char s[101];
    long int k;
    scanf("%s",s);
    scanf("%ld",&k);
    for(int i = 0;;i++) {
        int ss = s[i] - 48;
        if(k <= pow(ss,5000000000000000)) {
//             printf("%d\n",ss);
            printf("%c",s[i]);
            return 0;
        }
        else k -= pow(ss,5000000000000000);
    }
}

Measured memory_bytes: 128
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readvec<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readlines<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
    }
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
            fn parse(s: &str) -> ($($t),*) {
                let mut tokens = s.split_whitespace();
                ($($t::parse(tokens.next().unwrap())),*)
            }
        }
    }
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let a: usize = read();
    if n % 500 <= a {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
n = int(input())
a = list(map(int,input().split()))
counter = 0
flag = True
while(flag):
		counter += 1
		for i in range(n):
				if a[i]%2 == 1:
						print(counter-1)
						flag = False
						break
				else:
						a[i] = a[i]/2


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

static const int MAX=100;
static const long long INFTY=(1LL<<32);

int n;
long long d[MAX][MAX];

void floyd(){
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			if(d[i][k]==INFTY)continue;
			for (int j = 0; j < n; ++j) {
				if(d[k][j]==INFTY)continue;
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
}

int main(){
	int e,u,v,c;
	cin>>n>>e;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			d[i][j]=((i==j)?0:INFTY);
		}
	}
	for (int i = 0; i < e; ++i) {
		cin>>u>>v>>c;
		d[u][v]=c;
	}
	floyd();
	bool negative=false;
	for (int i = 0; i < n; ++i) {if(d[i][i]<0)negative=true;}
	if(negative){
		cout<<"NEGATIVE CYCLE"<<endl;
	}else{
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if(j)cout<<" ";
				if(d[i][j]==INFTY)cout<<"INF";
				else cout<<d[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3176
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  vector<pair<char,ll>> p;
  runlength(s,p);
  vector<ll> v;
  if(p[0].first=='0')  v.push_back(0);
  rep(i,p.size()){
    v.push_back(p[i].second);
  }
  if(p[p.size()-1].first=='0') v.push_back(0);
  vector<ll> sum(v.size()+1);
  sum[0]=0;
  rep(i,v.size()){
    sum[i+1]=sum[i]+v[i];
  }
  ll ans=0;
  ll tmp=0;
  rep(i,(v.size()/2)+1){
    chmax(ans,v[2*i]);
  }
  if(k>=(v.size()/2)){
    cout<<n<<endl;
    return 0;
  }
  rep(i,(v.size()/2)-k+1){
    chmax(ans,sum[2*(k+i)+1]-sum[2*i]);
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3776
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




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


	vector<ll> facto(m + 1);
	vector<ll> inv_mod(m + 1);
	vector<ll> inv_facto(m + 1);

	inv_mod[1] = 1;
	for (int i = 2; i <= m; i++) {
		inv_mod[i] = (MOD - ((inv_mod[MOD % i]) * (MOD / i)) % MOD) % MOD;


	}

	facto[0] = inv_facto[0] = 1;
	for (int i = 1; i <= m; i++) {
		facto[i] = (i * facto[i - 1]) % MOD;
		inv_facto[i] = (inv_mod[i] * inv_facto[i - 1]) % MOD;

		
	}


	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		ll a = 1;
		a = (a * facto[n]) % MOD;
		a = (a * inv_facto[i]) % MOD;
		a = (a * inv_facto[n - i]) % MOD;

		a = (a * facto[m]) % MOD;
		a = (a * inv_facto[m - i]) % MOD;

		for (int j = 0; j < 2; j++) {
			a = (a * facto[m - i]) % MOD;
			a = (a * inv_facto[m - n]) % MOD;

			
		}

		if (i % 2 == 1) {
			a *= -1;
		}
		
		ans = (ans + a + MOD) % MOD;
	}

	cout << ans << endl;

}


Measured memory_bytes: 14792
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextIntList()
    val B = A.reduce { a, b -> a xor b }
    A.forEach { a ->
        println(B xor a)
    }
}

Measured memory_bytes: 70540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll cnt =0;
    rep(i,n) cin >> a[i];
    bool hantei=false;
    while(1){
        rep(i,n){
            if(a[i]%2 == 1) hantei=true;
        }
        if(hantei) break;
        rep(i,n){
            a[i] /= 2;
        }
        cnt++;
       
        
    }
    cout << cnt << endl;
}

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

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



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

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    int n;
    cin >> n;
    int mp[3]={};
    REP(i,n){
        int tmp;
        cin >> tmp;
        if(tmp%4==0) mp[2]++;
        else if(tmp%4==2) mp[1]++;
        else mp[0]++;
    }
    bool ans = false;
    
    if(mp[0]<=mp[2] || (mp[0]==mp[2]+1 && mp[1]==0)) ans = true;
    
    if(ans) cout << "Yes" << ENT;
    else cout << "No" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/


signed main() {
	int x;
	cin >> x;
	int ans = 2;
	rep(i, x)ans = ans * 2 + 2;
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 256
# n, k = map(int, input().split())
# n = int(input())
# li = list(map(int, input().split()))
s = input()
from collections import Counter
d = Counter(s)
if len(d.keys()) == 2 and all(i == 2 for i in d.values()):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 65024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n; cin >> n;
  vi p(n); rep(i,n) cin >> p[i];
  vi q(n); rep(i,n) cin >> q[i];

  int a = 0, b = 0;

  vi v(n); rep(i,n) v[i] = i+1;
  int cnt = 0;
  do
  {
    cnt++;
    if(v == p){
      a = cnt;
      break;
    }
  } while (next_permutation(all(v)));

  rep(i,n) v[i] = i+1;
  cnt = 0;
  do
  {
    cnt++;
    if(v == q){
      b = cnt;
      break;
    }
  } while (next_permutation(all(v)));
  
  cout << abs(a-b) << endl;
  
}

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

int main(){
  string a,b,c="EQUAL";
  cin >> a >> b;
  if(a.size()>b.size())
    c = "GREATER";
  else if(a.size()<b.size())
    c = "LESS";
  else{
    if(a>b)
      c = "GREATER";
    else if(a<b)
      c = "LESS";
  }
  cout << c << endl;
}


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

int main(){
   int N,Y;
   cin >> N >> Y;
   int num10000=-1,num5000=-1,num1000=-1;
   for(int i=0;i<=N;i++){
       int total = 0;
       for(int j=0;j<=N-i;j++){
           total = 10000*i + 5000*j + 1000*(N-i-j);
           if(total == Y){
               num10000=i;
               num5000=j;
               num1000=N-i-j; 
               break;
           }
       }
       if(total == 0)
        break;
   }
   cout << num10000 << " " << num5000 << " " << num1000 << endl;
}

Measured memory_bytes: 256