akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b;
    scan(a, b);
    foreach (i; iota(MAX).map!(x => x + 1))
    {
        if (cast(long)(i * 0.08) == a && cast(long)(i * 0.10) == b)
        {
            i.writeln();
            return;
        }
    }
    writeln(-1);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2728
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

typedef long long ll;
#define INF 1LL << 60
ll H, W;

ll f(ll a, ll b, ll c) {
    ll ma = max(a, max(b, c));
    ll mi = min(a, min(b, c));
    return ma - mi;
}
ll solA() {
    ll res = INF;
    if (2 < H) {
        ll h = H / 3;
        if (H % 3 == 0) return 0;
        res = min(res, W);
    }
    if (2 < W) {
        ll w = W / 3;
        if (W % 3 == 0) return 0;
        res = min(res, H);
    }
    return res;
}
ll solB() {
    ll res = INF;
    rep(x, 1, W) {
        ll xx = x;
        ll b = H / 2;
        res = min(res, f(xx * b, xx * (H - b), (W - xx) * H));
    }

    rep(y, 1, H) {
        ll yy = y;
        ll b = W / 2;
        res = min(res, f(yy * b, yy * (W - b), (H - yy) * W));
    }
    return res;
}
int main() {
    cin >> H >> W;
    ll ans = min(solA(), solB());
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<string> split(string S, char symbol) {
	vector<string> vs;
	stringstream ss{S};
	string buf;
	while (getline(ss, buf, symbol)) {
		vs.push_back(buf);
	}
	return vs;
}

int main() {
	string S;
	cin >> S;

	int N = S.size();
	vector<int> A(N, 0);
	rep(i, N) A[i] = S[i] - '0';

	N--;
	ll ans = 0;
	rep(i, (1<<N)) {
		string tmp;
		rep(j, N) {
			tmp += S[j];
			if (i & (1<<j)) {
				tmp += '+';
			}
		}
		tmp += S.back();
		// cout << tmp << endl;
		vector<string> vs = split(tmp, '+');
		vector<ll> vll;
		for(string v: vs) {
			vll.push_back(stol(v));
		}
		ans += accumulate(ALL(vll), 0LL);
	}
	
	cout << ans << endl;
}

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


int main() {
    int N;
    cin >> N;
    int A[2][N];
    for (int i=0;i<=1;i++){
        for (int j=0;j<N;j++){
            cin >>A[i][j];
        }
    }
    int T[2][N];
    for (int i=0;i<=1;i++){
        for (int j=0;j<N;j++){
            if (j==0) T[i][j]=A[i][j];
            else T[i][j]=T[i][j-1]+A[i][j];
        }
    }
    int m=0, d;
    for (int i=0;i<N;i++){
        if (i==0) {
            d=T[0][0]+T[1][N-1];
            m=max(m,d);
        }
        else {
            d=T[0][i]+T[1][N-1]-T[1][i-1];
            m=max(m,d);
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N,R;
    cin>>N>>R;
    if(N>=10){
        cout<<R<<endl;
    }else{
        cout<<R+100*(10-N)<<endl;
    }
}

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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }

        static long Solve(int N, long M, long[] A)
        {
            var B = A.Select(a => a / 2).ToArray();
            long lcm = B[0];
            for (int i = 1; i < N; ++i)
            {
                lcm = Lcm(lcm, B[i]);
                if (lcm > M) { return 0; }
            }
            if (B.Any(b => (lcm / b) % 2 == 0)) { return 0; }
            return (M / lcm + 1) / 2;
        }

        static void Main(string[] args)
        {
            var V = ReadLongs();
            var A = ReadLongs();
            Console.WriteLine(Solve((int)V[0], V[1], A));
        }
    }
}


Measured memory_bytes: 29784
k = gets.to_i
q = [1,2,3,4,5,6,7,8,9]

while k > 0
  s = q.shift
  q.push(s*10+s%10-1) if s%10 != 0
  q.push(s*10+s%10)
  q.push(s*10+s%10+1) if s%10 != 9
  k -= 1
end

puts s

Measured memory_bytes: 3964
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> A(1,0);
	vector<ll> B(1,0);

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		A.emplace_back(k);
	}
	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		B.emplace_back(k);
	}
	ll time = 0;
	ll A_num = 0;
	ll B_num = 0;
	ll max = 0;
	for (int i = 1; i <= n; i++) {
		if (time + A[i] > k) break;
		else {
			time += A[i];
			A_num++;
		}
	}
	for (int i = 1; i <= m; i++) {
		if (time + B[i] > k) break;
		else {
			time += B[i];
			B_num++;
		}
	}
	
	max = A_num + B_num;
	while (B_num < m&&A_num > 0) {
		time -= A[A_num];
		A_num--;
		
		while (time+B[B_num+1]<=k&&B_num<m) {
			B_num++;
			time += B[B_num];
		}
		if (max < A_num + B_num) max = A_num + B_num;
		
	}

	cout << max;
	return 0;
	
}


Measured memory_bytes: 7928
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;

signed main(){
    int n,t;
    cin >> n >> t;
    vector<string> s;
    rep(i,n){
        string a;
        cin >> a;
        s.pb(a);
    }
    SORT(s);
    rep(i,n)cout << s[i];
    cout << endl;
    
    
    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://arc060.contest.atcoder.jp/tasks/arc060_a

Measured memory_bytes: 768
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b = readInts()
print(a*b if (1 <= a <= 9 and 1 <= b <= 9) else '-1')


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

const int ma=1000000000;

int main(){
  int n,m,i;
  cin >> n >> m;
  vector<int> a(m),b(m);
  vector<pair<int,int>> ab(m);
  for(i=0;i<m;++i){
    cin >> a[i] >> b[i];
    ab[i]=make_pair(b[i],a[i]);
  }
  sort(ab.begin(),ab.end());
  int ans=0;
  int cal=-ma;
  for(i=0;i<m;++i){
    if(cal<=ab[i].second){
      ans++;
      cal=ab[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using lint = long long int;
typedef long long ll;
typedef pair<int, int> P;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define rep(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int r, c, sy, sx, gy, gx;
char ch[55][55];
int ans[55][55], flag[55][55];
int ans2[55][55], flag2[55][55];

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
queue<P> que;

// 幅優先探索
int main()
{
    cin >> r >> c;
    rep(i, r)
    {
        rep(j, c)
        {
            cin >> ch[i][j];
            if(ch[i][j]=='.'){
                sy = i+1;
                sx = j+1;
            }
        }
    }
    int maxans = 0;
    rep(i, r)
    {
        rep(j, c)
        {
            if (ch[i][j] == '.')
            {
                sy = i + 1;
                sx = j + 1;

                rep(i, r)
                {
                    rep(j, c)
                    {
                        flag[i][j] = 0;
                        ans[i][j] = 0;
                    }
                }

                flag[sy - 1][sx - 1] = 1;
                que.push(P(sy - 1, sx - 1));
                while (!que.empty())
                {
                    P p = que.front();
                    que.pop();
                    rep(i, 4)
                    {
                        int x = p.second + dx[i];
                        int y = p.first + dy[i];
                        if (0 <= x && x <= c && 0 <= y && y <= r && !flag[y][x] && ch[y][x] == '.')
                        {
                            flag[y][x] = 1;
                            ans[y][x] = ans[p.first][p.second] + 1;
                            que.push(P(y, x));
                        }
                    }
                }
                int maxi, maxj;
                rep(i, r)
                {
                    rep(j, c)
                    {
                        //cout << ans[i][j] << "";
                        if (ans[i][j] > maxans)
                        {
                            maxans = ans[i][j];
                            maxi = i;
                            maxj = j;
                        }
                    }
                    //cout << "\n";
                }
                //cout << maxans<<" "<<maxi<<maxj << "\n";
            }
        }
    }
    

    cout <<maxans<< "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
ll dp[100001][10];
inline bool chk(int x){
	return 0<=x&&x<10;
}
void sol(int i, int j, int K){
	printf("%d",j);
	if(i==1) return;
	for(int l=-1;l<=1;l++){
		if(chk(j+l)){
			if(K<=dp[i-1][j+l]) return sol(i-1,j+l,K);
			else K-=dp[i-1][j+l];
		}
	}
}
int main(){
	int K;scanf("%d",&K);
	for(int i=0;i<10;i++){
		dp[1][i]=1;
		if(i==0) continue;
		if(K<=dp[1][i]){
			sol(1,i,K);
			return 0;
		}
		else K-=dp[1][i];
	}
	
	for(int i=2;i<=100;i++){
		for(int j=0;j<10;j++){
			for(int l=-1;l<=1;l++){
				if(chk(j+l)) dp[i][j] += dp[i-1][j+l];
			}
			if(j==0) continue;
			if(K<=dp[i][j]){
				sol(i,j,K);
				return 0;
			}
			else K-=dp[i][j];
		}
	}
}

Measured memory_bytes: 128
from functools import reduce
from math import gcd
from random import randint


def brent(N):
    if N % 2 == 0:
        return 2
    y, c, m = randint(1, N-1), randint(1, N-1), randint(1, N-1)
    g, r, q = 1, 1, 1
    while g == 1:
        x = y
        for i in range(r):
            y = ((y*y) % N+c) % N
        k = 0
        while (k < r and g == 1):
            ys = y
            for i in range(min(m, r-k)):
                y = ((y*y) % N+c) % N
                q = q*(abs(x-y)) % N
            g = gcd(q, N)
            k = k + m
        r = r*2
    if g == N:
        while True:
            ys = ((ys*ys) % N+c) % N
            g = gcd(abs(x-ys), N)
            if g > 1:
                break
    return g


def factorize(n1):
    if n1 == 0:
        return []
    if n1 == 1:
        return [1]
    n = n1
    b = []
    p = 0
    mx = 1000000
    while n % 2 == 0:
        b.append(2)
        n //= 2
    while n % 3 == 0:
        b.append(3)
        n //= 3
    i = 5
    inc = 2
    while i <= mx:
        while n % i == 0:
            b.append(i)
            n //= i
        i += inc
        inc = 6-inc
    while n > mx:
        p1 = n
        while p1 != p:
            p = p1
            p1 = brent(p)
        b.append(p1)
        n //= p1
    if n != 1:
        b.append(n)
    return sorted(b)


n = int(input())
if n == 1:
    print(0)
    quit()
li = factorize(n)


def sums(factors):
    dicc = {}
    for factor in set(factors):
        n = factors.count(factor)
        dicc[factor] = [1]
        n -= 1
        while n > dicc[factor][-1]:
            dicc[factor].append(dicc[factor][-1] + 1)
            n -= dicc[factor][-1]
    return dicc


# print(li)
# print(sums(li))
count = 0
for i in sums(li).values():
    count += len(i)
print(count)


Measured memory_bytes: 78040
N, W = map(int, input().split())

V0 = []
V1 = []
V2 = []
V3 = []

for i in range(N):
    w, v = map(int, input().split())
    if i == 0:
        w1 = w
        V0.append(v)
    else:
        if w == w1:
            V0.append(v)
        elif w == w1+1:
            V1.append(v)
        elif w == w1+2:
            V2.append(v)
        else:
            V3.append(v)

V0.sort(reverse=True)
V1.sort(reverse=True)
V2.sort(reverse=True)
V3.sort(reverse=True)

from itertools import accumulate
CV0 = [0] + V0
CV0 = list(accumulate(CV0))
CV1 = [0] + V1
CV1 = list(accumulate(CV1))
CV2 = [0] + V2
CV2 = list(accumulate(CV2))
CV3 = [0] + V3
CV3 = list(accumulate(CV3))

ans = -float('inf')
for a in range(len(V0)+1):
    for b in range(len(V1)+1):
        for c in range(len(V2)+1):
            for d in range(len(V3)+1):
                if w1*a + (w1+1)*b + (w1+2)*c + (w1+3)*d <= W:
                    sum_v = CV0[a]+CV1[b]+CV2[c]+CV3[d]
                    ans = max(ans, sum_v)

print(ans)

Measured memory_bytes: 42604
#include<stdio.h>
int main()
{
    int i=0,j,t,n;
    scanf("%d",&n);
    int s[n],b[n];
    for(i=0;i<n;i++)
       scanf("%d",&b[i]);

    t=n-1;
    j=n-1;
    for(i=0;i<=n/2&&j>=0;i++)
    {
        s[i]=b[j--];
        if(j<0)break;
        s[t-i]=b[j--];
    }

    i=0;
    while(i<n)
        printf("%d ",s[i++]);
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow ---question galat mat padhna yr*/
{
    fast;
    ll n;
    cin>>n;
    ll a[n+1];
    cin>>a[0];
    // multiset<ll> x;
    map<ll,ll>x;
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
        cin>>a[i];
        x[(a[i-1]+i-1)]++;
        ans+=x[((i-a[i]))];
    }
    cout<<ans<<endl;
    // time;
}   

Measured memory_bytes: 27812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
    return 0;
}

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

const int INF = 1001001001;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> mp;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        ans += A[i];
        mp[A[i]]++;
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int B, C;
        cin >> B >> C;
        auto t = mp.find(B);
        if (t != mp.end()) {
            ll tmp = t->second;
            ans -= tmp * (ll)B;
            mp.erase(t);
            mp[C] += tmp;
            ans += C * tmp;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 6560
#include <stdio.h>
#include <string.h>
#include <string.h>
char a[100005];
int b[100005] = { 0 };
int main()
{
	int len, count = 0, max = 0, i, j, flag,x,y;
	char b = 0;
	scanf("%s", a);
	len = strlen(a);
	for (i = 0; i < len; i++)
	{
		if (a[i] == 'R' && a[i + 1] == 'L')
		{
			j = i - 1;
			flag = 1;
			x = y = 1;
			while (j >= 0 && a[j] == 'R')
			{
				if (flag == 1)
					y++;
				else x++;
				flag = 1 - flag;
				j--;
			}
			flag = 1;
			j = i + 2;
			while (j < len && a[j] == 'L')
			{
				if (flag == 1)
					x++;
				else y++;
				flag = 1 - flag;
				j++;
			}
			printf("%d %d ", x, y);
			i++;
		}
		else printf("0 ");
	}
}

Measured memory_bytes: 3284
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll x,a=0;
	cin >> x;
	ll ans = 100,count=0;
	while (1)
	{
		if (ans >= x)
			break;
		ans += (ans / 100);
		count += 1;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3704
import sys

n = int(input())

c = input()

count = 0
check = 0
wList = []
rList = []

for i in range(n):
    if c[i] == "W":
        wList.append(i)
    else:
        rList.append(i)

if len(wList) == 0 or len(rList) == 0:
    print(0)
    sys.exit()

rMax = rList[-1]
wMin = wList[0]

for i in range(len(rList)):
    if rList[-1] < wList[0]:
        break
    else:
        count += 1
        del rList[-1]
        del wList[0]

print(count)


Measured memory_bytes: 17292
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    
    freopen("output.txt", "w", stdout);
    #endif

    ll n,i;
    cin>>n;
    
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        ans+=(n/i);
        if(n%i==0){
            ans--;
        }
    }
    cout<<ans<<endl;
}

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

//素集合データ構造
// ref:https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
struct union_find {
    // parent[v]==w(>=0):vの親はw
    // parent[v]==k(<0):vは根&&vの属するグループの要素数は-k
    vector<long long int> parent;
    //コンストラクタ
    union_find(long long int n) {
        parent.assign(n, -1);
    }
    // vの根を求める
    //求めると同時に親を根に置き換える(木の圧縮)
    long long int root(long long int v) {
        if (parent[v] < 0) {
            return v;
        } else {
            parent[v] = root(parent[v]);
            return parent[v];
        }
    }
    // vが属するグループの要素数を求める
    long long int size(long long int v) {
        return -parent[root(v)];
    }
    // vとwを繋げる
    void unite(long long int v, long long int w) {
        v = root(v);
        w = root(w);
        if (v == w) return;
        if (parent[v] < parent[w]) swap(v, w);
        parent[w] += parent[v];
        parent[v] = w;
    }
    // vとwが同値か判定
    bool isSame(long long int v, long long int w) {
        return root(v) == root(w);
    }
};

int main() {
    long long int n, m;
    cin >> n >> m;
    vector<pair<int, int>> bridge(m);
    for (int i = 0; i < m; i++) {
        cin >> bridge[i].first >> bridge[i].second;
        bridge[i].first--;
        bridge[i].second--;
    }
    // unconv[i]:i番目の橋が壊れた時の不便さ
    vector<long long int> unconv(m);
    unconv[m - 1] = n * (n - 1) / 2;
    union_find uf(n);
    // i:くっつける橋
    for (int i = m - 1; i > 0; i--) {
        int x = bridge[i].first, y = bridge[i].second;
        if (!uf.isSame(x, y)) {
            unconv[i - 1] = unconv[i] - uf.size(x) * uf.size(y);
            uf.unite(x, y);
        } else {
            unconv[i - 1] = unconv[i];
        }
    }
    for (int i = 0; i < m; i++) {
        cout << unconv[i] << endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
    int n, l;
    cin >> n >> l;
    int mn = 300;
    int sum = 0;
    rep (i, n) {
        sum += l + i;
        if (abs(l + i) < abs(mn)) {
            mn = l + i;
        }
    }
    cout << sum - mn << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define per(i,a,b) for(ll i=(a)-1; i>=(b); i--)
const ll maxn=1e5+5;
ll x,y,a,b,c,v,t;
tuple<ll, ll> f[maxn*3];
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>x>>y>>a>>b>>c;
    rep(i,0,a) cin>>v, f[i]=make_tuple(v,1);
    rep(i,a,a+b) cin>>v, f[i]=make_tuple(v,2);
    rep(i,a+b,a+b+c) cin>>v, f[i]=make_tuple(v,3);
    sort(f, f+a+b+c); reverse(f,f+a+b+c);
    ll ans=0, cntx=0, cnty=0, cnt=0;
    rep(i,0,a+b+c) {
        tie(v,t) = f[i];
        if(t==1 && cntx<x) cntx++, ans+=v; 
        if(t==2 && cnty<y) cnty++, ans+=v; 
        if(t==3) cnt++, ans+=v;
        if(cnt+cntx+cnty==x+y) break;
    }
    cout<<ans<<"\n";
}

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

int main(){
    int a[3];
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(a,a+3);
    int n;
    n=a[0]+a[1];
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  ll n;
  cin >> n;
  n--;

  string ans = "";
  while(1){
    ll cnt = n % 26;
    ans = char('a' + cnt) + ans;
    n /= 26;
    n--;
    if(n == -1) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x[10] = {};
    x[a]++; x[b]++; x[c]++; x[d]++;

    if(x[1] == 1 && x[4] == 1 && x[7] == 1 && x[9] == 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
double X[50],Y[50],Z[50];
double R[50];
long L[50];
int n,q;
double sx,sy,sz,dx,dy,dz;
main()
{
	cin>>n>>q;
	for(int i=0;i<n;i++)cin>>X[i]>>Y[i]>>Z[i]>>R[i]>>L[i];
	for(;q--;)
	{
		cin>>sx>>sy>>sz>>dx>>dy>>dz;
		double x=dx-sx,y=dy-sy,z=dz-sz;
		long ans=0;
		for(int i=0;i<n;i++)
		{
			double t=(X[i]-sx)*x+(Y[i]-sy)*y+(Z[i]-sz)*z;
			t=t/(x*x+y*y+z*z);
			if(t<0)t=0;
			else if(t>1)t=1;
			double xx=sx+x*t,yy=sy+y*t,zz=sz+z*t;
			double dis=hypot(hypot(X[i]-xx,Y[i]-yy),Z[i]-zz);
			if(dis<R[i]+1e-9)ans+=L[i];
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
int a[MAXN],n,cnt,b[MAXN];
bool flag=false,visit[MAXN]={false};
int read(){
    int f=1,x=0;
    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 f*x;
}
void dfs(int x,int sum){
    //cout<<x<<" "<<sum<<endl;
    if(visit[x]==true) return;
    if(sum==3){
        //cout<<x<<endl;
        flag=true;
        return;
    }
    visit[x]=true;
    
    for(int i=1;i<=3;i++){
        if(a[i]==x&&visit[b[i]]==false){
            dfs(b[i],sum+1);
            //visit[b[i]]=false;
        }
        if(b[i]==x&&visit[a[i]]==false){//visit[a[i]]=true;
            dfs(a[i],sum+1);
            //visit[a[i]]=false;
        }
    }
    visit[x]=false; 
}
int main(){
    for(int i=1;i<=3;i++) cin>>a[i]>>b[i];
    dfs(1,0);
    dfs(2,0);
    dfs(3,0);
    dfs(4,0);
    if(flag==true) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;   
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if (k%2==0) {
    printf("%d\n",a-b);
  } else {
    printf("%d\n",b-a);
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int array[]=new int[N];
    int count=0;
    for(int i=0;i<N;i++) array[i]=sc.nextInt();
    for(int i=0;i<N;i++){
      int minj=i;
      for(int j=i;j<N;j++){
        if(array[j]<array[minj]) minj=j;
      }
      if(i!=minj){
        int c=array[i];
        array[i]=array[minj];
        array[minj]=c;
        count+=1;
      }
    }
    for(int i=0;i<N-1;i++) System.out.print(array[i]+" ");
    System.out.println(array[N-1]+"\n"+count);
    sc.close();
  }
}


Measured memory_bytes: 26464
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 

#define int             long long

 
void anmol()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
 
//const int N = 1e6 + 5 ;
 //int a[N], nums2[N] , freq[N];


int32_t main(){

  anmol();
    
  int l,r,d;
  cin>>l>>r>>d;

  int count =0;

  for(int i = l; i<=r; i++){

     
     if(i%d==0){

      count++;
     }
  }

  cout<<count<<endl;
 
}










  
 






   

  
  

   
   





  










 
 





  



 
 
    

  
 
 
 
 
 


 

   

 
 



  
  












 
 





  



 
 
    

  































 
 



  
  












 
 





  



 
 
    

  
 
 
 
 
 


 

   

 
 



  
  












 
 





  



 
 
    

  


Measured memory_bytes: 3608
from heapq import heapify, heappop, heappush
from collections import defaultdict

N, M = map(int, input().split())

lst = [list(map(int, input().split())) for s in range(N)]

dic = defaultdict(list)
for a, b in lst:
    dic[a].append(b)

heap = []
heapify(heap)

r = 0
for i in range(1, M + 1):
    can = dic[i]
    while can:
        heappush(heap, -can.pop(0))

    if len(heap) != 0:
        r += heappop(heap) * (-1)

print(r)


Measured memory_bytes: 48528
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int x,y; cin >> x >> y;
    rep(i,x+1){
        rep(j,x-i+1){
            if(10000*i + 5000*j + 1000*(x-i-j) == y){
                cout << i << " " << j << " " << x-i-j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
// Problem A

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;



int main() {
  int N, X, T;
  cin >> N >> X >> T;
  cout << (int)T*(int)ceil(N*1.0/X) << endl;
  
  
  return 0;
}


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

template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> p(N);
    cin >> p;
    int cnt = 0;
    for (int i =0; i < N; i ++) {
        if ((i + 1 != p[i])) cnt ++;
    }
    if (cnt == 0 || cnt == 2) {
        cout << "YES" << endl;
    } else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n; cin>>n;
    Graph G(n);
    rep(i,n-1){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }
    ll q,k; cin>>q>>k;
    k--;
 
    vector<ll>dist(n,0);
    queue<ll>que;
    vector<bool>seen(n,false);
    que.push(k);
    while(!que.empty()){
        ll v=que.front();que.pop();
        seen[v]=true;
        for(auto nv:G[v]){
            if(seen[nv.first]==true)continue;
            dist[nv.first]=dist[v]+nv.second;
            que.push(nv.first);
        }
    }
    vector<ll>x(q),y(q);
    rep(i,q){
        cin>>x[i]>>y[i];
        x[i]--;y[i]--;
    }
    rep(i,q){
        cout<<dist[x[i]]+dist[y[i]]<<endl;
    }


    /*rep(i,n){
        cout<<dist[i]<<" ";
    }
    cout<<endl;*/

}











Measured memory_bytes: 13388
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  string s,t;cin>>s>>t;
  for(int i = 0; n > i; i++){
    cout << s[i] << t[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))

minX=min(X)
maxX=max(X)

ans=float('inf')

for p in range(minX,maxX+1):
    culc=0
    for i in range(N):
        culc+=(X[i]-p)**2
    
    if ans>culc:
        ans=culc

print(ans)


Measured memory_bytes: 3060
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        private boolean isPalindrome(char[] arr, int left, int right) {
            left--;
            right--;
            while (left < right) {
                if (arr[left] != arr[right]) {
                    return false;
                }
                left++;
                right--;
            }
            return true;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String str = in.next();
            char[] arr = str.toCharArray();
            int len = arr.length;

            boolean isOk = isPalindrome(arr, 1, len) && isPalindrome(arr, 1, (len - 1) / 2) &&
                    isPalindrome(arr, (len + 3) / 2, len);

            out.println(isOk ? "Yes" : "No");
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

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

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

    }

}

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

int main() {
	long long int N, sum = 1;
	long long int X[26] = { 0 };
	string S;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		X[S[i] - 97]++;
	}
	for (int i = 0; i < 26; i++) {
		sum *= (X[i] + 1);
		sum = sum % 1000000007;
	}
	cout << sum  - 1 << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int s;
  long long m;
  int a[1000000] = {};
  scanf("%d", &s);
  for (m = 0; m < 1000000; m++) {
    if (a[s] == 1)
      break;
    a[s]++;
    if (s % 2)
      s = 3*s+1;
    else
      s = s/2;
  }
  printf("%lld\n", m+1);
}

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-

import sys

def readline():
	return sys.stdin.readline().rstrip()
def read(f=int):
	return f(readline())
def reads(f=int):
	return [f(s) for s in readline().split()]

N = read()
H = reads()

max_count = 0
count = 0
prev_h = 0
for h in H:
	if prev_h < h:
		count = 0
	else:
		count += 1
	prev_h = h
	max_count = max(max_count, count)

print(max_count)


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

int n;
vector<int> g[100005];
vector<int> ans(100005);
map<P, int> mp;
int ans1;

void dfs(int v, int p = -1, int prev = -1) {
	int pos = 0;
	int li = ans1;
	while (pos == prev || pos == li) pos++;
	for (int c : g[v]) {
		if (c == p) continue;
		mp[P(c, v)] = pos;
		mp[P(v, c)] = pos;
		dfs(c, v, pos);
		pos++;
		while (pos == prev || pos == li) pos++;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	vector<P> res(n - 1);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		res[i] = P(a, b);
	}
	ans1 = 0;
	rep(i, n) maxs(ans1, int(g[i].size()));
	printf("%d\n", ans1);
	dfs(0);
	rep(i, n - 1) {
		printf("%d\n", mp[res[i]] + 1);
	}
	return 0;
}


Measured memory_bytes: 21760
# In progress
class Queue(object):
    def __init__(self, queue_size):
        self.queue_size = queue_size
        self.Q = [None] * self.queue_size
        self.head = 0
        self.tail = 0

    def enqueue(self, x):
        self.Q[self.tail] = x
        self.tail = (self.tail + 1) % self.queue_size

    def dequeue(self):
        x = self.Q[self.head]
        self.Q[self.head] = None
        self.head = (self.head + 1) % self.queue_size
        return x


if __name__ == "__main__":
    # Input
    n, q = list(map(int, input().split()))
    pt = list([input().split() for _ in range(n)])
    p = [val[0] for val in pt]
    t = list(map(int, [val[1] for val in pt]))
    # Enqueue all data
    q_size = 1000000  # Assumed max_size
    p_queue = Queue(q_size)
    t_queue = Queue(q_size)
    for i in range(n):
        p_queue.enqueue(p[i])
        t_queue.enqueue(t[i])
    # print(t_queue.Q)
    # Do round-robin
    n_finished = 0
    elapsed_time = 0
    while n_finished < n:
        tmp_t, tmp_p = t_queue.dequeue(), p_queue.dequeue()
        tmp_lefttime = tmp_t - q
        if tmp_lefttime <= 0:
            # 処理が終わった場合
            elapsed_time += tmp_t
            print(tmp_p, elapsed_time)
            n_finished += 1
        else:
            # 処理が残っている場合
            elapsed_time += q
            t_queue.enqueue(tmp_lefttime)
            p_queue.enqueue(tmp_p)



Measured memory_bytes: 33568
n = int(input())
k = int(input())

def one(n):
    l = len(str(n))
    ans = 9 * (l-1)
    ans += n//(10**(l-1))
    return ans

def two(n):
    l = len(str(n))
    if l == 1:
        ans = 0
    elif l == 2:
        ans = (n//10-1) *9 + n%10
    else:
        ans =   81 * (l-1) * (l-2) // 2
        t = n % (10**(l-1))
        ans += one(t) + one(10**(l-1)-1)* (n// (10**(l-1))-1)
    return ans

def three(n):
    l = len(str(n))
    if l <= 2:
        ans = 0
    elif l == 3:
        ans = (n//100-1) * two(99) + two( n % 100 )
    else:
        ans = 729 * (l-1) * (l-2) * (l-3) // 6
        t = n % (10**(l-1))
        ans += two(t) + two(10**(l-1)-1)* (n// (10**(l-1))-1)
    return ans

if k == 1:
    ans = one(n)
if k == 2:
    ans = two(n)
if k == 3:
    ans = three(n)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

int a;
string s;

int main() {
	cin >> a >> s;
	cout << (a >= 3200 ? s : "red") << endl;

	return 0;
}


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

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

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = Gcd(a, b);
    vector<int> Ans;
    for (int i = 2; i <= sqrt(ans); i++) {
        if (ans % i == 0) {
            Ans.push_back(i);
            do{
                ans = ans / i;
            }while (ans % i == 0);
        }
    }
    if (ans > 1) Ans.push_back(ans);
    cout << (int)Ans.size() + 1 << endl;
    return 0;
}

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

int main() {
  string n;
  cin >> n;
  if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
//
// Created by yijiezhu on 12/20/16.
//

#include <iostream>
#include <cstring>
using namespace std;

#define MAX_N 101

int m, n;
char matrix[MAX_N][MAX_N];
bool visited[MAX_N][MAX_N];
int cnt;

void dfs(int i, int j, char ch) {
    visited[i][j] = true;
    matrix[i][j] = (char) ('a' + cnt - 1);
    int delta[] = {0, 1, 0, -1, 0};
    for (int q = 0; q < 4; q++) {
        int ni = i + delta[q], nj = j + delta[q+1];
        if (ni < 0 || ni >= m || nj < 0 || nj >= n) continue;
        if (visited[ni][nj] || matrix[ni][nj] != ch) continue;
        dfs(ni, nj, ch);
    }
}

void solve() {
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (!visited[i][j]) {
                cnt++;
                dfs(i, j, matrix[i][j]);
            }
        }
    }
    cout << cnt << endl;
}

int main() {
    while (true) {
        cin >> m >> n;
        if (m == 0) break;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                cin >> matrix[i][j];
            }
        }
        cnt = 0;
        memset(visited, false, sizeof(visited));
        solve();
    }
}

Measured memory_bytes: 4204
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  cout << a/b << " " << a%b << " ";
  cout << fixed;
  cout << setprecision(5) << (double)a/(double)b << endl;
  return 0;
}



Measured memory_bytes: 3240
from collections import deque

H, W = map(int, input().split())
A = [input() for i in range(H)]

Map = [[-1] * W for i in range(H)]

d = deque([])
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      Map[i][j] = 0
      d.append([i, j])

ans = 0
while d:
  x, y = d.popleft()
  dist = Map[x][y]
  for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
    u, v = x + dx, y + dy
    if 0<=u<H and 0<=v<W and Map[u][v]==-1:
      Map[u][v] = dist + 1
      ans = max(ans, dist + 1)
      d.append([u, v])

print(ans)

Measured memory_bytes: 141020
#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int main() {
    cin >> N;
    vector<int> a(N);
    set<int> set;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        set.insert(a[i]);
    }

    if (set.size() == 3 && N % 3 == 0) {
        if (set.count(0) == 1) {
            cout << "No" << endl;
            return 0;
        }
        int i = 0;
        int x[3];
        for (auto tmp : set) {
            x[i] = tmp;
            i++;
        }
        int c = x[0] ^ x[1];
        if (count(a.begin(), a.end(), x[0]) == N / 3 && count(a.begin(), a.end(), x[1]) == N / 3 && c == x[2]) {
            cout << "Yes" << endl;
            return 0;
        }
    } else if (set.size() == 2 && N % 3 == 0) {
        if (count(a.begin(), a.end(), 0) == N / 3) {
            cout << "Yes" << endl;
            return 0;
        }
    } else {
        if (count(a.begin(), a.end(), 0) == N) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 4224