akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define M 100000
#define N 2000000000

typedef struct{
  char x;
  int y;
}card;

card L[M/2+2];
card R[M/2+2];

void meg(card *A,int z,int l,int m,int r){
  int s1,s2,i,j,k;

  s1=m-l;
  s2=r-m;
  
  for(i=0;i<s1;i++){
    L[i]=A[l+i];
  }
  for(i=0;i<s2;i++){
    R[i]=A[m+i];
  }

  L[s1].y=R[s2].y=N;
  i=j=0;
  for(k=l;k<r;k++){
    if(L[i].y<=R[j].y){
      A[k]=L[i++];
    }
    else {
      A[k]=R[j++];
    }
  }
}

void meg_sort(card *A,int z,int left,int right){
  if(left+1<right){
    int m=(left+right)/2;
    meg_sort(A,z,left,m);
    meg_sort(A,z,m,right);
    meg(A,z,left,m,right);
  }
}

int partition_s(card *A,int g,int h){
  int i,z;
  card o,s;
  o=A[h];
  i=g-1;
  for(z=g;z<h;z++){
    if(A[z].y<=o.y){
      i++;
      s=A[i];
      A[i]=A[z];
      A[z]=s;
    }
  }
  s=A[i+1];
  A[i+1]=A[h];
  A[h]=s;
  return i+1;
}

void quick(card *A,int i,int g,int h){
  int s;
  if(g<h){
    s=partition_s(A,g,h);
    quick(A,i,g,s-1);
    quick(A,i,s+1,h);
  }
}

void stable(card *A,card *B, int a) {
  int i,count=0;
  for(i=0;i<a;i++) {
    if(A[i].x!=B[i].x) count++;
  }
  if(count==0) printf("Stable\n");
  else printf("Not stable\n");
}

    
int main(){
  int i,order,number;
  char pic[10];
  card A[M];
  card B[M];
  
  scanf("%d",&order);

  for(i=0;i<order;i++){
    scanf("%s %d",pic,&number);
      A[i].x=B[i].x=pic[0];
      A[i].y=B[i].y=number;
    }
  
    meg_sort(A,order,0,order);
    quick(B,order,0,order-1);

    stable(A,B,order);

    for(i=0;i<order;i++){
      printf("%c %d\n",B[i].x,B[i].y);
    }
  
  return 0;
}

    



Measured memory_bytes: 4092
from collections import deque
def bfs():
    visited=[-1]*n
    q=deque()
    start=1
    visited[start-1]=0
    q.append(start)
    while q:
        now=q.popleft()
        for next in graph[now-1]:
            if visited[next-1]==-1:
                q.append(next)
                visited[next-1]=now
    return visited[1:]

n, m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(m)]

graph = [[] for _ in range(n)]
for v in p:
    graph[v[0]-1].append(v[1])
    graph[v[1]-1].append(v[0])  # 有向グラフなら消す

#print(graph)  # [[2, 3, 5], ..., [1, 3, 4]]

ans=bfs()
if -1 in ans:
    print('No')
else:
    print('Yes')
    for i in ans:
        print(i)

Measured memory_bytes: 58428
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int B[200010];
inline void add(int A) {
	while (A <= 200010) {
		B[A]++;
		A += A & -A;
	}
}

inline int query(int A) {
	int kotae = 0;
	while (A > 0) {
		kotae += B[A];
		A -= A & -A;
	}
	return kotae;
}

void pakuripair_sort(int N, ll A[], int B[]) {
	const int b = 8;
	ll tmp[200001];
	int tmp2[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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

	int N = getint();
	int K = getint();

	ll A[200001];
	A[0] = (ll)N * K;
	rep1(i, N) {
		B[i] = i;
		A[i] = A[i - 1] + getint() - K;
	}
	pakuripair_sort(N + 1, A, B);
	rep(i, N + 1) A[B[i]] = i + 1;
	memset(B, 0, sizeof(B));
	ll kotae = 0;
	rep(i, N + 1) {
		kotae += query(A[i]);
		add(A[i]);
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))


int main(){
    
    string s; cin>>s;
    
    REP(i,s.size()){
        if(s[i]!=s[i%2])goto nextf;
    }
    
    cout<<"Second"<<endl;
    return 0;
    
nextf:;
    
    if(s[0]==s[s.size()-1]){
        if(s.size()%2==0){
            cout<<"First"<<endl;
        }else{
            cout<<"Second"<<endl;
        }
    }else{
        if(s.size()%2==0){
            cout<<"Second"<<endl;
        }else{
            cout<<"First"<<endl;
        }
    }
    
    return 0;
}





Measured memory_bytes: 512
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var y1 = int.Parse(line[0]);
        var m1 = int.Parse(line[1]);
        var d1 = int.Parse(line[2]);
        line = Console.ReadLine().Trim().Split(' ');
        var y2 = int.Parse(line[0]);
        var m2 = int.Parse(line[1]);
        var d2 = int.Parse(line[2]);
        var ans = getAge(y1, m1, d1, y2, m2, d2);
        Console.WriteLine(ans);
    }
    public static int getAge(int y1, int m1, int d1, int y2, int m2, int d2)
    {
        var ans = -1;
        var yyyy = 3004;
        var bd1 = new DateTime(y1, m1, d1);
        var bd2 = new DateTime(y2, m2, d2);
        var start = new DateTime(yyyy, 1, 1);
        for (int i = 0; i <= 365; i++)
        {
            var now = start.AddDays(i);
            var age1 = now.Year - bd1.Year;
            if (bd1 > now.AddYears(-age1)) age1--;
            var age2 = now.Year - bd2.Year;
            if (bd2 > now.AddYears(-age2)) age2--;
            ans = Max(ans, Abs(age1 - age2));
        }
        return ans;
    }
}



Measured memory_bytes: 17980
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
MOD =   998244353
DP = [[0 for p in range(S+1)]for x in range(N)]
ans = N * (A[0]==S)
if A[0]<=S:
    DP[0][A[0]] = 1
for n,a in enumerate(A):
    if n!=0:
        #もらう
        for p in range(a,S+1):
            DP[n][p] += DP[n-1][p-a]
        for p in range(S+1):
            DP[n][p] += DP[n-1][p]
            DP[n][p] %= MOD
        #初期化
        if a<=S:DP[n][a] += n+1
    ans += (DP[n][S]*(N-n))% MOD
    DP[n][S] = 0
    ans %= MOD
print(ans)

Measured memory_bytes: 119900
#include<stdio.h>

int main(){
  char X[2], Y[2];
  
  scanf("%s %s", X, Y);
  
  if(X[0] > Y[0]){
    printf(">\n");
  } else if(X[0] == Y[0]){
    printf("=\n");
  } else {
    printf("<\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
//		solveA(args);
//		solveB(args);
		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int N= nextInt();
		int X= nextInt();
		int T= nextInt();
		pw.println(((N+X-1)/X)*T);
	}
	public static void solveB(String[] args) throws Exception{
		String N = nextString();
		int sum =0;
		for(int i=0;i<N.length();i++) {
			sum+=N.charAt(i)-'0';
		}
		if(sum%9==00) {
			pw.println("Yes");
		}else {
			pw.println("No");
		}
	}
	public static void solveC(String[] args) throws Exception{
		int N = nextInt();
		long[] A = nextLongs();

		long ans = 0;
		for(int i=1;i<N;i++) {
			if(A[i-1]>A[i]) {
				ans+=A[i-1]-A[i];
				A[i]=A[i-1];
			}
		}

		pw.println(ans);
	}

	public static void solveD(String[] args) throws Exception{

	}


	public static void solveE(String[] args) throws Exception{

	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 55844
n = int(input())
r = 0
i = 2
while i * i <= n:
  j = k = 1
  while n % i == 0:
    n //= i
    j -= 1
    if j == 0:
      r += 1
      j = k = k + 1   
  i += 1
print(r + (n > 1))


Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << "\n";
    } else {
        cout << S.substr(0, K) << "...\n";
    }
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long int i,n,ans=1;
string s;
cin>>n>>s;

for(i=1;i<n;i++)
{

   if(s[i]!=s[i-1])
    ans++;

}
cout<<ans;
return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		sc.close();

		if((b-a)==(c-b)){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23892
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int) 90000000;
  // static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	
	 int n = sc.nextInt();
	 List<Integer> list = new ArrayList<>();
	 List<Integer> ans = new ArrayList<>();
	 list.add(0);
	 for(int i=0;i<n;++i) list.add(sc.nextInt());
	 boolean run = true;
	 while(list.size()>1 && run) {
		 run = false;
		 for(int i=list.size()-1;i>0;--i) {
			 if(list.get(i) == i) {
				 run = true;
				 list.remove(i);
				 ans.add(i);
				 break;
			 }
		 }
	 }
//	 out.print(list);
//	 out.print(ans);
	 if(list.size() == 1) {
	 Collections.reverse(ans);
	 for(int x : ans) out.println(x);
	 }else out.print(-1);
	 out.close();
		
	}

}

Measured memory_bytes: 21844
N, C, K, *T = map(int, open(0).read().split())
T.sort()

ans = 1
curm = T[0]
curc = 0
for t in T:
    curc += 1
    if t > curm+K or curc > C:
        ans += 1
        curm = t
        curc = 1
print(ans)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    char a; cin >> a;
    if((int)a>=(int)'a') cout<<"a"<<endl;
    else cout <<"A"<<endl;

}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int m, k;
  cin >> m >> k;
  int n = pow(2, m);
  if (k >= n) {
    cout << -1 << endl;
    return 0;
  }
  if (m == 1) {
    if (k == 0) {
      cout << "0 0 1 1" << endl;
    }
    else {
      cout << -1 << endl;
    }
    return 0;
  }
  vi a(2*n);
  rep (i, n) {
    a[i] = i;
  }
  rep1 (i, n - 1) {
    a[2*n - i] = i;
  }
  rep (i, 2*n) {
    a[i] ^= k;
  }
  rep (i, 2*n) {
    cout << a[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int p,q,r;
    cin >> p >> q >> r;
    cout << min(p+q, min(p+r, q+r)) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	string t;
	cin>>t;
	int sz=t.size();
	string s="";
	for(int i=0;i<sz;i++)
	{
		if(i>0 && t[i-1]=='P' && t[i]=='?')
		s+='D';
		else if(t[i]=='?')
		s+='D';
		else
		s+=t[i];
	}
	cout<<s<<endl;
}

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

using namespace std ;

string s, o ;
int len, f = 0 ;

void change()
{
    int y = 0 ;
    for(int i=0 ; i<len ; i++)
    {
        swap(o[y],o[len-1]) ;
        y++ ;
    }
}

int main()
{

    cin >> s >> o ;

    len = s.size() ;

    for(int i=0 ; i<len ; i++)
    {
        if(s==o)
        {
            f = 1 ;
            break ;
        }

        else
            change() ;

    }
    if(!f)cout << "No" << endl ;
    else cout << "Yes" << endl ;

}



Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005,MAXM=200005;
int n,m,q;
int cl[MAXN],co[MAXN];
struct edge
{
	int v,nxt;
	edge(){}
	edge(int vv,int nn)
	{
		v=vv,nxt=nn;
	}
}E[MAXM];
int w[MAXN],ncnt=0;
void addedge(int u,int v)
{
	E[++ncnt]=edge(v,w[u]);
	w[u]=ncnt;
	E[++ncnt]=edge(u,w[v]);
	w[v]=ncnt;
}
struct node
{
	int u,t,id;
	node(){}
	node(int uu,int tt,int ii)
	{
		u=uu,t=tt,id=ii;
	}
	bool operator<(const node &a)const
	{
		if(a.t==t)
			return a.id>id;
		return a.t>t;
	}
};
struct Que
{
	int v,d,c;
}que[MAXN];
priority_queue<node>Q;
int main()
{
	//freopen("splatter.in","r",stdin);
	//freopen("splatter.out","w",stdout);
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		addedge(u,v);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
	{
		int v,d,c;
		scanf("%d %d %d",&v,&d,&c);
		Q.push(node(v,d,i));
		co[i]=c;
	}
	while(!Q.empty())
	{
		node x=Q.top();
		Q.pop();
		if(cl[x.u]>=x.id)
			continue;
		cl[x.u]=x.id;
		if(x.t==0)
			continue;
		for(int i=w[x.u];i;i=E[i].nxt)
		{
			int v=E[i].v;
			if(cl[v]>=x.id)
				continue;
			Q.push(node(v,x.t-1,x.id));
		}
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",co[cl[i]]);
	}
	fclose(stdin);
	fclose(stdout);
}

Measured memory_bytes: 10736
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	int m; cin >> m;
	VE a(n); rep(i, n)cin >> a[i];
	priority_queue<int>prique;
	rep(i, n) {
		prique.push(a[i]);
	}
	rep(i, m) {
		int t = prique.top(); prique.pop();
		t /= 2; prique.push(t);
	}
	int ans = 0;
	rep(i, n) {
		ans += prique.top(); prique.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;

const double EPS = 1e-6;

int main() {
	int n;
	while(cin >> n, n) {
		double x[n], y[n];
		rep(i,n) {
			cin >> x[i] >> y[i];
		}
		int maxi = 1;
		rep(i, n) {
			for(int j=i+1; j<n; j++) {
				if( ((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])) > 4.0 ) continue;
				double mx = (x[i]+x[j]) / 2.0;
				double my = (y[i]+y[j]) / 2.0;
				double px0, py0, px1, py1;
				if( fabs(y[i]-y[j]) < EPS ) {
					px0 = px1 = mx;
					py0 = my + sqrt(1.0 - (x[i]-mx)*(x[i]-mx));
					py1 = my - sqrt(1.0 - (x[i]-mx)*(x[i]-mx));
				} else if( fabs(x[i]-x[j]) < EPS ) {
					py0 = py1 = my;
					px0 = mx + sqrt(1.0 - (y[i]-my)*(y[i]-my));
					px1 = mx - sqrt(1.0 - (y[i]-my)*(y[i]-my));
				} else {
					double m = - (x[i]-x[j]) / (y[i]-y[j]);
					double l = sqrt(1.0 - ((x[i]-mx)*(x[i]-mx)+(y[i]-my)*(y[i]-my)));
					px0 = mx + sqrt(l*l/(1.0+m*m));
					px1 = mx - sqrt(l*l/(1.0+m*m));
					py0 = my + m * (px0-mx);
					py1 = my + m * (px1-mx);
				}
				int cnt0 = 0, cnt1 = 0;
				rep(k, n) {
					double d0 = (px0-x[k])*(px0-x[k]) + (py0-y[k])*(py0-y[k]);
					if( d0 <= 1.0+EPS ) {
						cnt0++;
					}
				}
				rep(k, n) {
					double d1 = (px1-x[k])*(px1-x[k]) + (py1-y[k])*(py1-y[k]);
					if( d1 <= 1.0+EPS ) {
						cnt1++;
					}
				}
				maxi = max(maxi, cnt0);
				maxi = max(maxi, cnt1);
			}
		}
		cout << maxi << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<string>
using namespace std;
int main() {
	int stop;
	string A, B, C;

	cin >> A >> B >> C;
	if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<int,pair<int,pair<int,int>>> P;

ll longinf=1ll<<60;
int inf=1<<29;

int N,M;
pair<int,int> p[100002];
int main(){
    cin>>N>>M;
    rep0(i,M){
        cin>>p[i].first>>p[i].second;
    }
    sort(p,p+M);
    int ans=1;
    int a=p[0].first;
    int b=p[0].second;
    cout<<endl;
    rep1(i,M-1){
        if(b>p[i].second) b=p[i].second;
        if(p[i].first>=b){
            ans++;
            b=p[i].second;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];


int main(){
	IOS;
	IOS;
	int n, k;
	cin >> n >> k;
	vec<ll> a(n);
	REP(i,n){
		cin >> a[i];
	}
	vec<ll> s;
	for(int i = 0;i < n;i++){
		ll sum = a[i];
		s.push_back(sum);
		for(int j = i + 1;j < n;j++){
			sum += a[j];
			s.push_back(sum);
		}
	}
	ll m = s.size();
	ll ans = 0;
	for(ll i = 40;i >= 0;i--){
		ll x = ans + (1ll << i);
		ll cnt = 0;
		for(int j = 0;j < m;j++){
			if((s[j] & x) == x)cnt++;
		}
		if(cnt >= k)ans = x;
	}	
	dump(ans);
}

Measured memory_bytes: 6128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod =  998244353;





void solve(){
    
    ll num;
    cin >> num;
    
    string result = "";
    while (num > 0) {
      num--; // 1 => a, not 0 => a
      int remainder = num % 26;
      char digit = (char) (remainder + 97);
      result = digit + result;
      num = (num - remainder) / 26;
    }

    cout << result;
    
}



int main(){
    solve();
}




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

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }

    sort(h.begin(), h.end(), greater<ll>());
    rep(i, k)
    {
        if (i == n)
        {
            break;
        }
        h[i] = 0;
    }
    ll ans = 0;
    rep(i, n)
    {
        ans += h[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  int cnt = lower_bound(A.begin(), A.end(), 0) - A.begin();  // 負整数の個数
  if (cnt % 2 == 0) {
    for (int i = 0; i < cnt; i++) A.at(i) *= -1;
  }
  else {
    if (cnt == N) {
      for (int i = 0; i < N-1; i++) A.at(i) *= -1;
    }
    else {
      if (abs(A.at(cnt-1)) < abs(A.at(cnt))) {
        for (int i = 0; i < cnt-1; i++) A.at(i) *= -1;
      }
      else {
        for (int i = 0; i <= cnt; i++) A.at(i) *= -1;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) ans += A.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for (int i=1;i<=b;i++)
	{
		if (a*i%b==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

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

int main() {
  int INF = 1000000000;
  int H, N; cin >> H >> N;
  vector<int> A(N), B(N);
  int mB = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    mB = max(mB, B[i]);
  }
  int M = H+mB;
  vector<int> dp1(M, INF), dp2(M);
  dp1[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (A[i] <= j) {
        dp2[j] = min(dp1[j], dp2[j-A[i]]+B[i]);
      } else {
        dp2[j] = dp1[j];
      }
    }
    dp1 = dp2;
  }
  int ans = INF;
  for (int i = H; i < M; i++) {
    ans = min(ans, dp1[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
N,K = map(int,input().split())
import math

A = K

ans = 0

i = 0
last = K
while True:
    i += 1
    A = K/pow(2,i)
    num = last - math.ceil(A)
    if math.ceil(A) <= N:
        if last-1 >= N:
            num = N - math.ceil(A) + 1
        ans += (num / N) / pow(2,i)
    
    last = math.ceil(A)
    if A <= 1:
        break
    
    
if N >= K:
    ans += (N - K + 1) / N
    
print('{:.14g}'.format(ans))


Measured memory_bytes: 38256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#include<cstring>
using namespace std;

int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s,t;
    cin>>s>>t;

    int n=s.size();
    int m=t.size();
    int i;
    int count=0;
    for(i=0;i<n;i++)
    {
    	
       if(s[i]==t[i])
       {
       	
       	count++;
       	
	   }
    	
    	
    	
	}
	
	
	
	if(count==n&&m>n)
	{
		
		
		cout<<"Yes"<<endl;
		
	}
	
	
	else 
	{
		
		cout<<"No"<<endl;
		
	}
    
  
    
    return 0;
    
}

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

using namespace std;

vector<vector<int>> opt;

void gen(int x, vector<int> curr) {
  curr.push_back(x);
  if (curr.size() == 10) {
    opt.push_back(curr);
    return;
  }
  gen(0, curr);
  gen(1, curr);
}


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

  int n;
  cin >> n;
  vector<vector<int>> P(n, vector<int>(11));
  vector<vector<int>> F(n, vector<int>(10));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> F[i][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> P[i][j];
    }
  }

  gen(0, vector<int>());
  gen(1, vector<int>());

  long long res = -1e18;
  for (auto &o : opt) {
    int sum = 0;
    for (auto &oo: o) sum += oo;
    if (sum == 0) continue;
    sum = 0;
    vector<int> c(n,0);
    for (int i = 0; i < n; ++i) {
      for (int p = 0; p < 10; ++p) {
        if (o[p] == 1 && F[i][p] == 1) c[i]++;
      }
      sum += P[i][c[i]];
    }
    if (sum > res) res = sum;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
//__int128
const int maxn = 5e5;
char s[maxn];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n;
	scanf("%d%s", &n, s);
	int x = 0, y = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] == '.'){
			y++;
		}
	}
	int res = y;
	for(int i = 0; i < n; ++i){
		if(s[i] == '#'){
			x++;
		} else {
			y--;
		}
		res = min(res, x + y);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int f[1000005];
int find(int x){
	return f[x]==x?x:f[x]=find(f[x]);
}
void join(int x,int y){
	int fx=find(x);
	int fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int main(){
	int n,q,t,l,r;
	cin>>n>>q;
	for(int i=0;i<=n;i++)f[i]=i;
	while(q--){
		cin>>t>>l>>r;
		if(t)cout<<(find(l)==find(r))<<"\n";
		else join(l,r);
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<long long> leaves(n+1);
  long long sum_leaf = 0;
  for(int i=0; i<=n; i++){
    cin >> leaves[i];
    sum_leaf += leaves[i];
  }
  
  long long sum_node = 1;
  if(n == 0 && leaves[0] == 1){
    cout << 1 << endl;
    return 0;
  }
  if(leaves[0] != 0){
    cout << -1 << endl;
    return 0;
  }
  
  long long root = 1;
  
  for(int i=1; i<=n; i++){
    int leaf = leaves[i];
    sum_leaf -= leaf;
    
    long long max_root = min ( root * 2 - leaf, sum_leaf );
    
    long long node = max_root+leaf;
    
    if(max_root < 0 || node>root*2){
      sum_node = -1;
      break;
    }
    
    root = max_root;
    sum_node += node;
  }
  
  cout << sum_node << endl;
  
  

}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;

int main(void)
{
    int K, N;
    cin >> K >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    int longest = 0;
    for (int i = 0; i < N; i++)
    {
        longest = max(longest, A[i + 1] - A[i]);
    }
    longest = max(longest, K + A[0] - A[N - 1]);
    cout << K - longest << endl;
    return (0);
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n;
    cin>>n;
    int t[n];
    int i, j;
    int ans = 0;
    REP(i, n){
        cin>>t[i];
        ans += t[i];
    }

    int m;
    cin>>m;
    int p[m], x[m];

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

    for(i=0; i<m; i++){
        cout<<ans-t[p[i]-1]+x[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'
#define INF (1ll<<60)

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int MOD = 1e9 + 7;

string s, t;

signed main()
{
	cin >> s >> t;
	if (s.substr(0, s.size()) == t.substr(0, t.size()-1)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    int N;
    map<LL,int> ps;
    int M;
    cin>>N;
    REP(i,N){
        LL p;
        cin>>p;
        ps[p]++;
    }
    cin>>M;
    REP(i,M){
        LL T;
        cin>>T;
        ps[T]--;
        if(ps[T]<0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
     return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
int main(){
  int i,j,k;
  int d;	//365
  int c[26];
  int score[9490];
  int t[365] = {0};
  int day1[26] = {0};
  double x = 0.36787944117;
  int tmp1=-99999,tmp2=-99999;
  int z = 99999;
  int zz = 0;
  
  scanf("%d",&d);
  for(i=0;i<26;i++){
      scanf("%d ",&c[i]);
  }
  for(i=0;i<d*26;i++){
      scanf("%d ",&score[i]);
  }

  for(i=0;i<26;i++){
   if(c[i]<z){
     z=c[i];
    zz=i; 
   }
  }
  
  
  for(i=0;i<d;i++){
      printf("%d\n",zz+1);
  }
 return 0; 
}




Measured memory_bytes: 2192
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

struct Edge {
    int to, id;
};

vector<vector<Edge>> G;
vector<int> ans;

void dfs(int v, int color = -1, int p = -1) {

    int num = 1;
    rep(i, G[v].size()) {

        int u = G[v][i].to;
        int ei = G[v][i].id;

        if(u == p) {
            continue;
        }

        if(num == color) {
            num++;
        }

        ans[ei] = num;
        num++;

        dfs(u, ans[ei], v);
    }

}

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

    G.resize(n);
    ans.resize(n-1);

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back((Edge){b,i});
        G[b].push_back((Edge){a,i});
    } 

    dfs(0);

    int K = 0;
    rep(i, n) {
        K = max(K, (int)G[i].size());
    }

    cout << K << "\n";

    rep(i, n-1) {
        cout << ans[i] << "\n";
    }

    return 0;
}

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

int findSumOfDigits(int n){
    int sum = 0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int total = 0;
    for(int i=0;i<=N;i++){
        int sum =findSumOfDigits(i); 
        if(A<=sum&&sum<=B) {
            total+=i;
//            printf("%d\n",i);
//            printf("%d\n",findSumOfDigits(i));
        }
    }
    cout<<total<<endl;
}

Measured memory_bytes: 256
x = int(input())
def createC(x, z):
  tmp = []
  for y in range(x):
    p = pow(y+1, z)
    if p <= x:
      tmp.append(p)
    else:
      return tmp

z = 2
max_c = 1
while True:
  if x == 1:
    break
  c_tmp = createC(x, z)
  if len(c_tmp) != 1:
    s = sorted(c_tmp)
    if max_c < s[-1]:
      max_c = s[-1]
    z += 1
  else:
    break
print(max_c)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>
#include<climits>
#include<queue>
#include<random>

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

using namespace std;

int n;
int cnt;
int ccnt;

int main(int argc, char const *argv[]) {
    cin >> n;
    for(int j=1;j<=n;j++){
        cnt=0;
        if(j%2!=0){
            for(int i = 1;i <= j;i++){
                if(j%i==0){
                    cnt++;
                }
            }
        }
        if(cnt == 8){
            //cout << j << endl;
            ccnt++;
        }
    }
    cout << ccnt << endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
N,M=map(int,input().split())
path=[[] for _ in range(N)]
for _ in range(M):
  l,r,c=map(int,input().split())
  path[l-1].append([r,c])
for i in range(1,N):
  path[i].append([i,0])

dist=[float("inf")]*N
dist[0]=0
q=[[dist[i],i] for i in range(N)]
heapq.heapify(q)

while q:
  d,ind=heapq.heappop(q)
  if d<=dist[ind]:
    for i in range(len(path[ind])):
      r,c=path[ind][i]
      if dist[r-1]>d+c:
        dist[r-1]=d+c
        heapq.heappush(q,[dist[r-1],r-1])

if dist[N-1]==float("inf"):
  print(-1)
else:
  print(dist[N-1])

Measured memory_bytes: 65160
#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

int main(){
	int N,M; cin>>N>>M;
	vector<int>L(M),R(M);
	for(int i=0;i<M;i++){
		cin>>L[i]>>R[i];
	}
	sort(L.begin(),L.end());
	sort(R.begin(),R.end());
	int ans=R[0]-L[M-1]+1;
	if(ans<0){
		cout<<0<<endl;
	}
	else{
		cout<<ans<<endl;
	}
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
string S;
const int mod=1000000007;
int dp[5010][5010];

int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}


signed main(){
    cin>>N>>S;

    dp[0][0]=1;
    rep(i,N){
        for(int j=0;j<=i;j++){
            dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*2)%mod;
            if(j){
                dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j])%mod;
            }
            else{
                dp[i+1][0]=(dp[i+1][0]+dp[i][0])%mod;
            }
        }
    }

    cout<<dp[N][S.size()]*mpow(mpow(2,S.size()),mod-2)%mod<<endl;
    return 0;
}


Measured memory_bytes: 116992
package main

import (
	"fmt"
)

func main() {
	var A, B, C, X int

	fmt.Scan(&A, &B, &C, &X)
	ans := 0

	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				if (X == (500 * a + 100 * b + 50 * c)) {				
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
from fractions import gcd

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

MOD = 10**9 + 7

MAXN = N + 1
fact = [1] * MAXN
for i in range(1, MAXN): fact[i] = (fact[i-1] * i) % MOD
invfact = [0] * MAXN; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(MAXN-2, -1, -1): invfact[i] = invfact[i+1] * (i+1) % MOD
def comb(n, k):
  return fact[n] * invfact[n-k] * invfact[k] % MOD if 0 <= k <= n else 0
def inv(n):
  return pow(n, MOD-2, MOD)

ss = [0] * (N+1)
ss[0] = 0
for i in range(1, N+1):
  ss[i] = ss[i-1] + fact[N] * inv(i) % MOD

ans = 0
for i in range(N):
  ans = (ans +  A[i] * (ss[i+1] + ss[N-i] - ss[1])) % MOD
print(ans)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

i32 n,m, u,v, s,t;
vii graph;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    // input
    cin >> n >> m;
    graph.resize(n*3);
    /**
     * けんちょんさんありがとー
     * "mod3をどう使うか"だが、これは、頂点vをv0 v1 v2に分けると良い!!!
     * u0->v1
     * u1->v2
     * u2->v0
     * という有向辺が張られていると考えればよく、
     * この拡張されたグラフで
     * s0->...->t0の最短経路を調べればよくなる
     * すげぇ
     *
     */
    rep(i,m) {
        cin >> u >> v;
        --u, --v;
        u*=3, v*=3;  // 拡張！
        graph[u].push_back(v+1);
        graph[u+1].push_back(v+2);
        graph[u+2].push_back(v);
    }
    cin >> s >> t;
    --s, --t;
    s*=3, t*=3;  // 拡張！

    // solve
    queue<i32> que;
    vi dist(n*3, -1);
    dist[s] = 0;
    que.push(s);
    while (que.size()) {
        i32 v = que.front(); que.pop();
        for(auto nv : graph[v]) {
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }

    if(dist[t] == -1) cout << -1 << '\n';
    else cout << dist[t]/3 << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 19072