akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL x, y;
    cin >> x >> y;
    if( x % y == 0 ) cout << -1;
    else cout << x;
    cout << endl;
    return 0;
}



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

int par[10000];
int rank[10000];

int find(int x){
  
  if(x == par[x]){
    return x;
  }else{
    par[x]=find(par[x]);
  }
  return par[x];
  
}
bool same(int x,int y){
  int x_oya,y_oya;
  
  x_oya=find(x);
  y_oya=find(y);

  if(x_oya == y_oya){
    return true;
  }else{
    return false;
  }
  
}
void unite(int x,int y){
  
  int x_oya,y_oya;

  x_oya=find(x);
  y_oya=find(y);
  
  if(rank[x_oya] > rank[y_oya]){
    par[y_oya]=x_oya;
  }else if(rank[x_oya] < rank[y_oya]){
    par[x_oya]=y_oya;
  }else{
    par[y_oya]=x_oya;
    rank[x_oya]++;
  }
  
}
 
int main(){
  
  int n,q,com,x,y;
  
  cin >>n>>q;

  for(int i=0 ; i < n ; i++){
    par[i]=i;
    rank[i]=0;
  }
  

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

    if(com == 0){
      cin >>x>>y;
      unite(x,y);
    }else{
      cin >>x>>y;
      cout <<same(x,y)<<endl;
    }
  
  }


  return 0;
}

Measured memory_bytes: 1236
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

ans = False
for u in range(n-m+1):
    for l in range(n-m+1):
        #check
        ok = True
        for i in range(m):
            for j in range(m):
                ok &= a[u+i][l+j] == b[i][j]
        if ok:
            ans = True
if ans:
    print('Yes')
else: print('No')

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  REP(i, x+1){
    int val = i * 2 + (x-i) * 4;
    if (val == y){
      cout << "Yes" << endl;
      return 0;
    }
  }

cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3100
a = []
b = []
n, m = gets.split.map(&:to_i)
n.times {a << gets.split.map(&:to_i)}
m.times {b << gets.to_i}

a.each do |is|
  j = 0
  sum = 0
  is.each do |i|
    sum += i * b[j]
    j += 1
  end
  puts sum
end

Measured memory_bytes: 6132
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10桁出力 cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	int n;
	cin >> n;
	VI a(n + 1, 0);

	FOR(i, 0, n) {
		a[i] = IN<int>();
	}
	LL ans = 0;
	FOR(i, 0, n) {
		if (a[a[i] - 1] == i + 1) {
			ans++;
		}
	}
	ans /= 2;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
from collections import deque
n,m,*inp=map(int,open(0).read().split())
d=[[] for i in range(n)]
for i in range(m):
    j=2*i
    a,b=inp[j:j+2]
    a-=1
    b-=1
    d[a].append(b)
    d[b].append(a)
l=[-1 for i in range(n)]
q=deque([0])
#print(d)
while len(q)>0:
    x=q.popleft()
    for i in d[x]:
        #print(i)
        if l[i]==-1:
            q.append(i)
            #print(i)
            l[i]=str(x+1)
l=l[1:]
#print(l)
print('No' if 0 in l else 'Yes\n'+'\n'.join(l))


Measured memory_bytes: 57156
#include <bits/stdc++.h>
#define N 200010
using namespace std;
 
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge{int v,next;}vs[N<<1];
int n,ee,st[N<<1],du[N],Rt,F[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}

inline bool cmp(int a,int b){return F[a]<F[b];}

inline bool dfs(int rt,int pr,int x)
{
	vector <int> v; v.clear();
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		if(!dfs(vs[i].v,rt,x)) return false;
		v.push_back(vs[i].v);
	}
	if(v.size()==0){
		F[rt]=1;
		return true;
	}
	if(du[rt]&1) v.push_back(0);
	sort(v.begin(),v.end(),cmp);
	// printf("son of node %d len of %d\n",rt,x);
	// for(int i=0;i<v.size();i++) printf("%d ",v[i]); puts("");
	int l=0,r=v.size()-1,rs=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1,fg=1;
		for(int i=0,j=v.size()-1;i<j;i++,j--)
		{
			if(i==mid) i++; if(j==mid) j--;
			int tmp1=F[v[i]],tmp2=F[v[j]];
			fg&=(tmp1+tmp2)<=x;
		}
		if(fg) r=mid-1,rs=v[mid];
		else l=mid+1;
	}
	if(rs==n+1) return false;
	F[rt]=F[rs]+1;
	return F[rt]<=x+1;
}
inline bool check(int x)
{
	return dfs(Rt,0,x);
}
int main()
{
	// freopen("read.in","r",stdin);
	n=read(); for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v); du[u]++;
		addedge(v,u); du[v]++;
	}
	int cnt=0; for(int i=1;i<=n;i++) 
		cnt+=du[i]&1,Rt=du[i]==1? i:Rt;
	//Rt=1;
	int l=1,r=n,B=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1,B=mid;
		else l=mid+1;
	}
	cout << cnt/2 << " " << B << endl;
	return 0;
}

Measured memory_bytes: 12800
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll t[200002];

int
main(void){  
  ios_base::sync_with_stdio(false);

  ll n, T;  
  cin >> n >> T;
  REP(i, n) cin >> t[i];
  ll ans = 0LL;
  REP(i, n-1){
    if(t[i+1] < T+t[i]) ans += t[i+1]-t[i];
    else ans += T;
  }
  ans += T;
  cout << ans << endl;
  
  return 0;
}


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            char[] s = in.next().toCharArray();
            int n = s.length;

            int[] cnt = new int[26];

            long ans = 1;
            for (int i = 0; i < n; ++i) {
                ans += i - cnt[s[i] - 'a'];
                cnt[s[i] - 'a']++;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> line(m);
  int qw,er;
  rep(i,0,m){
    cin >> qw >>er;
    line[i] = make_pair(qw,er);
  }
  
  int ans = 0;
  
  rep(i,0,m){
    queue<int> next;
    set<int> kind;
    next.push(line[i].first);
    kind.insert(line[i].first);
    bool ok = false;
    
    while(next.size()!=0){
      rep(j,0,m){
        if(j==i) continue;
        if(line[j].first==next.front() && kind.count(line[j].second)==0) {
          next.push(line[j].second);
          kind.insert(line[j].second);
        }
        if(line[j].second==next.front() && kind.count(line[j].first)==0) {
          next.push(line[j].first);
          kind.insert(line[j].first);
        }
      }
      
      next.pop();
    }
    if(kind.count(line[i].second)) ans++;
    
  }
  cout << m-ans << endl;
  
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s,t;
 cin>>s>>t;
 sort(s.begin(),s.end());
 sort(t.begin(),t.end());
 reverse(t.begin(),t.end());
 if(s<t)
  cout<<"Yes";
else
 cout<<"No";
return 0;
}

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

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<long long> div(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    long long n;
    long long ans = 9223372036854775807;
    cin >> n;
    vector<long long> v = div(n);
    //n = i * jを満たすようなiとjの列挙
    for(long long c : v){
        ans = min(ans,c + n/c -2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ull =unsigned long long;
using ll=long long;
int main()
{
ull n,k;cin>>n>>k;
if(n%k==0)cout<<0<<endl;
else{
    n=n-((n/k)*k);
while(abs((ll)(n-k))<=n&&n!=0)
{n=abs((ll)(n-k));
}
cout<<n<<endl;
}
}

Measured memory_bytes: 256
H,W=map(int,input().split())
L=[]
for i in range(H):
    w=list(input())
    L.append(w)
    
ANS=[[0 for i in range(W)]for j in range(H)]
ANS[0][0]=1
for i in range(1,W):
    if L[0][i]=="#":
        ANS[0][i]=0
    else:
        ANS[0][i]=ANS[0][i-1]
for i in range(1,H):
    for j in range(W):
        if L[i][j]!="#":
            ANS[i][j]=0
            if j>0:
                ANS[i][j]+=ANS[i][j-1]
            ANS[i][j]+=ANS[i-1][j]
            ANS[i][j]%=(10**9+7)
print(ANS[H-1][W-1])

Measured memory_bytes: 52388
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
bool cmp(char a,char b)
{
	return a>b;
}
int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if(s<t)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
line = readlines
len = line.length
i = 0
l = 0

while i < len
    line[i] = line[i].chomp.split(' ')
    i += 1
end

i = 1

while line[i][0] != line[line.length - 1][0]
  i += 1
end

i += 1

while i < line.length - 1
  l += line[i][1].to_i
  i += 1
end

puts l

Measured memory_bytes: 1788
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    char c;
    cin >> a >> c >> b;
    if ( c == '+' ) cout << a + b;
    else cout << a - b;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#define MAXN 200001
#define int long long

const int mod = 1000000007;
int n, ans, a[MAXN], sum[MAXN];

signed main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		sum[i] = (1ll * sum[i - 1] + 1ll * a[i]) % mod;
	}
	for (int i = 1; i < n; ++i) {
		ans = (ans + 1ll * a[i] * ((sum[n] - sum[i] + mod) % mod) % mod) % mod;
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6660
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
ls3 = list(map(int, input().split()))

ls = [ls1, ls2, ls3]
ans = 0
if ls[1][0]-ls[0][0] == ls[1][1]-ls[0][1] and ls[1][1]-ls[0][1] == ls[1][2]-ls[0][2]:
    ans += 1 
if ls[2][0]-ls[1][0] == ls[2][1]-ls[1][1] and ls[2][1]-ls[1][1] == ls[2][2]-ls[1][2]:
    ans += 1 
if ls[0][1]-ls[0][0] == ls[1][1]-ls[1][0] and ls[1][1] -ls [1][0] == ls[2][1]-ls[2][0]:
    ans += 1 
if ls[0][2]-ls[0][1] == ls[1][2]-ls[1][1] and ls[1][2] -ls [1][1] == ls[2][2]-ls[2][1]:
    ans += 1 

if ans == 4:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
def main():
    A, B = map(int, input().split())
    x = int(A/0.08)
    y = int((A+1)/0.08)
    for i in range(x, y+1):
        if int(i*0.08) == A and int(i*0.1) == B:
            print(i)
            return
    print(-1)

main()

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

int main(){
  int n, m; cin >> n >> m;
  vector<vector <int> > g(n+1);
  vector<pair <int, int> > ed;
  
  for(int i = 0; i < m; i++){
    int a, b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    ed.push_back(make_pair(a, b) );
  }
  int ans = 0;
  
  for(int i = 0; i < m; i++){
    int a = ed[i].first, b = ed[i].second;
    vector<bool> vsd(n+1, false);
    stack<int> st;
    st.push(1);
    int re = 0;
    
    while(!st.empty()){
      int now = st.top(); st.pop();
      if(vsd[now]) continue;
      vsd[now] = true;
      re++;
      
      for(int j = 0; j < g[now].size(); j++){
        int next = g[now][j];
        if((now == a && next == b) || (now == b && next == a)){
          continue;
        }else if(!vsd[next]){
          st.push(next);
        }
      }
    }
    if(re == n) ans++;
  }
  
  cout << m - ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
vector<vector<pi > > G;
vector<bool > seen;
vector<ll > ans;
ll color_mx = -1;
//辺をデータとして持っておく
map<pi, ll> edge;

void dfs(ll idx, ll from = -1){
    seen[idx] = true;
    //始点の前には辺がない
    if(from == -1){
        edge[make_pair(from, idx)] = -1;
    }

    ll cn = 1;
    for(ll i = 0; i < G[idx].size(); i++){

        //次の行き先は？
        ll to = G[idx][i].first;
        //edge番号は？
        ll edge_num = G[idx][i].second;
        //探査済み
        if(seen[to] == true){
            continue;
        }
        //前の辺が同じ色だったら同じ色には塗らない
        if(edge[make_pair(from, idx)] == cn){
            cn++;
        }
        //cout << cn << endl;
        edge[make_pair(idx, to)] = cn;
        //cout << t_from << " " << cn << endl;
        ans[edge_num ] = cn;
        cn++;
        dfs(to , idx);
    }

    color_mx = max(cn-1, color_mx);

}

int main(){
    ll N;
    cin >> N;
    //初期化
    G.assign(N, vector<pi >());
    seen.assign(N, false);
    ans.assign(N - 1, 0);
    
    //グラフ入力
    for(ll i = 0; i < N - 1; i++){
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        //重みとして今現在貼った辺が何個目の辺であるかを記憶しておく
        G[u].push_back(make_pair(v, i));
        G[v].push_back(make_pair(u, i));
    }

    //根っこの色は1（初期値）
    dfs(0);

    cout << color_mx << endl;

    for(ll i = 0; i < N - 1; i++){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 16128
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class UnionFind(object):
    def __init__(self, n, recursion = False):
        self._par = list(range(n))
        self._size = [1] * n
        self._recursion = recursion

    def root(self, k):
        if self._recursion:
            if k == self._par[k]:
                return k
            self._par[k] = self.root(self._par[k])
            return self._par[k]
        else:
            root = k
            while root != self._par[root]: root = self._par[root]
            while k != root: k, self._par[k] = self._par[k], root
            return root

    def unite(self, i, j):
        i, j = self.root(i), self.root(j)
        if i == j: return False
        if self._size[i] < self._size[j]: i, j = j, i
        self._par[j] = i
        self._size[i] += self._size[j]
        return True

    def is_connected(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, k):
        return self._size[self.root(k)]

def resolve():
    n = int(input())
    uf = UnionFind(n)
    potential = [[1, 1] for _ in range(n)]
    x_to_index = {}
    y_to_index = {}

    for i in range(n):
        x, y = map(int, input().split())

        # 双方にくっつけられる場合
        if x in x_to_index and y in y_to_index:
            s = uf.root(x_to_index[x])
            t = uf.root(y_to_index[y])
            xs, ys = potential[s]
            xt, yt = potential[t]
            # くっつけても意味が無い場合
            if s == t:
                uf.unite(i, s)
                potential[uf.root(i)] = [xs, ys]
            # くっつけると意味がある場合
            else:
                uf.unite(i, s)
                uf.unite(i, t)
                potential[uf.root(i)] = [xs + xt, ys + yt]
        # 片方にくっつけられる場合
        elif x in x_to_index:
            s = uf.root(x_to_index[x])
            xs, ys = potential[s]
            uf.unite(i, s)
            potential[uf.root(i)] = [xs, ys + 1]
        elif y in y_to_index:
            t = uf.root(y_to_index[y])
            xt, yt = potential[t]
            uf.unite(i, t)
            potential[uf.root(i)] = [xt + 1, yt]

        x_to_index[x] = i
        y_to_index[y] = i

    res = -n
    for v in range(n):
        if v != uf.root(v):
            continue
        x, y = potential[v]
        res += x * y

    print(res)
resolve()

Measured memory_bytes: 90912
#include <iostream>

using namespace std;

int main() {
	int H, W;
	int check = 0;

	while (cin >> H >> W && (H != 0 || W != 0)) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
			    if(j == 0)
			        check = i % 2;
			        
				if (check == 0){
				    cout << "#";
				    check++;
				}
				else{
				    cout << ".";
				    check--;
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3124
package main

import "fmt"

func min(a []int) (idx, val int) {
	val = a[0]
	for i, aa := range a {
		if aa < val {
			idx, val = i, aa
		}
	}
	return
}

func main() {
	var p, q, r int
	fmt.Scan(&p, &q, &r)
	x := p + q
	y := q + r
	z := r + p
	_, ans := min([]int{x, y, z})
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int a,b,c;
  int count = 0;
  scanf("%d %d %d", &a,&b,&c);//
  for(int i = a; i<=b; i++){
      if(c%i==0) count++;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2748
#include<bits/stdc++.h>
typedef long long ll;
#define     FAST            ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
    
        ll a,b;
        cin>>a>>b;
        cout<<a*b<<endl;








    

    return 0;

}


Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ATravelingBudget {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            out.println(Math.min(a, b) + Math.min(c, d));
        }

    }
}



Measured memory_bytes: 21716
import sys

weight = [2**x for x in range(10)]
weight.reverse()

for s in sys.stdin:
	w = int(s)
	ans = []
	for i in range(10):
		if w == 0:
			break
		if w >= weight[i]:
			w -= weight[i]
			ans.append(weight[i])

	ans.reverse()
	for i in range(len(ans)):
		print(ans[i], end='')
		if i < len(ans)-1:
			print(' ', end='')
	print()

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
const ll mod = 1e9 + 7;
ll a[N][2];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j < 2; ++j)
            cin >> a[i][j];
    ll ans = 0;
    for (int i = 0; i < 4; ++i)
    {
        ll maxV = -1e18, minV = 1e18;
        for (int j = 1; j <= n; ++j)
        {
            ll v = 0;
            for (int k = 0; k < 2; ++k)
            {
                v = v + (i & (1 << k) ? 1 : -1) * a[j][k];
            }
            maxV = max(maxV, v);
            minV = min(minV, v);
        }
//        cout << maxV << '\t' << minV << endl;
        ans = max(ans, maxV - minV);
    }
    cout << ans;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr ll MOD = 998244353;

// a^b
template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

ll N, A, B, K;

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

    cin >> N >> A >> B >> K;
    ll res = 0;
    vector<ll> fact(N + 1, 1), inv(N + 1, 1);
    for (int i = 1; i <= N; i++)
    {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;

        inv[i] = mypow(fact[i], MOD - 2);
    }
    for (int i = 0; i <= N; i++)
    {
        ll x = i;
        if ((K - A * x) % B)
            continue;
        ll y = (K - A * x) / B;
        if (y < 0 || N < y)
            continue;
        ll tmp = fact[N];
        tmp *= inv[x];
        tmp %= MOD;
        tmp *= inv[N - x];
        tmp %= MOD;

        tmp *= fact[N];
        tmp %= MOD;
        tmp *= inv[y];
        tmp %= MOD;
        tmp *= inv[N - y];
        tmp %= MOD;

        res += tmp;
        res %= MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#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())
#define PB push_back
#define MP make_pair
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; }


vector<pair<int,int>> v;
map<int,int> check;

int main() {
  int n,m;
  scanf("%d%d", &n,&m);
  int a[m],b[m];
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a[i],&b[i]);
    v.PB(MP(a[i],b[i]));
  }

  FOR(i,0,m-1){
    int ref1 = v[i].first;
    int ref2 = v[i].second;
    if(ref1==1){
      ++check[ref2];
    }
    if(ref2==n){
      ++check[ref1];
    }
  }

  bool flug = false;

  FOR(i,1,n){
    if(check[i]==2) flug = true;
  }

  if(flug == true) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;


  


}



Measured memory_bytes: 12784
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	int n;
	int i;
	int x;
	int ans,cnt,MAX;
	scanf("%d",&n);
	ans=0;
	MAX=-1;
	for(i=1;i<=n;i++){
		x=i;
		cnt=0;
		//printf("x=%d\n",x);
		while(x%2==0){
			x/=2;
			cnt++;
		}
		//printf("cnt=%d\n",cnt);
		if(MAX<cnt){
			MAX=cnt;
			ans=i;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
*A, = map(int, input().split())
for i in range(n):
  v = A[i]
  j = i - 1
  while j >= 0 and A[j] > v:
    A[j + 1] = A[j]
    j -= 1
  A[j + 1] = v;print(*A)


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

int main() {
  char c;
  cin >> c;
  string vowel = "aiueo";
  string ans = "consonant";
  
  for (int i=0; i<5; i++){
	if (c == vowel.at(i) ){
	    ans = "vowel";
    	break;
    }
  }
  cout << ans;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e5;  
using  p = pair<int,int>;

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

   int c=0;
   for (int i = 0; i < s.size(); i++)
   {
      if(s[i] == t[i]) c++;
   }
   
   cout << c;
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a = 1, b = 1, c = 1;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        a = a * 10 % mod;
        b = b * 9 % mod;
        c = c * 8 % mod;
    }
    cout << (a - b - b + c + 4ll * mod) % mod;
}


Measured memory_bytes: 3612
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int GCD(int m, int n) {
  if ((0 == m) || (0 == n)) return 0;
  while ((m != 0) && (n != 0)) m > n ? m %= n : n %= m;
  return m > n ? m : n;
}  // End_Func
int LCM(int m, int n) {
  if ((m == 0) || (n == 0)) return 0;
  return m * n / GCD(m, n);
}  // End_Func

int main() {
  int k;
  cin >> k;
  long long sum = 0;

  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      for (int ngo = 1; ngo <= k; ++ngo) {
        sum += GCD(GCD(i, j), GCD(j, ngo));
      }
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws Exception {
try {
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	int x = Integer.parseInt(buf.readLine());
	int count = 1;
	
	while(x != 0){
		System.out.println("Case " + count + ": " + x);
		x = Integer.parseInt(buf.readLine());
		count ++;
	}
} catch (Exception e) {
	// TODO: handle exception
}
		 }
    }

Measured memory_bytes: 31780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

class Tree{
    public:
    vector<vector<int> >edge;
    vector<int>depth;
    Tree(int num){
        edge = vector<vector<int> >(num);
        depth = vector<int>(num, 0);
    }
    void add(int a, int b){
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    void dfs(int x = 0, int from = -1, int dep = 1){
        depth[x] = dep;
        for(int i = 0; i < edge[x].size(); i++){
            int nxt = edge[x][i];
            if(from == nxt)continue;
            dfs(nxt, x, dep + 1);
        }
    }
    int diameter(){
        dfs();
        int mxIdx = 0;
        for(int i = 0; i < depth.size(); i++){
            if(depth[mxIdx] < depth[i]){
                mxIdx = i;
            }
        }
        dfs(mxIdx);
        int mxDepth = 0;
        for(int i = 0; i < depth.size(); i++){
            mxDepth = max(mxDepth, depth[i]);
        }
        return mxDepth;
    }
};
int main(){

    int N;
    cin >> N;
    Tree tree(N);
    for(int i = 1; i < N; i++){
        int a, b;
        cin >> a >> b;
        tree.add(a - 1, b - 1);
    }
    if(tree.diameter() % 3 == 2)cout << "Second" << endl;
    else cout << "First" << endl;

    return 0;
}

Measured memory_bytes: 17920
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
P = rl()

import itertools

def check(P):
	#print(P)
	prev = P[0]
	for i in range(1, len(P)):
		if prev > P[i]:
			return False
		prev = P[i]
	return True

P0 = list(P)
if check(P):
	print('YES')
	exit()
for c in itertools.combinations(list(range(N)), 2):
	i, j = c
	#print(i, j)
	P = list(P0)
	P[i], P[j] = P[j], P[i]
	if check(P):
		print('YES')
		exit()
print('NO')

Measured memory_bytes: 68908
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
ll a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)puts("0");
	else
	{
		cout<<min(a*b,min(b*c,a*c))<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
  char buf1[400001];
  char* i = buf1 + 200000;
  gets(buf1);
  gets(i);
  int ans = 0;
  do ans += *(i - 200000) != *i; while(*(++i));
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 2020
#include<cstdio>
#define M 200005
int A[M],B[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	int cnt=0;
	for(int i=n;i>=1;i--){
		for(int j=i+i;j<=n;j+=i){
			A[i]^=A[j];
		}
		if(A[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=1;i<=n;i++){if(A[i])printf("%d ",i);}
	return 0;
}

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

const int MAXN=1e5+10;

vector<int> g[MAXN];
bool odw[MAXN];
int dp[MAXN];

void dfs(int u)
{
    odw[u]=true;
    for(auto v:g[u])
        if(!odw[v])
            dfs(v),dp[u]=max(dp[u],dp[v]);
        else
            dp[u]=max(dp[u],dp[v]);
    if(!g[u].empty())
        dp[u]++;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,a,b,ans=0;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a>>b;
        g[a].emplace_back(b);
    }
    for(int i=1;i<=n;i++)
        if(!odw[i])
            dfs(i),ans=max(ans,dp[i]);
    cout<<ans;
}


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

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const int MOD = 1000000007;

int main()
{
  int N;
  cin >> N;
  vector<int> v(N);
  REP(i, 0, N)
  {
    cin >> v[i];
  }
  sort(ALL(v));
  ll div_num = 1;
  REP(i, 0, N - 1)
  {
    div_num *= 2;
  }
  double sum_v = ((double)v[0]) / div_num;
  REP(i, 1, N)
  {
    sum_v += ((double)v[i]) / div_num;
    div_num /= 2;
  }

  cout << sum_v << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 

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


int main() {
    Vl c1(3), c2(3), c3(3);
    rep(i, 0, 3) cin >> c1[i];
    rep(i, 0, 3) cin >> c2[i];
    rep(i, 0, 3) cin >> c3[i];

    ll a = c1[0]-c1[1], b = c1[1]-c1[2];
    if(c2[0]-c2[1]==a && c2[1]-c2[2]==b && 
    c3[0]-c3[1]==a && c3[1]-c3[2]==b ) co("Yes");
    else co("No");

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> s = a;
    sort(s.rbegin(), s.rend());
    rep(i, n) {
        int ans = s[0];
        if (s[0] == a[i])
            ans = s[1];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4804
S = input()

flg = True
for n in range(len(S)):
  if n%2==0 and (S[n]!='R' and S[n]!='U' and S[n]!='D'):
    flg=False
  if n%2==1 and (S[n]!='L' and S[n]!='U' and S[n]!='D'):
    flg=False
if flg:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 38704
import kotlin.math.abs
import kotlin.math.max

fun main() {
    val n = readLine()?.toInt() ?: return
    val al = mutableListOf<Long>()
    repeat(n) {
        val a = readLine()?.toLong() ?: return
        al.add(a)
    }
    al.sort()
    var l = 1
    var r = n - 1
    var lv = al[0]
    var rv = al[0]
    var f = 2
    var t = 0L
    while (l <= r) {
        if (l == r) {
            val a = abs(al[l] - lv)
            val b = abs(al[l] - rv)
            t += max(a, b)
            l++
        } else if (f < 0) {
            val all = al[l]
            if (f == -2) {
                t += abs(all - lv)
                lv = al[l]
            } else {
                t += abs(all - rv)
                rv = al[l]
            }
            l++
            f++
            if (f == 0) {
                f = 2
            }
        } else {
            val alr = al[r]
            if (f == 2) {
                t += abs(alr - lv)
                lv = alr
            } else {
                t += abs(alr - rv)
                rv = alr
            }
            r--
            f--
            if (f == 0) {
                f = -2
            }
        }
    }
    println(t.toString())
}

Measured memory_bytes: 63160
#include<iostream>
#include<vector>
#include<limits.h>
using namespace std;

int out(vector<int> &A,int n){
	int i;
	for (i=0;i<=n-2;i++){
		cout << A[i] <<" ";
	}
	cout << A[n-1] <<endl;
}

int merge(vector<int> &A, int left, int mid, int right){
	int count=0;
	int n1=mid-left;
	int n2=right-mid;
	int i, j;
	vector<int> L(n1+1);
	vector<int> R(n2+1);
	for (i=0;i<=n1-1;i++){
		L[i]=A[left+i];
	}
	for (i=0;i<=n2-1;i++){
		R[i]=A[mid+i];
	}
	L[n1]=INT_MAX;
	R[n2]=INT_MAX;
	i=0;
	j=0;
	int k;
	for (k=left;k<right;k++){
		count++;
		if (L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}else{
			A[k]=R[j];
			j++;
		}
	}
	
	return count;
}

int mergeSort(vector<int> &A, int left, int right){
	int count=0;
	if (left+1<right){
		int mid=(left+right)/2;
		count=mergeSort(A,left,mid)+mergeSort(A,mid,right)+merge(A,left,mid,right);
	}
	return count;
}
int main(){
	int n;
	int count=0;
	cin >> n;
	vector<int> A(n);
	int i;
	for (i=0;i<n;i++){
		cin >> A[i];
	}
	
	count=mergeSort(A,0,n);
	
	out(A,n);
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 5064
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    int sum = 0;

    for(int i = 0; i < 2; i++) {
        if(a > b) {
            sum += a;
            a--;
        } else {
            sum += b;
            b--;
        }
    }

    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for i in range(3)]
#a = []
# for i in range(3):
#    temp = list(map(int, input().split()))
#    a.extend(temp)
n = int(input())
b = [int(input()) for _ in range(n)]
ans = []

for i in b:
    for index, cow in enumerate(a):
        for index2, k in enumerate(cow):
            if i == k:
                a[index][index2] = True

for i in a:
    if i.count(True) == 3:
        print('Yes')
        exit(0)


for i in zip(*a):
    if i.count(True) == 3:
        print("Yes")
        exit(0)


temp = [a[i][i] for i in range(3)]
temp2 = [a[i][2-i] for i in range(3)]
if temp.count(True) == 3 or temp2.count(True) == 3:
    print('Yes')
    exit(0)


print('No')


Measured memory_bytes: 9136
#include <vector>
#include <string>
#include <iostream>
#include <stdlib.h> // @atoi
#include <algorithm>
using namespace std;


#define NUMBEROF(Array)		( sizeof( Array ) / sizeof( Array[ 0 ] ) )

bool cookSort(int a, int b)
{
	if (a % 10 == 0 && b % 10 != 0) { return true; }
	if (a % 10 != 0 && b % 10 == 0) { return false; }
	int diffA = 10 -( a % 10);
	int diffB = 10 - (b % 10);
	return (diffA < diffB ? true : false) ;
}

int main(void)
{
	std::vector<int> v_cook;
	for (int i = 0; i < 5; ++i)
	{
		int tmp = 0;
		cin >> tmp;
		v_cook.push_back(tmp);
	}

	std::sort(v_cook.begin(), v_cook.end(), cookSort);

	int waitTime = 0;
	for (int i = 0; i < v_cook.size() - 1; ++i)
	{
		if (v_cook.at(i) % 10 == 0)
		{
			waitTime += v_cook.at(i);
		}
		else
		{
			waitTime += ((v_cook.at(i) / 10) * 10) + 10;
		}
	}
	waitTime += v_cook.at(v_cook.size()-1);
	
	cout << waitTime << endl;
	return 0;
}

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

int main()
{
	int n;

	while (cin >> n, n){
		long long e[5000] = {0}, p, q, t;
		bool out = false, f = false;
		vector<int> s;
		for (int i = 0; i < n; i++){
			cin >> t >> p >> q;
			for (int j = 0; j < s.size(); j++){
				if (s[j] == t){
				 	f = true;
					break;
				}
			}
			if (f == false){
				s.push_back(t);
			}
			e[t] += p * q;
		}
		for (int i = 0; i < s.size(); i++){
			if (e[s[i]] >= 1000000){
				cout << s[i] << endl;
			  out = true;
			}
		}
		if (out == false) cout << "NA" << endl;
	}
	return (0);
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = 0; i < k; i++) {
        vector<int> d(n+1, 0);
        for (int j = 0; j < n; j++) {
            int l = j - a[j], r = j + a[j] + 1;
            l = max(0, l);
            r = min(r, n);
            d[l]++;
            d[r]--;
        }
        int k = 0;
        int mi = n;
        for (int j = 0; j < n; j++) {
            k += d[j];
            a[j] = k;
            mi = min(mi, k);
        }
        if (mi == n)
            break;
    }
    for (int i = 0; i < n; i++)
        cout << a[i] << " ";
    cout << endl;
    return 0;
}


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

int N;
vector<int> P, Q;

void input_data(void) {
	cin >> N;
	P.resize(N);
	Q.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
		Q[P[i] - 1] = i;
	}
}

int solve(void) {
	int max_cnt = 0;
	int cnt = 1;
	for (int i = 1; i < N; ++i) {
		if (Q[i] > Q[i - 1])
			++cnt;
		else {
			max_cnt = max(cnt, max_cnt);
			cnt = 1;
		}
	}
	max_cnt = max(cnt, max_cnt);
	return max_cnt;
}

int main(void) {
	input_data();
	int cnt = solve();
	int ans = N - cnt;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1792
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,C,s,t,c;
vector<pair<int,int>>vec;
int m[100];
int ans;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> C;
	for(int i = 1;i <= n;i++)
	{
		cin >> s >> t >> c;
		vec.pb(mp(s,-c));
		vec.pb(mp(t,c));
	}
	sort(vec.begin(),vec.end());
	for(auto it : vec)
	{
		m[abs(it.second)] -= it.second / abs(it.second);
		int x = 0;
		for(int i = 1;i <= C;i++) if(m[i]) x++;
		ans = max(ans,x);
	}
	rc(ans);
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int N;
    cin >> N;
    int a[2][N];
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            cin >> a[i][j];
        }
    }
    int imos[N],rimos[N];
    memset(imos,0,sizeof(imos));
    memset(rimos,0,sizeof(rimos));
    imos[0]=a[0][0];
    rimos[N-1]=a[1][N-1];
    for(int i=0;i<N-1;i++){
        imos[i+1]+=a[0][i+1]+imos[i];
        rimos[N-i-2]+=a[1][N-i-2]+rimos[N-i-1];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans=max(ans,imos[i]+rimos[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    int n;
	cin >> n;
	vector<string> w(n);
  	rep(i,n) {
      	cin >> w[i];
      	if(i != 0 && w[i-1].back() != w[i].front()){
        	puts("No");
          	return;
        }
    }
	sort(all(w));
  	rep(i,n-1){
    	if(w[i] == w[i+1]){
        	puts("No");
          	return;        
        }
    }
  
  	puts("Yes");
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    ll ans = 0;
    ll tmp = 0;
    for(int i = 0; i < n; ++i){
        cin >> h.at(i);
        if(i > 0){
            if(h.at(i - 1) >= h.at(i)){
                tmp++;
                ans = max(ans, tmp);
            }else{
                ans = max(ans, tmp);
                tmp = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024