akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll i,o,t,j,l,s,z; cin >> i >> o >> t >> j >> l >> s >> z;
	ll ans = o;
	ll ijl = min({i,j,l});
	if((ijl%2==i%2) + (ijl%2==j%2) + (ijl%2==l%2) != 1){
		ans += ijl * 3;
		i -= ijl; j -= ijl; l -= ijl;
		ans += i/2 * 2 + j/2 * 2 + l/2 * 2;
	}else{
		if(ijl == 0) ans += i/2 * 2 + j/2 * 2 + l/2 * 2;
		else{
			if(ijl & 1 ^ 1){
				ijl--; i--; j--; l--;
				ans += 3;
			}
			ans += i/2 * 2 + j/2 * 2 + l/2 * 2;
		}
	}
	cout << ans << endl;
}


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


public class Main {
	
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long upper = N, lower = 0;
			
			while(lower + 1 < upper){
				final long MAX = (lower + upper) / 2;
				
				long rest = N - MAX;
				for(long use = MAX - 1; use >= 1; use--){
					if(rest >= use){ rest -= use; }
				}
				
				//System.out.println(MAX + " " + rest);
				
				if(rest > 0){
					lower = MAX;
				}else{
					upper = MAX;
				}
			}
			
			System.out.println(upper);
			long rest = N - (upper);
			for(long use = upper - 1; use >= 1; use--){
				if(rest >= use){ 
					rest -= use;
					System.out.println(use);
				}
			}
		}
	}
	
	
}


Measured memory_bytes: 11836
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456];
int ok[213456];
signed main() {
	int n, a, b, ans = 0; cin >> n >> a >> b;
	ans += n / (a + b) * a;
	ans += min(a, n % (a + b));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
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<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 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())

//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);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

string s;
int N;

int main(){
    cin>>N;
    cin>>s;

    int only_left=0,only_right=0;

     REP(i,N){
 
       if(s[i]=='('){only_left++;}
       if(s[i]==')'){  if(only_left!=0){only_left--;}else{only_right++;}}
    }

    REP(i,only_right){cout<<"(";}
    cout<<s;
    REP(i,only_left){cout<<")";}
    cout<<endl;
    

}

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

int main(){
	double a, b, c, S, L, h, cosc, sinc;
	scanf("%lf %lf %lf", &a, &b, &c);
	cosc = cos(c * 3.14159265 / 180.0);
	sinc = sin(c * 3.14159265 / 180.0);
	S = 0.5 * a * b * sinc;
	L = a + b + sqrt(a * a + b * b - 2 * a * b * cosc);
	h = b * sinc;
	printf("%lf\n%lf\n%lf", S, L, h);
	return 0;
}

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

int main() 
{
	int n;
	scanf("%d", &n);

	long long bits[62][2];

	for(int i = 0; i < 62; i++) 
	{
		bits[i][0] = bits[i][1] = 0;
	}

	for(int i = 0; i < n; i++) 
	{
		long long v;
		scanf("%lld", &v);
		for(int j = 0; j < 62; j++) 
		{
			if(v&1LL) 
				bits[j][1]++;
			else 
				bits[j][0]++;
			v >>= 1;
		}
	}

	long long resp = 0;
	long long mod = 1000000007;

	for(int i = 0; i < 62; i++) 
	{
		long long qt = bits[i][0] * bits[i][1];
		resp += ((qt%mod)*((1LL << i)%mod))%mod;
	}

	printf("%lld\n",resp%mod);

	return 0;
}

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

int main()
{
	string s;
	int a = 0;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		a += ((s[i] == '+')?1:-1);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = Integer.parseInt(scn.next());
		int[] alphabet = new int[26];
		for(int i=0;i<26;i++){
			alphabet[i] = 51;//max50
		}
		for(int i=0;i<n;i++){
			String S = scn.next();
			int[] alphabet2 = new int[26];
			for(int j=0;j<S.length();j++){
				int index = S.charAt(j) - 'a';
				alphabet2[index]++;
			}
			for(int j=0;j<alphabet2.length;j++){
				if(alphabet[j] > alphabet2[j]){
					alphabet[j] = alphabet2[j];
				}
			}
		}

		for(int i=0;i<alphabet.length;i++){
			for(int j=0;j<alphabet[i];j++){
				System.out.print((char)(i+'a'));
			}
		}

		System.out.println();

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

long long int a, b, k;

int main() {
  cin >> a>>b>>k;
  long long int remain_t = a;
  long long int remain_a = b;
  if(k < a) {
    remain_t = a-k;
  } else {
    remain_t = 0;
    remain_a = max(b - (k - a), (long long int) 0);
  }
  
  cout << remain_t << " " << remain_a << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int k,t,i,am=0,a;
    cin >> k >> t;
    for(i=0;i<t;i++){
        cin >> a;
        am = max(am,a);
    }
    cout << max(2*am-k-1,0)<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		boolean bool = false;
		for (int i = 0; i < k; i++) {
			if (a < b) {
				if (b < c) {
					bool = true;
					break;
				} else {
					c = c * 2;
				}
			} else {
				b = b * 2;
			}
		}

		if (a < b && b < c) {
			bool = true;
		}
		if (bool) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 35628
s = input()
if len(s) % 2 == 1:
    print('No')
    exit()
for i in range(len(s)):
    if i % 2 == 0 and s[i] != 'h':
        print('No')
        exit()
    if i % 2 == 1 and s[i] != 'i':
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
#define MOD 1000000007
int n,m;
char a[1200][1200];
int dp[1200][1200];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	dp[1][1]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#'||(i==1&&j==1))
				continue;
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 7040
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1) {
        cout << "No";
        return 0;
    }
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

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

int main(){
    int n;
    while(cin>>n,n){
        vector<int> p(n);
        for(int i=0;i<n;i++) cin>>p[i];
        const int INF=1e8;
        vector<vector<pair<int,int>>> dp(n+1,vector<pair<int,int>>(100000,make_pair(-INF,INF)));
        dp[0][0]=make_pair(0,0);
        for(int i=0;i<n;i++){
            for(int j=0;j<dp[i].size();j++){
                if(0<p[i]%1000 && p[i]%1000<=500){
                    pair<int,int> x=make_pair(dp[i][j].first+1,dp[i][j].second-p[i]);
                    int to=j+500-p[i]%1000;
                    if(to<dp[i+1].size()){
                        dp[i+1][to]=max(dp[i+1][to],x);
                    }
                }
                else if(500<p[i]%1000){
                    int to=j+1000-p[i]%1000;
                    if(to<dp[i+1].size()){
                        dp[i+1][to]=max(dp[i+1][to],make_pair(dp[i][j].first,dp[i][j].second-p[i]));
                    }
                    to=j-(p[i]+500)%1000;
                    if(to>=0){
                        dp[i+1][to]=max(dp[i+1][to],make_pair(dp[i][j].first+1,dp[i][j].second-p[i]));
                    }
                }
                else{
                    if(j>=500) dp[i+1][j-500]=max(dp[i+1][j-p[i]%1000-500],make_pair(dp[i][j].first+1,dp[i][j].second-p[i]));
                }
                dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
            }
        }
        pair<int,int> res=make_pair(-INF,INF);
        for(int i=0;i<dp[n].size();i++){
            res=max(res,dp[n][i]);
        }
        cout<<res.first<<" "<<-res.second<<endl;
    }
    return 0;

}

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

int main(){
    int n, m;
    cin >> n >> m ;
    cout << n * ( n - 1 ) / 2 + m * ( m - 1 ) / 2 << endl;
    return 0;
}

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

int func(string s, string t) {
	int ans = 0;
	for (char c = 'a'; c <= 'z'; c++) {
		bool founds = false, foundt = false;
		for (int i = 0; i < s.length(); i++) {
			if (s[i] == c) {
				founds = true;
			}
		}
		for (int i = 0; i < t.length(); i++) {
			if (t[i] == c) {
				foundt = true;
			}
		}
		if (founds && foundt)ans++;
	}
	return ans;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	rep(i, n) {
		int tmp = func(s.substr(0, i), s.substr(i));
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int aa[2222][2222];
int aa1[2222][2222];
int a1a1[2222][2222];
int mp[2222][2222];
int n, d, ma;

int getImos(int a,int b,int c,int d,int v[2222][2222]){
	int ret = v[c][d];
	if(a > 0){
		ret -= v[a-1][d];
	}
	if(b > 0){
		ret -= v[c][b-1];
	}
	if(a > 0 && b > 0){
		ret += v[a-1][b-1];
	}
	return ret;
}

void makeImos() {
	REP(i,2*d){
		REP(j,2*d){
			aa[i+1][j] += aa[i][j];
			aa1[i+1][j] += aa1[i][j];
			a1a1[i+1][j] += a1a1[i][j];
		}
	}
	REP(i,2*d){
		REP(j,2*d){
			aa[i][j+1] += aa[i][j];
			aa1[i][j+1] += aa1[i][j];
			a1a1[i][j+1] += a1a1[i][j];
		}
	}
}

void makeBoad() {
	REP(i,d){
		REP(j,d){
			while((ma+1) * (ma+1) < mp[i][j])ma++;
		}
	}

	REP(i,d){
		REP(j,d){
			if(mp[i][j] > ma * ma){
				aa[i][j]++;aa[i+d][j]++;aa[i][j+d]++;aa[i+d][j+d]++;
			}
			if(mp[i][j] > ma * (ma + 1)){
				aa1[i][j]++;aa1[i+d][j]++;aa1[i][j+d]++;aa1[i+d][j+d]++;
			}
			if(mp[i][j] > (ma + 1) * (ma + 1)){
				a1a1[i][j]++;a1a1[i+d][j]++;a1a1[i][j+d]++;a1a1[i+d][j+d]++;
			}
		}
	}
}

bool check(int mid) {
	bool flag = false;
	REP(i,d){
		REP(j,d){
			int tmp = 0;
			tmp += getImos(i,j,i+mid,j+mid,a1a1);
			tmp += getImos(i,j+mid+1,i+mid,j+d-1,aa1);
			tmp += getImos(i+mid+1,j,i+d-1,j+mid,aa1);
			tmp += getImos(i+mid+1,j+mid+1,i+d-1,j+d-1,aa);
			if(tmp == 0)flag = true;
		}
	}
	return flag;
}

void input() {
	cin >> n >> d;
	REP(i,n){
		int x, y;cin >> x >> y;
		x %= d;y %= d;
		mp[y][x]++;
	}
}

int BinarySearch() {
	int l = -2,r = d-1;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(check(mid))r = mid;
		else l = mid;
	}
	return r;
}

int main(){
	
	input();
	makeBoad();
	makeImos();
	int ans = BinarySearch();

	cout << d * ma + ans << endl;

	return 0;
}


Measured memory_bytes: 67584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e6+10;
const ll mod=1e9+7;

ll fac[N];

ll mul(ll a,ll b){
	return a*b%mod;
}

ll poww(ll a,ll b){
	ll r=1;
	while(b){
		if(b&1) r=mul(r,a);
		a=mul(a,a);
		b>>=1;
	}
	return r;
}

ll inv(ll x){
	return poww(x,mod-2);
}

void add_self(ll& a,ll b){
	a+=b;
	a%=mod;
}

void init(){
	fac[0]=fac[1]=1;
	for(int i=2;i<N;++i){
		fac[i]=mul(fac[i-1],1ll*i);
	}
}

ll bino(ll n,ll k){
	if(k<0) return 1;
	if(!k) return 1;
	return mul(fac[n],mul(inv(fac[n-k]),inv(fac[k])));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	init();
	ll k;
	string s;
	cin>>k>>s;
	ll n=(ll)s.size();
	ll ans=0;
	for(ll last=0;last<=k;++last){
		ll ch26=poww(26,last);
		ll ch25=poww(25,k-last);
		ll chpos=bino(k+n-last-1,n-1);
		ll cur=mul(ch26,mul(ch25,chpos));
		add_self(ans,cur);
	} 
	cout<<ans;
	return 0;
}


Measured memory_bytes: 19892
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int A = stdIn.nextInt();
		while(N >= 500) {
			N -= 500;
		}
		if(N <= A) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 23124
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a = I()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print("red")
    return

#B
def B():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans += 1/i
    print(1/ans)
    return

#C
def C():
    n = I()
    v = LI()
    q = []
    for i in v:
        heappush(q,i)
    while q:
        x = heappop(q)
        if not q:
            print(x)
            return
        y = heappop(q)
        heappush(q,(x+y)/2)
    return

#D
def D():
    def dfs(x,d,s):
        for y in v[x]:
            if d[y]:
                s += f[y]
                ans[y] = s
                d[y] = 0
                dfs(y,d,s)
                s -= f[y]
    n,q = LI()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [0]*n
    for i in range(q):
        p,x = LI()
        p -= 1
        f[p] += x
    ans = [0]*n
    d = [1]*n
    d[0] = 0
    ans[0] = f[0]
    s = f[0]
    dfs(0,d,s)
    print(*ans)
    return

#E
def E():
    s = input()
    t = input()
    n = len(s)
    m = len(t)
    d = defaultdict(lambda : [])
    for i in range(n):
        d[s[i]].append(i)
    f = [-1]*m
    alp = list("abcdefghijklmnopqrstuvwxyz")
    for i in range(m):
        if not d[t[i]]:
            print(-1)
            return
        j = bisect.bisect_right(d[t[i]],f[i-1])
        if j == len(d[t[i]]):
            f[i] = d[t[i]][0]
        else:
            f[i] = d[t[i]][j]
    ans = 0
    for i in range(m-1):
        if f[i] >= f[i+1]:
            ans += 1
    print(ans*n+f[-1]+1)
    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 9204
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

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

	if ((a == 0 || b == 0) || (a < 0 && b > 0)) {
		cout << "Zero" << endl;
	}
	else if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else {
		if ((b - a + 1) % 2 == 1) {
			cout << "Negative" << endl;
		}
		else {
			cout << "Positive" << endl;
		}
	}
}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int n,m,x,y,par[100005]={},z;
int find(int x) {
  if(par[x]==x) {
    return x;
  }
  return par[x]=find(par[x]);
}
bool same(int x,int y) {
  return par[x]==par[y];
}
void unit(int x,int y) {
  x=find(x),y=find(y);
  if(x!=y) {
    par[x]=y;
  }
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    par[i]=i;
  }
  for(int i=0; i<m; i++) {
    cin >> x >> y >> z;
    x--,y--;
    if(!same(x,y)) {
      unit(x,y);
    }
  }
  set<int> s;
  for(int i=0; i<n; i++) {
    s.insert(find(i));
  }
  cout << s.size() << endl;
}



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

using namespace std;

typedef long long ll;
typedef priority_queue <ll> pq;
typedef priority_queue <ll, vector <ll>, greater<ll> > pqr;

int main(){
        int N;
        cin>>N;
        vector <ll> a;
        pqr frt;
        pq bak;
        for(int i=0;i<3*N;i++){
                ll aa;
                cin>>aa;
                a.push_back(aa);
        }
        ll sum1[111111]={0}, sum2[111111]={0};
        for(int i=0;i<N;i++){
                frt.push(a[i]);
                sum1[0]+=a[i];
        }
        for(int i=2*N;i<3*N;i++){
                bak.push(a[i]);
                sum2[N]+=a[i];
        }
        for(int i=N;i<2*N;i++){
                sum1[i-N+1]=sum1[i-N];
                ll e=frt.top();
                frt.pop();
                sum1[i-N+1]-=e;
                sum1[i-N+1]+=a[i];
                frt.push(a[i]);
        }
        for(int i=2*N-1;i>=N;i--){
                sum2[i-N]=sum2[i-N+1];
                ll e=bak.top();
                bak.pop();
                sum2[i-N]-=e;
                sum2[i-N]+=a[i];
                bak.push(a[i]);
        }
        for(int i=0;i<=N;i++){
                if(sum1[i]>sum1[i+1]){
                        sum1[i+1]=sum1[i];
                }
                if(sum2[i]>sum2[i+1]&&i!=N){
                        sum2[i]=sum2[i+1];
                }
        }
        ll res=-1111111111111111111;
        for(int i=0;i<=N;i++){
                res=max(res, sum1[i]-sum2[i]);
        }
        cout<<res<<endl;
        return 0;
}


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

using namespace std;

const int N = 123456, mod = 1e9 + 7;

int n, number[200];
string s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    ++number[s[i]];
  }
  int answer = 1;
  for (int i = 0; i < 26; ++i) {
    answer = (long long) answer * (number['a' + i] + 1) % mod;
  }
  cout << (answer - 1) << '\n';
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int arlong;
    cin >> arlong;
    int ar[100];
    int color[8] = { 0 };
    int more = 0;
    for (int i = 0; i<arlong; i++) {
        cin >> ar[i];
    }
    for (int i = 0; i < arlong; i++) {
        if (ar[i]<3200) {
            if (color[ar[i] / 400] == 0) {
                color[ar[i] / 400] = 1;
            }
        }
        else {
            more++;
        }
    }
    int sum = 0;
    for (int i = 0; i < 8; i++) {
        sum += color[i];    // 合計に追加
    }
    if (sum > 0) {
        cout << sum << " " << (sum + more) << endl;
    }
    else {
        cout << 1 << " " << more << endl;
    }
    return 0;
}

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

using i64 = int64_t;

constexpr int INF = INT_MAX;

struct Point{
    int x, s, t;
    bool operator<(const Point &rhs)const{
        return x < rhs.x;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    vector<Point> v;
    for(int i=0;i<n;++i){
        int s, t, x;
        cin >> s >> t >> x;
        v.push_back({x, s, t});
    }
    sort(v.begin(), v.end());
    map<int, int> mp;
    for(int i=0;i<q;++i){
        int d;
        cin >> d;
        mp[d] = i;
    }

    vector<int> ans(q, INF);
    for(auto e: v){
        auto left = mp.lower_bound(e.s-e.x);
        auto right = mp.lower_bound(e.t-e.x);
        for(auto it=left;it!=right;++it){
            //cerr << e.x << " " << it->first << " " << it->second << endl;
            ans[it->second] = e.x;
        }
        mp.erase(left, right);
    }

    for(auto e: ans){
        cout << (e == INF ? -1 : e) << endl;
    }

    return 0;
}

Measured memory_bytes: 15088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m,ans=0;
  cin >>n;
  vector<string>s(n);
  rep(i,n){
    cin>>s.at(i);
  }
  sort(s.begin(),s.end());
  cin>>m;
  vector<string>t(m);
  rep(i,m){
    cin>>t.at(i);
  }
  int cnt=1;
  rep(i,n){
    if (i==0 || s.at(i)!=s.at(i-1) ) {
      cnt=1;
      rep(j,m){
        if (t.at(j)==s.at(i)) {
          cnt-=1;
        }
    }
  }
    else {
      cnt+=1;
    }
    if (cnt>ans) {
      ans=cnt;
    }
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	if (k % 2 == 0) {
		int tmp = k / 2;
		int cnt1 = 0, cnt2 = 0;
		for (int i = 1; i <= n; ++i) {
			if (i % k == 0) cnt1++;
			if (i % k == tmp) cnt2++;
		}
		ll ans = pow(cnt1, 3) + pow(cnt2, 3);
		cout << ans << endl;
	}
	else {
		int cnt = 0;
		int now = k;
		while (1) {
			if (now > n) break;
			cnt++;
			now = k * (cnt + 1);
		}
		ll ans = pow(cnt, 3);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   ll n,m;
  cin>>n>>m;
  ll ar[m+1];memset(ar,0,sizeof(ar));
  ll ans=0;
  for(int i=0;i<n;i++)
  {
  	ll k; cin>>k;
    	for(int j=0;j<k;j++)
        {
        	ll a;cin>>a;
          	ar[a]++;
          	if(ar[a]==n)ans++;
        }
  }
  cout<<ans;
   return 0;

}


Measured memory_bytes: 256
#要修正　方針は合っているようだが・・・
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while True:
    for i in range(BC[index][0]):
        if pt < N:
            A[pt] = max(A[pt],card)
        else:
            break
        pt += 1

    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break

print(sum(A))


Measured memory_bytes: 32964
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


H, W, h, w = map(int, input().split())
yes, no = "Yes", "No"

if (H%h == 0) and (W%w == 0):
    print(no)
    exit()

print(yes)

unit = 1000
if (W%w != 0):
    for i in range(H):
        # l_ = [str(unit)] * (w-1)
        # l_ += [str(-unit*(w-1)-1)]
        # l = l_ * (W//w)
        # l += [str(unit)] * (W%w)
        l = []
        for j in range(W):
            if j % w == w-1:
                l.append(str(-unit*(w-1)-1))
            else:
                l.append(str(unit))
        print(" ".join(l))
    exit()
if (H%h != 0):
    for i in range(H):
        if i%h == h-1:
            l = [str(-unit*(h-1)-1)] * W
        else:
            l = [str(unit)] * W
        print(" ".join(l))
    exit()
raise Exception("hogeeee")


Measured memory_bytes: 45276
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++) cin >> v.at(i) >> w.at(i);
    vector<vector<int>> dp(N + 1, vector<int>(W + 1));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            int d = dp.at(i).at(j);
            if (j >= w.at(i)) d = max(d, dp.at(i + 1).at(j - w.at(i)) + v.at(i));
            dp.at(i + 1).at(j) = d;
        }
    }
    cout << dp.at(N).at(W) << endl;
}


Measured memory_bytes: 6872
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S = "";
    cin >> S;

    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();

    String s = String.valueOf(g)+String.valueOf(b);
    int k = Integer.parseInt(s);

    if (k % 4 == 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }

}


Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <queue>

using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int N;
  cin >> N;
  int ans;
  rep (i, N) {
    long x;
    cin >> x;
    while (x%2==0) {
      ans++;
      x/=2;
    }
  }
  cout << ans << endl;

  return 0;
}








Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CPoll {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      map<string, int> mp;
      int ma = 0;
      rep(i, n) {
        string s; cin >> s;
        mp[s]++;
        chmax(ma, mp[s]);
      }

      for(auto e: mp) {
        if (e.second == ma) {
          cout << e.first << '\n';
        }
      }

    }
};

signed main() {
  CPoll solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
	cin >> n >> m;
	int l = (n - 1) / 2;
	for(int i = 0; i < l; i++) printf(i ? " %d" : "%d", 0);
	for(int i = l; i < n; i++) printf(i ? " %d" : "%d", m);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class B {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();

            List<Edge> ans = new LinkedList<>();
            int mid = n + 1;
            if (n % 2 == 1)
                mid = n;
            for (int i = 1; i <= n; i++) {
                if (n % 2 == 1 && i == n) {
                    break;
                }
                for (int j = i + 1; j <= n; j++) {
                    if (j == mid - i)
                        continue;
                    ans.add(new Edge(i, j));
                }
            }
            out.println(ans.size());
            for (Edge edge : ans) {
                out.println(edge.a + " " + edge.b);
            }
        }

        class Edge {
            int a;
            int b;

            public Edge(int a, int b) {
                this.a = a;
                this.b = b;
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

  if(s.size() == t.size()){
    if(s==t) return 1;
    else return 0;
  }

  int r = 1;
  int cur = t.size();
  while(s.size() >= cur){
    cur += (cur+1)*t.size();
    r++;
  }

  auto f = [&](int x){
    if(x==0) return true;
    string tt = "";
    rep(i,x){
      string ns = tt;
      rep(j,t.size()) ns += t[j] + tt;
      swap(ns, tt);
    }
    // dbg(x,tt);
    int is=0,it=0;
    while(is<s.size() && it<tt.size()){
      if(s[is] == tt[it]){
        is++; it++;
      } else {
        is++;
      }
    }
    return it == tt.size();
  };

  int l=0;
  while(r-l>1){
    int mid = (l+r)/2;
    if(f(mid)) l = mid;
    else r = mid;
  }
  return l;
}


int main(){
  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 3464
#include<bits/stdc++.h>
#include<stdint.h>
#define ff first
#define ss second

using namespace std;


#define MOD 1e9+7
#define ll long long int


void solve()
{
	ll a,b,n,mm;
	cin>>a>>b>>n;
	if(n>=b)
		mm=b-1;
	if(n<b)
		mm=n;

	mm=floor((mm*a)/b)-(a*floor(mm/b));

	cout<<mm<<"\n";
	
}



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifndef ONLINE_JUDGE 
      	freopen("_input.txt", "r", stdin); 
  	freopen("_output.txt", "w", stdout); 
  	#endif 
	

    solve();

	
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

def main():
	N = inputInt()
	A = inputList()

	ans = 0
	for i,val in enumerate(A):
		ii = i+1
		if ii % 2 == 1:
			if val % 2 == 1:
				ans += 1

	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 76920
//start from a vertex with no incoming edges
//and then recurse there
#include<bits/stdc++.h>
using namespace std;
int n;
vector<vector<int > >adjlist(100000);
vector<int >memo(100000,-1);
int calc(int u){
	if(adjlist[u].empty())return 0;
  if(memo[u]!=-1)return memo[u];
  else{
  	int maxi = 0;
    for(int i=0;i<adjlist[u].size();i++){
    	maxi = max(maxi,1+calc(adjlist[u][i]));
    }
    memo[u]=maxi;
    return maxi;
  }
}
int main(){
  	int m;
	cin>>n>>m;
  vector<int >indegree(n,0);
  for(int i=0,a,b;i<m;i++){
  	cin>>a>>b;
    adjlist[a-1].push_back(b-1);
    indegree[b-1]+=1;
  }
  int maxi=1;
  for(int i=0;i<n;i++){
  	if(indegree[i]==0)maxi = max(maxi,calc(i));
  }
  cout<<maxi;
}

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

using namespace std;

const int MAXN = 1e7 + 10;

int n, T, k, m;

int a[MAXN], dp[MAXN];

string s, t;

const int MOD = 1e9 + 7;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = n - 2; i >= 0; i--) {
        int cur = 1e9, cnt = 0;
        for (int j = i + 1; j < n; j++) {
            cnt++;
            if (cnt > k)
                break;
            
            cur = min(cur, dp[j] + abs(a[j] - a[i]));
        }
  
        dp[i] = cur;
    }

    cout << dp[0];
}


Measured memory_bytes: 4408
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
int n,k;
signed main(){
	Rd(n),Rd(k);
	wr(min(n%k,k-(n%k)));
	exit(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

	int n;
	int num[10];
	int pos;
	cin >> n;
	while (n-- > 0)
	{
		int min_A = 0, min_B = 0;
		for (int i = 0; i < 10; i++)
		{
			cin >> num[i];
		}
		for (pos = 0; pos < 10; pos++)
		{
			if (num[pos] > min_A)
			{
				min_A = num[pos];
			}
			else if (num[pos] > min_B)
			{
				min_B = num[pos];
			}
			else
			{
				break;
			}
		}
		if (pos == 10)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        for i in range(H):
            if i==0 or i==H-1: 
                print(W*"#")
            else:
                print("#"+(W-2)*"."+"#")
        print("")


Measured memory_bytes: 5608
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s, h1, h2;
  cin >> s;
  int n = s.size();

  h1 = s.substr(0,n/2);
  h2 = s.substr(n-n/2,n);

  int ans = 0;
  for(int i = 0; i < h1.size(); i++){
    if(h1[i] != h2[h2.size()-i-1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#Computation - Simple Calculator

while True:
    a,op,b=map(str,input().split())
    if op=="?":
        break
    
    if op=="+":
        print(int(a)+int(b))
    elif op=="-":
        print(int(a)-int(b))
    elif op=="*":
        print(int(a)*int(b))
    elif op=="/":
        print((int(a)//int(b)))


Measured memory_bytes: 5600
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [usize; n]
    }
    let s = a.iter().fold(0, |a, b| a ^ b);
    for i in 0..n {
        print!("{} ", s ^ a[i])
    }
}


Measured memory_bytes: 6320
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
template <class T>
vector<ll> countVector(vector<T>v,T guard=0){
    ll size=v.size();
    v.push_back(guard);
    vector<ll>ret;
    ll count=1;
    for(int i=0;i<size;i++){
        if(v[i]==v[i+1]){
            count++;
        }else{
            ret.push_back(count);
            count=1;
        }
    }
    return ret;
}
ll gcd(ll a,ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
	init();
	ll N;cin>>N;
	vector<ll>A(N);
	vector<ll>B(N);
	ll sumA=0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		sumA+=A[i];
	}
	for(int i=0;i<N;i++){
		cin>>B[i];
		sumA-=B[i];
	}
	
	if(sumA<0){
		cout<<-1<<endl;
		return 0;
	}
	
	vector<ll>v;
	for(int i=0;i<N;i++){
		if(A[i]>=B[i])v.push_back(A[i]-B[i]);
	}
	sort(v.begin(),v.end());
	ll ans=0;
	for(int i=0;i<v.size();i++){
		if(sumA>=v[i]){
			//cout<<"tay"<<endl;
			ans++;
			sumA-=v[i];
		}
	}
	cout<<N-ans<<endl;

}


Measured memory_bytes: 2936
long[long] solve(long n){
	long[long] dic;
	for(long x=1; x^^2<=n; x++){
		for(long y=1; x^^2+y^^2<=n; y++){
			for(long z=1; x^^2+y^^2+z^^2<=n; z++){
				dic[x^^2+y^^2+z^^2 + x*y+y*z+z*x]++;
			}
		}
	}
	return dic;
}

void main(){
	long n = _scan!long();
	auto ans = solve(n);
	foreach(i; 1..n+1){
		ans.get(i, 0).writeln();
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 3472
#include <bits/stdc++.h>
/*cout<<setprecision(5)<<ret<<endl;で、数字部分を計5桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(5)<<ret<<endlで、小数部のみ5桁表示かつゼロ埋め有*/
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
/* [Shift+Command+b]（コンパイル）ー＞[Ctrl+Shift+`]（ターミナル起動）ー＞[./a.out] */

//////////////////
//  A
int main(void){
    int a,b;cin>>a>>b;
    double c=(double)(a+b)/2.0;
    if(c==(a+b)/2) cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

    return 0;
}
//////////////////
//  B
/*int main(void){

    return 0;
}*/
//////////////////
//  C 
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/


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

using namespace std;

typedef long long ll;

int main(){
 int N,K; cin >> N >> K;
 string S; cin >> S;
  vector<int> memory;
  if( S[0] == '0'){ memory.push_back(0);}
  //0,2,4,,,番目は連続する1の個数、1,3,5,,,は連続する0の個数
  
  for(int i = 0; i < N; ){
    //iは先頭イテレータ 
    int search = i;
    while(  search < N && S[search] == S[i]){ search++;}
    memory.push_back(search - i);
    i = search;}
  
  if(*(S.end())){ memory.push_back(0);} //両端は1の個数にしておきたい
  
  vector<int> sum((int)memory.size() + 1,0);
  for(int i = 0; i < (int) memory.size(); i++){
    sum[i+1] = sum[i] + memory[i];}
  //sum[i] はmemory[0] + ... + memory[i-1]までの足し算,ただしsum[0] = 0
  
  int ans = 0;
  
  for(int left = 0; left < (int) sum.size(); left += 2){
    int right = left + 2 * K + 1;
    if( right > (int)sum.size() - 1){ right = (int) sum.size() - 1;}
    int wa = sum[right] - sum[left];
    ans = max( ans, wa);}
    
    cout << ans << endl; return 0;}
    //memory[left] +.. memory[left + 2* K] = sum[left + 2*K + 1] - sum[left]
    
     
 

Measured memory_bytes: 1272
a,b,m = map(int,input().split())
l_a = list(map(int,input().split()))
l_b = list(map(int,input().split()))

ans = min(l_a)+min(l_b)

for i in range(m):
    tmp_a,tmp_b,tmp_c = map(int,input().split())
    tmp = l_a[tmp_a-1] + l_b[tmp_b-1] - tmp_c
    if tmp < ans:
        ans = tmp
    
print(ans)        

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

using namespace std;

int main()
{
    int n {0};
    cin >> n;
    vector <int> a (n), b (n), c (n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    int maximum {0};
    for (int i = 0; i < 3; i++)
    {
        maximum = max(maximum, dp[n - 1][i]);
    }
    cout << maximum << endl;
    return 0;
}

Measured memory_bytes: 5568
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1LL << 60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i, m) for (long long i = 0; i < m; i++)
#define FOR(i, n, m) for (long long i = n; i < m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  bitset<4000000> x = 1;
  int n;
  cin >> n;
  int sum = 0;
  REP(i, n){
    int a;
    cin >> a;
    sum += a;
    x |= x << a;
  }
  int k = 1+(sum-1)/2;
  while(true){
    if(x[k]){
      cout << k << endl;
      return 0;
    }
    k++;
  }
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main(){
  int n,m;
  int k[100001];
  while( cin >> n >> m , n+m ){
    int sum = 0;
    for(int i = 0 ; i < n ; i++ )cin >> k[i];
    for(int i = 0 ; i < m ; i++ )sum+=k[i]; 

    int mx = 0;

    for(int i = 0 ; m < n ; m++,i++){
      sum += k[m]-k[i];
      mx = max(mx,sum);
    }
    cout << mx << endl;
  }
  return 0;
}

Measured memory_bytes: 1548
#include<stdio.h>
int main(){
    int n,a[3],i,j;
    scanf("%d",&n);
    for(i=0;i<3;i++){
        a[i]=n%10;
        n=n/10;
        if(a[i]==1){
            a[i]=9;
        }
        else if(a[i]==9){
            a[i]=1;
        }
    }
    for(i=2;i>=0;i--){
        printf("%d",a[i]);
    }
    return 0;
}


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

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

  ll N; cin >> N;
  ll M; cin >> M;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  ll cnt = 0, sum = 0;
  for (ll i = 0; i < N; i++) {
    sum += A[i];
  }
  for (ll i = 0; i < N; i++) {
    if (4 * M * A[i] >= sum) cnt++;
  }
  string ans = "No";
  if (cnt >= M) ans = "Yes";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256