akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
int main(){
  int n;cin>>n;
  const int Mod=1e9+7;
  //[0:T][1:A][2:G][3:C]<x123><x132><x213><1x23><12x3>
  /*
  <0-123><1-123><2-123><3-123><0-132><1-132>
  <2-132><3-132><0-213><1-213><2-213><3-213>
  
  <1-023><1-203><1-323><1-223><1-233><1-233>
  */
  long long int seq[n+1][4][4][4];
  for(int s=2;s<=n;s++){
    for(int x=0;x<4;x++){
      for(int y=0;y<4;y++){
        for(int z=0;z<4;z++){
           seq[s][x][y][z]=0;
        }
      }
    }
  }
  for(int d=0;d<4;d++){
    for(int f=0;f<4;f++){
      seq[2][0][d][f]++;
    }
  }
  for(int s=3;s<=n;s++){
    for(int x=0;x<4;x++){
      for(int y=0;y<4;y++){
        for(int z=0;z<4;z++){
          if(((x==1)&&(y==2)&&(z==3))||((x==2)&&(y==1)&&(z==3))||((x==1)&&(y==3)&&(z==2))){
            seq[s][x][y][z]=0;
          }else if((x==0)&&(y==2)&&(z==3)){
            seq[s][x][y][z]+=(seq[s-1][0][x][y]%Mod+seq[s-1][2][x][y]+seq[s-1][3][x][y])%Mod;
          }else if((x==2)&&(y==0)&&(z==3)){
            seq[s][x][y][z]+=(seq[s-1][0][x][y]%Mod+seq[s-1][2][x][y]+seq[s-1][3][x][y])%Mod;
          }else if((x==3)&&(y==2)&&(z==3)){
            seq[s][x][y][z]+=(seq[s-1][0][x][y]%Mod+seq[s-1][2][x][y]+seq[s-1][3][x][y])%Mod;
          }else if((x==2)&&(y==2)&&(z==3)){
            seq[s][x][y][z]+=(seq[s-1][0][x][y]%Mod+seq[s-1][2][x][y]+seq[s-1][3][x][y])%Mod;
          }else if((x==2)&&(y==3)&&(z==3)){
            seq[s][x][y][z]+=(seq[s-1][0][x][y]%Mod+seq[s-1][2][x][y]+seq[s-1][3][x][y])%Mod;
          }else{
            seq[s][x][y][z]+=(seq[s-1][0][x][y]%Mod+seq[s-1][1][x][y]+seq[s-1][2][x][y]+seq[s-1][3][x][y])%Mod;
          }
          
        }
      }
    }
  }
  llint ans=0;
    for(int x=0;x<4;x++){
      for(int y=0;y<4;y++){
        for(int z=0;z<4;z++){
          ans+=seq[n][x][y][z]%Mod;
          ans=ans%Mod;
        }
      }
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 2e5 + 10;
int n, a[N], t[N], _t[N], b[N], c[N], f[N], g[N], v[N], st[N], tp, res;
inline int qwq (int x, int y, int z) {
	return (v[y] - v[x]) * (z - y) < (v[z] - v[y]) * (y - x);
}
signed main() {
	read (n); int mx = 0, tot = 0;
	for (int i = 1; i <= n; ++i) read (t[i]);
	for (int i = 1; i <= n; ++i) read (_t[i]);
	for (int i = 1; i <= n; ++i) if (t[i] > t[mx]) mx = i;
	for (int i = mx; i <= n; ++i) a[++tot] = t[i];
	for (int i = 1; i <= mx; ++i) a[++tot] = t[i]; tot = 0;
	for (int i = mx; i <= n; ++i) b[++tot] = _t[i];
	for (int i = 1; i <= mx; ++i) b[++tot] = _t[i];
	for (int i = 3; i <= n + 1; ++i)
		c[i] = 2 * c[i - 1] + 2 * b[i - 1] - c[i - 2];
	for (int i = 1; i <= n + 1; ++i) v[i] = a[i] - c[i];
	
	for (int i = 1; i <= n + 1; ++i) {
		while (tp > 1 && qwq (st[tp - 1], st[tp], i)) --tp; st[++tp] = i; 
	} int res = 0;	
	for (int i = 1; i < tp; ++i) {
		int _ = st[i + 1] - st[i];
		res += v[st[i]] * (_ + 1) + v[st[i + 1]] * (_ - 1);
	} for (int i = 1; i <= n; ++i) res += 2 * c[i];
	return printf ("%.12lf\n", res / 2.00000 / n), 0;
}

Measured memory_bytes: 14604
#include <iostream>
#include <bitset>
#include <vector>

using namespace std;
typedef long long ll;
bitset<60> a[100005];

int main() {
  int n;
  cin >> n;
  bitset<60> tmp(0);
  for(int i = 0; i < n; i++) {
    ll A; cin >> A;
    a[i] = A;
    tmp ^= A;
  
  }
  
   for(int i = 0; i < n; i++) {
    for(int j = 0; j <= 65; j++) {
      if(tmp[j] == 1) {
	a[i][j] = 0;
      }
    }
  }

  
   int rank = 0;
   for(int i = 59; i >= 0; i--) {
     int j = rank;
     while(j < n && a[j][i] == 0) j++;
     if(j == n) continue;
     swap(a[rank],a[j]);
     for(int k = 0; k < n; k++) {
       if(k == rank) continue;
       if(a[k][i] == 0) continue;
       a[k] ^= a[rank];
     }
     rank++;
   }

   for(int i = 1; i < n; i++) a[0] ^= a[i];
   ll ans = 0;
   ll ans2 = 0;
   for(int i = 0; i < 60; i++) {
     if(a[0][i] == 1) {
       ans += (1ll << i);
     }
     if(tmp[i] == 1) {
       ans2 += (1ll << i);
     }
   }
   ans <<= 1;
   cout << ans + ans2 << endl;

     
   //unsigned long long int  aa = ans.to_ulong() + tmp.to_ulong();
   
     
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>

using namespace std;

const int INF = 1 << 30;
const int SIZE = 200;
const int N = 1000002;
int p[SIZE+1];
int dp1[N], dp2[N];

void make_pollock (void )
{
	memset (p, 0, sizeof (p ) );

	for (int i = 0; i <= SIZE; i++ )
		p[i] = i*(i+1)*(i+2)/6;
}

void make_dp (void )
{
	fill (dp1, dp1+N, INF );
	fill (dp2, dp2+N, INF );

	dp1[0] = 0;
	for (int i = 1; i <= SIZE; i++ ){
		int m = p[i];
		for (int j = m; j <= N; j++ )
			if (dp1[j] > dp1[j - m] + 1 )
				dp1[j] = dp1[j - m] + 1;
	} // end for

	dp2[0] = 0;
	for (int i = 1; i <= SIZE; i++ ){
		if (p[i] % 2 == 0 ) continue;
		int m = p[i];
		for (int j = m; j <= N; j++ )
			if (dp2[j] > dp2[j - m] + 1 )
				dp2[j] = dp2[j - m] + 1;
	} // end for	
}
	
int main()
{
	make_pollock();
	make_dp ();

	int n;
	while (cin >> n && n )
		cout << dp1[n] << ' ' << dp2[n] << endl;
	
	return 0;
}

Measured memory_bytes: 8560
import java.util.*;

public class Main {
	int n, m, cnt, even, odd, sumA, sumB;
	char[] c;
	int[] a, e, o, p;
	
	
	void loopA(int x, int y){
		if(y==odd){
			loopB(0,0);
		}else{
			for(int i=x;i<m;i++){
				o[a[i]]++;
				loopA(i, y+1);
				o[a[i]]--;
			}
		}
	}
	
	void loopB(int x, int y){
		if(y==even){
			check();
		}else{
			for(int i=x;i<m;i++){
				e[a[i]]++;
				loopB(i, y+1);
				e[a[i]]--;
			}
		}
	}
	
	void check(){
		sumB = 0;
		for(int i=0;i<10;i++){
			sumB += i*o[i] + i*e[i]*2;
			if(i>=5) sumB -= 9*e[i];
		}
		if((sumA+sumB)%10==0){
			int p1 = 1;
			for(int i=0;i<10;i++) p1 *= p[o[i]];
			int p2 = 1;
			for(int i=0;i<10;i++) p2 *= p[e[i]];
			cnt += (p[odd]*p[even])/(p1*p2);
		}
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		c = sc.next().toCharArray();
		sumA = 0;
		even = 0;
		odd = 0;
		int i=n-1;
		while(true){
			if(c[i]=='*') odd++;
			else sumA += (int)c[i]-48;
			i--;
			if(i<0) break;
			if(c[i]=='*') even++;
			else sumA += ((int)c[i]-48)*2;
			if(((int)c[i]-48)*2>=10) sumA -= 9;
			i--;
			if(i<0) break;
		}
		
		m = sc.nextInt();
		a = new int[m];
		e = new int[10];
		o = new int[10];
		p = new int[]{1,1,2,6,24,120,720,5040};
		for(int j=0;j<m;j++) a[j] = sc.nextInt();
		
		cnt = 0;
		loopA(0, 0);
		System.out.println(cnt);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 27408
N=int(input())
S=list(input())
if N == 1:
  print(1)
if N>=2:
  if S[0] == S[1]:
    S[0]==" "
  for i in range(1,N):
    if S[i-1]==S[i]:
      S[i-1]=" "
  A=[]
  for i in range(N):
        if S[i]!=" ":
              A.append(S[i])
  print(len(A))

Measured memory_bytes: 76604
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 1000000007
#define ve vector
#define pi pair<int,int>
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}



void solve()
{ 
 ll n,i;
    cin>>n;
    vector<ll>a(n);
    for(ll &x:a)cin>>x;
    ll ans=0;
    for(i=1;i<n;i++)
    {
        if(a[i-1]>a[i]){ans+=(a[i-1]-a[i]);a[i]=a[i-1];}   
    }
    cout<<ans<<endl;

}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;
   
    
     int t=1;
  //  cin>>t;
     while(t--)
    	solve();
    return 0;
}



Measured memory_bytes: 4780
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
// #include <unordered_map>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
#define debug(x) cout << #x << " " << x << "\n"
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
#ifdef DEBUG
const int MAX = 1e6 + 50;
#else
const int MAX = 1e6 + 50;
#endif
const int mod = 1e9 + 7;

LL N,K;
LL f[MAX];
LL fact[MAX];
inline LL add(LL x, LL y){
    LL res = x + y;
    return res >= mod ? res - mod : res;
}
inline LL qpow(LL x, LL n){
    LL res = 1;
    while (n)
    {
        if(n &1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
LL F(LL K, LL N){
    if(f[K]) return f[K];
    LL &res =f[K];
    if(K==1){
        return res = 1;
    }
    // res = qpow(K, N);
    res = fact[K];
    for(LL i = 2, j; i <= K; i=j+1){
        j = K/(K/i);
        // res = add(res, mod-F(K/i, N));
        LL tmp = (j-i+1LL) * F(K/i, N) % mod;
        res = add(res, mod-tmp);                                                                    
    }
    return res;
}
int main(){
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    scanf("%lld%lld", &N, &K);
    for(LL i = 1; i <= K; i++)
        fact[i] = qpow(i, N);
    LL ans = 0;
    f[1] = 1LL;
    for(LL k= 1; k <= K; k++){
        F(k, N);
        // LL &res = f[k];
        // res = qpow(k, N);
        // for(LL i = 2, j; i <= k; i=j+1){
        //      j = k/(k/i);
        //     res = add(res, mod-f[k/i]);
        //     LL tmp = (j-i+1LL) * f[k/i] % mod;
        //     res = add(res, mod-tmp);      
        // }
    }
    for(LL i = 1, j; i <= K; i++){
        // j = K/(K/i);
        // ans +=  F(K/i, N) % mod * i % mod;
        ans +=  f[K/i] % mod * i % mod;
        if(ans >= mod)
            ans -= mod;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 5376
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <map>
using namespace std;

int n,m;
long x;

int main(){
	cin>>n>>m>>x;
	long c[n];
	long a[n][m];

	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}

	long ans=99999999999;
	bool check=false;

	for(int N=0;N<(1<<n);N++){
		long cost=0;
		long level[m]={0};
		bool ok = true;
		for(int i=0;i<n;i++){
			if((N>>i)&1){
				cost += c[i];
				for(int j=0;j<m;j++){
					level[j]+=a[i][j];
				}
			}
		}
		for(int j=0;j<m;j++){
			if(level[j]<x) ok = false;
		}

		if(ok){
			check = true;
			ans = min(ans,cost);
		}
	}
	if(check)cout<<ans<<endl;
	else cout<<-1<<endl;
}


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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define vl					vector<ll>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 3e5+5;
int n, va[MAXN], vb[MAXN];
char inp[MAXN];

int main() {
	gi(n);
	scanf("%s", inp);
	for (int i=1; i<=n; i++) {
		if (inp[i-1]=='W') va[i] = 1;
		else vb[i] = 1;
	}
	for (int i=1; i<=n; i++) va[i] += va[i-1];
	for (int i=n; i>=1; i--) vb[i] += vb[i+1];
	int ans = inf;
	for (int i=1; i<=n; i++)
		ans = min(ans, va[i-1]+vb[i+1]);
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i=0 ; i<N ; i++){
  	cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end()); // {1, 2, 2, 5}
  //reverse(card.begin(), card.end()); // {1, 2, 2, 5}
  
  int a = 1;
  for(int i = 1 ; i< N ; i++){
    if (mochi.at(i-1) != mochi.at(i)){
      a++;
    }
  }
  
  cout << a << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
int max(int a,int b){return a > b ? a : b;}
int main(){
    int a, b;
    int ans = 0;
    scanf("%d%d",&a,&b);
    if(max(a,b) == a){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    if(max(a,b) == a){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
a=sorted([int(input())for _ in[0]*int(input())])
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[c*10**len(str(d))+d,d*10**len(str(c))+c]
print(sorted(p)[2])


Measured memory_bytes: 6024
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<int, int> m1, m2;
    for(int i = 0; i < N; i += 2){
        m1[A[i]]++;
    }
    for(int i = 1; i < N; i += 2){
        m2[A[i]]++;
    }
    vector<P> num1, num2;
    for(auto v: m1){
        num1.push_back(P(v.second, v.first));
    }
    for(auto v: m2){
        num2.push_back(P(v.second, v.first));
    }
    sort(num1.begin(), num1.end());
    sort(num2.begin(), num2.end());
    int ans = 1e9;
    if(num1.size() == 1 && num2.size() == 1 && num1[0].second == num2[0].second){
        cout << N / 2 << endl;
        return 0;
    }
    for(int i = (int)num1.size() - 1; i >= 0 && i >= (int) num1.size() - 2; i--){
        for(int j = (int)num2.size() - 1; j >= 0 && j >= (int)num2.size() - 2; j--){
            if(num1[i].second != num2[j].second){
                ans = min(ans, N - num1[i].first - num2[j].first);
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int sum = 1;
  rep(i,n-1){
    if (v.at(i) > v.at(i+1)){
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
p = []
for i in range(N):
    x, y = [int(c) for c in input().split()]
    p.append((x,y))

t = {}
for i, pi in enumerate(p):
    for j, pj in enumerate(p):
        if i==j : continue
        
        dx, dy = pi[0] - pj[0], pi[1] - pj[1]
        if (dx, dy) in t:
            t[(dx, dy)] += 1
        else:
            t[(dx, dy)] = 1

if N==1:
    print(1)
else:
    print(N-max([t[k] for k in t]))


Measured memory_bytes: 3444
N,M = map(int, input().split())
vote_list = [int(i) for i in input().split()]
vote_list.sort(reverse=True)

Mth_got_vote = vote_list[M - 1]

if Mth_got_vote < sum(vote_list) / (4 * M):
    print("No")
else:
    print("Yes")

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

int main(){

    ll N,K;
    cin >> N >> K;
    ll ans = N%K;
    while(ans > K/2){
        ans = abs(ans-K);
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0)
    {
        cout << (B - A) / 2 << endl;
    }
    else
    {
        cout << min(A + (B - A - 1) / 2, (N - B + 1 + (B - A - 1) / 2)) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
    if(x-r<0||x+r>W||y-r<0||y+r>H){
        cout << "No";
        cout << endl;
    }
    else{
        cout << "Yes";
        cout << endl;
    }
}


Measured memory_bytes: 3108
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstdlib>


namespace vector {
  template<typename T, size_t dcap = 16ULL>
  class vec {
    size_t sz;
    size_t cap;
    T* a;
  public:
    vec() : sz(0), cap(dcap) {
      a = (T*)std::malloc(sizeof(T) * cap);
    }
    vec(size_t n) : sz(n), cap(dcap) {
      while (cap < sz) cap <<= 1;
      a = (T*)std::malloc(sizeof(T) * cap);
    }
    vec(size_t n, T v) : sz(n), cap(dcap) {
      while (cap < sz) cap <<= 1;
      a = (T*)std::malloc(sizeof(T) * cap);
      for (size_t i = 0; i < sz; i++) {
        a[i] = v;
      }
    }
    T& operator[](size_t i) {
      return a[i];
    }
    size_t size() const {
      return sz;
    }
    void output(std::ostream& out, char delim = ' ') const {
      for (size_t i = 0; i < sz; i++) {
        if (i) out << delim;
        out << a[i];
      }
    }
    friend std::ostream& operator<<(std::ostream& out, const vec& v) {
      v.output(out);
      return out;
    }
    void input(std::istream& in) {
      for (size_t i = 0; i < sz; i++) {
        in >> a[i];
      }
    }
    friend std::istream& operator>>(std::istream& in, vec& v) {
      v.input(in);
      return in;
    }
    ~vec() {
      std::free(a);
    }
  };
}

namespace algorithm {
  template<typename T>
  void insertion_sort(vector::vec<T>& v, bool verbose = false) {
    for (int i = 0, n = v.size(); i < n; i++) {
      int x = v[i], j;
      for (j = i - 1; j >= 0 && v[j] > x; j--) {
        v[j + 1] = v[j];
      }
      v[j + 1] = x;
      if (verbose) std::cout << v << std::endl;
    }
  }
}

int main() {
  using namespace vector;
  using namespace algorithm;

  int N;
  std::cin >> N;

  vec<int> A(N);
  std::cin >> A;

  insertion_sort(A, true);
  
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 vector<vector<int>> to(200005);
 vector<int> ans;

void dfs(int v,int p){
    for(auto u:to.at(v)){
        if(u==p) continue;
        ans.at(u) += ans.at(v);
        dfs(u,v);
    }
    

}

int main(){
    int n,q;
    cin >> n >> q;
   
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        to.at(a).push_back(b);
        to.at(b).push_back(a);
    }
    ans.resize(n);
    for(int i=0;i<q;i++){
        int p;
        cin >> p;
        p--;
        int x;
        cin >> x;
        ans.at(p) += x; 
    }
    dfs(0,-1);
    for(int i=0;i<n;i++){
        cout << ans.at(i) << " ";
    }
}

Measured memory_bytes: 26624
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
def up(i):
    if i%10 != 0:
        return (i//10+1)*10
    else:
        return i
print(min([a+up(b)+up(c)+up(d)+up(e),up(a)+b+up(c)+up(d)+up(e),up(a)+up(b)+c+up(d)+up(e),up(a)+up(b)+up(c)+d+up(e),up(a)+up(b)+up(c)+up(d)+e]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,m;
	cin>>n>>m;
	if(n>=2&&m>=2){
		cout<<(n-2)*(m-2)<<endl;
	}else if(n==1&&m==1){
		cout<<1<<endl;
	}else{
		cout<<max(0ll,max(n,m)-2)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long A =sc.nextLong();
      long B =sc.nextLong();
      long K =sc.nextLong();
      
      if(A==K){
      System.out.println((A-K)+" "+" "+B);
      }
      else if(A>K){
      System.out.println((A-K)+" "+" "+B);
      }
      else if(A<K && B>=(K-A)){
       System.out.println(0+" "+" "+(B-(K-A)));
      }
      else if(A<K && B<=(K-A)){
       System.out.println(0+" "+" "+0);
      }
    }
}

Measured memory_bytes: 23764
import java.util.Arrays;
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; ;)
		{
			int[] a = new int[3];
			int end_count = 0;
			for(int i=0; i<3; i++)
			{
				a[i] = scanner.nextInt();
				if(a[i] == 0)
				{
					end_count ++;
				}
				a[i] /= 2;
			}
			if(end_count == 3)
			{
				break;
			}
			
			Arrays.sort(a);

			int n = scanner.nextInt();
			for(int i=0; i<n; i++)
			{
				int r = scanner.nextInt();
				
				String output = "NA";
				if(r*r > a[0]*a[0]+a[1]*a[1])
				{
					output = "OK";
				}
				System.out.println(output);
			}
			
		}
	}
}

Measured memory_bytes: 26088
#include <iostream>
#include <queue>
#define mp make_pair
using namespace std;
deque<pair<int,int> > q;bool vis[100005];int k,ans=0; 
int main(){
	cin>>k;q.push_front(mp(1,1));while(!q.empty()){pair<int,int> x=q.front();q.pop_front();if(x.first==0){cout<<ans+x.second;return 0;}if(vis[x.first]){continue;}vis[x.first]=1;q.push_back(mp((x.first+1)%k,x.second+1));q.push_front(mp((x.first*10%k),x.second));}return 0;
}

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

int main(){
  map<char,int> mas;
  mas['A']=1;
  mas['B']=0;
  mas['C']=0;
  char a,b;
  while(scanf("%c,%c",&a,&b)!=EOF){
    int temp=mas[a];
    mas[a]=mas[b];
    mas[b]=temp;
  }
  char ans=0;
  for(int i='A';i<='C';i++){
    if(1==mas[i]){
      ans=i;
    }
    
  }
  cout<<ans<<endl;
}

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


int main(){
    ll N;
    cin >> N;
    if (N%2) cout << 0 << endl;
    else {
        ll ans = 0;
        ll k = 2;
        while (k <= N) {
            k *= 5;
            ans += N/k;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


template<int d> int nearest(vector<INT> &l, INT pos)
{
	int begin = 0, end = l.size() - 1;

	while (1) {
		int half = (begin + end) / 2;
		if (pos < l[half])
		{
			end = half;
		}
		else
		{
			begin = half;
		}
		if (end - begin < 2)
		{
			if (d == 0)
			{
				return pos - l[begin] > l[end] - pos ? end : begin;
			}
			else if(d == 1)
			{
				return begin;
			}
			else
			{
				return end;
			}
		}
	}
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007

string syugei(int N){
  string ST="b";
  for(int i=0;i<N;i++){
    if(i%3==0||i==0)ST="a"+ST+"c";
    else if(i%3==1||i==1)ST="c"+ST+"a";
    else if(i%3==2||i==2)ST="b"+ST+"b";
  }
  return ST;
}
//main
signed main(){
  int N,M,O,P,X,count=0,count2=0;
  double D;
  int c='A'-'a';
  char C;
  str S,T;
  cin>>N>>T;
  if(N>=3200)cout<<T<<endl;
  else cout<<"red"<<endl;
}


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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
    //~ if (!bit) break;
//~ }
int next_combination(int sub){
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a){
    if(a==2) return true;
    if(a<=1 || a%2==0) return false;
  
    for(int i=3; i*i<=a; i+=2){
        if(a%i==0) return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> a;
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (a[index] >= key) return true;
    else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

long long modpow(long long a, long long n, long long mod){
    long long res = 1;
    while(n>0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

int main(){
    int A, B;
    cin >> A >> B;
    
    int ans = 1;
    //~ 1 + (A-1)*ans >= B;
    //~ 式変形すると、ans >= (B-1) / (A-1)
    //~ このまま実行すると右辺の式は切り下げになるので、分子に(分母-1)を足す
    ans = ((B-1 + A-2)  / (A-1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;
# define LL long long

/*
1≦N≦100
1≦Ti≦105
1≦M≦100
1≦Pi≦N
1≦Xi≦105

N
T1 T2 … TN
M
P1 X1
P2 X2
:
PM XM
*/

int main() {
	//
	const int MAXN = 111;
	int N, M;
	int T[MAXN];
	LL P[MAXN];
	LL X[MAXN];

	cin >> N;
	rep(n, N){ cin >> T[n]; }
	cin >> M;
	rep(m, M) { cin >> P[m] >> X[m]; }

	rep(m, M){
		LL ret = 0;
		rep(n, N){ ret += T[n]; }
		int p = P[m] - 1;
		ret -= T[p];
		ret += X[m];
		cout << ret << endl;
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int k,i=0,sum=0;
    cin>>k;
    while(i<=k)
    {
        if((i%3==0)&&(i%5==0))
            i++;
        else if(i%3==0)
            i++;
        else if(i%5==0)
            i++;
        else
        {
        sum=sum+i;
        i++;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include <iostream>

int main(){
  int h,w,i,q;

  std::cin >> h>> w;
  while(h != 0 && w != 0){
    for (i = 0; i < h; i++) {
      /* code */
      for (q = 0; q < w; q++) {
        if((i == 0 || i == h-1) || (q == 0 || q == w-1) ){
          std::cout << "#";
        }else{
          std::cout << ".";
        }
      }
      std::cout << '\n';
    }
    std::cout  << '\n';
    std::cin >> h>> w;
  }
  return 0;
}



Measured memory_bytes: 3024
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int res = K;
    for (int i = 1; i < N; i++) {
      res *= K - 1;
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 21844
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	LL a, b;
	LL c, d;
	while(cin >> n >> a >> b >> c >> d) {
		LL dis = b-a;
		string ans = "NO";
		REP(i,n-1+1){
			DEBUG(i);
			LL up = (n-1-i*2)*c;
			LL low = (n-1-i*2)*d;
			if(up < low) swap(up, low);
			DEBUG(up); DEBUG(low);
			LL t = min(i, n-1-i);
			up += (d-c)*t;
			low -= (d-c)*t;
			DEBUG(up); DEBUG(low);
			if(low <= dis and dis <= up) {
				ans = "YES";
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for i in range(0, A+1):
    for j in range(0, B+1):
        for k in range(0, C+1):
            tmp = i * 500 + j * 100 + k * 50
            if (tmp == X):
                ans += 1

print(ans)


Measured memory_bytes: 14536
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)



int main(){
    int n,m;
    cin >> n >> m;
    vector<int>a(m),b(m);
    vector<int> c(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        rep(j,b[i]){
            int k;
            cin >> k;
            k--;
            c[i]^=(1<<k);
        }
    }
    vector<int>dp(1<<n,inf);
    dp[0] = 0;
    rep(i,1<<n){
        if(dp[i]!=inf){
            rep(j,m){
                dp[i|c[j]] = min(dp[i|c[j]],dp[i]+a[j]);
            }
        }
    }
    if(dp[(1<<n)-1]==inf){
        cout << -1 << endl;
    }else{
        cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  vvi testimony_h(N);
  vvi testimony_u(N);
  rep(i,N){
    i64 a;
    cin >> a;
    rep(j,a){
      i64 x,y;
      cin >> x >> y;
      x--;
      if(y) testimony_h[i].emplace_back(x);
      else testimony_u[i].emplace_back(x);
    }
  }
  i64 ans = 0;
  rep(i,1<<N){
    v(bool) honest(N,false);
    rep(j,N){
      if(i&(1<<j)) honest[j] = true;
    }
    bool flag = true;
    rep(j,N){
      if(honest[j]){
        for(auto &p:testimony_h[j]){
          if(!honest[p]) flag = false;
        }
        for(auto &p:testimony_u[j]){
          if(honest[p]) flag = false;
        }
      }
    }
    if(flag){
      i64 ans_tmp = 0;
      rep(j,N){
        if(i&(1<<j))ans_tmp++; 
      }
      chmax(ans,ans_tmp);
    }
  }
  cout << ans << "\n";

}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		String s;
		String sl[];

		s = r.readLine();
		sl = s.split(" ");

		int n = Integer.parseInt(sl[0]);
		int m = Integer.parseInt(sl[1]);

		ArrayList<ArrayList<Integer>> g = new ArrayList<>(300000);
		boolean b[] = new boolean[300000];

		for (int i = 0; i < 3 * n; i++) {
			g.add(new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			s = r.readLine();
			sl = s.split(" ");
			int u = Integer.parseInt(sl[0]) - 1;
			int v = Integer.parseInt(sl[1]) - 1;
			g.get(u).add(v + n);
			g.get(u + n).add(v + 2 * n);
			g.get(u + 2 * n).add(v);
		}

		// System.out.println(g);
		s = r.readLine();
		sl = s.split(" ");

		int start = Integer.parseInt(sl[0]) - 1;
		int term = Integer.parseInt(sl[1]) - 1;

		ArrayDeque<Integer> qv = new ArrayDeque<>();
		ArrayDeque<Integer> qd = new ArrayDeque<>();

		qv.offer(start);
		qd.offer(0);

		while (!qv.isEmpty()) {
			int v = qv.poll();
			int d = qd.poll();
			// System.out.println(v + ", " + d);
			if (v == term) {
				System.out.println(d / 3);
				System.exit(0);
			}
			for (Integer e : g.get(v)) {
				if (!b[e]) {
					qv.offer(e);
					qd.offer(d + 1);
					b[e] = true;
				}
			}
		}
		System.out.println(-1);
	}

}

Measured memory_bytes: 100560
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n,k;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	int dig=0;
	while(n){
		dig++;
		n/=k;
	}
	cout<<dig<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename T> class Heap {
public:
    struct node {
        node* l; node* r; T val;
        node(T t) : l(nullptr), r(nullptr), val(t){}
    };
    node* root;
    Heap() : root(nullptr){}
    node* meld(node* a, node* b){
        if(!a) return b; if(!b) return a;
        if(a->val > b->val) swap(a, b);
        a->r = meld(a->r,b); swap(a->l, a->r);
        return a;
    }
    void push(T val){ node* p = new node(val); root = meld(root, p); }
    T top(){ return root->val; }
    void pop(){ node* p = root; root = meld(root->r, root->l); delete p; }
};


struct edge{
    int to, cost;
};

int d[MAX_N];
vector<edge> G[MAX_N];

void dijkstra(int s)
{
    Heap<P> que;
    d[s] = 0;
    que.push(P(0,s));
    while(que.root){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(auto w : G[v]){
            if(d[w.to] > d[v] + w.cost){
                d[w.to] = d[v] + w.cost;
                que.push(P(d[w.to],w.to));
            }
        }
    }
}

int main()
{
    int n,m,s;
    scanf("%d%d%d",&n,&m,&s);
    rep(i,m){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        G[a].pb((edge){b,c});
    }
    fill(d,d+n,INF);
    dijkstra(s);
    rep(i,n){
        if(d[i] == INF){
            cout << "INF\n";
        }else{
            cout << d[i] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 14600
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
#define PI 3.141592653589

int main(){
    int x, y, a=1000000, b=-1000000;
long c = 0;
    cin >> y;
    for(int i = 0;i < y;i++){
        cin >> x;
        c += x;
        if(a>x)a=x;
        if(b<x)b=x;
    }
    cout <<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 3100
n=int(input())
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=[v[i]-c[i] for i in range(n)]
ans.sort(reverse=True)
A=0
for i in ans:
    if i>0:
        A+=i
    else:
        break
print(A)

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

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

using namespace std;
using ll = long long;

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

    int n, a;
    ll fr = 0, ans = 0;
    cin >> n;
    rep(i, n) {
        cin >> a;
        if(fr > a) ans += fr - a;
        else fr = a;
    }

    printf("%lld\n", ans);

    return 0;
}

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

int main(){

	int n;
	double five, ten;
	map<int, string> mp;
	double cls[7][2] = {{70.0, 148.0},
											{55.0, 116.0},
											{50.0, 105.0},
											{43.0, 89.0},
											{40.0, 83.0},
											{37.5, 77.0},
											{35.5, 71.0}};
	mp.insert(make_pair(0, "NA"));
	mp.insert(make_pair(1, "E"));
	mp.insert(make_pair(2, "D"));
	mp.insert(make_pair(3, "C"));
	mp.insert(make_pair(4, "B"));
	mp.insert(map<int, string>::value_type(5, "A"));
	mp.insert(pair<int, string>(6, "AA"));
	mp.insert(make_pair(7, "AAA"));
	
	while(cin >> five >> ten){
		n = 0;
		for(int i=0; i<7; i++){
			if(five < cls[i][0] && ten < cls[i][1]){
				 n++;
				 if(i == 6) cout << mp[n] << endl;
			}
			else{
				cout << mp[n] << endl;
				break;
			}
		}
	}

	return 0;

}

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

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



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

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

Measured memory_bytes: 3528
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll int
#define N 200005
#define mod 1000000007
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,x,sum,tmp=mod;
int main(){
	n=read();
	rep(i,1,n){
		sum+=x=read();
		if (x%10) tmp=min(tmp,x);
	}
	if (sum%10) printf("%d",sum);
	else if (tmp!=mod) printf("%d",sum-tmp);
	else printf("%d",0);
}

Measured memory_bytes: 128
//B-Maximum Sum
#include <bits/stdc++.h>
using namespace std;

int main(){
  int A,B,C,K;
  cin>>A>>B>>C;
  if(B<C) swap(B, C);
  if(A<C) swap(A, C);
  if(A<B) swap(A, B);

  cin>>K;
  for(int i=0;i<K;i++) A*=2;

  cout<<A+B+C<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		int i1, i2;
		Scanner sc = new Scanner(System.in);
		while (true) {
			i1 = sc.nextInt();
			i2 = sc.nextInt();
			if (i1 == 0 && i2 == 0)
				break;
			for (int i = 0; i < i1; i++) {
				for (int j = 0; j < i2; j++)
					System.out.print("#");
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 25708
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] A = new int[N];

		for (int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		for (int k=0; k<N; k++) {
			if (k==0) {
				System.out.print(A[k]);
			} else {
				System.out.print(" "+A[k]);
			}
		}
		System.out.println();

		for (int i=1; i<N; i++) {
			int v = A[i];
			int j = i - 1;
			while (j>=0&&A[j]>v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			for (int k=0; k<N; k++) {
				if (k==0) {
					System.out.print(A[k]);
				} else {
					System.out.print(" "+A[k]);
				}
			}
			System.out.println();
		}

		sc.close();
	}

}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int mod = 998244353;

int32_t main()
{   fastio;

    int n;
    cin>>n;
    if(n <= 999) cout<<"ABC\n";
    else cout<<"ABD\n";

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
 
using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;
using ll=long long;
 
int main()
{
	int n, m; cin >> n  >> m;

	int res_l = -1, res_r;
	res_r = 1e5+10;

	for (int i = 0; i < m; i++)
	{
		int l, r; cin >> l >> r;
		res_l = max(res_l, l);
		res_r = min(res_r, r);
	}

	cout << max(res_r - res_l + 1, 0) << "\n";
}


Measured memory_bytes: 384
# https://atcoder.jp/contests/abc120/tasks/abc120_d


class UnionFind():

    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}をリストで返す
        return [list(self.members(r)) for r in self.roots()]





from itertools import combinations
import sys
input = sys.stdin.readline

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

data = [map(int, input().split()) for _ in range(M)]

tree = UnionFind(N)

res = []
inconv = N*(N-1)//2

for a, b in reversed(data):                                 # O(M)
    a -= 1
    b -= 1
    if tree.find(a) != tree.find(b):
        inconv -= tree.size(a)*tree.size(b)
        tree.union(a, b)
    res.append(inconv)

res.pop()                                   # 橋が落ちる前の最初の状態については出力しない

for a in reversed(res):
    print(a)

print(N*(N-1)//2)                           # 全ての道が切れた時の不便さを最後に追加

'''

4 5
1 2
3 4
1 3
2 3
1 4

'''

Measured memory_bytes: 107900