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

int main() {
	// your code goes here
int a,b,c;
cin>>a>>b>>c;
if (a<=b){
  if(a<=c){
    if(b<=c){
      cout<<a<<" "<<b<<" "<<c<<endl;
    }else{
      cout<<a<<" "<<c<<" "<<b<<endl;
    }	
  }else{
  	cout<<c<<" "<<a<<" "<<b<<endl;
  }
 }else{
 	if(b<=c){
  	if(a<=c){
  	   cout<<b<<" "<<a<<" "<<c<<endl;	
  	}else{
  	   cout<<b<<" "<<c<<" "<<a<<endl;
  	}
  }else{
  	cout<<c<<" "<<b<<" "<<a<<endl;
  }
}
}

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = sc.nextInt();

        long ans = 0;

        Arrays.sort(a);

        Map<Long, Long> map = new HashMap<>();

        for (int i=0; i<n; i++){
            if (map.containsKey(a[i])){
                long c = map.get(a[i]);
                map.put(a[i], ++c);
            }else {
                map.put(a[i], 1l);
            }
        }

//        for (Long key: map.keySet()){
//            if (key!=map.get(key)){
//                if (key<map.get(key)){
//                    ans += (map.get(key)-key);
//                }else if (key>map.get(key)){
//                    ans += map.get(key);
//                }
//            }
//        }

        for (Long key: map.keySet()){
            if (key!=map.get(key) && key<map.get(key)){
                    ans += (map.get(key)-key); }
                    else if (key!=map.get(key) && key>map.get(key)){
                    ans += map.get(key);
                }else if (key!=map.get(key) && key==map.get(key)){
                return;
            }
            }


//        System.out.println(map);
        System.out.println(ans);

    }
}


Measured memory_bytes: 56712
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    int n;
    cin>>n;
    string s[n];
    rep0(i,n){
        cin>>s[i];
    }
    int ba=0;
    int a=0;
    int b=0;
    int ans=0;
    rep0(i,n){
        int k=s[i].size();
        if(s[i][0]=='B') b++;
        if(s[i][k-1]=='A') a++;
        if(s[i][0]=='B'&&s[i][k-1]=='A') ba++;
        rep0(j,k-1){
            if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
        }
    }
    int bba=min(a,b);
    if(a==ba&&b==ba&&ba>0) ans+=(ba-1);
    else ans+=bba;
    cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 768
/*  ex3_4
    B30095    */
#include <stdio.h>
 
int main(void){
    int num;
    int condition = 0; // is num a product of integers between 1 and 9
    scanf("%d", &num);
    
    if(1 <= num && num <= 81){  // num can not be less than 1(1*1) or greater than 81(9*9) 
        for (int i = 1; i <= 9; i++){
            int quotient = num / i;
            int remainder = num % i;
            if((1 <= quotient && quotient <= 9) && (remainder == 0))
                condition = 1;
        }
    }
 
    if(condition) 
        printf("Yes");
    else 
        printf("No");
 
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var n2 = n / 2;
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		if (n % 2 == 0)
		{
			long M = a.Where((x, i) => i % 2 == 1).Sum(x => (long)x), t = M;
			for (int i = 0; i < n2; i++)
				M = Math.Max(M, t += a[2 * i] - a[2 * i + 1]);
			Console.WriteLine(M);
		}
		else
		{
			var dp = new long[n2 + 1, 3];
			for (int i = 1; i <= n2; i++)
				for (int j = 0; j < 3; j++)
					dp[i, j] = -1L << 60;

			for (int i = 0; i < n2; i++)
				for (int j = 0; j < 3; j++)
					for (int k = j; k < 3; k++)
						dp[i + 1, k] = Math.Max(dp[i + 1, k], dp[i, j] + a[2 * i + k]);
			Console.WriteLine(Enumerable.Range(0, 3).Max(j => dp[n2, j]));
		}
	}
}


Measured memory_bytes: 49168
#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() {
  ll h, w;
  cin >> h >> w;
  ll ans = h * w;
  if (h == 1 || w == 1)
    cout << 1 << endl;
  else
    cout << (ans + 1) / 2 << 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: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int a, b;
  cin >> a >> b;

  if(b>=a){
    prt("unsafe");
  } else {
    prt("safe");
  }
}


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

int main() {
  int N = 0;
  cin >> N;

  int cnt = 0;
  int d1 = 0;
  int d2 = 0;
  while( N-- > 0 ) {
    cin >> d1 >> d2;
    if( d1 == d2 ) {
      if( ++cnt == 3 ) {
        cout << "Yes";
        return 0;
      }
    } else {
      cnt = 0;
    }
  }
  cout << "No";
  return 0;
}

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

using namespace std;

long long a[100004];

int main() {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr);

    int k;
    cin >> k;

    for(int i = 0; i < k; ++i)
        cin >> a[i];

    if(a[k - 1] != 2) {
        cout << -1; return 0;
    }
    long long mn = 2;
    long long mx = 3;

    for (int i = k - 2; i >= 0; --i) {
        mx = mx + a[i] - (mx % a[i]) - 1;
        if (mn > mn - mn % a[i])
            mn = mn + a[i] - mn % a[i];
    }

    long long  d1 = mn, d2 = mx;

    for (int i = 0; i < k; ++i) {
        d1 = d1 - (d1 % a[i]);
        d2 = d2 - (d2 % a[i]);
    }

    if (d1 != 2) {
        cout << -1;
    } else {
        if (d2 == 2) {
            cout << mn << " " << mx;
        } else {
            cout << -1;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int n=s.length()+1;
  vector<ll> runlength;
  char c='<';
  int now=0;
  REP(i,n-1){
    if(c==s[i]){
      now++;
    }else{
      runlength.push_back(now);
      now=1;
      if(c=='<'){
        c='>';
      }else{
        c='<';
      }
    }
  }
  if(now!=0){
    runlength.push_back(now);
  }
  if(c=='<'){
    runlength.push_back(0);
  }
  ll ans=0;
  REP(i,runlength.size()/2){
    ll ma=max(runlength[2*i],runlength[2*i+1]);
    ll mi=min(runlength[2*i],runlength[2*i+1]);
    ans+=ma*(ma+1)/2+(mi-1)*mi/2;
  }
  cout<<ans<<endl;
}


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

const int N = 105;

int n, k, ans;
int x[N];

int main() {
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; ++i) {
		scanf("%d", x + i);
	}
	for(int i = 0; i < n; ++i) {
		ans += (min(x[i] - 0, k - x[i]) * 2);
	}
	printf("%d\n", ans);
}

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

int main(){
  int n,u,k,v;
  int data[N][N];
  cin >> n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      data[i][j] = 0;
    }
  }
  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      data[u][v] = 1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j>0) cout << " ";
      cout << data[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3152
import queue

n = int(input())

adj = [ [] for _ in range (n) ]

for i in range(n):
    _, _, *adj[i] = list(map(int, input().split()))

q = queue.Queue()

d = [-1] * n
flag = [0] * n

q.put(1)
d[0] = 0
flag[0] = 1

while not q.empty():
    u = q.get()

    for v in adj[u-1]:
        if flag[v-1] == 0:
            flag[v-1] = 1
            d[v-1] = d[u-1] + 1
            q.put(v)

for i in range(n):
    print(i+1, d[i]) 



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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int a, b, c;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

	cin >> a >>b >> c;
	cout << c << ' ' << a << ' ' << b << endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] num = str.split("\\s");
		int a = Integer.parseInt(num[0]);
		int b = Integer.parseInt(num[1]);
		System.out.println(a * b + " " + (2 * a + 2 * b));
	}
}

Measured memory_bytes: 24368
n=int(input())

s=input() 

ans = 0

for i in range(1000):
    count = 0
    i = str(i)
    i = (3-len(i))*'0'+i
    for j in range(n):
        if i[count] == s[j]:
            count += 1
        if count == 3:
            break
    if count == 3:
        ans += 1
print(ans)

Measured memory_bytes: 41068
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int main(){
    long long int N;
    cin>>N;
    int x=(N/500);
    N-=x*500;
    x=x*1000;
    x+=(N/5)*5;
    cout<<x<<endl;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  
  if(a==b&&b==c){
    cout << 1 << endl;
  }
  
  else if(a==b||b==c||c==a){
    cout << 2 << endl;
  }
  
  else{
    cout << 3 << endl;
  }
}


Measured memory_bytes: 256
N=int(input())
S=[]
for _ in range(N):
  S.append(input())
  
import collections

c=collections.Counter(S)
vl=list(c.values())
mv=max(vl)

ans=[]
cc=list(c.items())
cc.sort(key=lambda x:x[1], reverse=True)

for k, v in cc:
  if v==mv:
    ans.append(k)
  else:
    break
ans.sort()
[print(a) for a in ans]
  

Measured memory_bytes: 50436
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i
cnt = 0
0.upto(A) do |i|
  0.upto(B) do |j|
    t = X - 500 * i - 100 * j
    if 0 <= t && t <= 50 * C
      cnt += 1
    end
  end
end

puts cnt

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=1e9+7;
//
int main(){
	int n;
	vector<pair<long long,long long> > c;
	cin>>n;
	for(int i=0;i<n;i++){
		long long a,b;
		cin>>a>>b;
		c.push_back(make_pair(b,a));
	}
	sort(c.begin(),c.end());
	long long now=0;
	for(int i=0;i<n;i++){
		if(now+c[i].second>c[i].first){
			cout<<"No"<<endl;
			return 0;
		}else{
			now+=c[i].second;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int a, p; cin >> a >> p;
  cout << (3*a+p)/2 << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = min(a, k);
  k -= ans;
  if(k > b) {
    ans -= k-b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n,m,ans=0;
  cin>>n;
  vll a(101);
  vector<pair<string, ll>> sp(n);
  for (ll i=0;i<n;i++) {
    cin>>sp[i].first>>sp[i].second;
    
    sp[i].second=-sp[i].second+100;
    a[sp[i].second]=i+1;
  }
  
  sort(sp.begin(),sp.end());
  
  for (ll i=0;i<n;i++) {
    cout<<a[sp[i].second]<<endl;
  }
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
// int dx[]={0,1,0,-1,1,1,-1,-1};
// int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int dx[]={-1,-1,0,0,1,1};
int dy[]={-1,0,-1,1,0,1};//RDLU
//nCr mod m
#define MOD 998244353
#define M 1000100
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int main(){
	ll n,m;
	cin>>n>>m;
	if(n>m)swap(n,m);
	ll out=m*nCr(n+m,n)%MOD;
	rep(i,n)(out+=nCr(2*i+m-n,i)*nCr(2*n-1-2*i,n-i)%MOD)%=MOD;
	cout<<out*powmod(nCr(n+m,n),MOD-2)%MOD<<endl;
}







Measured memory_bytes: 8192
# coding: utf-8
# Your code here!

def partition(A,p,r):
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j] <= x:
            i = i + 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i + 1
n = int(input())
A = [int(e) for e in input().split()]
b = partition(A,0,n-1)
A[b] = f"[{A[b]}]"
print(*A)


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

#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define eb emplace_back
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;

void run() {
    int n;
    cin >> n;
    vector<int> ara(n), dp(n, 1e9);
    
    for (auto& i : ara) {
        cin >> i;
    } 
    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < i+3 && j < n; ++j) {
            dp[j] = min(dp[j], dp[i]+ abs(ara[i] - ara[j])); 
        }
    }
    cout << dp[n-1] << endl;
}

int main() 
{
    IO;
    double st = clock();
    run();
    cerr << "\n" << "time = " << (clock() - st) / CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }

    ll ans = 1;
    ll flag = 0;
    for(ll i=1;i<n;++i){
        if(flag == 0){
            if(a[i-1] > a[i]){
                flag = 1;
            }else if(a[i-1] == a[i]){
                flag = 0;
            }else if(a[i-1] < a[i]){
                flag = 3;
            }
        }else if(flag == 1){
            if(a[i-1] >= a[i]){
                continue;
            }else{
                ans++;
                flag = 0;
            }
        }else if(flag == 3){
            if(a[i-1] > a[i]){
                ans++;
                flag = 0;
            }else{
                continue;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			Scanner stdin = new Scanner(System.in);	
			int a=stdin.nextInt();
			int b=stdin.nextInt();
			int x=stdin.nextInt();
			if(x-a>=0&&x-a<b) {
				System.out.println("YES");
			}else {
				System.out.println("NO");

			}


		// TODO 自動生成されたメソッド・スタブ

	}

}


Measured memory_bytes: 21972
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
char s[100010];
int t[100010];
int main(){
	scanf("%s",s+1);
	if(s[1]==s[2]&&s[2]==s[3]){
		puts("Yes");
		exit(0);
	}
	if(s[2]==s[3]&&s[3]==s[4]){
		puts("Yes");
		exit(0);
	}
	puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;cin >> S;
    int res=S.size();
    for(int i=0;i+1<S.size();++i) {
        if(S[i]==S[i + 1]) --res,i+=2;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> t(n+1),x(n+1),y(n+1);
    t[0]=0,x[0]=0,y[0]=0;
    for(int i=1;i<=n;i++){
        cin >> t[i] >> x[i] >> y[i];
        int dist = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        int tim = t[i]-t[i-1];
        if(tim-dist<0||(tim-dist)%2==1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
function main(input) {
    var N = input[0].split(" ")[0]-0;
    var sum = 0;
    var list = input[1].split(" ").map(v=>{
        sum += v-0;
        return v-0;
    });
    var tmpsum = 0;
    var ans = Number.MAX_SAFE_INTEGER;
    for(var i=0;i<N-1;i++){
        tmpsum+=list[i];
        ans = Math.min(Math.abs(tmpsum-(sum-tmpsum)),ans);
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 34624
n,tl = map(int,input().split())
cost = []
time = []
cost2 = []
for i in range(n):
  c,t = map(int,input().split())
  cost.append(c)
  time.append(t)
for y,z in zip(cost,time):
  if z<=tl:
    cost2.append(y)    
print("TLE" if min(time)>tl else min(cost2))

Measured memory_bytes: 3064
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

int main(void) {

	int N = 0,X = 0, A[100] = { 0 };
	int ans = 0,min = INT_MAX;

	scanf("%d%d", &N, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		if (min > A[i])
			min = A[i];
		ans++;
		X -= A[i];
	}

	ans += X / min;

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
#define mp make_pair

int W, H;
int dist[30][30];
const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};

int main (int argc, char const* argv[]) {
  while (true) {
    cin >> W >> H;
    cin.ignore();
    if (W == 0 && H == 0) break;
    
    vector<string> wall(2 * H - 1);
    for (int i=0;i<2*H-1;i++) getline(cin, wall[i]);
    memset(dist, -1, sizeof dist);
    
    queue<pair<int,P> > que;
    que.push(mp(1,mp(0,0)));
    bool goal_flag = false;
    while (!que.empty()) {
      pair<int,P> p = que.front(); que.pop();
      int x = p.second.first;
      int y = p.second.second;
      int d = p.first;
      if (dist[y][x] != -1) continue;
      dist[y][x] = d;
      if (x == W-1 && y == H-1) {
        cout << d << endl;
        goal_flag = true;
        break;
      }
      // right
      if (x+1 < W && wall[2*y][2*x+1] == '0' && dist[y][x+1] == -1) {
        que.push(mp(d+1,mp(x+1,y)));
      }
      // down
      if (y+1 < H && wall[2*y+1][2*x] == '0' && dist[y+1][x] == -1) {
        que.push(mp(d+1,mp(x,y+1)));
      }
      // up
      if (y-1 >= 0 && wall[2*y-1][2*x] == '0' && dist[y-1][x] == -1) {
        que.push(mp(d+1,mp(x,y-1)));
      }
      // left
      if (x-1 >= 0 && wall[2*y][2*x-1] == '0' && dist[y][x-1] == -1) {
        que.push(mp(d+1,mp(x-1,y)));
      }
    }
    if (!goal_flag) {
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
open System

let N = stdin.ReadLine() |> int
let Ds = seq { for _ in 1..N do stdin.ReadLine().Split(' ') } |> Seq.toList

let judgeArray = List.map (fun (x:string []) -> x.[0] = x.[1]) Ds |> List.toArray

let solve = seq {for i in 0..(N-3) -> judgeArray.[i] && judgeArray.[i+1] && judgeArray.[i+2]} |> Seq.toList

match (List.tryFind id solve) with
| Some(x) -> printfn "%s" "Yes"
| None -> printfn "%s" "No"

Measured memory_bytes: 29852
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int a, b; cin >> a >> b;

    if(a%2 == b%2) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int[] x = new int[3];
	int t =sc.nextInt();
	ArrayList<String> s = new ArrayList<String>();
	for(int i=0; i<t; i++){
	    for(int j=0; j<3; j++)
		x[j]=sc.nextInt();
	    Arrays.sort(x);
	    if(x[0]*x[0]+x[1]*x[1]==x[2]*x[2])
		s.add("YES");
	    else
		s.add("NO");
	}
	for(int i=0; i<s.size(); i++)
	    System.out.println(s.get(i));
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x=1000;
	cin>>n;
	string ip;
	map<string,int> fr;
	for(int i=1;i<=n;i++)
	{
		cin>>ip;
		fr[ip]++;
	}
	cout<<"AC x "<<fr["AC"]<<endl;
	cout<<"WA x "<<fr["WA"]<<endl;
	cout<<"TLE x "<<fr["TLE"]<<endl;
	cout<<"RE x "<<fr["RE"]<<endl;
}

Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
// ref https://atcoder.jp/contests/abc126/submissions/5458290
struct Tree {
    n: usize,
    edges: Vec<Vec<(usize, i64)>>,
}
impl Tree {
    fn new(n: usize) -> Tree {
        Tree {
            n: n,
            edges: vec![vec![]; n],
        }
    }
    fn add_edge(&mut self, s: usize, t: usize, w: i64) {
        self.edges[s].push((t, w));
        self.edges[t].push((s, w));
    }
    fn dists(&self, i: usize) -> Vec<i64> {
        let mut res = vec![0; self.n];
        self.dists_sub(i, self.n, &mut res);
        res
    }
    fn dists_sub(&self, i: usize, prev: usize, res: &mut Vec<i64>) {
        for &(v, w) in &self.edges[i] {
            if v == prev {
                continue;
            }
            res[v] = res[i] + w;
            self.dists_sub(v, i, res);
        }
    }
}
fn main() {
    input!{
        n:usize,
        tree: [(usize1,usize1,i64);n-1],
    }
    let mut tr = Tree::new(n);
    for &(s,t,w) in &tree {
        //tree[i][0] -> tree[i][1]
        tr.add_edge(s,t,w);
    }
    let start = tr.dists(0);
    // println!("{:?}", start);
    let mut ans = vec![0;n];
    for i in 0..start.len() {
        if start[i]%2 == 0 {
            ans[i] = 1;
        }
    }
    for i in 0..n {
        println!("{}", ans[i]);
    }
}

Measured memory_bytes: 21884
# -*-*-*- coding: utf-8 -*-*-*-
member = int(input())
days, choco = map(int, input().split())
ans = choco

for i in range(member):
    num = int(input())
    if days % num == 0:
        ans -= 1
    ans += days // num + 1
#    print(i, 'day : eat = {} // {} = {:2}, ans = {:2}'.format(days, num, (days // num + 1), ans))

print(ans)


Measured memory_bytes: 3064
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int dp[3010][3010];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	string s, t;
	cin >> s >> t;
	for (int i = 1; i <= s.size(); ++i)
		for (int j = 1; j <= t.size(); ++j)
			dp[i][j] = max({dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] + (s[i - 1] == t[j - 1])});
	int n = s.size();
	int m = t.size();
	string ans;
	while (dp[n][m] > 0) {
		if (s[n - 1] == t[m - 1])
			ans += s[n - 1], --n, --m;
		else if (dp[n - 1][m] == dp[n][m])
			--n;
		else
			--m;
	}
	reverse(ALL(ans));
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 35584
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

h = [  abs(a - (t - i*.006)) for i in h]

mins = h[0]
index = 0
for i in range(1, n):
  if h[i] < mins:
    mins = h[i]
    index = i
    
print((index+1))

Measured memory_bytes: 3064
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int n, power[14];
void solve(int x, int v, string S) {
	if (v == n) { reverse(S.begin(), S.end()); printf("%s\n", S.c_str()); return; }
	if (x == 14) return;
	solve(x + 1, v - power[x], S + '-');
	solve(x + 1, v, S + '0');
	solve(x + 1, v + power[x], S + '+');
}
int main() {
	power[0] = 1;
	for (int i = 1; i < 14; i++) power[i] = power[i - 1] * 3;
	scanf("%d", &n); solve(0, 0, "");
	return 0;
}

Measured memory_bytes: 3264
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 305
#define P 998244353
#define G 3
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define fuck printf("FUCK!!\n");
using namespace std;

int n, m, ans, a[MAXN], f[MAXN][MAXN*MAXN];

inline int add(int x, int y) {return x+y>=P?x+y-P:x+y;}
inline int sub(int x, int y) {return x>=y?x-y:x-y+P;}

inline int ksm(int x, int y)
{
    int ans=1;
    while(y)
    {
        if(y&1) ans=1LL*x*ans%P;
        x=1LL*x*x%P, y>>=1;
    }
    return ans;
}

int main()
{
    scanf("%d", &n);
    for(rint i=1; i<=n; ++i)
    {
        scanf("%d", &a[i]);
        m+=a[i];
    }
    ans=ksm(3, n);
    f[0][0]=1;
    for(rint i=1; i<=n; ++i)
    {
        for(rint j=0; j<a[i]; ++j) f[i][j]=2LL*f[i-1][j]%P;
        for(rint j=a[i]; j<=m; ++j) f[i][j]=(f[i-1][j-a[i]]+2LL*f[i-1][j])%P;
    }
    for(rint i=(m+1)/2; i<=m; ++i) ans=sub(ans, 3LL*f[n][i]%P);
    if(m%2==0)
    {
        memset(f, 0, sizeof(f));
        f[0][0]=1;
        for(rint i=1; i<=n; ++i)
        {
            for(rint j=0; j<a[i]; ++j) f[i][j]=f[i-1][j];
            for(rint j=a[i]; j<=m; ++j) f[i][j]=add(f[i-1][j-a[i]], f[i-1][j]);
        }
        ans=(ans+3LL*f[n][m/2])%P;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 111104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <functional>
using namespace std;

int main()
{
	int n,m;
	int min = 0;
	int max = 200000;

	cin >> n >> m;
	vector<vector<int>> gates;
	vector<int> pass;

	gates = vector<vector<int>>(m, vector<int>(2, 0));

	for(int i=0; i<m; i++){
		cin >> gates[i][0] >> gates[i][1];
		min = gates[i][0] > min ? gates[i][0] : min;
		max = gates[i][1] < max ? gates[i][1] : max;
	}

	// cout << min << "<->" << max << endl;

    if(max < min){
		cout << 0 << endl;
		return 0;
	}

    cout << max-min+1 << endl;

	return 0;
}


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

int main(){ 
  const int Nbits= 4;
  bitset<Nbits> bits;
  bits.set(); bits.reset(0);

  int a,b,ans;
  cin >> a >> b;
  bits.reset(a); bits.reset(b);

  for(int i=1; i<Nbits; i++){
    if(bits.test(i)) cout << i << endl;
  }
}

Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    char c; cin >> c;
    char next = c+1;
    cout << next << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
h, w= gets.strip.split.map(&:to_i)
ans = []

ans << 0 if h%3==0 || w%3==0
ans << h
ans << w
(1 .. h-1).each do |i|
  tmp = [w*i, (w/2)*(h-i)].min
  tmp2 = [w*i, ((w+1)/2)*(h-i)].max
  ans << tmp2 -tmp
end

(1 .. w-1).each do |i|
  tmp = [h*i, (h/2)*(w-i)].min
  tmp2 = [h*i, ((h+1)/2)*(w-i)].max
  ans << tmp2-tmp
end
puts ans.min


Measured memory_bytes: 3452
// abc156_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;

    int ans = 0;
    while (N > 0){
        N /= K;
        ans++;
    }
    print(ans);


    return 0;
}


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

int main() {
  // input
  int n, a, b;
  std::string input;
  std::cin >> n >> a >> b;
  std::cin >> input;
  
  // output
  int a_ = 0, b_ = 0;
  for (int i = 0; i < n; ++i) {
    switch (input[i]) {
    case 'a':
      if ((a_ + b_) < (a + b)) {
        std::cout << "Yes" << std::endl;
        ++a_;
      } else {
        std::cout << "No" << std::endl;
      }
      break;
      
    case 'b':
      if ((a_ + b_) < (a + b) && b_ < b) {
        std::cout << "Yes" << std::endl;
        ++b_;
      } else {
        std::cout << "No" << std::endl;
      }
      break;
      
    case 'c':
      std::cout << "No" << std::endl;
      break;
      
    default:
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    for( int i=0; i<k; i++)
    {
        if(x>=y)
        y=y*2;
        else if(y>=z)
        z=z*2;
        else 
z=z*2;
    }
    if(x<y && y<z)
    cout<<"Yes"<<"\n";
    else
    cout<<"No\n";
    return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  
  int S = 0;
  int T = 0;
  
  for (int i = 10000; i < A ; i++) {
    int a,b,c,d;
    a = i / 10000;
    b = (i % 10000 - i % 1000) / 1000;
    c = (i % 100 - i % 10) / 10;
    d = i % 10;
    
    if (a == d && b == c) {
      S++;
    }
    else {
      continue;
    }
    
  }
  for (int i = 10000; i <= B ; i++) {
    int a,b,c,d;
    a = i / 10000;
    b = (i % 10000 - i % 1000) / 1000;
    c = (i % 100 - i % 10) / 10;
    d = i % 10;
    
    if (a == d && b == c) {
      T++;
    }
    else {
      continue;
    }
    
  }
  cout << T - S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    string ss; cin>>ss;

    ll l = 0, r = n - 1;
    ll ans = 0;
    rep(i, n) {
        while (l < n && ss[l] == 'R') l++;
        while (r >= 0 && ss[r] == 'W') r--;
        if (l >= r) {
            ans = i;
            break;
        }
        l++; r--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3756
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
ll m = 1e9 + 7;

ll mulmod(ll a, ll b) {
    ll r = a * b - (ll)((long double)a * b / m + .5) * m;
    return r < 0 ? r + m : r;
}
ll expmod(ll b, ll e) {
    if (e == 0) return 1;
    if (e & 1) return mulmod(b, expmod(b, e - 1));
    b = expmod(b, e >> 1);
    return mulmod(b, b);
}
ll invmod(ll a) {
    return expmod(a, m - 2);
}
ll add(ll a, ll b) {
    a += b;
    if (a >= m) a -= m;
    return a;
}
ll lcm(ll a, ll b) {
    return (a * b) / __gcd(a, b);
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin >> n;
    vector<ll> A(n), B(n);
    //ll L = 1;
    forn(i, n) cin >> A[i];
    map<ll, ll> Fmax;
    forn(i, n) {
        map<ll, ll> F;
        ll cur = A[i];
        for (ll j = 2; j * j <= cur; j++) {
            while (cur % j == 0) F[j]++, cur /= j;
            Fmax[j] = max(Fmax[j], F[j]);
        }
        if (cur > 1) F[cur]++, Fmax[cur] = max(F[cur], Fmax[cur]);
    }
    ll L = 1;
    for (auto x : Fmax) {
        if (x.S != 0) {
            L = mulmod(L, expmod(x.F, x.S));
        }
    }
    ll ans = 0;
    forn(i, n) {
        ans = add(ans, mulmod(L, invmod(A[i])));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    int i,j,k;
    string buf;
    int d[50]={};
    for(i=0;i<n;i++){
      cin >> buf;
      d[i]=buf.size();
    }
    for(i=0;i<n;i++){
      int c=0;
      j=i;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<5) c+=d[j++];
      if(c!=5) continue;
      c=0;while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      while(c<7) c+=d[j++];
      if(c!=7) continue;
      c=0;
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
#include <tuple>

using e_type = uintmax_t;
using r_type = size_t;
using p_type = std::pair<e_type, r_type>;

std::vector<p_type> encode(std::vector<p_type> const& orig) {
  r_type cur = 0;
  std::vector<p_type> res;
  for (auto const& p: orig) {
    e_type e;
    r_type r;
    std::tie(e, r) = p;
    if (r == 0) continue;
    if (cur & 1) {
      ++cur;
      res.emplace_back(e, 1);
      --r;
    }
    if (r == 0) continue;
    r_type b = (r & 1);
    r ^= b;
    if (r) {
      cur += r;
      res.emplace_back(e, r);
    }
    if (b) {
      cur += b;
      res.emplace_back(e, b);
    }
  }
  // fprintf(stderr, "cur: %zu\n", cur);
  return res;
}

r_type nya(std::vector<p_type>& enc, e_type tg) {
  r_type res = 0;
  std::vector<p_type> next;
  while (!enc.empty()) {
    p_type s = enc.back();
    enc.pop_back();
    e_type es;
    r_type rs;
    std::tie(es, rs) = s;
    if (rs > 1) {
      if (!(tg & es)) {
        res += rs / 2;
      }
      next.emplace_back(es & (tg-1), rs/2);
      continue;
    }
    assert(!enc.empty());
    p_type t = enc.back();
    enc.pop_back();
    e_type et;
    r_type rt;
    std::tie(et, rt) = t;
    assert(rs == 1 && rt == 1);
    if ((tg & es) && (tg & et)) {
      next.emplace_back((es | et) & (tg-1), 1);
    } else if (tg & es) {
      next.emplace_back(et & (tg-1), 1);
    } else if (tg & et) {
      next.emplace_back(es & (tg-1), 1);
    } else {
      next.emplace_back((es | et) & (tg-1), 1);
      ++res;
    }
  }
  enc = encode(next);
  return res;
}

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  std::vector<r_type> a(m+1);
  for (auto& ai: a) scanf("%zu", &ai);
  std::vector<e_type> b(m);
  for (auto& bi: b) {
    scanf("%ju", &bi);
    bi = 1 << bi;
  }

  std::vector<p_type> input;
  for (size_t i = 0; i < m; ++i) {
    // fprintf(stderr, "b[%zu], a[%zu:%zu]\n", i, i+1, i);
    // fprintf(stderr, "emplace_back(%jd, %zu)\n", b[i], a[i+1]-a[i]);
    input.emplace_back(b[i], a[i+1]-a[i]);
  }
  std::vector<p_type> enc = encode(input);
  r_type res = 0;
  for (size_t i = 0; i < n; ++i) {
    res += nya(enc, 1 << (n-i));
  }

  assert(enc.size() == 1);
  {
    e_type e;
    r_type r;
    std::tie(e, r) = enc[0];
    if (!(e & 1)) ++res;
  }

  printf("%zu\n", res);
}



Measured memory_bytes: 4676