akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
set<int> s;

int main(){
  scanf("%d",&n);
  REP(i,n){
    int d;
    scanf("%d",&d);
    s.insert(d);
  }
  printf("%d\n",s.size());
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int size = str.size();
	for(int i=0;i<size-1;++i){
		if( str[i] == 'A' && str[i+1] == 'C' ){
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int c[15],a[15][15],b[15];
int main(){
    int n,m,x,ans=1e9;
    cin>>n>>m>>x;
    for(int i=1;i<=n;i++){
        cin>>b[i];
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<(1<<n);i++){
        memset(c,0,sizeof(c));
        int k=i,tag=0,mx=0;
        for(int j=1;j<=n;j++){
            int p=k%2;k/=2;
            if(p==0) continue;
            mx+=b[j];
            for(int t=1;t<=m;t++){
                c[t]+=a[j][t];
            }
        }
        for(int j=1;j<=m;j++){
            if(c[j]<x){
                tag=1;break;
            }
        }
        if(!tag) ans=min(ans,mx);
    }
    if(ans>1e8) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3584
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

int cnt[31];
int main(){
	int a;
	CLR(cnt);
	REP(i,28){
		cin>>a;
		cnt[a]++;
	}
	FOR(i,1,31)if(cnt[i]==0){
		cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
a,b,k=map(int,input().split())
n =[]
for i in range(a,a+k if k<(b-a) else b+1):
    n.append(i)
for i in range(b-k+1 if k<(b-a) else b+1,b+1):
    if(i not in n):
        n.append(i)
for i in n:
    print(i)

Measured memory_bytes: 3064
import numpy as np

[H, W] = [int(i) for i in input().split()]
N = int(input())
a = [int(i) for i in input().split()]

ans_flat = []
for i in range(len(a)):
    for j in range(a[i]):
        ans_flat.append(i + 1)

ans_flat = np.array(ans_flat)
ans_sq = ans_flat.reshape(H,W)

for i in range(H):
    if i % 2 == 1:
        ans_sq[i] = ans_sq[i][::-1]
    print(' '.join(ans_sq[i].astype(str)))



Measured memory_bytes: 21452
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int a[n];
    vector<int> v[m];
    rep(i, n) {
        scanf("%d", &a[i]);
        --a[i];
        if(i > 0) v[a[i]].push_back(i);
    }
    
    lint num[2*m];
    rep(i, 2*m) num[i] = 0;
    rep(i, n-1){
        if(a[i] < a[i+1]){
            ++num[a[i]+1];
            --num[a[i+1]];
        }
        else{
            ++num[a[i]+1];
            --num[a[i+1]+m];
        }
    }
    rep(i, 2*m-1) num[i+1] += num[i];
    rep(i, m) num[i] += num[i+m];
    
    lint cnt = 0;
    rep(i, n-1){
        lint dif = (a[i+1]-a[i]+m)%m * 1LL;
        if(((m-a[i])%m < dif && a[i+1] < dif) || a[i+1] == 0) cnt += 1+a[i+1] * 1LL;
        else cnt += dif;
    }
    
    lint ans = cnt;
    rep(i, m-1){
        for(int j: v[i]) cnt += (a[j]-a[j-1]+m)%m-1 * 1LL;
        cnt -= num[i];
        ans = min(ans, cnt);
    }
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 6912
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad         (forM_, replicateM)
import           Control.Monad.ST      (ST)
import qualified Data.Array.ST         as AM
import           Data.Array.Unboxed    ((!))
import qualified Data.Array.Unboxed    as AU
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)


main :: IO ()
main = do
  [n, c] <- getInts
  dss <- replicateM c getInts
  css <- replicateM n getInts
  print $ solve n c dss css

solve :: Int -> Int -> [[Int]] -> [[Int]] -> Int
solve n c dss css = minimum [f i j k | i <- [1 .. c]
                                     , j <- [1 .. c]
                                     , i /= j
                                     , k <- [1 .. c]
                                     , i /= k
                                     , j /= k] where
  f i j k = sum $ [dss' ! (l, i) * css' ! (0, l)
                  | l <- [1 .. c]]
            ++ [dss' ! (l, j) * css' ! (1, l)
               | l <- [1 .. c]]
            ++ [dss' ! (l, k) * css' ! (2, l)
               | l <- [1 .. c]]
  dss' = AU.array ((1, 1), (c, c)) [((i, j), d)
                                   | (ds, i) <- zip dss [1 .. c]
                                   , (d, j) <- zip ds [1 .. c]] :: AU.UArray (Int, Int) Int
  css' = AM.runSTUArray $ do
    arr <- AM.newArray ((0, 1), (2, c)) 0 :: ST s (AM.STUArray s (Int, Int) Int)
    forM_ (zip css [1 .. ]) $ \(cs, i) ->
      forM_ (zip cs [1 .. ]) $ \(c, j) -> do
        let k = (i + j) `mod` 3
        AM.writeArray arr (k, c) .
          (+ 1) =<< AM.readArray arr (k, c)
    return arr

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt

getInts :: IO [Int]
getInts = map readInt . BC.words <$> BC.getLine


Measured memory_bytes: 3452
#include<bits/stdc++.h>
int i,j,d[50],p,n,q,a[5]={5,7,5,7,7};
char s[15];
main(){
	for(n=1;n;){
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%s",s);
			d[i]=strlen(s);
		}
		for(i=0;n;i++){
			p=i;
			for(j=0;j<5;j++){
				q=a[j];
				while(q>0){
					q-=d[p];p++;
				}
				if(q<0)break;
			}
			if(j>4){
				printf("%d\n",i+1);
				break;
			}
		}
	}
}

Measured memory_bytes: 1196
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0

for i in range(n):
    a = list(map(int,input().split()))
    sum = 0
    for j in range(m):
        sum += b[j]*a[j]
    sum += c
    if sum > 0:
        count += 1
print(count)







Measured memory_bytes: 3060
def former(array, value)
  array.bsearch do |x|
    x >= value
  end
end

def latter(array, value)
  i = array.bsearch_index do |x|
    x >= value
  end
  if i.nil?
    array.empty? ? nil : array[-1]
  elsif i >= 1
    array[i - 1]
  else
    nil
  end
end

A, B, Q = gets.split.map(&:to_i)
s_list = A.times.map { gets.to_i }.sort
t_list = B.times.map { gets.to_i }.sort
Q.times do
  ans = 10 << 60
  q = gets.to_i
  # s
  2.times do |i|
    s = i == 0 ? former(s_list, q) : latter(s_list, q)
    next unless s
    sd = (s - q).abs
    2.times do |j|
      t = j == 0 ? former(t_list, s) : latter(t_list, s)
      next unless t
      td = (s - t).abs
      ans = sd + td if ans > sd + td
    end
  end
  # t
  2.times do |i|
    t = i == 0 ? former(t_list, q) : latter(t_list, q)
    next unless t
    td = (t - q).abs
    2.times do |j|
      s = j == 0 ? former(s_list, t) : latter(s_list, t)
      next unless s
      sd = (s - t).abs
      ans = sd + td if ans > sd + td
    end
  end
  puts ans
end


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

using namespace std;

typedef long long ll;

template<typename T>
void _dump(const char* s, T&& head)
{
  cerr << s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail)
{
  while (*s != ',')
    cerr << *s++;
  cerr << "=" << head << ",";
  _dump(s + 1, tail...);
}

template<typename T>
void _dumpv(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << *it << " ";
  }
  cerr << endl;
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__)
#define dumpv(...) _dumpv(#__VA_ARGS__, __VA_ARGS__)

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  string s;
  cin >> s;
  int ans;
  ans = 0;
  int n;
  dump(s);
  n = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
      n++;
    } else {
      ans = max(ans, n);
      dump(n, ans);
      n = 0;
    }
  }
  ans = max(ans, n);
  dump(ans);
  cout << ans << endl;
  return 0;
}


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

int main() {
  int l = 0, ml = 0;
  string s;
  cin >> s;
  REP(i, s.length()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      ++l;
    } else {
      ml = max(l, ml);
      l = 0;
    }
  }

  ml = max(l, ml);

  cout << ml << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.ComponentModel;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var X = ReadValue<int>();
            var ans = 0;
            if (X >= 1800) {
                ans = 1;
            } else if (X >= 1600) {
                ans = 2;
            } else if (X >= 1400) {
                ans = 3;
            } else if (X >= 1200) {
                ans = 4;
            } else if (X >= 1000) {
                ans = 5;
            } else if (X >= 800) {
                ans = 6;
            } else if (X >= 600) {
                ans = 7;
            } else if (X >= 400) {
                ans = 8;
            }
            Console.Write(ans);
        }

        static T1 ReadValue<T1>() {
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            return (T1)t1.ConvertFromString(Console.ReadLine());
        }
    }
}

Measured memory_bytes: 30156
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;
int P,Q,A,N;
int ufq(int p, int q,int t,int n){
	if(P*q==p*Q) return 1;
	if(P*q<p*Q) return 0;
	if(n==N) return 0;
	int ret=0;
	for(int i=t;i*q<=A;i++){
		ret+=ufq(q+p*i,i*q,i,n+1);
	}
	return ret;
}

int main(){
	while(cin>>P>>Q>>A>>N,Q){
		p(ufq(0,1,1,0));
	}
	return 0;
}

Measured memory_bytes: 2988
'''
a,op,b = input().split()

a,b = int(a),int(b)
'''
###############################################################
#whileの中に入れないと同じデータセットでの計算をずっとし続ける#
###############################################################

while True:
	a,op,b = input().split()

	a= int(a)
	b = int(b)

	if op == '+':
		print(a+b)
	elif op == '-':
		print(a-b)
	elif op == '*':
		print(a*b)
	elif op == '/':
		print(a//b)
	elif op == '?':
		break



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

int N;
int A[10];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  ll ans = 1;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans *= 3;
  }
  ll tmp = 1;
  for (int i = 0; i < N; i++) {
    if (A[i] % 2 != 0) continue;
    tmp <<= 1;
  }
  cout << ans-tmp << endl;

  return 0;
}

Measured memory_bytes: 256
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n=int(input())
B=list(map(int,input().split()))
A=[]
for i in range(n):
    A.append([B[i],i+1])
A.sort()
for i in range(n):
    print(A[i][1],end=" ")
        

Measured memory_bytes: 21440
#include <iostream>

int main (void)
{
	int a, b, c;
	std::cin >> a >> b >> c;
	
	if ( a < b && b < c )
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
	
	
	return 0;
}

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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> x(n),y(n);
  vector<pair<long,long>> xy(n);
  for(long i=0;i<n;i++) {
    cin >> x[i] >> y[i];
    xy[i]={x[i],y[i]};
  }
  sort(xy.begin(),xy.end());
  long gex=xy[0].first,gey=xy[0].second,zyox=xy[0].first,zyoy=xy[0].second;
  for(long i=0;i<n;i++) {
    long xx=xy[i].first,yy=xy[i].second;
    ans=max(ans,max(gex-xx,xx-gex)+max(gey-yy,yy-gey));
    ans=max(ans,max(zyox-xx,xx-zyox)+max(zyoy-yy,yy-zyoy));
    if(xx-gex<gey-yy) gex=xx,gey=yy;
    if(xx-zyox<yy-zyoy) zyox=xx,zyoy=yy;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9596
count1 = 0
count2 = 0
N, A, B = map(int, input().split())
S = list(input())
for i in S:
  if i == "a" and A + B > count1:
    print("Yes")
    count1 += 1
  elif i == "b" and A + B > count1 and B > count2:
    print("Yes")
    count1 += 1
    count2 += 1
  else :
    print("No")

Measured memory_bytes: 9988
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

ll imos[31][123456];
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	ll n, C; cin >> n >> C;
	rep(i, n) {
		ll s, t, c; cin >> s >> t >> c;
		t++;
		imos[c][s]++; imos[c][t]--;
	}
	rep2(i, C) {
		rep2(j, 100004) {
			imos[i][j] += imos[i][j - 1];
		}
	}
	ll ans = 0;
	rep2(i, 100004) {
		ll cnt = 0;
		rep2(j, C) {
			if (imos[j][i] > 0) { cnt++; }
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27156
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var n = rint();
        var l = inta();
        Array.Sort(l);
        int ct = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = i + 1; j < n; j++)
            {
                for(int k = j + 1; k < n; k++)
                {
                    if (l[i] != l[j] && l[k] < l[i] + l[j] && l[j] != l[k]) 
                      ct++;
                }
            }
        }
        Write(ct);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27564
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)

const ll INF = (1LL << 62) - 1;

void solve() {
	int N, K;
	cin >> N >> K;
	int cnt = 0;
	while (N >= 1) {
		N /= K;
		cnt++;
	}
	cout << cnt << endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	solve();

}

Measured memory_bytes: 256
/*
 
dunjen_master
 
*/
 

 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=998244353;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 

inline ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}

  

 
#define all(x) (x).begin(),(x).end()

/* ordered_set A;
   A.insert(x);
   A.erase(x);
   A.order_of_key(x) // no of elements less than (<) x
   *A.find_by_order(k-1) // kth smallest element
*/
// int n;
// ll dp[200005][205];
// ll ans=0;
// int a[200005];
// int req;
// ll neg=-1e15;


// ll fun(int indx,int last){
//    // cout<<indx<<" "<<last<<" "<<req<<endl;
//     if(indx==n){
//         if(last==req){
//             return 0;
//         }else{
//             return neg;
//         }
//     }

//     if(dp[indx][last]!=-1){
//         return dp[indx][last];
//     }
    
//     ll ans=neg;

//     ans=max(ans,fun(indx+1,last));

//     if(last==0)ans=max(ans,1+fun(indx+1,a[indx]));
//     if(last==a[indx])ans=max(ans,1+fun(indx+1,a[indx]));
//     if(a[indx]==req)ans=max(ans,1+fun(indx+1,a[indx]));

//     return dp[indx][last]=ans;


// }









int main(){


    int a,b,c,d;
    cin>>a>>b>>c>>d;

    while(true){
        c=c-b;
        if(c<=0){
            cout<<"Yes"<<"\n";
            return 0;
        }
        a=a-d;
        if(a<=0){
            cout<<"No"<<"\n";
            return 0;
        }
    }
    
 
    
}

    

    
 
    



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2005;
bool used[N];
int n,x[N];
ll dp[N][N];
int l,r,num;
ll ans,mx;
int main()
{
	cin>>n;
	r=n-1;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=0;i<n;i++)
	{
		mx=0;num=-1;
		for(int j=0;j<n;j++)
		{
			if(x[j]>mx&&!used[j])
			{
				mx=x[j];
				num=j;
			}
		}
		used[num]=true;
		for(int j=0;j<=i;j++)
		{
			int k=(n-(i-j+1));
			dp[j+1][k]=max(dp[j][k]+abs(j-num)*mx,dp[j+1][k]);
			dp[j][k-1]=max(dp[j][k]+abs(k-num)*mx,dp[j][k-1]);
		}
	}
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)ans=max(ans,dp[i][j]);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 26288
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Enclose All
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int CNT = 100;

/* typedef */

/* global variables */

int xs[MAX_N], ys[MAX_N];

/* subroutines */

inline double dist2(double dx, double dy) {
  return dx * dx + dy * dy;
}

double maxd2(int n, double x, double y) {
  double maxd2 = 0.0;
  for (int i = 0; i < n; i++) {
    double d2 = dist2(x - xs[i], y - ys[i]);
    if (maxd2 < d2) maxd2 = d2;
  }
  return maxd2;
}

double mind2(int n, double y, double minx, double maxx) {
  double x0 = minx, x1 = maxx;
  for (int cnt = 0; cnt < CNT; cnt++) {
    double x2 = (2 * x0 + x1) / 3;
    double x3 = (x0 + 2 * x1) / 3;

    if (maxd2(n, x2, y) > maxd2(n, x3, y)) x0 = x2;
    else x1 = x3;
  }

  return maxd2(n, (x0 + x1) / 2, y);
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);

  double minx = xs[0], maxx = xs[0], miny = ys[0], maxy= ys[0];
  for (int i = 1; i < n; i++) {
    if (minx > xs[i]) minx = xs[i];
    if (maxx < xs[i]) maxx = xs[i];
    if (miny > ys[i]) miny = ys[i];
    if (maxy < ys[i]) maxy = ys[i];
  }

  double y0 = miny, y1 = maxy;
  for (int cnt = 0; cnt < CNT; cnt++) {
    double y2 = (2 * y0 + y1) / 3;
    double y3 = (y0 + 2 * y1) / 3;

    if (mind2(n, y2, minx, maxx) > mind2(n, y3, minx, maxx)) y0 = y2;
    else y1 = y3;
  }

  printf("%.18lf\n", sqrt(mind2(n, (y0 + y1) / 2, minx, maxx)));
  return 0;
}


Measured memory_bytes: 256
def getLast(d, i):
    if last_d[i] == 0:
        return 0
    return d - last_d[i]

def calcC(d):
    res = 0
    for i in range(26):
        res = res + C[i] * getLast(d, i)
    return res

def getBestd(d):
    preLast_d = last_d[25]
    last_d[25] = d
    res = S[d][25] - calcC(d)
    last_d[25] = preLast_d
    res_i = 25
    now = 0
    for i in range(25):
        preLast_d = last_d[i]
        now = S[d][i] - calcC(d)
        last_d[i] = preLast_d
        if res < now:
            res = now
            res_i = i
    return res, res_i



D = int(input())
C = list(map(int, input().split()))
S = []
for i in range(D):
    s = list(map(int, input().split()))
    S.append(s)

score = 0

last_d = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

T = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]

resT = []

for d in range(D):
    now, i = getBestd(d)
    score = score + now
    last_d[i] = d
    resT.append(T[i])

for i in range(D):
    print(resT[i])


Measured memory_bytes: 9356
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        final int N = sc.nextInt();
        boolean flg = true;
        for (int i = 0; i < N; i++) {
            int Ai = sc.nextInt();
            if ((Ai % 2 == 0) && (Ai % 3 != 0) && (Ai % 5 != 0)) {
                flg = false;
                break;
            }
        }
        out.println(flg ? "APPROVED" : "DENIED");
        out.flush();
    }
}

// FastScanner start
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int maxn=1e5+10;
const int modn=1e9+7;
char s[maxn];
ll dp[maxn][15];
int main()
{
	scanf(" %s",s+1);
	int len=strlen(s+1);
	dp[0][0]=1; 
	for(int i=1;i<=13;i++)dp[0][i]=0;
	for(int i=1;i<=len;i++){
		for(int j=0;j<13;j++){
			if(s[i]!='?'){
				int x=s[i]-'0';
				dp[i][(j*10+x)%13]=(dp[i][(j*10+x)%13]+dp[i-1][j])%modn;
			}
			else{
				for(int k=0;k<=9;k++){
					dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%modn;
				}
			}
		}
	}
	printf("%lld\n",dp[len][5]);
}

Measured memory_bytes: 12032
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    input! {
        s: Chars,
        t: Chars
    };

    let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
    let mut prev = vec![vec![(0, 0); t.len() + 1]; s.len() + 1];
    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                dp[i + 1][j + 1] = dp[i][j] + 1;
                prev[i + 1][j + 1] = (i, j);
            } else {
                dp[i + 1][j + 1] = dp[i + 1][j].max(dp[i][j + 1]);
                prev[i + 1][j + 1] = if dp[i + 1][j] > dp[i][j + 1] {
                    (i + 1, j)
                } else {
                    (i, j + 1)
                };
            }
        }
    }
    let mut res = VecDeque::new();
    let mut i = s.len();
    let mut j = t.len();
    while i > 0 && j > 0 {
        if s[i - 1] == t[j - 1] {
            res.push_front(s[i - 1]);
        }
        let (ii, jj) = prev[i][j];
        i = ii;
        j = jj;
    }
    println!("{}", res.into_iter().join(""));
}


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

int f(int x){
    if (x % 2 == 0){
        return x/2;
    }
    else{
        return 3 * x + 1;
    }
}
 
int main(){
    int s;
    cin >> s;
    if (s == 1 || s == 2 || s == 4){
    cout << 4 << endl;
    }
    else{
        int count = 1;
  	    int flag = 0;
  	    while (flag == 0){
            s = f(s);
            count ++;
            if (s == 4){
                cout << count + 3 << endl;
                flag = 1;
            }
        }
    }
}

Measured memory_bytes: 256
N,X=gets.chomp.split.map(&:to_i)
b=[]
p=[]
p[0]=1
b[0]=0

1.upto(N) do |i|
    p[i] = 1+2*p[i-1]
    b[i] = 2+2*b[i-1]
end

def get_pb(n,m,s,p,b)
    return 1 + s if n == 0
    if m == 1 
        s
    elsif m == 2 + p[n-1] + b[n-1]
        s + 1 + p[n-1]
    elsif m == 3 + 2 * (p[n-1] + b[n-1])
        s + 1 + 2 * p[n-1]
    elsif m < 2 + p[n-1] + b[n-1]
        get_pb(n-1, m-1, s, p,b)
    else
        get_pb(n-1, m-2-p[n-1]-b[n-1], s+1+p[n-1], p,b)        
    end
end

puts get_pb(N,X,0,p,b)




Measured memory_bytes: 3836
#include <iostream>

using namespace std;

int main(){
    int N;
    //N
    int K;
    //K
    cin >> N >> K;
    //N,Kの順で標準入力
    if(K == 1){
      cout<< 0 <<endl;
      //K == 1 人の場合は、N個を1人に配るしかないので差は0
  } else {
    cout<< N - K <<endl;
    //全員に1個以上配る必要があるが、先に全員に1個ずつ配った上で残りのN − K個を自由に配ることを考えると、答えはN − Kだ
  }
}

Measured memory_bytes: 256
#include <iostream>


struct Answer {
    int yen_10000;
    int yen_5000;
    int yen_1000;
    
    bool is_valid() { 
        return yen_10000 != -1;
    }
    
    void print() {
        std::printf(
            "%d %d %d\n",
            yen_10000, yen_5000, yen_1000
        );
    }
};

struct Cond {
    bool use_10000 = true;
    bool use_5000  = true;
    bool use_1000  = true;
};


// n枚で1000*y円作る組み合わせを返す
Answer solve(const int n, const int ky, Cond cond) {
    //
    if(n == 0 && ky == 0) {
        return {0, 0, 0};
    }
    if(ky == 0) {
        return {-1, -1, -1};
    }
    if(ky == n) {
        return {0, 0, n};
    }
    
    //
    if(cond.use_10000) {
        for(int num = ky / 10; num >= 0; --num) {
            auto ans = solve(
                n - num, ky - num*10,
                {false, true, true}
            );
            if(ans.is_valid()) {
                ans.yen_10000 += num;
                return ans;
            }
        }
    }
    if(cond.use_5000) {
        for(int num = ky / 5; num >= 0; --num) {
            auto ans = solve(
                n - num, ky - num*5,
                {false, false, true}
            );
            if(ans.is_valid()) {
                ans.yen_5000 += num;
                return ans;
            }
        }
    }
    
    return {-1, -1, -1};
}

int main(void) {
    int N, Y;
    std::cin >> N >> Y;

    solve(N, Y/1000, {}).print();
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [0] * N
r = [0] * N
for i in range(M):
  a, b = list(map(int, input().split()))
  if H[a-1] > H[b-1]:
    g[a-1] += 1
  if H[a-1] < H[b-1]:
    g[b-1] += 1
  r[a-1] += 1
  r[b-1] += 1

ans = 0
for j in range(N):
  if g[j] == r[j]:
    ans += 1
print(ans)

Measured memory_bytes: 20072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	bool ans = 1;
	int C[3][3];
	FOR(i, 3) {
		FOR(j, 3)cin >> C[j][i];
	}
	FOR(i, 2) {
		int a = C[0][i] - C[0][i + 1], b = C[1][i] - C[1][i + 1], c = C[2][i] - C[2][i + 1];
		if (a != b || b != c || c != a) {
			cout << "No" << endl;
			return 0;
		}
	}
	FOR(j, 2) {
		int a = C[j][0] - C[j + 1][0], b = C[j][1] - C[j + 1][1], c = C[j][2] - C[j + 1][2];
		if (a != b || b != c || c != a) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


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

using namespace std;

int main()
{
   int n;string s;
   cin >>n;
   vector<string> v;
   set<string> set;
   for(int i=0;i<n;i++)
   {
       cin >> s;
       set.insert(s);
    }
   int ans=set.size();
   
   cout << ans << endl;
   
   

    return 0;
}


Measured memory_bytes: 19120
C = (1..3).map { gets.split.map &:to_i }

a = [0, nil, nil]
b = (0...3).map {|i| C[0][i]-a[0] }
for i in 1..2
  a[i] = C[i][0]-b[0]
end

for i in 0...3
  for j in 0...3
    if C[i][j]!=a[i]+b[j]
      puts "No"
      exit
    end
  end
end
puts "Yes"



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

using Vi = vector<int>;
using Vs = vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef pair<int, int> P;
typedef long long ll;

const int INF = 10000000, MAX_N = 200000, MAX_M = 1000, MAX_W = 10000;

int asc(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}


int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        rep(i, a)
            cout << b;
    }
    else {
        rep(i, b)
            cout << a;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <boost/array.hpp>

int main()
{
	int N;
	std::cin >> N;
	for (int i = 0; i < N; ++i) {
		boost::array<int, 3> sides;
		std::cin >> sides[0] >> sides[1] >> sides[2];
		std::sort(sides.begin(), sides.end());
		std::cout << (sides[0] * sides[0] + sides[1] * sides[1] == sides[2] * sides[2] ?
				"YES" : "NO") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
N, L = [int(x) for x in input().split()]

s =0
for i in range(1, N+1):
    s += L+i-1

ss = []
for k in range(1, N+1):
    ss.append(s - (L+k-1))

dif = []
for kk in range(0, N):
    dif.append(abs(s-ss[kk]))

print(ss[dif.index(min(dif))])

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

using namespace std;

void solve()
{
	string str;
	cin >> str;
	for(int i = 0; i < str.size(); ++i)
	{
		if(str[i] <= 'C')
		{
			str[i] = str[i] - 3 + 26; 
		}
		else
		{
			str[i] -= 3;
		}
		cout << str[i];
	}
	cout << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1176
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			char[] a = scan.next().toCharArray();
			char[] b = scan.next().toCharArray();
			TreeSet<Integer>[] get = new TreeSet[26];
			for(int i = 0; i < 26; i++) get[i] = new TreeSet<>();
			for(int i = 0; i < a.length; i++) get[a[i]-'a'].add(i);
			int at = -1;
			long total = 0;
			for(int i = 0; i < b.length; i++) {
				if(get[b[i]-'a'].isEmpty()) {
					out.println(-1);
					return;
				}
				Integer next = get[b[i]-'a'].higher(at);
				if(next == null) {
					next = get[b[i]-'a'].higher(-1);
					total += a.length-at+next;
				}
				else {
					total += next-at;
				}
				at = next;
			}
			out.println(total);
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 35936
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxN = 1e5 + 10;
const int MAXN = 1e5 + 5;
int counts = 1, ans, maxn = -INF;
int head[MAXN];
struct node{
	int to;
	int next;
	int color;
}edge[MAXN];

void addedge(int a,int b)
{	
	edge[counts].to = b;
	edge[counts].color = 0;
	edge[counts].next = head[a];
	head[a] = counts++;
}
vector < int > g[maxN], g1[maxN];
void dfs(int x, int col)
{
	printf("%d\n", x);
	printf("%d\n", g[x].size());
	for(int i = col; i < col + g[x].size(); i++){
		if(col != i + 1){
			g1[x].push_back(i + 1);
			ans = max(ans, i + 1);
		}
	}
	for(int i = 0; i < g[x].size(); i++){
		dfs(g[x][i], g1[x][i]);
	}
}
void dfs1(int u,int c)
{
	int tmp = 1;
	for(int i = head[u];i != 0;i = edge[i].next){
		int v = edge[i].to;
		if(tmp == c)
			tmp++;
		edge[i].color = tmp;
		maxn = max(maxn,tmp);
		dfs1(v,tmp);
		tmp++;
	}
}
int main()
{
	int n;
	cin >> n;
	for(int i = 0;i < n - 1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		addedge(a,b);
	}
	dfs1(1,0);
	printf("%d\n",maxn);
	for(int i = 1;i < counts;i++){
		printf("%d\n",edge[i].color);
	}
	return 0;
}

Measured memory_bytes: 9216
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long blue = sc.nextLong();
        long red = sc.nextLong();
        long set = red + blue;

        long ans = (n / set)*blue;
        ans += (n%set) >= blue?blue :(n%set);

        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int d,w;
	while(cin>>d>>w,d+w)
	{
		int e[d][w],ans=0;
		for (int i = 0; i < d; ++i) for (int j = 0; j < w; ++j) cin>>e[i][j];
		for (int i = 0; i < d-2; ++i)
		{
			for (int j = 0; j < w-2; ++j)
			{
				for (int k = i+2; k < d; ++k)
				{
					for (int l = j+2; l < w; ++l)
					{
						int outmin=10,inmax=-1;
						for (int m = i; m <= k; ++m) outmin=min(outmin,min(e[m][j],e[m][l]));
						for (int m = j; m <= l; ++m) outmin=min(outmin,min(e[i][m],e[k][m]));
						for (int m = i+1; m < k; ++m) for (int n = j+1; n < l; ++n) inmax=max(inmax,e[m][n]);
						if(outmin>inmax)
						{
							int cap=0;
							for (int m = i+1; m < k; ++m) for (int n = j+1; n < l; ++n) cap+=outmin-e[m][n];
							ans=max(ans,cap);
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3052
N = int(input())
s = {}
for i in range(N):
    si = input()
    if si in s:
        s[si] += 1
    else:
        s[si] = 1
M = int(input())
for i in range(M):
    ti = input()
    if ti in s:
        s[ti] -= 1
ans = 0
for val in s.values():
    ans = max(ans, val)
print(ans)


Measured memory_bytes: 3060
main = do
  li <- getLine
  let ans = compute li
  putStrLn (if ans then "Yes" else "No")

compute :: String -> Bool
compute s = and [ f c | (c,f) <- zip s (cycle [od,ev]) ]

-- od c = elem c "RUD"
-- ev c = elem c "LUD"
od c = c /= 'L'
ev c = c /= 'R'


Measured memory_bytes: 380
K=int(input())
A=[1,2,3,4,5,6,7,8,9]
B=[]
C=[]
D=[]
E=[]
F=[]
G=[]
H=[]
I=[]
J=[]
def henkan(A):
    a=len(A)
    B=[]
    for i in range(a):
        if A[i]%10==0:
            B.append(10*A[i])
            B.append(10*A[i]+1)
        elif A[i]%10==9:
            B.append(10*A[i]+9)
            B.append(10*A[i]+8)
        else:
            x=A[i]%10
            B.append(10*A[i]+x)
            B.append(10*A[i]+x+1)
            B.append(10*A[i]+x-1)
    return B

B=henkan(A)
C=henkan(B)
D=henkan(C)
E=henkan(D)
F=henkan(E)
G=henkan(F)
H=henkan(G)
I=henkan(H)
J=henkan(I)
ans=A+B+C+D+E+F+G+H+I+J
ans=sorted(ans)

print(ans[K-1])


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


int main() {
  int n, ans=0;
  cin >> n;
  
  vector<int> vec;
  int pre=-10;
  
  rep(i,n){
    int a;
    cin >> a;
    if(a == pre+1){
      vec.push_back(pre-1);
    }
    pre = a;
  }
  
  rep(i,n){
    int s;
    cin >> s;
    ans += s;
  }
  
  vector<int> c(n-1);
  rep(i, n-1){
    cin >> c.at(i);
  }
  
  for(int x: vec){
    ans += c.at(x);
  }
  
  cout << ans << endl;  
  return 0;
  
}

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

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

typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    cout << N - K + 1<< endl;
    return 0;
}


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

/*Cjの小さいものから見ていって、それより小さいAを順に書き換えていく
*/


int main() {
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N);
  vector<pair<ll,ll>> v(N);
  rep(i,N){
      ll a;
      cin >> a;
      v.push_back({a,1});
  }
  
  rep(i,M){
      int b,c;
      cin >> b >>c;
      v.push_back({c,b});
  }

  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  ll num = 0;//取得した要素数
  ll sum = 0;//sum
  
  for(auto p : v){
      if(num + p.second <= N){
          num += p.second;
          sum += p.first*p.second;
      }
      else if(num + p.second > N){
          sum += p.first*(N-num);
          num = N;
          break;
      }
  }
  cout << sum << endl;
 }


Measured memory_bytes: 9316
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N, K;

    cin >> N >> K;

    int sum = 0;

    for(int i = 0;i < N;i++)
    {
        int x;
        cin >> x;
        sum += min(x, abs(K - x)) * 2;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;
int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0 ;i<n ;i++ ){
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans = 0;
	if(k>=n){
		ans = 0;
	}
	for(int i=0 ;i< n-k;i++){
		ans += a[i];
	}
	cout<<ans<<"\n";

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll a,b,c; cin>>a>>b>>c;
	map<ll,ll> mp;
	ll cnt=a;
	bool ok=false;
	while(true){
		if(mp[cnt%b]>0)break;
		if(cnt%b==c){
			ok=true;
			break;
		}
		mp[cnt%b]++;
		cnt+=a;
	}
	cout<<(ok ? "YES":"NO")<<endl;



	return 0;
}

Measured memory_bytes: 3632