akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
using namespace std;

#define N 1000
#define EPS 1e-9


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	string ins;
	string verdicts[] = { "AC", "WA", "TLE", "RE" };
	map<string, int> table;
	for (int i = 0; i < 4; ++i)
		table[verdicts[i]] = 0;

	cin >> n;
	while (n--) {
		cin >> ins;
		++table[ins];
	}
	for (int i = 0; i < 4; ++i)
		cout << verdicts[i] << " x " << table[verdicts[i]] << '\n';
}

Measured memory_bytes: 3088
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for(auto &y:x){
        cin >> y;
    }

    if(n>=m){
        cout << 0 << endl;
        return 0;
    }

    sort(x.begin(),x.end());
    vector<int> diff(m-1);
    for(int i=0;i<m-1;i++){
        diff[i]=x[i+1]-x[i];
    }

    sort(diff.begin(),diff.end());

    ll maxdist=x[m-1]-x[0];
    for(int i=m-2;i>=m-n;i--){
        maxdist-=diff[i];
    }

    cout << maxdist << endl;

    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
const int N=2005,S=41e5;
int u[S],v[S],faa[S],n,m,i,j,a,b,xb,id0,id1,ans,dfn[N],dcnt,dad[N],dep[N],q[N*2],qw;
bool cov[N];
vector<int>e[N];
void dfs(int x,int fa){dfn[++dcnt]=x;dad[x]=fa;dep[x]=dep[fa]+1;for(int y:e[x])if(y!=fa)dfs(y,x);}
inline int lca(int x,int y){return x==y?x:(dep[x]>dep[y]?lca(dad[x],y):lca(x,dad[y]));}
inline void covchain(int b,int a){for(;b!=a;b=dad[b])cov[b]=1;}
inline void work(int x){
	int ii,i;
	for(ii=1;ii<=qw;++ii)if(i=q[ii],u[i]!=x)swap(u[i],v[i]);
	id0=id1=0;if(!cov[x])for(ii=1;ii<=qw;++ii)if(i=q[ii],!faa[i]){if(u[i]!=x)swap(u[i],v[i]);if(u[i]==x)(id0?id1:id0)=i;}
	if(id1){
		if(::i==2){if(v[id0]==v[id1])swap(u[id0],v[id0]);cov[x]=1;return;}
		faa[id0]=faa[id1]=++xb;u[xb]=u[id0]^v[id0]^x;v[xb]=u[id1]^v[id1]^x;
		a=lca(x,u[xb]);b=lca(x,v[xb]);
		if(a==b)covchain(lca(u[xb],v[xb]),a),covchain(x,a);
			else covchain(x,dep[a]>dep[b]?a:b);
		if(u[xb]==v[xb]){faa[xb]=-1;if(u[id0]==u[id1])swap(u[id0],v[id0]);}
			else q[++qw]=xb;
	}else if(id0)++ans;
	for(ii=1;ii<=qw;++ii)if(i=q[ii],!faa[i] && u[i]==x){
		if(v[i]!=dad[x])q[++qw]=faa[i]=++xb,u[xb]=dad[x],v[xb]=v[i];
			else faa[i]=-1;
	}
	int lim=qw;qw=0;
	for(ii=1;ii<=lim;++ii)if(!faa[q[ii]])q[++qw]=q[ii];
}
int main(){
	scanf("%d%d",&n,&m);xb=qw=m;for(i=1;i<=qw;++i)q[i]=i;
	for(i=1;i<n;++i)scanf("%d%d",&a,&b),e[a].push_back(b),e[b].push_back(a);
	for(i=1;i<=m;++i)scanf("%d%d",u+i,v+i);
	dfs(1,0);
	for(i=n;i>1;--i)work(dfn[i]);
	for(i=2;i<=n;++i)ans+=cov[dfn[i]]*2;
	for(i=xb;i;--i)if(faa[i]>0 && (u[i]==v[faa[i]] || v[i]==u[faa[i]]))swap(u[i],v[i]);
	printf("%d\n",ans);
	for(i=1;i<=m;++i)printf("%d %d\n",u[i],v[i]);
	return 0;
}

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

int main(){
    int N;
    cin>>N;
    int A[N];
    bool odd=false;
    for(int i=0;i<N;i++)cin>>A[i];
    int ans=0;
    while(true){
        for(int i=0;i<N;i++){
            if(A[i]%2!=0)odd=true;
        }
        if(odd)break;
        else{
            for(int i=0;i<N;i++)A[i]/=2;
            ans++;
        }
    }
    cout<<ans<<endl;



    
}

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

int main() {
    int n, a;
    cin >> n;
    vector<int> V;
    map<int, int> M;
    set<int> S1, S2;  // S1 pairwise coprime; s2 setwise coprime
    for (int i = 0; i < n; i++) {
        cin >> a;
        V.push_back(a);
    }

    bool pairwise = true;

    for (int j = n - 1; j >= 0; j--) {
        a = V[j];
        S2.clear();
        for (int i = 2; i * i <= a; i++) {
            if (a % i == 0) {
                if (S1.count(i) > 0 && S2.count(i) == 0) {pairwise = false;}
                S1.insert(i);
                S2.insert(i);
                a /= i;
                i--;
            }
        }
        if (a > 1) {
                if (S1.count(a) > 0 && S2.count(a) == 0) {pairwise = false;}
                S1.insert(a);
                S2.insert(a);
        }

        for (auto e : S2) {M[e]++;}
    }

    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    for (auto e : M) {
        if (e.second == n) {
            cout << "not coprime" << endl;
            return 0;
        }
    }
    cout << "setwise coprime" << endl;
}


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



// ============union_find_tree===============
ll MAX_N = 100000;
vector<ll> par(MAX_N);//MAX_N == num of node
vector<ll> tree_rank(MAX_N);

void init(ll n)
{
  for (ll i = 0; i < n; ++i)
  {
    par.at(i) = i;
    tree_rank.at(i) = 0;
  }
}

ll find(ll x)
{
  if (par.at(x) == x)
  {
    return x;
  }
  else
  {
    return par.at(x) = find(par.at(x));
  }
}

void unite(ll x, ll y)
{
  x = find(x);
  y = find(y);
  if (x == y)
  {
    return;
  }
  if (tree_rank.at(x) < tree_rank.at(y))
  {
    par.at(x) = y;
  }
  else
  {
    par.at(y) = x;
    if (tree_rank.at(x) == tree_rank.at(y))
    {
      tree_rank.at(x)++;
    }
  }
}

bool same(ll x, ll y)
{
  return find(x) == find(y);
}
// =======================================


int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> p(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> p.at(i);
  }
  init(N);
  for (ll i = 0; i < M; ++i)
  {
    ll x, y;
    cin >> x >> y;
    unite(x - 1, y - 1);
  }

  ll ans = 0;
  for (ll i = 0; i < N; ++i)
  {
    if (same(p.at(i) - 1, i))
    {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}


int main(){
	//in_o();
	string s;
	cin>>s;
	VI cnt(3);
	FOR(i,0,s.length()){
		cnt[(int)s[i]-'a']++;
	}
	if(abs(cnt[0]-cnt[1])<=1 && abs(cnt[2]-cnt[1])<=1 && abs(cnt[0]-cnt[2])<=1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


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


int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s.at(n-1)=='s'){
        s = s+"es";
    }else{
        s = s+'s';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=3001;
int p=998244353;
int log2_p_MAX = 32;
long long felmer(long long a)
{
  // a^(2^i) mod p
  long long rem[log2_p_MAX];
  rem[0] = a%p;
  for(int i=1;i<log2_p_MAX;i++)
    rem[i] = (rem[i-1]*rem[i-1])%p;
  long long res = 1;
  long long expo = p-2;
  for(int i=0;i<log2_p_MAX;i++){
	if(expo%2==1){
      res *= rem[i];
      res = res%p;
    }
  	expo /= 2;
  }
  return res;
}
long long pow_rem_p(long long a, long long n)
{
  long long ff,f,nn;
  ff=a; f=1; nn=n;
  while(nn>0){
    if(nn%2==1){
      f*=ff;
      f%=p;
    }
    ff*=ff;
    ff%=p;
    nn/=2;
  }
  return f;
}
int main()
{
  int n,s,i,j;
  int a[N_MAX];
  long long t,res;
  long long dp[N_MAX][N_MAX];
  cin >> n >> s;
  for(i=0;i<n;i++)
    cin >> a[i];
  t=felmer(2);
  dp[0][0]=pow_rem_p(2,n);
  fill(dp[0]+1,dp[0]+s+1,0);
  for(i=0;i<n;i++)
    for(j=0;j<=s;j++){
      if(j<a[i])
        dp[i+1][j]=dp[i][j];
      else
        dp[i+1][j]=(dp[i][j]+(dp[i][j-a[i]]*t)%p)%p;
    }
  cout << dp[n][s] << endl;
  return 0;
}

Measured memory_bytes: 73540
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int vec[100000];
map<int, int> ma;

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

	int t;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &t);

		if (++ma[t] == t) {
			cnt += t;
		}
	}

	printf("%d", n - cnt);
}

Measured memory_bytes: 4736
//#pagma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod= 99866353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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

main(){
	int a;
	cin >> a;
	cout << a / 2 - (a % 2 == 0);

}


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

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int64_t n, m;
  cin>>n>>m;
  if (min(n, m) > 1) {
    cout << (n-2) * (m-2) << endl;
  } else  if (max(n, m) > 1) {
    cout << max(n-2, m-2) << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int n;cin>>n;
	if(n<1000)cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var dic = new HashSet<long>();

        foreach(var x in ary) {
            if (dic.Contains(x)) {
                return "NO";
            }
            dic.Add(x);
        }
        return "YES";
    }

    static long[] ToIntArray(string strs, long n) {
        var ret = new long[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 42572
#include<cstdio>
using namespace std;
#define mod 1000000007
#define N 200050
int n,m,dp[N][2][2],fg,mx,fg2,dp2[N],su[N],as;
char s[N];
int main()
{
	scanf("%d%d%s",&n,&m,s+1);
	for(int i=2;i<=m;i++)if(s[i]!=s[i-1])fg=1;
	if(!fg)
	{
		dp[1][1][1]=dp[1][0][0]=1;
		for(int i=2;i<=n;i++)
		dp[i][0][0]=(dp[i-1][0][0]+dp[i-1][1][0])%mod,
		dp[i][0][1]=(dp[i-1][0][1]+dp[i-1][1][1])%mod,
		dp[i][1][0]=dp[i-1][0][0],
		dp[i][1][1]=dp[i-1][0][1];
		printf("%lld\n",(1ll*dp[n][0][0]+dp[n][0][1]+dp[n][1][0])%mod);
		return 0;
	}
	int su1=0;
	for(int i=1;i<=m;i++)
	if(s[i]==s[1])su1++;
	else
	{
		if((su1&1)&&mx>su1)mx=su1;
		if(!fg2)mx=su1+1;
		fg2=1;su1=0;
	}
	if(mx>n)mx=n;
	if(~mx&1)mx--;
	dp2[1]=1;su[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(i-mx>3)dp2[i]=(su[i-2]-su[i-mx-3]+mod)%mod;
		else dp2[i]=su[i-2];
		su[i]=(su[i-2]+dp2[i])%mod;
	}
	for(int i=1;i<=mx;i+=2)as=(as+1ll*dp2[n-i]*(i+1))%mod;
	printf("%d\n",as);
}//

Measured memory_bytes: 3456
#include <iostream>

using namespace std;

typedef struct Point{
	double x,y;
};

int main(){

	Point p[4];
	double x[2],y[2];
	while(cin>>p[0].x){
		cin>>p[0].y;
		for(int i=1;i<4;i++){
			cin>>p[i].x;
			cin>>p[i].y;
		}
		x[0] = p[0].x - p[1].x;
		x[1] = p[2].x - p[3].x;
		y[0] = p[0].y - p[1].y;
		y[1] = p[2].y - p[3].y;
		if(x[0] * x[1] + y[0] * y[1] == 0){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}

/*
Sample Input
1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0
0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0
10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1
2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3
Output for the Sample Input
YES
NO
NO
YES
*/

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};


ll calc(ll A, ll B, ll C)
{
    return (A/2+1) * B * C - A/2 * B * C;
}


int main()
{
    ll A, B, C;
    ll ans = 1e18;
    cin >> A >> B >> C;

    if (!(A%2) || !(B%2) || !(C%2)) {
        cout << 0 << endl;
        return 0;
    }

    ans = min(ans, calc(A, B, C));
    ans = min(ans, calc(B, C, A));
    ans = min(ans, calc(C, A, B));
    cout << ans << endl;
}



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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n, k; read(n,k);

    vector<int> v(n);

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

    int p = (n-1)/(k-1);

    int r = (n-1)%(k-1);

    if(r>0){
        p++;
    }
    cout<<p<<endl;
    
    return 0;
}

Measured memory_bytes: 3724
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


n, m = inpl()
n = 2 * m + 1
#left
for i in range(m//2):
    print(i + 1, m - i)
#right
base=m+1
for i in range((n-m)//2):
    print(base + i, n - i)



Measured memory_bytes: 72500
A = int(input())
B = int(input())
C = int(input())
x = int(input())

cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
           if x == 500*a + 100*b + 50*c:
               cnt += 1

print(cnt)

Measured memory_bytes: 9180
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	int N, K;
	cin >> N >> K;
	
	int id = 0;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		if(num == 1){
			id = i;
		}
	}
	
	cout << (N - 1) / (K - 1) + ((N - 1) % (K - 1) > 0) << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
signed main()
{
	long long k,l;
	cin>>k;
	long double j=100.0;
	for (long long i=1;i<4000;i++){
		j=j*1.01;
		l=j,j=l;
		if (l>=k){
			cout<<i;
			re 0;
		}
	}
}


Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 7)

n, u, v = [int(i) for i in sys.stdin.readline().split()]
u -= 1
v -= 1
graph = {i: [] for i in range(n)}
for i in range(n - 1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

distance = 0
stack = [(u, 0)]
already = set()
parent = [i for i in range(n)]
while len(stack) > 0:
    cur, dis = stack.pop(-1)
    already.add(cur)
    for _next in graph[cur]:
        if _next in already:
            continue
        parent[_next] = cur
        if _next == v:
            distance = dis + 1
            break
        stack.append((_next, dis + 1))
cur = v
path = []
while cur != u:
    path.append(cur)
    cur = parent[cur]

path_dict = {j: i for i, j in enumerate(path)}
already = set()
ls = []
stack = [(u, 0, 0)]
while len(stack) > 0:
    ind, cur_dis, minus = stack.pop(-1)
    already.add(ind)
    ls.append(cur_dis - minus)
    for _next in graph[ind]:
        parent[_next] = ind
        if _next in already:
            continue
        if _next in path:
            if path_dict[_next] <= cur_dis + 1:
                continue
            else:
                stack.append((_next, cur_dis + 1, minus + 2))
        else:
            stack.append((_next, cur_dis + 1, minus))

res = max(ls)

if res == 0:
    print(distance - 1)
else:
    print(distance + res - 1)

Measured memory_bytes: 79716
/*    三玖天下第一！！！  */
#include<bits/stdc++.h>
using namespace std;
int n,nums[30];
string s[60];
inline string sread()
{
	string s;
	char ch=getchar();
	while((ch<'a'||ch>'z')&&(ch<'A'||ch>'Z')) ch=getchar();
	while((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
	{
		 s+=ch;
		 ch=getchar();
	}
	return s;
}
inline void in()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) s[i]=sread();
}
inline void work()
{
	memset(nums,-1,sizeof(nums));
	for(int seat=1;seat<=n;seat++)
	{
		int len=s[seat].size();
		int temp[30]={};
		for(int i=0;i<len;i++) temp[s[seat][i]-'a']++;
		for(int i=0;i<26;i++) nums[i]=nums[i]<0?temp[i]:min(temp[i],nums[i]);
	}
}
inline void out()
{
	for(int i=0;i<26;i++) for(int j=1;j<=nums[i];j++) printf("%c",(char)(i+'a'));
	printf("\n");
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	in();
	work();
	out();
	return 0;
}


Measured memory_bytes: 256
N=int(input())
s = [input() for i in range(N)]
M=int(input())
t = [input() for i in range(M)]
tmp=[0]
point=0
for i in range(N):
    point+=s.count(s[i])
    if s[i] in t:
        point-=t.count(s[i])
    tmp.append(int(point))
    point=0 
print(max(tmp))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,ma,mb;cin>>n>>ma>>mb;
    vin a(n),b(n),c(n);rep(i,n)cin>>a[i]>>b[i]>>c[i];
    vvin m(401,vin(401,inf));
    int k=min(n/2,18);//こうするとちょっとはやくなる
    int materiala,materialb,money;
    rep(i,1<<(n-k)){
        bitset<23> tmp(i);
        materiala=0;materialb=0;money=0;
        rep(j,n-k){
            if(tmp[j]){
                materiala+=a[k+j];
                materialb+=b[k+j];
                money+=c[k+j];
            }
        }
        m[materiala][materialb]=min(m[materiala][materialb],money);
    }
    int ans=inf;
    rep(i,1<<k){
        bitset<19> tmp(i);
        materiala=0;materialb=0;money=0;
        rep(j,k){
            if(tmp[j]){
                materiala+=a[j];
                materialb+=b[j];
                money+=c[j];
            }
        }
        for(int i=1;i*max(ma,mb)<=400;i++){
            if(i*ma<materiala||i*mb<materialb)continue;
            ans=min(ans,m[i*ma-materiala][i*mb-materialb]+money);
        }
    }
    if(ans==inf)ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int mod = 1000000007;

int main(){
    int N, M; cin >> N >> M;
    vector<int> steps(N + 1, 0);
    rep(i, M){
        int m; cin >> m;
        steps[m] = -1;
    }
    
    steps[0] = 1;
    if(steps[1] == -1) steps[1] = 0;
    else steps[1] = steps[0];
    for(int i = 2; i <= N; i++){
        if(steps[i] == -1) steps[i] = 0;
        else steps[i] = steps[i - 1] + steps[i - 2];
        steps[i] %= mod;
    }
    cout << steps[N] << endl;
}

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

int main() {
	int num_balls, pos_b, pos_balls, distance = 0;
	cin >> num_balls >> pos_b;
	for (int i = 0; i < num_balls; i++) {
		cin >> pos_balls;
		if (pos_balls > pos_b / 2) distance += (pos_b - pos_balls);
		else distance += pos_balls;
	}
	cout << distance * 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;
using P = pair<int,int>;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m) cin >> p[i].first >> p[i].second;
    rep(x,1000) {
        int keta = 1;
        vector<int>d(1,x%10);
        int nx = x/10;
        while(nx > 0) {
            d.push_back(nx%10);
            nx /= 10;
            keta++;
        }
        if(keta!=n) continue;
        reverse(d.begin(),d.end());
        bool ok = true;
        rep(i,m) if(d[p[i].first-1] != p[i].second) ok = false;
        if(ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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


int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ll x, k, d;
	cin >> x >> k >> d;
	ll z = abs(x) / d;
	if(x > 0)
		x -= min(z,k) * d;
	else
		x += min(z,k) * d;
	k -= min(z,k);
	k = k%2;
	if(k)
	{
		if(x > 0)
			x -= d;
		else 
			x += d;
	}
	cout << abs(x);
}


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

///////////////////////////
int main() {
  string s;
  cin>>s;
  long long int k,ans=0,aans=0,p=0,str,count=0;
  bool flag=true;
  cin>>k;
  vector<string> v;
  
  for(long long int i=0;i<s.size();i++){
    
    if(flag){
      str=i;
      flag=false;
    }
    
    if(s[i]==s[i+1]){
      count++;
    }else{
      flag=1;
      v.push_back(s.substr(str,count+1));
      count=0;
      flag=true;
    }
    
  }
  
  if(v.size()!=1){
    
    if(s[0]==s[s.size()-1]){

      p+=v[0].size()/2+v[v.size()-1].size()/2;
      for(int i=1;i<v.size()-1;i++){
        ans+=v[i].size()/2;
      }
      aans+=(v[0].size()+v[v.size()-1].size())/2;
      cout<<ans*k+aans*(k-1)+p<<endl;

    }else{

      for(long long int i=0;i<v.size();i++){
        ans+=v[i].size()/2;
      }


      cout<<ans*k<<endl;

    }
    
  }else{
    cout<<s.size()*k/2<<endl;
  }
  
  
  
  
}
///////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll ans = 0;
    for (int i = 0; i < N - 1; i++)
    {
        ll total = a[i] + a[i + 1];
        if (total > x)
        {
            ans += total - x;
            a[i + 1] -= total - x;
            if (a[i + 1] < 0)
            {
                a[i] -= abs(a[i + 1]);
                a[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    map<int, int> m;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        if(m.count(a)>0){
            cout << "NO" << endl;
            return 0;
        }
        m[a]=1;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 9600
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Seg():
    def __init__(self, na, default, func):
        if isinstance(na, list):
            n = len(na)
        else:
            n = na
        i = 1
        while 2**i <= n:
            i += 1
        self.D = default
        self.H = i
        self.N = 2**i
        if isinstance(na, list):
            self.A = [default] * (self.N) + na + [default] * (self.N-n)
            for i in range(self.N-1,0,-1):
                self.A[i] = func(self.A[i*2], self.A[i*2+1])
        else:
            self.A = [default] * (self.N*2)
        self.F = func

    def find(self, i):
        return self.A[i + self.N]

    def update(self, i, x):
        i += self.N
        self.A[i] = x
        while i > 1:
            i = i // 2
            self.A[i] = self.merge(self.A[i*2], self.A[i*2+1])

    def merge(self, a, b):
        return self.F(a, b)

    def total(self):
        return self.A[1]

    def query(self, a, b):
        A = self.A
        l = a + self.N
        r = b + self.N
        res = self.D
        while l < r:
            if l % 2 == 1:
                res = self.merge(res, A[l])
                l += 1
            if r % 2 == 1:
                r -= 1
                res = self.merge(res, A[r])
            l >>= 1
            r >>= 1

        return res

def main():
    rr = []

    def f(n):
        a = LI()
        seg = Seg(n, 0, max)
        for c in a:
            t = seg.query(0,c)
            seg.update(c, t+c)
        r = sum(a) - seg.total()
        return r

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))
        break

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 19784
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
    int n,t;
    cin>>n>>t;
    vector<int> ans;
    for(int i=0;i<n;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	if(b<=t)
    		ans.push_back(a);
    }
    sort(ans.begin(),ans.end());
    if(ans.size()==0)
    	cout<<"TLE";
    else
    	cout<<ans[0];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<string> a(2 * n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i + n] = a[i];
    }
    for (int i = 0; i < 2 * n; ++i) {
        a[i] += a[i];
    }
    vector<vector<bool>> dp(2 * n, vector<bool>(n + 1));
    vector<vector<bool>> ndp(2 * n, vector<bool>(n + 1));
    int ans = 0;
    for (int i = 2 * n - 1; i >= 0; --i) {
        for (int j = 0; j < 2 * n; ++j) {
            ndp[j][1] = true;
            for (int len = 2; len <= n && i + len <= 2 * n && j + len <= 2 * n; ++len) {
                ndp[j][len] = dp[j + 1][len - 1] && ndp[j][len - 1] &&
                    (a[i + len - 1][j] == a[i][j + len - 1]);
            }
            if (i < n && j < n) {
                ans += ndp[j][n];
            }
        }
        ndp.swap(dp);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 768
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = ReadLineLongSplit();
			long n = s[0];
			long a = s[1];
			long b = s[2];
			long ans = (n / (a + b)) * a;
			long res = n % (a + b);
			Console.WriteLine(ans+Math.Min(res, a));
		}

		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n - 1, m - 1) / m;
		}

		public static string ReadLine()
		{
			return Console.ReadLine();
		}

		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}

		public static string[] ReadLineStringSplit(char s = ' ')
		{
			return ReadLine().Split(s).ToArray();
		}

		public static int[] ReadLineIntSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

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


int main() {
long n;
cin >> n;
vector<long> a(n),ans(n),cnt(n);
long long tmp=0;

for(int i=0;i<n;i++){
    cin >> a.at(i);
    cnt[i]=0;
}
for(int i=0;i<n;i++){
    cnt[a.at(i)-1]++;
}

for(int i=0;i<n;i++){
    if(cnt[a[i]-1]==0){ans[i]==0;}
    else{ans[i]=(cnt[a[i]-1]-1)*(cnt[a[i]-1]-2)/2;}
    tmp+=(cnt[i])*(cnt[i]-1)/2;
    
}
for(int i=0;i<n;i++){
    cout << tmp - (cnt[a[i]-1])*(cnt[a[i]-1]-1)/2 + ans[i] << endl;
}
}



Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;
int max(int x,int y)
{
	if (x<=y)
	{
		return x;
	}
	
	else
	{
		return y;
	}
}
int main()
{
	int a,b,c,d;
	
	while (scanf("%d%d%d%d",&a,&b,&c,&d)==4)
	{
		printf("%d\n",max(a,b)+max(c,d));
	}
	
	return 0;
 } 

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int a,b,t;
  cin>>a>>b>>t;
  cout<<(t/a)*b<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main(){

    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<setprecision(12) <<(double)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) <<endl;
    return 0;
}

Measured memory_bytes: 3228
n,m,c = map(int, input().split())
b=list(map(int, input().split()))
l=[]
for i in range(n):
    l.append(list(map(int, input().split())))

cnt=0
for i in range(n):
    ans=c
    for j in range(m):
        ans+=l[i][j]*b[j]
    if ans>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
fun main(args:Array<String>){
    val (a,b) = readLine()!!.split(" ").map{it.toInt()}
    val ma = Math.max(a,b)
    val mi = Math.min(a,b)
    println(if(a % 2 == b % 2) mi + (ma - mi) / 2 else "IMPOSSIBLE")
}

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

int main(void)
{
	int i, j, t;
	int k, s;
	int cnt = 0;
	int x, y, z;

	cin >> k >> s;


	for (i = 0; i <= k; i++) {
		x = i;


		for (j = 0; j <= k; j++) {
			y = j;

			z = s - (x + y);

			if (z >= 0 && z <= k) {

				cnt++;
			
			}

			
		}
	}
	cout << cnt << endl;

	return (0);
	
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
 int w,h;

 while(1){
 scanf("%d %d",&h,&w);
 
 if(w==0 && h==0){
  return 0;
 }
 for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
    printf("#");
    }
   printf("\n");
 }
 printf("\n");
}
}


Measured memory_bytes: 2588
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
using namespace std;
int main() {
	long long int a, b;
	cin >> a >> b;
	if ((a > 0 && b > 0 && b > a)|| (a < 0 && b < 0 && -b < -a)) {
		cout << b - a << endl;
		return 0;
	}
	if ((a > 0 && b > 0 && b < a)|| (a < 0 && b < 0 && b < a)) {
		cout << a - b + 2 << endl;
		return 0;
	}
	if ((a < 0 && b > 0 && b >= -a)|| a > 0 && b < 0 && -b <= a) {
		cout << b + a + 1 << endl;
		return 0;
	}
	if ((a < 0 && b > 0 && b <=- a)||(a > 0 && b < 0 && -b >= a)) {
		cout << -a - b + 1 << endl;
		return 0;
	}
	if (a == 0 && b > 0) {
		cout << b << endl;
		return 0;
	}
	if (a == 0 && b < 0) {
		cout << -b + 1 << endl;
		return 0;
	}
	if (a > 0 && b == 0) {
		cout << a + 1 << endl;
		return 0;
	}
	if (a < 0 && b == 0) {
		cout << -a << endl;
		return 0;
	}
}

Measured memory_bytes: 256
def create():
    for i in range(H):
        for j in range(W):
            if i % 2 == j % 2 == 0\
            or i % 2 != 0 and j % 2 != 0:
                print('#', end='')
            else:
                print('.', end='')
        print()


while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    create()
    print()



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

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

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

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    scanf("%d", &i);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    scanf("%lld", &i);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';

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

int main()
{
    int N;
    io >> N;
    vi a(N);
    for (int i = 0; i < N; i++)
        io >> a[i];

    int all = 0;
    for (int i = 0; i < N; i++)
        all ^= a[i];

    for (int i = 0; i < N; i++)
    {
        int ans = a[i] ^ all;
        io << ans << BR;
    }
}

Measured memory_bytes: 4056
/**
 *	@file: B.cpp
 *	@author: Huy Le
 *	@created: 08-17-2020 10:29:18
**/


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
const char newl = '\n';

int ts;
int n;
ll k;
vector<int> p;
vector<ll> c,sum;
bool vis[5005];
ll cur=0;

void dfs(int i) {
	vis[i] = 1;
	cur+=c[i];
	sum.push_back(cur);
	if(!vis[p[i]])
		dfs(p[i]);
}

void solve() {
	cin >> n >> k;
	p=vector<int>(n);
	c=vector<ll> (n);
	for(int i=0; i< n; ++i) {
		cin >> p[i];
		--p[i];
	}
	for(int i=0; i< n; ++i)
		cin >> c[i];
	ll ans=LLONG_MIN;
	for(int i=0; i<n; ++i) {
		memset(vis, 0, sizeof(vis));
		cur=0;
		sum.clear();
		dfs(i);
		//for(auto it:sum)
			//cout << it << ' ';
		//cout << newl;
		for(int j=0; j<sz(sum); ++j) {
			int rest=k-j-1;
			if(rest < 0)
				break;
			ans=max(ans, (rest/sz(sum))*max(0LL, cur) + sum[j]);
		}
	}
	cout << ans << newl;
}

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

	//cin >> ts;
	//while(ts--)
		solve();
}


Measured memory_bytes: 3816
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	ll out = 1;
	rep1(i, n) {
		(out *= (ll)i) %= MOD;
	}
	cout << out << endl;
	return 0;
}

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

int selectionSort(int A[],int N){
    int i,j,minj,sw = 0;
    for (i=0; i<N; i++) {
        minj=i;
        for (j=i; j<N; j++) {
            if (A[j]<A[minj]) {
                minj=j;
            }
        }
        swap(A[i], A[minj]);
        if (i!=minj) {
            sw++;
        }
    }
    return sw;
}




int main(int argc, const char * argv[]) {
    int A[105],N,i,sw;
    cin >>N;
    for (i=0; i<N; i++) {
        cin >>A[i];
    }
    sw=selectionSort(A, N);
    for (int i=0; i<N; i++) {
        if (i<N-1) {
            cout <<A[i]<<" ";
        } else {
            cout <<A[i]<<endl;
        }
    }
    cout <<sw<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3104
s=input()
l=len(s)
def len_s(l,n):
    return l-n+1

def get_tail(s,n,number):
    if n==0:
        return s[-number:]
    else:
        return s[-number-n:-n]


    
def check(s,n):
    tail=get_tail(s,n,3)
    if tail=="eam" and len_s(l,n)>=5:
        if get_tail(s,n,5)=="dream":
            return True,n+5
        else:
            return False,None
    elif tail=="mer" and len_s(l,n)>=7:
        if get_tail(s,n,7)=="dreamer":
            return True,n+7
        else:
            return False,None
    elif tail=="ase" and len_s(l,n)>=5:
        if get_tail(s,n,5)=="erase":
            return True,n+5
        else:
            return False,None
    elif tail=="ser" and len_s(l,n)>=6:
        if get_tail(s,n,6)=="eraser":
            return True,n+6
        else:
            return False,None
    else:
        return False,None
ans=0
tail=0
while True:
    bool,tail=check(s,tail)
    if bool:
        if tail==l:
            break
    else:
        ans+=1
        break   
if ans==0:
    print("YES")
else:
    print("NO") 


Measured memory_bytes: 9328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<pll> v(0);
  rep(i,a){
    int aa; cin >> aa;
    v.push_back(pll(aa,1));
  }
  rep(i,b){
    int bb; cin >> bb;
    v.push_back(pll(bb,2));
  }
  rep(i,c){
    int cc; cin >> cc;
    v.push_back(pll(cc,0));
  }
  sort(all(v));
  reverse(all(v));
  ll ans=0;
  int r=0;
  int g=0;
  int mu=0;
  rep(i,v.size()){
    if(r<x&&v[i].second==1){
      r++;
      ans+=v[i].first;
    }
    if(g<y&&v[i].second==2){
      g++;
      ans+=v[i].first;
    }
    if(v[i].second==0){
      mu++;
      ans+=v[i].first;
    }
    if(r+g+mu==x+y){
      break;
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 10476
#include <bits/stdc++.h>
using namespace std;
int sti(string s){
    stringstream rohit(s);
    int x=0; rohit>>x;
    return x;
}
int sti(char s){
    int x=(int)s-48;
    return x;
}
bool iseven(int t){
    if(t%2==0)
        return true;
    else
        return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    }
    int m1=a[n-1]-a[0],m2=(a[0]-0)+(k-a[n-1]);
    int lf=min(m1,m2);
    int d[n]; d[0]=lf;
    for(int i=1; i<n; i++){
        d[i]=a[i]-a[i-1];
    }
    sort(d,d+n,greater<int>());
    int m3=a[n-1]-a[0];
    cout<<min(m3,k-d[0]);


    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(j=1;j<=H;j++){
            for(i=1;i<=W;i++){
                if(j>1&&j<H&&i<W&&i>1){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;

}



Measured memory_bytes: 2020
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>A>>B;
    cout<<(abs(N - A) < abs(N - B) ? 'A' : 'B')<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
queue<int> q;
int a,b;
vector<int> ga[100010];
int indeg[100010];
int n,m;
int dp[100010];
int res;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		ga[a].push_back(b);
		indeg[b]++;
	}
	for(int i=1;i<=n;i++){
		if(indeg[i]==0)
		   q.push(i);
	}
	while(!q.empty()){
		int u=q.front();
		q.pop();
		res=max(res,dp[u]);
		for(int i=0;i<ga[u].size();i++){
			int v=ga[u][i];
			indeg[v]--;
			dp[v]=max(dp[v],dp[u]+1);
			if(indeg[v]==0)
			   q.push(v);
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define f(a, b, c) for(ll a=b; a<c; a++)
#define fo(a, b, c) for(ll a=b; a<=c; a++)

using namespace std;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // ll t;
    // cin>>t;
    // while(t--){
    ll a, b;
    cin>>a>>b;
    if((a>=1 && a<=9) && (b>=1 && b<=9)) cout<<a*b<<endl;
    else cout<<-1<<endl;
    // }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n, a, b);

  vector<bool> v1(n, false);
  vector<bool> v2(n, false);

  int max = 0;
  for (int i = 0; i < a; ++i) v1[i] = true;
  for (int i = 0; i < b; ++i) v2[i] = true;
  for (int i = 0; i < n; ++i) max += v1[i] && v2[i];

  int min = 0;
  reverse(all(v2));
  for (int i = 0; i < n; ++i) min += v1[i] && v2[i];

  printf("%d %d\n", max, min);

  return 0;
}

Measured memory_bytes: 256