akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

vector<ll>R,G,C;
ll gone[500005];
vector<pll>v;
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m,a,b,c;

	//x red, y green
	cin >> x >> y >> a >> b >> c; 
	for(i=1;i<=a;i++)
	{
		cin >> t;
		R.pb(t);
	}
	for(i=1;i<=b;i++)
	{
		cin >> t;
		G.pb(t);
	}
	for(i=1;i<=c;i++)
	{
		cin >> t;
		C.pb(t);
	}

	sort(all(R)),reverse(all(R));
	sort(all(G)),reverse(all(G));
	sort(all(C)),reverse(all(C));

	for(i=0;i<min(x,a);i++)
		v.pb(mp(R[i],0));
	
	x-=min(x,a);
	
	for(i=0;i<c;i++)
	{
		if(!x)
			break;
		if(!gone[i])
			v.pb(mp(C[i],2)),gone[i]=1,x--;
	}
	
	for(i=0;i<min(y,b);i++)
		v.pb(mp(G[i],1));
	y-=min(y,b);

	for(i=0;i<c;i++)
	{
		if(!y)
			break;
		if(!gone[i])
			v.pb(mp(C[i],2)),gone[i]=1,y--;
	}
	
	sort(all(v));

	// for(i=0;i<sz(v);i++)
	// 	cout<<v[i].ff<<" "<<v[i].ss<<endl;

	j=0;
	while(j<c && gone[j])j++;

	i=0;
	while(i<sz(v) && j<c)
	{
		if(v[i].ss==2)i++;
		else
		{
			if(C[j]>v[i].ff)
				v[i]=mp(C[j],v[i].ss),j++,i++;
			else
				break;
		}
	}
	ll ans=0;
	for(i=0;i<sz(v);i++)
		ans+=v[i].ff;
	cout<<ans<<endl;	
}

Measured memory_bytes: 8432
var sx,sy,tx,ty,i:Integer;
begin
	read(sx,sy,tx,ty);
	for i:=1 to ty-sy do write('U');
	for i:=1 to tx-sx do write('R');
	for i:=1 to ty-sy do write('D');
	for i:=1 to tx-sx do write('L');
	write('L');
	for i:=1 to ty-sy do write('U');
	write('UR');
	for i:=1 to tx-sx do write('R');
	write('DR');
	for i:=1 to ty-sy do write('D');
	write('DL');
	for i:=1 to tx-sx do write('L');
	write('U');
end.


Measured memory_bytes: 128
#include <stdio.h>

int BinarySearch(int A[],int n,int key){
	int left = 0;
	int right = n;
	int mid;
	while(left < right){
		mid = (left + right) / 2;
		if(A[mid] == key){
			return mid;
		}
		else if(key < A[mid]){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	return -1;
}

int main(void){
	int i,n,q,key,sum=0;
	int A[100000];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&key);
		if(BinarySearch(A,n,key)!=-1){
			sum=sum+1;
		}
	}
	
	printf("%d\n",sum);

	return 0;
}


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

int main(){
  const long long INF = 1e18;
  int N, M, L;
  cin >> N >> M >> L;
  vector<vector<long long>> D(N,vector<long long>(N,INF));
  for(int i = 0; i < M; ++i){
    int a, b, c;
    cin >> a >> b >> c;
    --a,--b;
    if(c > L) continue;
    D[a][b] = c;
    D[b][a] = c;
  }
  for(int i = 0; i < N; ++i) D[i][i] = 0;
  for(int k = 0; k < N; ++k)
    for(int i = 0; i < N; ++i)
      for(int j = 0; j < N; ++j)
        D[i][j] = min(D[i][j],D[i][k]+D[k][j]);
  vector<vector<long long>> A(N,vector<long long>(N,INF));
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N; ++j){
      if(D[i][j] <= L) A[i][j] = 0;
    }
  }
  for(int k = 0; k < N; ++k)
    for(int i = 0; i < N; ++i)
      for(int j = 0; j < N; ++j)
        A[i][j] = min(A[i][j],A[i][k]+A[k][j]+1);

  int Q;
  cin >> Q;
  while(Q--){
    int s, t;
    cin >> s >> t;
    --s,--t;
    if(D[s][t] >= INF){
      cout << -1 << endl;
      continue;
    }
    cout << A[s][t] << endl;
  }
}


Measured memory_bytes: 1920
io = STDIN
n=io.gets.to_i
x=io.gets.split.map(&:to_i)
xs=x.sort
x.each do |a|
  if a<=xs[n/2-1]
    puts xs[n/2]
  elsif xs[n/2]<=a
    puts xs[n/2-1]
  end
end


Measured memory_bytes: 23396
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char a,b;
  cin>>a>>b;
  if(a=='H' && b=='H')
    cout<<'H'<<endl;
  else if(a=='D' && b=='D')
    cout<<'H'<<endl;
  else if(a=='D' && b=='H')
    cout<<'D'<<endl;
  else if(a=='H' && b=='D')
    cout<<'D'<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int n = stdIn.nextInt();
		int[] S = new int[n];
		for (int i=0; i<n; i++) {
			S[i] = stdIn.nextInt();
		}

		int q = stdIn.nextInt();
		int[] T = new int[q];
		for (int i=0; i<q; i++) {
			T[i] = stdIn.nextInt();
		}
		
		Arrays.sort(S);
		Arrays.sort(T);

		int count = 0;
		for (int i=0; i<q; i++) {
			if(Arrays.binarySearch(S,T[i]) >= 0)
				count++;
		}

		System.out.println(count);
	}
}

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

int main() {
	int n;
	while (cin >> n) {
		int sum = 0;
		
		for (int i = 0;i <= 1000;i++) {
			for (int j = 0;j <= 1000;j++) {
				int c = n - i - j;
				if (c >= 0 && c <= 2000) {
					int d = min(1000, c);
					int e = c - d;
					sum += (d - e + 1);
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>

int main(void) {
	int r, c;
	int i, j, k;
	int t;
	int a[102][102];
	
	scanf("%d %d", &r, &c);
	
	for(i = 0; i < r + 1; i++) {
		for(j = 0; j < c + 1; j++) {
			a[i][j] = 0;
		}
	}
	
	for(i = 0; i < r + 1; i++) {
		for(j = 0; j < c + 1; j++) {
			if(j == c) {
				if(i != r) {
					a[r][c] += a[i][j];
				}
			} else if(i != r) {
				scanf("%d", &t);
				
				a[i][c] += t;
				a[r][j] += t;
				a[i][j] = t;
			} 
		}
	}
	
	for(i = 0; i < r + 1; i++) {
		for(j = 0; j < c + 1; j++) {
			printf("%d", a[i][j]);
			if(j != c) {
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 644
#include<stdio.h>

int main(void)


{


int a,b,d,r ;


double f ;


scanf("%d %d",&a,&b) ;


d = a/b ;


r = a%b ;


f = (double)a/(double)b ;


printf("%d %d %lf\n",d,r,f) ;


return 0 ;


}

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N;
vector<ll> C(4,0);
string S;
cin >> N;

for(ll i = 0;i < N;++i){

    cin >> S;

    if(S == "AC") ++C[0];
    else if(S == "WA") ++C[1];
    else if(S == "TLE") ++C[2];
    else if(S == "RE") ++C[3];
}

cout << "AC x " << C[0] << endl;
cout << "WA x " << C[1] << endl;
cout << "TLE x " << C[2] << endl;
cout << "RE x " << C[3] << endl;

return 0;

}


Measured memory_bytes: 3628
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

P f(int x) {
  int OnesPlace=x%10;
  int LastPlace;
  while (x) {
    LastPlace=x;
    x/=10;
  }
  return P(LastPlace,OnesPlace);
}

int main(int argc, char const *argv[]) {
  int n; std::cin >> n;
  std::map<P, ll> freq;
  FOR(i,1,n) {
    P p = f(i);
    freq[p]++;
  }
  ll ans = 0;
  FOR(i,1,n) {
    P p = f(i);
    P q(p.S,p.F);
    ans +=freq[q];
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
// [ABC104]
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d, g; cin >> d >> g;
  vector<int> a(d), c(d);
  int ans = 1e9;
  for (int i = 0; i < d; i++) {
    cin >> a[i] >> c[i];
  }
  for (int n = 0; n < (1 << d); n++) {
    int tmp = 0; int gtmp = g;
    bitset<20> b = n;
    for (int i = 0; i < d; i++) {
      if (b[i]) {
        tmp += a[i];
        gtmp -= a[i] * (i+1) * 100 + c[i];
      }
    }
    if (gtmp <= 0) {
      ans = min(ans, tmp);
      continue;
    } else {
      for (int i = d-1; i >= 0; i--) {
        if (!b[i]) {
          int m = min(a[i], (gtmp-1)/((i+1)*100)+1);
          tmp += m;
          gtmp -= m * (i+1) * 100;
          if (gtmp <= 0) break;
        }
      }
      if (gtmp <= 0) {
        ans = min(ans, tmp);
        continue;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long int ll;
vector<ll> fact(200001);
ll mod_pow(ll x, ll p){
	ll res=1;
	ll n=x;
	while(p>0){
		if(p&1==1)res=(res*n)%MOD;
		n=(n*n)%MOD;
		p=(p>>1);
	}
	return res;
}
ll nCr(int n, int r){
	ll res=1;
	for (int i = n; i > n-r; i--){
		res*=i;
		res%=MOD;
	}
	res*=mod_pow(fact[r],MOD-2);
	res%=MOD;
	return res;
}
int main() {
	int n,a,b;
	cin>>n>>a>>b;
	fact[0]=1;
	for (int i = 1; i < b+1; i++){
		fact[i]=i*fact[i-1];
		fact[i]%=MOD;
	}
	ll total=mod_pow(2,n)-1;
	total-=(nCr(n,a)+nCr(n,b));
	total%=MOD;
	if(total<0)total+=MOD;
	cout<<total<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if(S[i] != T[i]) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstdio>

int main(int argc, char* argv[])
{
  int N, K;
  std::cin >> N >> K;

  int ans = N % K == 0 ? 0 : 1;
  std::cout << ans << std::endl;

  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){if(a < b) a = b;}



int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	set<int> st;
	rep(i, n){
		if(st.count(a[i]) ) {puts("NO"); return 0;}
		st.insert(a[i]);
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 11136
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  printf("%d\n",n*n*n );
  return 0;
}


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

public class Main {

    public static void main(String[] args) throws IOException {

        ArrayList<Integer> x_list = new ArrayList<>();
        ArrayList<Integer> y_list = new ArrayList<>();

        int x;
        int y;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        do {
            String[] line = br.readLine().split(" ");
            x = Integer.parseInt(line[0]);
            y = Integer.parseInt(line[1]);

            if (x == 0 && y == 0) {
                break;
            }

            x_list.add(x);
            y_list.add(y);

        } while (x != 0 || y != 0);

        for (int n = 0; n < x_list.size(); n++) {
            for (int a = 0; a < x_list.get(n); a++) {

                for (int b = 0; b < y_list.get(n); b++) {
                    
                    if(a % 2 == 0){
                        if(b % 2 == 0) System.out.printf("#");
                        else System.out.printf(".");
                    }
                    else{
                        if(b % 2 == 0) System.out.printf(".");
                        else System.out.printf("#");
                    }
                }

                System.out.println();
            }

            System.out.println();
        }

    }

}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};

int main(void)	
{
	ll n, m, k;
	cin >> n >> m >> k;
	vector<set<ll>> link(n);
	vector<set<ll>> block(n);
	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		link[a].insert(b);
		link[b].insert(a);
	}
	rep(i, k) {
		ll c, d;
		cin >> c >> d;
		c--; d--;
		block[c].insert(d);
		block[d].insert(c);
	}
	UnionFind uf(n);
	rep(i, n) {
		for (auto e : link[i]) {
			uf.merge(i, e);
		}
	}
	vector<ll> ns(n, 0);
	rep(i, n) {
		ns[uf.root(i)]++;
	}

	rep(i, n) {
		ll own = uf.root(i);
		ll g = ns[own];
		g -= link[i].size();
		for (auto b : block[i]) {
			ll other = uf.root(b);
			if (own == other) {
				g--;
			}
		}
		cout << g-1 << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 31360
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <cmath>
#include <string.h>
#include <set>


using namespace std;



int main(){
    int n;
    while(cin>>n){
        int graph[101][101]={0};
        for(int roop=0; roop<n; roop++){
            int r;
            cin>>r;
            int k;
            cin>>k;
            for(int roop2=0; roop2<k; roop2++){
                int t;
                cin>>t;
                graph[r][t]=1;
            }
        }
        
        int q;
        cin>>q;
        for(int roop=0; roop<q; roop++){
            int s,d,v;
            cin>>s>>d>>v;
            int visit[101]={0};
            visit[s]=1;
            queue<pair<int,int> > qu;
            pair<int,int> now;
            now.first=s;
            now.second=v;
            
            qu.push(now);
            bool find=false;
            
            
            while(!qu.empty()){
                
                now=qu.front();
                //cout<<now.first<<" "<<now.second<<endl;
                qu.pop();
                if(now.first==d){
                    find=true;
                    break;
                }
                if(now.second>1){
                    for(int i=1; i<=n; i++){
                        if(graph[now.first][i]==1&&visit[i]==0){
                            visit[i]=1;
                            pair<int,int> temp;
                            temp.first=i;
                            temp.second=now.second-1;
                            qu.push(temp);
                        }
                    }
                }
            }
            if(find)cout<<v-now.second+1<<endl;
            else cout<<"NA"<<endl;
            
        }
    }
}

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

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

  int ans = 0;
  int l = 0, r = s.length() - 1;
  while (l < r) {
    if (s[l] == s[r]) {
      l++;
      r--;
    } else if (s[l] == 'x') {
      ans++;
      l++;
    } else if (s[r] == 'x') {
      ans++;
      r--;
    } else {
      ans = -1;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

         StringBuffer sb = new StringBuffer();
         Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
         String S = sc.next();

         for(int i = 0;i<S.length();i++){
             char c = S.charAt(i);
             c = (char)((int)'A'+((int)c-(int)'A'+N)%26);
             sb.append(c);
         }
         System.out.println(sb);
    }
}


Measured memory_bytes: 24148
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: XXOR
 */

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

/* constant */

const int MAX_N = 100000;
const int M = 40;

/* typedef */

typedef long long ll;

/* global variables */

ll as[MAX_N], ms[M + 1];
int bns[M];

/* subroutines */

inline void setmax(ll &a, ll b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  ll k;
  scanf("%d%lld", &n, &k);
  k++;
  
  for (int i = 0; i < n; i++) {
    ll ai;
    scanf("%lld", &ai);

    for (int j = 0; ai > 0; j++, ai >>= 1)
      if (ai & 1) bns[j]++;
  }
  //for (int i = 0; i < M; i++) printf("%d,%d ", bns[i][0], bns[i][1]);
  //putchar('\n');

  ms[0] = 0;
  for (int i = 0; i < M; i++)
    ms[i + 1] = ms[i] + (1LL << i) * max(bns[i], n - bns[i]);

  ll maxf = 0, fu = 0;
  for (int i = M - 1; i >= 0; i--) {
    ll bi = 1LL << i;
    ll fu0 = fu + bi * bns[i];
    if (k >= bi) {
      setmax(maxf, fu0 + ms[i]);
      fu0 = fu + bi * (n - bns[i]);
      k -= bi;
    }
    fu = fu0;
  }

  printf("%lld\n", maxf);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 1004;

llong fac[n_max];  /// fac[n] = n!
llong finv[n_max]; /// (fac[n] * finv[n]) % MOD = 1
llong inv[n_max];  /// (n * inv[n]) % MOD = 1
 
void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR (i, 2, n_max) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}
 
llong nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


llong beki(llong a,llong x){
    llong res = 1;
    llong tmp = a;
    while(x > 0){
        if(x & 1) res *= tmp; res %= MOD;
        tmp *= tmp;
        tmp %= MOD;
        x >>=1;
    }
    return res;
}

signed main(){
    int n,a,b,c,d;
    cin >> n >> a >>b >> c >> d;
    init();

    int dp[n_max][n_max];
    REP(i,n_max) REP(j,n_max) dp[i][j] = 0;
    int gyakugen[n_max];
    FOR(i,1,n_max) gyakugen[i] = beki(i,MOD-2);

    dp[b][n] = 1;
    REPR(i,b){
        if(i == a-1) break;

        REP(j,n + 1){
            dp[i - 1][j] += dp[i][j];
            dp[i-1][j] %= MOD;
            int tmp = 1;
            FOR(k,1,d+1){
                if(k * i > j) break;
                tmp *= nCk(i * k,i);
                tmp %= MOD;
                tmp *= gyakugen[k];
                tmp %= MOD;
                if(k < c) continue; 
                int hoge = dp[i][j] * tmp;
                hoge %= MOD;
                hoge *= nCk(j,k * i);
                hoge %= MOD;
                dp[i-1][j-k * i] += hoge;
                dp[i-1][j-k * i] %= MOD;
            }
        }
    }
    cout << dp[a-1][0] << endl;


}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct Graph {
    static constexpr int INF = 1 << 30;
    struct Edge {
        int i, r, f;
    };
    Graph(int n) : v(n), h(n), q(n), e(n) {}
    void add_edge(int i, int j, int f) {
        int r0 = e[j].size();
        int r1 = e[i].size();
        e[i].push_back({ j, r0, max(+f, 0) });
        e[j].push_back({ i, r1, max(-f, 0) });
    }
    void bfs(int i0, int i1) {
        fill(v.begin(), v.end(), -1);
        v[i0] = 0;
        int j0 = 0, j1 = 0;
        q[j1++] = i0;
        while (j0 < j1) {
            int i = q[j0++];
            for (Edge& o : e[i]) {
                if (v[o.i] >= 0 || o.f == 0) continue;

                v[o.i] = v[i] + 1;
                if (o.i == i1) return;
                q[j1++] = o.i;
            }
        }
    }
    int dfs(int i, int i1, int f0) {
        for (; h[i] < e[i].size(); h[i]++) {
            Edge& o = e[i][h[i]];
            if (v[o.i] <= v[i] || o.f == 0) continue;

            int f = min(f0, o.f);
            if (o.i != i1) f = dfs(o.i, i1, f);
            if (f == 0) continue;

            o.f -= f;
            e[o.i][o.r].f += f;
            return f;
        }
        return 0;
    }
    int64_t max_flow(int i0, int i1) { // i0 != i1
        for (int64_t f = 0;;) {
            bfs(i0, i1);
            if (v[i1] < 0) return f;
            fill(h.begin(), h.end(), 0);
            while (1) {
                int t = dfs(i0, i1, INF);
                if (t == 0) break;
                f += t;
            }
        }
    }
    vector<int> v, h, q;
    vector<vector<Edge>> e;
};

int main() {
    int n, m;
    cin >> n >> m;

    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;

        g.add_edge(a, b, c);
    }

    cout << g.max_flow(0, n - 1) << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll H, W, K;
vvll c;

ll check(vvll c, ll state_1, ll state_2){
  REP(i,H){
    if(state_1%2==1){
      REP(j,W){
        c[i][j] = 0;
      }
    }
    state_1/=2;
  }
  REP(j,W){
    if(state_2%2==1){
      REP(i,H){
        c[i][j] = 0;
      }
    }
    state_2/=2;
  }

  ll tmp = 0;
  REP(i,H){
    REP(j,W){
      tmp += c[i][j];
    }
  }

  if(tmp==K) return 1;

  return 0;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(H,W,K);
  c.resize(H, vll(W));
  REP(i,H){
    string str;
    IN(str);
    REP(j,W){
      if(str[j]=='.'){
        c[i][j] = 0;
      }else{
        c[i][j] = 1;
      }
    }
  }

  ll ans = 0;
  REP(i,1<<H){
    REP(j,1<<W){
      ans += check(c, i, j);
    }
  }

  OUT(ans);


  return 0;
}

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

int mod = 1e9 + 7;

int N;

int main() {
    cin >> N;
    long long a;
    vector<long long> one(61);
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        for (int j = 0; j < 61; j++) {
            if (a & 1LL << j) {
                ans = ans + (1LL << j) % mod * (i - one[j]) % mod;
                one[j]++;
            } else {
                ans = ans + (1LL << j) % mod * one[j] % mod;
            }
            ans %= mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
	int n,i,j,x,c,a[101]={0};
cin>>n;
for(i=0;i<n;i++){
cin>>x;
	for(j=x;j>0;j--){
a[j]++;
}
}
	for(i=n;i>0;i--){
		if(i<=a[i]){
			break;
		}
	}
	cout<<i<<endl;
return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		//台形の計算式
		int trapezoid = (a+b)*h/2;
		System.out.println(trapezoid);
	}

}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll gt[maxn], igt[maxn];

ll Pow(ll a, ll b){
  if (b == 0) return 1;
  ll tmp = Pow(a, b / 2);
  tmp = (tmp * tmp) % mod;
  if (b % 2) return (tmp * a) % mod;
  return tmp;
}

void init(){
  const int mx = 2e6 + 1;
  gt[0] = 1;
  for (int i = 1; i <= mx; ++i) gt[i] = (gt[i-1] * i) % mod;
  igt[mx] = Pow(gt[mx], mod - 2);
  for (int i = mx - 1; i >= 0; --i) igt[i] = (igt[i+1] * (i+1)) % mod;
}

ll C(int k, int n){
  return (((gt[n] * igt[k]) % mod) * igt[n-k]) % mod;
}

ll calc(int i, int j){
  return C(i+1, i+j+1);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int r1, r2, c1, c2; cin >> r1 >> c1 >> r2 >> c2;
  ll ans = 0;
  init();
  for (int i = r1; i <= r2; ++i){
    ans = ans + calc(i, c2) - calc(i, c1 - 1);
    ans = ans + mod;
    ans = ans % mod;
  }
  cout << ans;
}




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

int main(){

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

    int m = max({a, b, c}); 
    int tmp = a+b+c-m;
    for(int i = 1; i <= k; i++){
        m*= 2;
    }

    cout << tmp+m << endl;

    return 0;
}

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

int a[5000];
int dp[5000];
int k,n;
int main(){
  while(1){
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++)cin>>a[i];
    dp[0]=a[0];
    for(int i=1;i<n;i++)dp[i]=max(dp[i-1]+a[i],a[i]);
    int ans=-9999999;
    for(int i=0;i<n;i++)ans=max(ans,dp[i]);
    cout<<ans<<"\n";
  }
}



Measured memory_bytes: 3032
n = int(input())
dp = [float('inf')]*(n+1)
dp[0] = 0

six = 0
while True:
    if 6**(six+1) > n:
        break
    six += 1

nine = 0
while True:
    if 9**(nine+1) > n:
        break
    nine += 1

for a, b in zip([1, 6, 9], [1, six, nine]):
    for i in range(1, b+1):
        k = a**i
        for j in range(n):
            if j+k > n:
                break
            dp[j+k] = min(dp[j+k], dp[j]+1)
print(dp[n])

Measured memory_bytes: 6852
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h, m, s;
		
		h = S / 3600;
		m = S % 3600 / 60;
		s = S % 60;
		System.out.println(h + ":" + m + ":" + s);
		sc.close();
	}

}


Measured memory_bytes: 26320
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;

	int a[2][n];
	for(int i=0; i<2; i++)
		for(int j=0; j<n; j++)
		cin >> a[i][j];

	int sum1=0, sum2=0, max=0;

	for(int i=0; i<n; i++)
	{
		sum1 += a[0][i];

		sum2 = 0;
		for(int j=i; j<n; j++)
			sum2 += a[1][j];

		if(max < sum1 + sum2) max = sum1 + sum2;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

double a[200001],b[200001];

int32_t main()
{
    FIO
    int n,m; cin>>n>>m;
    double s=0;
    fi(i,n) {
        cin>>a[i];
        s+=a[i];
    }
    double f=(s/double(4*m));
    int c=0;
    fi(i,n) {
        if(a[i]>=f) c++;
    }
    if(c>=m) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll fin=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            fin*=x;
            fin%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return fin;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    string s; cin>>s;
	    ll abc = 0, w=1, fin=0;
	    ll z= s.length();
	   ll m[2019]={0};
	   
	  
     	m[0]++;
   
	 ifl(i,0,z)
	  {
	    abc = ( abc + (s[i]-'0')*w );
	    abc%=2019;
	    fin =fin+ m[abc];
	    m[abc]++;
	   
	     w =w*10;
	       w=w%2019;
	    
	  }
	 cout<<fin<<bn;
	    
	}
	
	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)    
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);
 

int main()
{
   ll n;
   cin>>n;
   ll h[n];
   rep(i,n) cin>>h[i];
   ll curr=0,ans = 0;
   rep(i,n-1){
      if(h[i+1]<=h[i]){
         curr++;
         ans = max(ans,curr);
      }
      else curr=0;
   }
   cout<<ans<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m)+m)%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,K; cin >> N >> K;
    ll ans = 1, n=K;
    while(N/K){
        K *= n;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n,ans=0;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    rep(i,n){
        if(v[i]-c[i]>0)
            ans += v[i]-c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll N,H,W;
		cin >> N >> H >> W;
		cout << (N-H+1)*(N-W+1) << endl;
		
	}
	return 0;

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	VLL A(3); cin >> A[0]>>A[1]>>A[2];
	ll ans = 0;
	sort(all(A));
	while (1) {
		if (A[0] + 2 <= A[1]) {
			A[0] += 2;
			ans++;
		}
		else if (A[0] + 1 == A[1]) {
			A[0]++;
			A[2]++;
			ans++;
		}
		else if (A[0] == A[1])break;
	}
	cout << ans+A[2]-A[1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n, k;
	cin >> n >> k;
	n %= k;
	cout << min(n, k - n) << endl;			
}

Measured memory_bytes: 256
N,M = [int(x) for x in input().split()]
S = [int(x) for x in input().split()]+[0]
T = [int(x) for x in input().split()]+[0]
MOD = 10**9+7
dp=[[[0]*2 for _ in range(M+2)] for _ in range(N+2)]
dp[0][0][0]=1
for i in range(N+1):
    for j in range(M+1):
        dp[i+1][j][0] += dp[i][j][0]
        dp[i+1][j][0] %= MOD
        dp[i][j][1] += dp[i][j][0]
        dp[i][j][1] %= MOD
        dp[i][j+1][1] += dp[i][j][1]
        dp[i][j+1][1] %= MOD
        if(S[i]==T[j]):
            dp[i+1][j+1][0] += dp[i][j][1]
            dp[i+1][j+1][0] %= MOD

print(dp[N][M][1])


Measured memory_bytes: 371580
/**-------------------------
|--------From A.R.A--------|
-------------------------**/

#include <bits/stdc++.h>

#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}

using namespace std;
int64_t R=1;
void solution(){

    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k){cout<<s<<endl;}
    else{
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}
int main()
{
    FOR(i,R){solution();}
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            int N = int.Parse(Console.ReadLine());
            var A = cin.SplitRead();
            int[] c = new int[N];
            Initialize(ref c, 0);
            foreach(var a in A)
            {
                c[a - 1]++;
            }
            Sort(c);

            int[] d = new int[N + 1];
            d[0] = 0;
            for(var i = 0; i < N; i++)
            {
                d[i + 1] = d[i] + c[i];
            }

            for(var K = 1; K <= N; K++)
            {
                int l = -1;
                int r = (N / K) + 1;
                while (r - l > 1)
                {
                    int X = (l + r) / 2;

                    int ll = -1;
                    int rr = c.Length;
                    while (rr - ll > 1)
                    {
                        int cc = (ll + rr) / 2;
                        if (c[cc] >= X)
                        {
                            rr = cc;
                        }
                        else
                        {
                            ll = cc;
                        }
                    }

                    if (d[ll + 1] + X * (N - ll - 1) >= X * K)
                    {
                        l = X;
                    }
                    else
                    {
                        r = X;
                    }
                }

                Console.WriteLine(l);
            }

           
            //Console.Out.Flush();
        }

        
    }

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 44328