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

int main()
{
	int N;
	cin >> N;
	vector<int> x(N), y(N), h(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	int cx = 0, cy = 0, H = 0;
	for (int xx = 0; xx <= 100; xx++) {
		for (int yy = 0; yy <= 100; yy++) {
			int th = 2e9;
			for (int i = 0; i < N; i++) {
				th = min(th, h[i] + abs(x[i] - xx) + abs(y[i] - yy));
			}
			bool ok = true;
			for (int i = 0; i < N; i++) {
				if (h[i] != max(th - abs(xx - x[i]) - abs(yy - y[i]), 0)) {
					ok = false;
					break;
				}
			}
			if (ok) {
				cx = xx;
				cy = yy;
				H = th;
			}
		}
	}
	cout << cx << ' ' << cy << ' ' << H << endl;
	return 0;
}


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

using namespace std;

#define fo(i,a,b) for(int i=(a);i<(b);++i)
#define fd(i,b,a) for(int i=(b);i>(a);--i)

typedef long long ll;

int main() {
    int N;cin>>N;
    map<int, int> mp;
    fo(i,0,N) {
        int a;cin>>a;
        mp[min(8, a / 400)]++;
    }
    int min, max;
    min=mp.size()-((mp.count(8))?1:0);
    max=min+mp[8];
    if(min==0)min=1;
    cout<<min<<" "<<max;
    return 0;
}



Measured memory_bytes: 3596
import sys

def main():
    input = sys.stdin.readline
    N, C = map(int, input().split())
    dic = [[] for _ in range(C + 1)]
    for _ in range(N):
        s, t, c = input().split()
        dic[int(c)].append([int(s), int(t)])
    for c in range(C + 1):
        l = len(dic[c])
        if l == 1:
            continue
        dic[c] = sorted(dic[c])
        i = 0
        while i < l - 1:
            if i < l - 1 and dic[c][i][1] == dic[c][i + 1][0]:
                dic[c][i + 1][0] += 1
            else:
                i += 1
    f = [0 for _ in range(100002)]
    for c in range(C + 1):
        for t in dic[c]:
            f[t[0]] += 1
            f[t[1] + 1] -= 1
    ans = 0
    for i in range(1, 100001):
        f[i] += f[i - 1]
        if ans < f[i]:
            ans = f[i]
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 21140
from collections import defaultdict
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] -= 1

mods = defaultdict(int)
cnt = 0
tmp = 0
for i in range(min(k-1, n)):
	tmp = (tmp+a[i])%k
	mods[tmp] += 1
	cnt += 1

ans = 0
tmp2 = 0
for i in range(n):
	ans += mods[tmp2]
	tmp2 = (tmp2+a[i])%k
	mods[tmp2] -= 1
	if cnt < n:
		tmp = (tmp+a[cnt])%k
		mods[tmp] += 1
		cnt += 1

print(ans)

Measured memory_bytes: 38920
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s, t;
  string ng = "UNRESTORABLE";

  cin >> s >> t;

  int n = (int)s.size();
  int m = (int)t.size();

  if (n < m) {
    cout << ng << endl;
    return 0;
  }
  for (int i = n - m; i >= 0; i--) {
    string head = s.substr(0, i);
    string sub = s.substr(i, m);
    string tail = s.substr(i + m, n - i - m);
    bool is_ok = true;
    for (int j = 0; j < m; j++) {
      if (sub[j] != '?' && sub[j] != t[j]) {
        is_ok = false;
      }
    }
    if (is_ok) {
      for (int c = 0; c < head.size(); c++) {
        if (head[c] == '?') {
          cout << "a";
        } else {
          cout << head[c];
        }
      }
      cout << t;
      for (int c = 0; c < tail.size(); c++) {
        if (tail[c] == '?') {
          cout << "a";
        } else {
          cout << tail[c];
        }
      }
      cout << endl;
      return 0;
    }
  }
  cout << ng << endl;

  return 0;
}


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

ll N,K,x[100000],start,m=100000000000;


int main(void){
    cin >> N >> K;
    rep(i,N)cin>>x[i];
    start = lower_bound(x,x+N,0) - x;
    //cout << start << endl;
    rep(i,K+1){
        ll l = start - i;
        ll r = start + K - i-1;
        if(l>=0 && r<N){
            m = min(m,x[r] - x[l] + abs(x[r]));
            m = min(m,x[r] -x[l] + abs(x[l]));
        }
        //cout << l << " " << r << endl;

    }

    cout << m << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long lnt;
#define REP(i, n) for (lnt i = 0; i < (n); i++)
#define FOR(i, a, b) for (lnt i = (a); i < (b); i++)
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (lnt)pow
#define BIT(i) (lnt)pow(2, i)
#define INF 2e18 // cf. LLONG_MAX ≒ 9x10^18

//最大公約数:gcd(n, m)
long long gcd(const long long n, const long long m) {
  long long nDivided, nDividing;
  nDivided = max(n, m);
  nDividing = min(n, m);
  while (nDivided % nDividing) {
    nDivided = nDivided % nDividing;
    swap(nDivided, nDividing);
  }
  return nDividing;
}

int main() {
  lnt n, x0;
  cin >> n >> x0;
  vector<lnt> d;
  lnt xPrev = x0;
  REP(i, n) {
    lnt x;
    cin >> x;
    d.push_back(abs(xPrev - x));
    xPrev = x;
  }

  lnt ans = d[0];
  for (lnt dist : d) {
    ans = gcd(ans, dist);
  }

  cout << ans << endl;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  vi rc(n + 1);
  vi gc(n + 1);
  vi bc(n + 1);
  rep(i, n) {
    if (s[i] == 'R')
      rc[i + 1] = rc[i] + 1;
    else
      rc[i + 1] = rc[i];
    if (s[i] == 'G')
      gc[i + 1] = gc[i] + 1;
    else
      gc[i + 1] = gc[i];
    if (s[i] == 'B')
      bc[i + 1] = bc[i] + 1;
    else
      bc[i + 1] = bc[i];
  }
  dump(rc, gc, bc);
  rep(i, n) rep(j, n) {
    if (i < j) {
      if (s[i] != s[j]) {
        if (s[i] != 'R' && s[j] != 'R')
          ans += (rc[n] - rc[j + 1]);
        else if (s[i] != 'G' && s[j] != 'G')
          ans += (gc[n] - gc[j + 1]);
        else
          ans += (bc[n] - bc[j + 1]);
        int d = j - i;
        if (j + d < n) {
          if (s[i] != s[j + d] && s[j] != s[j + d]) ans--;
        }
        dump(i, j, ans);
      }
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

bool dp1[8005][16005],dp2[8005][16005];

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

    string a;
    cin>>a;
    int l,r;
    cin>>l>>r;
    int n=a.length();
    vector<int>x,y;
    int dis=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='F')
            dis++;
        else
        {
            if(x.size()==y.size())
            {
                x.push_back(dis);
                dis=0;
            }
            else
            {
                y.push_back(dis);
                dis=0;
            }
        }
    }
    if(a[n-1]!='T')
    {
        if(x.size()==y.size())
        {
            x.push_back(dis);
        }
        else
        {
            y.push_back(dis);
        }
    }
    int lim=8000;
    dp1[0][lim]=1;
    dp2[0][lim]=1;
    int sz=x.size();
    for(int i=0;i<sz;i++)
    {
        int tt=x[i];
        for(int j=0;j<=2*lim;j++)
        {
            if(j+tt<=2*lim && i>0)
               dp1[i+1][j]|=dp1[i][j+tt];
            if(j-tt>=0)
                dp1[i+1][j]|=dp1[i][j-tt];
        }
    }

    int z=0;
    z+=dp1[sz][lim+l];
    sz=y.size();
    for(int i=0;i<sz;i++)
    {
        int tt=y[i];
        for(int j=0;j<=2*lim;j++)
        {
            if(j+tt<=2*lim)
               dp2[i+1][j]|=dp2[i][j+tt];
            if(j-tt>=0)
                dp2[i+1][j]|=dp2[i][j-tt];
        }
    }

    z+=dp2[sz][lim+r];
    if(z==2)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    



}

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

struct DICE
{
	int f[8];
};
DICE dice;

int  ch(char a)
{
	int s[60];
	for (int i = 1; i < 7; i++)
	{
		s[i] = dice.f[i];
	}
		int k = a;
	switch (k)
	{
	case 78://N
		dice.f[1] = s[2];
		dice.f[2] = s[6];
		dice.f[6] = s[5];
		dice.f[5] = s[1];
		break;
	case 69:
		dice.f[1] = s[4];
		dice.f[4] = s[6];
		dice.f[6] = s[3];
		dice.f[3] = s[1];
		break;
	case 83://S
		dice.f[2] = s[1];
		dice.f[1] = s[5];
		dice.f[5] = s[6];
		dice.f[6] = s[2];
		break;
	case 87:
		dice.f[4] = s[1];
		dice.f[1] = s[3];
		dice.f[3] = s[6];
		dice.f[6] = s[4];
		break;
	}
	return 0;
}

int main()
{
	
	for (int i = 1; i < 7; i++)cin >> dice.f[i];
	char d[10000];
	cin >> d;
	int z = strlen(d);
	for (int i = 0; i <z; i++)
	{
		int a=ch(d[i]);
	}

	cout << dice.f[1]<<endl;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
vector<vector<ll> > comb;
void pascal(int n)
{
  comb.resize(n+1);
  rep(i,n+1) comb[i].assign(n+1,1);

  for(int i=2;i<=n;++i){
    for(int j=1;j<i;++j){
      comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
    }
  }
}
template <typename X>
struct RLE{
  vector<X> array;
  int n;
  vector<X> key;
  vector<int> value;
  
  RLE(vector<X> _array){
    array = _array;
    n = array.size();
  }

  vector<int> compress(){
    vector<int> res(0);
    int cnt = 1;
    key.push_back(array[0]);    
    rep(i,n-1){
      if(array[i]==array[i+1]){
	cnt++;
      }
      else{
	res.push_back(cnt);
	cnt = 1;
	key.push_back(array[i+1]);
      }
    }
    res.push_back(cnt);
    value = res;
    return res;
  }
  
};
bool comp(double &a,double &b) {return a>b;}
int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  vector<double> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(), v.end(),comp);
  double res = 0;
  rep(i,a) res += v[i];
  double aa = a;
  res /= aa;
  printf("%.7f\n", res);
  
  RLE<double> rle(v);
  vector<int> val = rle.compress();
  
  int cnt = val[0];
  int index = 0;
  while(cnt<a){
    index++;
    cnt += val[index];
  }
  if(index == 0){
    int m = val[index];
    pascal(m);
    ll ans = 0;
    for(int i=a;i<=min(b,m);++i) ans += comb[m][i];
    cout << ans << "\n";
  }
  else{
    cnt -= val[index];
    pascal(val[index]);
    cout << comb[val[index]][a-cnt] << "\n";
  }

  
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()

    def is_ok(l1, l2, l3):
        if A[l2] < A[l1] + A[l3]:
            return True
        else:
            return False

    def binary_search_meguru(l1, l2):
        ng = l1
        ok = l2
        while abs(ok - ng) > 1:
            mid = ng + (ok - ng) // 2
            if is_ok(l1, l2, mid):
                ok = mid
            else:
                ng = mid
        return ok

    ans = 0
    for l1 in range(N):
        for l2 in range(l1+1, N):
            # l2 を最大辺とする
            ans += l2 - binary_search_meguru(l1, l2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47336
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  int m = in();
  vector<ll> poses(n,-1);
  vvector<pii> edges(n);
  vector<int> in_edges(n,0);
  rep(i,m){
    int a = in()-1;
    int b = in()-1;
    ll c = in();
    ++in_edges[b];
    edges[a].emplace_back(b,c);
  }
  bool flag = [&](){
                stack<int> st;
                rep(i,n)if(!in_edges[i]){
                  poses[i] = 0;
                  st.push(i);
                }
                while(st.size()){
                  int d = st.top();
                  st.pop();
                  foreach(i,edges[d]){
                    if(poses[i.first]==-1){
                      poses[i.first] = poses[d] + i.second;
                      if(!(--in_edges[i.first]))st.push(i.first);
                      continue;
                    }
                    if(poses[i.first] != poses[d] + i.second)return false;
                    if(!(--in_edges[i.first]))st.push(i.first);
                  }
                }
                foreach(i,poses)if(i==-1)return false;
                return true;
              }();
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 7168
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
using namespace std;

const int N = 2e5 + 10;
string s[N];
int a[N];
int n;

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

	sort(s, s + n);

	int mmax = -1;
	int t = 1;
	a[0] = 1;
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i-1]) {
			t++;
		}
		else {
			a[i - 1] = t;
			mmax = max(mmax, t);
			t = 1;
		}
	}
	mmax = max(mmax, t);
	a[n - 1] = t;

	for (int i = 0; i < n; i++) {
		if (a[i] == mmax) {
			cout << s[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 15104
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    GVI(a,N);
    int ans=1<<28;
    FORIN(x,-100,101){
        int c=0;
        FOR(i,N){
            c+=(a[i]-x)*(a[i]-x);
        }
        if(ans>c)ans=c;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long k;
    cin>>n>>k;
    vector<pair<int,int>> pa(n);
    for(int i = 0; i < n; i++)
        cin>>pa[i].first>>pa[i].second;
    sort(pa.begin(),pa.end(),[](auto x,auto y){return x.first<y.first;});
    long sum = 0;
    for(auto x:pa){
        sum += x.second;
        if(k<=sum){
            cout<<x.first;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

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

	static class CSubarraySum {
		PrintWriter out;
		InputReader in;

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int t, i, j, tt, k;
			this.out = out;
			this.in = in;
			int n = in.nextInt();
			k = in.nextInt();
			int s = in.nextInt();
			int x = s + 1;
			if (x > 1000000000)
				x = s - 1;
			int a[] = new int[n];
			for (i = 0; i < k; i++) {
				a[i] = s;
			}
			for (i = k; i < n; i++) {
				a[i] = x;
			}
			for (i = 0; i < n; i++) {
				p(a[i]);
			}
			pn("");
		}

		void pn(String zx) {
			out.println(zx);
		}

		void p(int zx) {
			out.print(zx + " ");
		}

	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1) {
				throw new UnknownError();
			}
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new UnknownError();
				}
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

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

		public String next() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuffer res = new StringBuffer();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

	}
}



Measured memory_bytes: 37808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        if (N <= 999)
        {
            Console.WriteLine($"ABC");
        }
        else
        {
            Console.WriteLine($"ABD");
        }

    }
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; 
	string ret;
	for (int i=0; i<3; i++)
		cin>>s,ret+=s.front();
	cout<<ret<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 25
#define NIL -1

struct Node{
  int right;
  int left;
  int parent;
};

struct Node T[N];
int n;

void preorder(int u){
  if(u==NIL) return;
  printf(" %d",u);
  preorder(T[u].left);
  preorder(T[u].right);
}

void inorder(int u){
  if(u==NIL) return;
  inorder(T[u].left);
  printf(" %d",u);
  inorder(T[u].right);
}

void postorder(int u){
  if(u==NIL) return;
  postorder(T[u].left);
  postorder(T[u].right);
  printf(" %d",u);
}


int main(){
  int i,id,l,r,root;
  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].parent=NIL;
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    T[id].left=l;
    T[id].right=r;
    if(l!=NIL) T[l].parent=id;
    if(r!=NIL) T[r].parent=id;
  }

  for(i=0;i<n;i++) if(T[i].parent==NIL) root=i;
  
  printf("Preorder\n");
  preorder(root);
  printf("\nInorder\n");
  inorder(root);
  printf("\nPostorder\n");
  postorder(root);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2140
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define DEBUG_PRINT(var) std::cout<<#var<<" = " << var << std::endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef long double ld;


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

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

	ll A;
	cin >> A;
	ld B;
	cin >> B;
	
	//ll ans = round(A * 100*B / 100);
	//cout << ans << endl;
  
    ll b = round(B*100);
    ll ans = A*b / 100;
  	cout << ans << endl;

}


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

main() {
  int N, C, K; cin >> N >> C >> K;
  int T[N]; rep(i, N) cin >> T[i];

  sort(T, T + N);
  int pos = 0, ans = 0;
  while (pos < N) {
    ans++;
    rep(i, C) {
      if (pos + i >= N || T[pos + i] > T[pos] + K) {
        pos += i;
        break;
      }
      if (i == C - 1) pos += C;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include <cmath>
using namespace std;
int N;
vector<int> v;
int main() {    
    cin >> N;
    int score, odd=0, even=0;
    for(int i=0; i<N; ++i){
        cin >> score;
        v.push_back(score);
    }
    sort(v.begin(), v.end());
    for(int i=0; i<N; ++i){
        if(i%2==0) even+=v[i];
        if(i%2==1) odd+=v[i];
    }
    cout << abs(even-odd) << endl;
            
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long
int main(void){
  int N;
  ll power = 1;
  scanf("%d", &N);
  for (ll i = 1; i < N + 1; i++) {
    power *= i;
    power%=1000000007;
  }
  printf("%lld\n", power);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

        String[] a = scanner.nextLine().split(" ");
        int N = Integer.parseInt(a[0]);
        int K = Integer.parseInt(a[1]);

        System.out.println((N - 1 + K - 2) / (K - 1));
    }
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  return str.find(c) != string::npos;
}
*/


int main() {
  int n, m;
  cin >> n >> m;
  vector<int> food(m, 0);
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      int a;
      cin >> a;
      ++food[a - 1];
    }
  }
  cout << count(food.begin(), food.end(), n) << endl;
}


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

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator - () {
		x = (-x % Mod + Mod) % Mod;
	}
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator ++ () {
		*this += 1;
	}
	void operator ++(int) {
		operator++();
	}
	void operator -= (const mll& a) {
		if ((x += Mod - a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	mll operator + (const mll& a) const {
		mll ans = *this;
		ans += a;
		return ans;
	}
	mll operator - (const mll& a) const {
		mll ans = *this;
		ans -= a;
		return ans;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
	bool operator < (const mll& a) {
		return this->x < a.x;
	}
	void pow(long long n) {
		long long xx = x;
		x = 1;
		while (n > 0) {
			if (n & 1) x = x * xx % Mod;
			xx = xx * xx % Mod;
			n >>= 1;
		}
	}
	mll inv() {
		long long a = x, b = Mod, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= Mod;
		if (u < 0) u += Mod;
		a = u;
		return mll(a);
	}
};
int main() {
	int N;
	cin >> N;
	int ZeroZero = 0;
	map<pair<long long, long long>, pair<int, int>> Nums;
	for (int i = 0; i < N; i++) {
		long long A, B;
		cin >> A >> B;
		if (A == 0 && B == 0) {
			ZeroZero++;
			continue;
		}
		if (A != 0 && B != 0) {
			if (B < 0) {
				A *= -1;
				B *= -1;
			}
			long long G = gcd(A, B);
			A /= G;
			B /= G;
			if (A > 0) Nums[{A, B}].first++;
			else Nums[{B, -A}].second++;
		}
		else {
			if (A == 0) Nums[{0, 1}].first++;
			else Nums[{0, 1}].second++;
		}
	}
	mll ans = 1;
	for (auto& p : Nums) {
		mll a = 2, b = 2;
		a.pow(p.second.first);
		b.pow(p.second.second);
		a += b;
		a += -1;
		ans *= a;
	}
	ans += ZeroZero-1;
	cout << ans.x << endl;
}

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

int main(){
    //入力
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string S="";
    for(int i=0;i<ty-sy;i++){
        S+='U';
    }
    for(int i=0;i<tx-sx;i++){
        S+='R';
    }
    for(int i=0;i<ty-sy;i++){
        S+='D';
    }
    for(int i=0;i<tx-sx+1;i++){
        S+='L';
    }
    for(int i=0;i<ty-sy+1;i++){
        S+='U';
    }
    for(int i=0;i<tx-sx+1;i++){
        S+='R';
    }
    S+="DR";
    for(int i=0;i<ty-sy+1;i++){
        S+='D';
    }
    for(int i=0;i<tx-sx+1;i++){
        S+='L';
    }
    S+='U';

    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define INT_MAX LONG_MAX
const int64_t N = 405;
int64_t dp[N][N];
int64_t prefix[N];

int32_t main() {
	int n , i , j , k, l;
	cin >> n;
	int a[n+1];
	for(i=1;i<=n;i++) 
	    cin >> a[i];
	for(i=1;i<n;i++) {
	    dp[i][i] = 0;
	}
	for(i=1;i<=n;i++)
	    prefix[i] = prefix[i-1] + a[i];
	for(l=2;l<=n;l++) {
		for(i=1;i<=n-l+1;++i) {
			j = i+l-1;
			dp[i][j] = INT_MAX;
			for(k=i;k<j;k++) {
				dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k+1][j] + prefix[j] - prefix[i-1]);
			}
		}
	}
	cout << dp[1][n] << endl;
	// for(i=1;i<=n;i++) {
	// 	for(j=1;j<=n;j++) {
	// 		cout << dp[i][j] << ' ' ;
	// 	}
	// 	cout << endl;
	// }
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>

int main()
{
	int N = 0, M = 0;
	std::cin >> N >> M;

	int p;
	std::string S;
	std::vector<std::pair<bool, int>> c(N);
	for (int i = 0; i < N; i++)
	{
		c[i].first = false;
		c[i].second = 0;
	}

	std::pair<int, int>ans;
	for (int i = 0; i < M; i++)
	{
		std::cin >> p >> S;
		if (c[p - 1].first) continue;
		if (S == "AC")
		{
			c[p - 1].first = true; 
			ans.first++;
		}
		else if (S == "WA") c[p - 1].second++;
	}

	for (int i = 0; i < N; i++)
	{
		if(c[i].first) ans.second += c[i].second;
	}

	std::cout << ans.first << " " << ans.second << std::endl;

	return 0;
}

Measured memory_bytes: 1024
def main():
    n = int(input())

    if n == 0:
        print(0)
        exit()

    ans = ''
    while n != 0:
        if n % (-2) == 0:
            ans = '0' + ans
        else:
            n -= 1
            ans = '1' + ans

        n /= (-2)

    print(ans)

if __name__ == "__main__":
    main()


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

int main() {

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

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, x; cin >> N >> x;
    vector<int> A(N); REP(i, N) cin >> A[i];
    SORT(A);
    int ans = 0;
    REP(i, N) {
        if (A[i] > x) {
            cout << ans << "\n";
            return 0;
        }
        x -= A[i];
        ans++;
    }
    if (x > 0) {
        ans--;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
using namespace std;

ll fastExp(ll base, ll exp)
{
	ll result = 1;
	while(exp > 0)
	{
		if(exp % 2 == 1)
			result = result * base;
		base = base * base;
		exp /= 2;
	}
	return result;
}

int main()
{
    ll n, k;
    cin >> n >> k;

    ll ans = k * fastExp(k - 1, n - 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] s = new String[N];
        int[] t = new int[N];
        for(int n=0; n<N; n++){
            s[n]=sc.next();
            t[n]=sc.nextInt();
        }
        String X = sc.next();

        boolean sleep = false;
        int ans = 0;
        for(int n=0; n<N; n++){
            if(sleep) ans += t[n];
            if(X.equals(s[n])) sleep = true;
        }
        System.out.println(ans);
    }

}


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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

vector<int> nums;
int ans[200009];

int main() {
    int N;
    cin >> N;
    
    rep(i,N){
        int x; cin >> x;
        nums.push_back(x);
    }
    
    pair<int,int> now={1,1},nxt={N,-1};
    rrep(i,N-1){
        ans[now.first] = nums[i];
        //cout2(now.first,nums[i]);
        now.first += now.second;
        swap(now,nxt);
    }
    
    rep1(i,N){
        if(i>1) cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
}


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

using namespace std;

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

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

    bool IsA = false;
    bool IsB = false;
    rep(i, 0, S.length())
    {
        if (S[i] == 'A') IsA = true;
        if (S[i] == 'B') IsB = true;
    }
    if (IsA && IsB) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    int t,n,k,q;
    cin >> n >> k >> q;
    int arr[n+1] = {0};
    for(int i = 0; i < q; i++){
        cin >> t;
        arr[t]++;
    }
    for(int i = 1; i < n+1; i++){
        arr[i] = arr[i] + k - q;
        if(arr[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
}

Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}

int B[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int A[200000];
	rep(i, N) A[i] = getint();

	rep(i, N) if (i + A[i] < N) B[i + A[i]]++;

	ll kotae = 0;
	rep(i, N) if (i - A[i] >= 0) kotae += B[i - A[i]];

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;
int MX = 1500005;

vector<int> count(int p,vector<int> A){
    vector<int> res(MX,0);
    rep(i,p){
        int a = 0;
        for(int j=i;j<p;j++){
            a += A[j];
            ++res[a];
        }
    }
    return res;
}

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0 && m==0) break;
        ll ans = 0;
        vector<int> a(n),b(m);
        rep(i,n) cin >> a[i];
        rep(i,m) cin >> b[i];
        vector<int> V = count(n,a);
        vector<int> H = count(m,b);
        rep(i,MX){
            ans += V[i] * H[i];
        }
        cout << ans << endl;

    }
    return 0;
}


Measured memory_bytes: 14560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  string s, t;
  cin >> n >> s >> t;
  ll ans = n * 2;
  rep2(i, 1, n + 1) {
    bool ok = true;
    rep(j, i) if(s[n - i + j] != t[j]) ok = false;
    if(ok) ans = 2 * n - i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


//System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
    	try {
	    	FastScannerMain1 sc = new FastScannerMain1(System.in);
	        int N = sc.nextInt();
	        int K = sc.nextInt();

	        String base32 = Integer.toString(N, K);
	        System.out.println(base32.length());

    	}catch(Exception e) {
    		e.printStackTrace();
    	}

    }
}


//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

int main(){
    int m,d,ans=0;
    cin>>m>>d;
    for(int i=1;i<=d;i++){
        int a=i%10,b=i/10;
        if(a>=2&&b>=2&&a*b<=m) ans++;
    }
    cout<<ans;
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	for (auto &i : s) i -= '0';
	int n = s.size();
	int num = ri();
	int dp[n + 1][num + 1][2];
	memset(dp, 0, sizeof(dp));
	dp[0][0][1] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= num; j++) {
			for (int k = 0; k < 2; k++) {
				for (int l = 0; l <= (k ? s[i] : 9); l++) {
					if (l && j == num) continue;
					int &target = dp[i + 1][j + !!l][k && l == s[i]];
					target += dp[i][j][k];
				}
			}
		}
	}
	printf("%d\n", dp[n][num][0] + dp[n][num][1]); 
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;


int main(){
in n,a,b;
  cin>>n>>a>>b;
vector<in> x(0);
  
  //in ans =1;
  if((a-b)%2ll==0ll){
    //if(a>b) x.push_back((a-b)/2ll);
  x.push_back((b-a)/2ll);
    //ans ++;
  }

  else{
    in ans =0ll;
  //min--1
  in aa,bb;
  aa =a;
  bb=b;
  ans +=(a-1ll);
  aa =1ll;
  bb -= (a-1ll);
  ans +=1ll;
  bb --;
  x.push_back((bb-aa)/2ll+ans);
  
    
  //max--2
  ans =0ll;
  ans += (n-b);
    a += (n-b);
  a ++;
  b=n;
  ans ++;
  x.push_back((b-a)/2ll+ans);
  }
  
    
    /*x.push_back(n-abmin);
  x.push_back(abmax-1);*/
  sort(all(x));
  cout<<x.at(0)<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string, core.stdc.stdlib;

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp.map!(c => c.to!int).array;

    S.uniq.array.length.writeln;
}


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

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

void Main() {
  int N; cin >> N;
  vector<int> b(N);
  rep(i, 0, N) cin >> b[i];
  vector<int> v;
  while(true){
    for(int i = b.size() - 1; i >= 0; i--){
      if(b[i] == i + 1){
        v.push_back(b[i]);
        b.erase(b.begin() + i);
        break;
      }
      if(i == 0){
        cout << -1 << endl;
        return;
      }
    }
    if(b.size() == 0) break;
  }
  for(int i = N - 1;  i >= 0; i--){
    cout << v[i] << endl;
  }
}

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

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

  Main();
}


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

int main() {
	int M = 2147483646;
	int H,W,K;
	cin >> H >> W >> K;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	char* s = new char[W + 1];
	vector<vector<int> > P(H+2, vector<int>(W+2, -1));
	for (int i = 1; i <= H; i++) {
		cin >> s;
		for (int j = 1; j <= W; j++) {
			if (s[j-1] == 64) {
				P[i][j] = -1;
			}
			else {
				P[i][j] = M;
			}
		}
	}

//	for (int i = 0; i < H + 2; i++) {
//		cout << "::::";
//		for (int j = 0; j < W + 2; j++) {
//			if (P[i][j] == M) cout << ".";
//			else if (P[i][j] == -1) cout << "@";
//			else cout << P[i][j];
//		}
//		cout << endl;
//	}



	vector<int> dx = { 1,0,-1,0 };
	vector<int> dy = { 0,1,0,-1 };
	vector<int> b = { 2,3,0,1 };

	// start
	deque<pair<pair<int,int>, int> > Q;
	Q.push_back(pair<pair<int,int>, int>(pair<int,int>(x1, y1),-1));
	P[x1][y1] = 0;
	while (!Q.empty()) {
		pair<pair<int, int>,int> qq = *Q.begin();
		pair<int, int> q = qq.first;
		Q.pop_front();
		int c = P[q.first][q.second] + 1;
		for (int d = 0; d < 4; d++) {
			if (qq.second == b[d]) continue;
			for (int i = 1; i <= K; i++) {
				if (P[q.first + dx[d] * i][q.second + dy[d] * i] == -1) break;
				if (c < P[q.first + dx[d] * i][q.second + dy[d] * i]) {
					P[q.first + dx[d] * i][q.second + dy[d] * i] = c;
					Q.push_back(pair<pair<int, int>, int>(pair<int,int>(q.first + dx[d] * i, q.second + dy[d] * i),d));
				}
			}
		}
		if (P[x2][y2] < M) {
			cout << P[x2][y2] << endl;
			return(0);
		}

		/*
		for (int i = 0; i < H + 2; i++) {
			cout << "::::";
			for (int j = 0; j < W + 2; j++) {
				if (P[i][j] == M) cout << ".";
				else if (P[i][j] == -1) cout << "@";
				else cout << P[i][j];
			}
			cout << endl;
		}
		*/


	}
	cout << -1 << endl;
	return(0);
}


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

int main() {
  int x, i;
  i = 1;
  while (1) {
    cin >> x;
    if (x == 0) {
      break;
    }
    cout << "Case " << i << ": " << x << endl;
    i++;
  }
}


Measured memory_bytes: 3000