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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int MOD = 1e9+7;
signed main(){
	fastio
	int n,k;
	cin >> n >> k;
	int a[n];
	for(auto &x : a) cin >> x;
	int dp[n][k+1]; //nth child, the total sum of candies => how many ways
	memset(dp,0,sizeof dp);
	for(int j = 0;j <= k;j++){
		if(j > a[0]) dp[0][j] = 0;
		else{
			dp[0][j] = 1;
		}
	}
	for(int i = 1;i < n;i++){
		vector<int> pref(k+2,0);
		for(int j = 0;j <= k;j++){
			pref[j+1] = (pref[j+1] + dp[i-1][j])%MOD;
			pref[j+1] = (pref[j+1] + pref[j])%MOD;	
		}
		for(int j = 0;j <= k;j++){
			//cout << j << " " << j+1 << " " << max((int)0,j-a[i]) << ' ' << pref[j+1] << " " << pref[max((int)0,j-a[i])] << "\n";
			dp[i][j] = (dp[i][j] + pref[j+1] - pref[max((int)0,j-a[i])]+MOD)%MOD;
		}
		/*for(int x = max((int)0,j-a[i]); x <= j; x++){
				dp[i][j] = (dp[i][j] + dp[i-1][x])%MOD;
		}*/
	}
	cout << dp[n-1][k] << "\n";
}

Measured memory_bytes: 82388
#include <stdio.h>
void solve(void)
{
	int n,m,x;
	scanf("%d %d", &n,&m);
	x = 1800*m + 100*n;
	while(m-->0) x *= 2;
	
	printf("%d\n", x);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a[1000000],n,p[100000],len,l1,l2,t;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
	}
	sort(a+1,a+1+n);
//	for(int i=1;i<=len;i++)cout<<a[i]<<" ";
	for(int i=n;i>=1;i--){
	    if(a[i]==a[i-1]){
		    p[++t]=a[i];
			i--;
			if(t==2)break; 
		} 
	}
	cout<<p[1]*p[2];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    string s;
    string t;
    cin >> s;
    cin >> t;
    int cnt = 0;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

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

#define INF INT_MAX

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

int main(int, char**)
{
    int k;
    string s;
    cin >> k >> s;

    if (s.size() <= k)
        cout << s << endl;
    else
        cout << s.substr(0, k) << "..." << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  ll l0=2, l1=1, ans;
  for(int i=2; i <=N ;i++){
    ans =l0 + l1;
    //更新処理
    l0 = l1;
    l1 = ans;
  }
  if(N==0){
    cout << l0 << endl;
  }else if(N==1){
    cout << l1 << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#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 rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw_2(62,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,61) pw_2[i]=-2*pw_2[i-1];}
    
    ll N; cin>>N;
    map<P,ll> m;
    vector<ll> x(N);
    vector<ll> y(N);
    rep(i,N) cin>>x[i]>>y[i];
    rep(i,N-1)FOR(j,i+1,N){
        ll X=x[i]-x[j],Y=y[i]-y[j];
        
        if(X==0){
            m[P(0,abs(Y))]++;
        }
        else{
            if(X<0) m[P(-X,-Y)]++;
            else m[P(X,Y)]++;
        }
    }
    
    ll M=0;
    for(auto i:m){
        chmax(M,i.b);
    }
    
    cout<<N-M<<endl;
}



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

#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int,int>

int main(){
	ll n;
	cin >> n;
	ll pre[n+5] = {};
	ll sum = 0;
	f(n){
		ll add;
		cin >> add;
		sum += add;
		pre[i] = sum;
	}
	ll mi = 1e18;
	f(n){
		ll dif=abs(sum-pre[i]-pre[i]);
		mi = min(mi,dif);
	}
	cout << mi << endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <cmath>
    #include <limits.h>
    #include <utility>
    #include <map>
    #include <algorithm>
    #include <set>
    using namespace std;
    using P = pair<int,int>;
    using ll = long long;
    const int MOD=1e9+7;
    int main(){
        int n,m;
        cin>>n>>m;
        vector<ll> x(n),y(n),z(n),s(n);
        for(int i=0;i<n;i++){
            cin>>x[i]>>y[i]>>z[i];
        }
        ll ret=0;
        for(int a=-1;a<=1;a+=2){
            for(int b=-1;b<=1;b+=2){
                for(int c=-1;c<=1;c+=2){
                    for(int i=0;i<n;i++)s[i]=x[i]*a+y[i]*b+z[i]*c;
                    sort(s.rbegin(),s.rend());
                    ll cnt=0;
                    for(int i=0;i<m;i++){
                        cnt+=s[i];
                    }
                    ret=max(ret,cnt);
                }
            }
        }
        cout<<ret<<endl;
        return(0);
    }

Measured memory_bytes: 3660
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    map <int, int>m;
    REP(i, M){
        if(s[i]==1 && c[i]==0){
            if(N==1){ cout<<0<<endl;return;}
            else{ cout<<-1<<endl;return;}
        }
    }
    int lim;
    int start;
    if(N==1){start=0;lim=9;}
    else if(N==2){start=10;lim=99;}
    else {start=100;lim=999;}
    for(int i=start; i<=lim; i++){
        string str = to_string(i);
        bool flag=true;
        REP(j, M){
            if(s[j]<=N && c[j]==(int)(str[s[j]-1]-'0')){}
            else {flag=false;}
        }
        if(flag){
            cout<<i<<endl;return;
        }
    }
    cout<<-1<<endl;return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
 
 public static void main(String [] args)
 {
Scanner sc = new Scanner(System.in);
   int N=sc.nextInt();
   if(N%2==0) System.out.println ((N/2)-1); 
	/*int count=0;   
   HashMap<Integer> map = new HashMap<Integer>();
   for(int i=1;i<N/2;i++)
   {
	if(map.get(i)==null)
    {
		count++;
      	
    }*/
    else 
   System.out.println(N/2);
     
   }
   
 
  
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;

    lint ans = 0;
    rep(i, 4) {
        if(s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>

using namespace std;

struct Test{
	int bat,mot,cab,res;
};

bool operator<(const Test &t1,const Test &t2)
{
	return t1.res>t2.res;	// passed one is faster
}

int main()
{
	for(int a,b,c;cin>>a>>b>>c,a;){
		int n;	cin>>n;
		Test ts[1000];
		for(int i=0;i<n;i++){
			int bat,mot,cab;
			cin>>bat>>mot>>cab>>ts[i].res;
			ts[i].bat=bat-1;
			ts[i].mot=mot-1;
			ts[i].cab=cab-1;
		}
		sort(ts,ts+n);

		int stat[300];
		for(int i=0;i<a+b+c;i++)	stat[i]=2;
		for(int i=0;i<n;i++){
			if(ts[i].res==1){	// test passed
				stat[ts[i].bat]=1;
				stat[ts[i].mot]=1;
				stat[ts[i].cab]=1;
			}
			else{	// test rejected
				if(stat[ts[i].bat]==1 && stat[ts[i].mot]==1)	stat[ts[i].cab]=0;
				if(stat[ts[i].mot]==1 && stat[ts[i].cab]==1)	stat[ts[i].bat]=0;
				if(stat[ts[i].cab]==1 && stat[ts[i].bat]==1)	stat[ts[i].mot]=0;
			}
		}
		for(int i=0;i<a+b+c;i++)	cout<<stat[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<int>> vec(H,vector<int>(W));
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            cin >> vec.at(i).at(j);
        }
    }
    vector<tuple<int,int,int,int>> ret;
    for(int i = 0;i < H;i++) {
        if(i % 2 == 0) {
            for(int j = 0;j < W - 1;j++) {
                if(vec.at(i).at(j) % 2 == 1) {
                    ret.push_back(make_tuple(i,j,i,j + 1));
                    vec.at(i).at(j + 1)++;
                }
            }
            if(i != H - 1 && vec.at(i).at(W - 1) % 2 == 1) {
                ret.push_back(make_tuple(i,W - 1,i + 1,W - 1));
                vec.at(i + 1).at(W - 1)++;
            }
        }
        else {
            for(int j = W - 1;j >= 1;j--) {
                if(vec.at(i).at(j) % 2 == 1) {
                    ret.push_back(make_tuple(i,j,i,j - 1));
                    vec.at(i).at(j - 1)++;
                }
            }
            if(i != H - 1 && vec.at(i).at(0) % 2 == 1) {
                ret.push_back(make_tuple(i,0,i + 1,0));
                vec.at(i + 1).at(0)++;
            }
        }
    }
    std::cout << ret.size() << endl;
    for(int i = 0;i < ret.size();i++) {
        std::cout << get<0>(ret.at(i)) + 1 << " " << get<1>(ret.at(i)) + 1 << " " << get<2>(ret.at(i)) + 1 << " " << get<3>(ret.at(i)) + 1 << endl;
    }
}

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

int main(){
    int N, T;
    cin >> N >> T;

    int ans = 1001;
    while(N--){
        int c, t;
        cin >> c >> t;
        if(t <= T) ans = min(ans, c);
    }
    cout << (ans == 1001 ? "TLE" : to_string(ans))  << endl;
}

Measured memory_bytes: 256
//
// Created by kota_ on 2019/12/30.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
}Node;

typedef Node* Nodepointer;
void print_preorder(Nodepointer root);
void print_inorder(Nodepointer root);
void clear(Nodepointer root);

Nodepointer make_1node(int key){
    Nodepointer ret = malloc(sizeof(Node));
    ret->key = key;
    ret->parent = NULL;
    ret->left = NULL;
    ret->right = NULL;
    return ret;
}


void insert(Nodepointer *Tree, int key){
    Nodepointer x, y, z;
    y = NULL;
    x = *Tree;
    while(x != NULL){
        y = x;
        if(key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    z = make_1node(key);
    z->parent = y;

    if(y == NULL){
        *Tree = z;
    }
    else if(key < y->key){
        y->left = z;
    }
    else{
        y->right = z;
    }

}


int main(){
    int i, n, key;
    char command[7];
    Nodepointer Tree = NULL;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s", command);
        if(strcmp("insert", command) == 0){
            scanf("%d", &key);
            insert(&Tree, key);
        }
        else if(strcmp("print", command) == 0){
            print_inorder(Tree);
            printf("\n");
            print_preorder(Tree);
            printf("\n");
        }
    }
    clear(Tree);
    return 0;
}

void print_preorder(Nodepointer root){
    if(root == NULL){
        return;
    }
    printf(" %d", root->key);
    print_preorder(root->left);
    print_preorder(root->right);
}

void print_inorder(Nodepointer root) {
    if(root == NULL){
        // 安全対策、ヨシ！
        return;
    }
    if(root->left != NULL){
        print_inorder(root->left);
    }
    printf(" %d", root->key);
    if(root->right != NULL){
        print_inorder(root->right);
    }
}

void clear(Nodepointer root){
    if(root == NULL){
        // 安全対策、ヨシ！
        return;
    }
    clear(root->right);
    clear(root->left);
    free(root);
}



Measured memory_bytes: 25184
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <sstream>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const double EPS=1e-6;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) a.rbegin(),a.rend()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) FLL(a,0)
#define declare(a,it) __typeof(a) it=(a)
#define FOR(it,a) for(declare(a.begin(),it);it!=a.end();++it)
#define FORR(it,a) for(declare(a.rbegin(),it);it!=a.rend();++it)
template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
int s2i(string& a){stringstream ss(a);int r;ss>>r;return r;}
int geti(){int n;scanf("%d", &n);return n;}

string gutyoku(ll s){
  stringstream ss;
  for(int i = 1;ss.str().size()<s+100;++i){
    if(i%3==0) ss << "Fizz";
    if(i%5==0) ss << "Buzz";
    if(i%3 && i%5) ss << i;
  }
  
  return ss.str().substr(s-1,20);
}

int main(int argc, char *argv[])
{
  ll s;
  cin >> s;
  //string gu=gutyoku(s);
  --s;
  ll d=1;
  while(true){
    ll b = pow(10LL,d)/10;
    ll e = pow(10LL,d);
    ll bd = (e-b)*d;
    //cout << bd << endl;
    bd += ((e-1)/3 - (b-1)/3) * (4-d);
    //cout << bd << endl;
    bd += ((e-1)/5 - (b-1)/5) * (4-d);
    //cout << bd << endl;
    bd += ((e-1)/15 - (b-1)/15) * d;
    //cout << bd << endl;
    if(bd < s) s -= bd;
    else break;
    ++d;
  }
  //cout << endl;
  ll b = pow(10LL,d)/10;
  ll low = b;
  ll up = b*10;
  ll ofs = s;
  while(low+1 < up){
    ll mid = (low+up)/2;
    ll bd = (mid-b)*d;
    bd += ((mid-1)/3 - (b-1)/3) * (4-d);
    bd += ((mid-1)/5 - (b-1)/5) * (4-d);
    bd += ((mid-1)/15 - (b-1)/15) * d;
    //cout << s << " " << bd << endl;
    if(bd >= s){
      up = mid;
    }else{
      low = mid;
      ofs = s-bd;
      //cout << " " << low << " " << ofs << endl;
    }
  }
  
  // cout << low << endl;
  // cout << ofs << endl;
  
  stringstream ss;
  rep(i,100){
    if((low+i)%3 == 0) ss << "Fizz";
    if((low+i)%5 == 0) ss << "Buzz";
    if((low+i)%3 && (low+i)%5) ss << low+i;
  }

  cout << ss.str().substr(ofs,20) << endl;
  //cout << gu << endl;
  return 0;
}

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

typedef long long ll;

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

	ll N, K;
	cin >> N >> K;

	ll ans = 0;

	vector<ll> A(N);

	for(int i = 0; i < N; i++) {
		cin >> A[i];
		ans += A[i];
	}

	ll count = 0;

	for(ll i = 45; i >= 0; i--) {
		ll x = 1LL << i;
		if(count + x > K) continue;
		ll c = 0;
		for(int j = 0; j < N; j++) {
			if(A[j] & x) {
				c++;
			}
		}
		c = N - c;
		//cerr << c << endl;
		if(c > N / 2LL) {
			count += x;
			ans += x * (2LL * c - N);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(i<a)
        {
            if(s[i]>'9'||s[i]<'0')
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        else if(i==a)
        {
            if(s[i]!='-')
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        else
        {
            if(s[i]>'9'||s[i]<'0')
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    if(s.size()!=a+b+1)
    {
                cout<<"No"<<endl;
                return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    // if(N == 1){
    //     cout << 1 << endl;
    //     return 0;
    // }
    vector<pair<int, int>> XYs(N);
    int x, y;
    for(int i = 0; i < N; ++i){
        cin >> x >> y;
        XYs[i] = make_pair(x, y);
    } 

    map<pair<int, int>, int> table;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(i == j) continue;
            table[{(XYs[i].first - XYs[j].first), (XYs[i].second - XYs[j].second)}]++;
        }
    }
    int ans = 0;
    for(auto i : table){
        ans = max(ans, i.second);
    }
    cout << N-ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    if (n<m) {
        for(int i=0;i<m;i++)printf("%d",n);
    } else {
        for(int i=0;i<n;i++)printf("%d",m);
    }
    puts("");
}

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

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

    if(n<3){
        if(x==2) cout<<"Yes"<<endl<<1<<endl<<2<<endl<<3<<endl;
        else cout<<"No"<<endl;
        return 0;
    }
 
    else {
        if(x==2*n-1 || x==1) cout<<"No"<<endl;
        else {
            cout<<"Yes"<<endl;
            int cnt=1;
            int a[2*n]={};
            a[x]++;
            int t,tt;
            if(x==2*n-2) t=x+1,a[t]++,tt=x-1;
            else t=x-1,a[t]++,tt=x+1;
            a[tt]++;
                for(int i=2*n-1;;i--){
                    if(a[i]==0){
                        a[i]++;
                        cout<<i<<endl;
                        cnt++;
                    }
                    if(cnt==n-1){
                        cout<<tt<<endl<<x<<endl<<t<<endl;
                        cnt+=3;
                        break;
                    }
                }
                for(int i=1;;i++){
                    if(a[i]==0){
                    cnt++;
                    cout<<i<<endl;
                    a[i]++;
                    }
                    if(cnt==2*n) break;
                }
                
        }
    }

}

Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int main()
{
  long long t1,t2,a1,a2,b1,b2,c,d,n,res;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  if(a1>b1){
    c=t1*(a1-b1);
    d=t2*(b2-a2)-c;
  }else{
    c=t1*(b1-a1);
    d=t2*(a2-b2)-c;
  }
  if(d<0){
    cout << "0" << endl;
    return 0;
  }
  if(d==0){
    cout << "infinity" << endl;
    return 0;
  }
  n=c/d;
  res=2*n+1;
  if(c%d==0)
    res--;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC041A - Table Tennis Training

        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long x = 0;
        long y = 0;

        if (a > b) {
            x = a;
            y = b;
        } else {
            x = b;
            y = a;
        }

        long cnt = 0;
        if ((x - y) % 2 == 0) {
            cnt = (x - y) / 2;
        } else {
            if (n - x >= y - 1) {
                cnt = y + (x - y - 1) / 2;
            } else {
                cnt = (n - x + 1) + (n - (y + n - x + 1)) / 2;
            }
        }

        System.out.println(cnt);
    }
}

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

int main(void){

    vector<int> A(3);
    for (int i = 0; i < 3; ++i) {
        cin>>A[i];
    }
    sort(A.rbegin(),A.rend());
    cout<<A[0]*10+A[1]+A[2]<<endl;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int N, M; cin >> N >> M;
  vector<int> L(M), R(M);
  vector<int> v(N+1, 0);
  vector<int> S(N+1, 0);
  int ans = 0;
  for(int i = 0; i < M; ++i) {
    cin >> L[i] >> R[i];
    L[i]--;
    v[L[i]]++;
    v[R[i]]--;
  }
  for(int i = 0; i < N+1; ++i) {
    if(i==0) S[i] += v[i];
    else S[i] = S[i-1] + v[i];
  }

  for(int i = 0; i < N+1; ++i) {
    if(S[i] == M) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, can[55][55];
const ll mod = 1e9+7;
ll add (ll a, ll b){
	return (a%mod + b%mod + mod)%mod;
}
ll mult(ll a, ll b){
	return (a%mod * b%mod +mod)%mod;
}
struct M{
	ll t[55][55];
	M(){
		for (ll i = 0; i < n; i++){
			for (ll j = 0; j< n; j++){
				t[i][j] = 0;
			}
		}
	}
	M operator* (const M& b) const {
		M c = M();
		for (ll i = 0; i < n; i++){
			for (ll j = 0; j < n; j++){
				for (ll k = 0; k <n; k++){
					c.t[i][k] = add(c.t[i][k], mult(t[i][j], b.t[j][k]));
				}
			}
		}
		//here we are just multiplying the matrices together
		return c;
	}
};
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll k;
	cin >> n >> k;
	for (ll i= 0; i < n; i++){
		for (ll j = 0; j < n; j++){
			cin >> can[i][j];
		}
	}
	//~ the relation is can matrix^k times the base case = kth state
	M answer = M();
	for (ll i = 0; i< n; i++){
		answer.t[i][i] = 1; //setting base case for f(1)
		//~ since for every node, there is one way of visiting it
	}
	M m = M();
	for  (ll i = 0; i< n; i++){
		for (ll j = 0;j< n; j++){
			m.t[i][j] = can[i][j];
		}
	}
	while (k){
		//~ trying to evaluate m^k times base case quickly
		if (k% 2 == 1){
			answer = answer *m;
		}
		m = m*m;
		k/=2;
	}
	//exponentiate the can matrix ^k to get f(k)
	ll total = 0;
	for (ll i = 0; i < n; i++){
		for (ll j= 0; j < n; j++){
			total = add(total, answer.t[i][j]);
		}
	}	
	cout << total;return 0;
	
	//~ dp[i] stores the number of paths that i can get to node i
	vector<ll> dp(n, 1);
	//~ for (ll i = 0; i < n; i++)dp[i] = 1;
	for (ll step = 0; step < k; step++){
		vector<ll> new_dp(n);
		for (ll i= 0; i< n; i++){
			for (ll j = 0; j < n; j++){
				if (can[i][j]){
					new_dp[j] += dp[i];
					//so new dp stores for cur k, 
					//dp is k-1, so if there is an edge, we can update
				}
				
			}
		}
		dp = new_dp;
	}
	ll ans  = 0;
	for (ll i= 0; i < n; i++){
		ans += dp[i];
	}
	cout << ans;
}


Measured memory_bytes: 384
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long mv = A[0];
    long mi;
    foreach (i; 0 .. N)
        if (abs(mv) < abs(A[i]))
        {
            mv = A[i];
            mi = i;
        }
    writeln(2 * N - 1);
    if (mv < 0)
    {
        foreach (i; 0 .. N)
        {
            writefln("%s %s", mi + 1, i + 1);
        }
        foreach_reverse (i; 1 .. N)
        {
            writefln("%s %s", i + 1, i);
        }
    }
    else
    {
        foreach (i; 0 .. N)
        {
            writefln("%s %s", mi + 1, i + 1);
        }
        foreach (i; 0 .. N - 1)
        {
            writefln("%s %s", i + 1, i + 2);
        }
    }
}


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

int main() {

    int x, n, p, cout = 1;
    int a[110];

    scanf("%d %d", &x, &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &p);
        a[i] = p - x;
        if (a[i] == 0) {
            cout = 0;
        }
    }
    if (cout) {
        printf("%d\n", x);
        return 0;
    }

    if (n == 0) {
        printf("%d\n", x);
        return 0;
    }

    int j, pp, pm;
    j = 1;
    while (1) {
        pp = j;
        pm = j*(-1);
        for (int i = 0; i < n; i++) {
            if (a[i] == pp) {
                pp=0;
            } else if (a[i] == pm) {
                pm = 0;
            }
        }
        if ((pp != 0) || (pm != 0)) {
            break;
        }
        j++;
    }

    if (pm != 0) {
        printf("%d\n", x+pm);
        return 0;
    } else {
        printf("%d\n", x+pp);
        return 0;
    }


}

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

int main() {
	double a,b,c;
	cin >> a >> b >> c;
	double pi=3.14159265358979;
	c=c/180*pi;
	double S,l,L,H;
	S=1.0/2.0*a*b*sin(c);
	H=b*sin(c);
	l=sqrt(pow(a,2.0)+pow(b,2.0)-2*a*b*cos(c));
	L=a+b+l;
	cout << fixed << setprecision(10);
	cout << S << endl << L << endl << H << endl;
}


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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr int INF = 1<<30;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), ans(n);
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            int x;
            cin >> x;
            if(x == a[i]) ans[j]++;
            else ans[a[i]-1]++;
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long
#define MAXN 310
int n,k,MOD,f[MAXN][MAXN][MAXN];
inline void add(int&a,int b){a=(a+b)%MOD;}
signed main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>k>>MOD;
	f[0][1][0]=1;
	for(int i=0;i<=n;++i)
		for(int v=1;v<=k;++v)
			for(int p=i;~p;--p){
				if(p)add(f[i][v][p-1],f[i][v][p]);
				else add(f[i][v+1][i],f[i][v][p]);
				add(f[i+1][v][p],f[i][v][p]*(p+1)%MOD);
			}
	cout<<f[n][k+1][n]<<endl;
	return 0;
}

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

int main() {
    ll N, K;
    cin >> N >> K;
    ll p[N];
    long double sum=0, mx;

    for(ll i = 0; i < N; ++i) cin >> p[i];

    //まずK番目まで合計
    for(ll i = 0; i < K; ++i) sum += (p[i] + 1.0) / 2;
    mx=sum;
    
    //以降差分のみ計算
    for(ll i = K; i < N; ++i){
        sum += (p[i] + 1.0) / 2;
        sum -= (p[i-K] + 1.0) / 2;
        mx = max(mx,sum);
    }

    cout << fixed << setprecision(10) << mx << endl;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h + 2);
    for (int i = 0; i < w + 2; i++) {
        a[0] += '#';
        a[h + 1] += '#';
    }

    for (int i = 1; i < h + 1; i++) {
        a[i] += '#';
        string s;
        cin >> s;
        a[i] += s;
        a[i] += '#';
    }

    for (int i = 0; i < h + 2; i++) {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N; cin >> N;
	vector<int> x(N),y(N),t(N);
	rep(i,N) cin >> t[i] >> x[i] >> y[i];

	int nt = 0, ny = 0, nx = 0;
	rep(i,N) {
		int at = t[i] - nt;
		int ax = abs(x[i] - nx);
		int ay = abs(y[i] - ny);
		if (at < ax + ay || at%2 != (ax+ay)%2) {
			cout << "No" << ln;
			return 0;
		}
		nt = t[i];
		ny = y[i];
		nx = x[i];
	}

	cout << "Yes" << ln;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
int N, W;
vvi dp;
vi w, v;

ll solve(int cur=0, ll rest=W){

    ll &ret=dp[cur][rest];
    if(ret != -1) return ret;

    ret=0;
    if(rest >= w[cur]) ret=v[cur]+solve(cur+1, rest-w[cur]);
    ret=max(ret, solve(cur+1, rest));

    return ret;

}

int main(){
    scanf("%d %d",&N, &W);
    dp=vvi(N+2, vi(W+2));
    for(int i=0;i<=N;i++) for(int j=0;j<=W;j++) dp[i][j]=-1;
    w=vi(N), v=vi(N);
    for(int i=0;i<N;i++) scanf("%lld %lld",&w[i], &v[i]);

    printf("%lld", solve());

    return 0;
}


Measured memory_bytes: 81024
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)


int main() {
  int MAX = 110000, times = 0, cnt = 0;

  ll X;
  cin>>X;
  
  for (int i = 2; i <= MAX; i++) {
    bool isPrime = true;
    for (int j = 2; j <= sqrt(i); j++) {
      times++;
      if (i % j == 0) {
        isPrime = false;
        break;
      }
    }
    if (isPrime) {
      //cout << i << " ";
      if(i>=X){
        cout<<i<<endl;
        break;
      }
      cnt++;
    }
  }
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N,D,X;
cin >> N >> D >> X;

int ans = X;
rep(i,N) {
    int A;
    cin >> A;
    ans += (D-1)/A + 1;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> V(N);
    ll ans = 0;
    REP(i,N){
        cin >> V[i];
        ans += V[i];
        ans -= (i+1);
    }
    cout << ans << endl;
}


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

const int MAX = 100;
int main() {
	int H, W;
	string a[MAX];
	cin >> H >> W;
	for (int i = 0;i < H;++ i) cin >> a[i];
	bool column[MAX], row[MAX];
	for (int i = 0;i < H;++ i) {
		column[i] = false;
		for (int j = 0;j < W;++ j) column[i] |= a[i][j] == '#';
	}
	for (int i = 0;i < W;++ i) {
		row[i] = false;
		for (int j = 0;j < H;++ j) row[i] |= a[j][i] == '#';
	}
	for (int i = 0;i < H;++ i) {
		for (int j = 0;j < W;++ j) if (column[i] && row[j]) cout << a[i][j];
		if (column[i]) cout << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

各行および列に対してその行/列が全て.で構成されているか調べておきます
そして、後は各文字に対して対応する行/列の両方が.で構成されていないなら出力すれば良いです
*/

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

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

    int a[n];
    int a_pula[n];
    int a_mina[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a_pula[i] = a[i] + 1;
        a_mina[i] = a[i] - 1;
    }

    map<int, int> map;
    for(int i = 0; i < n; i++){
        map[a[i]]++;
        map[a_pula[i]]++;
        map[a_mina[i]]++;
    }

    int ans = 0;
    int max = 0;
    for(auto itr = map.begin(); itr != map.end(); ++ itr){
        int key = itr -> first;
        int dis = itr -> second;
        if(max <= dis){
            max = dis;
            ans = key;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 5888
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, m, A[N], B[N], C[N], par[N], sm[N], ans[N], sz[N];
vector<pii> E;

int getpar(int v){
	return (par[v] == v?v:par[v]=getpar(par[v]));
}

bool cmp(pii x, pii y){
	return (max(C[x.F], C[x.S]) < max(C[y.F], C[y.S]));
}

void merge(int v, int u){
//	cout << v << ' ' << u << '\n';
	int vv = v, uu = u;
	v = getpar(v), u = getpar(u);
//	cout << v << ' ' << u << '\n';
	if (u == v) return;
//	cout << vv << ' ' << uu << '\n';
//	cout << v << ' ' << u << ' ' << ans[v] << ' ' << ans[u] << ' ' << sm[v] << ' ' << sm[u] << ' ' << C[vv] << ' ' << C[uu] << '\n';
	if (sz[v] < sz[u]) swap(v, u), swap(vv, uu);
	ans[v] = min(max(ans[v], max(0ll, C[uu] - sm[v])), max(ans[u], max(0ll, C[vv] - sm[u])));
	par[u] = v;
//	cout << ans[v] << '\n';
	sz[v] += sz[u];
	sm[v] += sm[u];
}


int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> A[i] >> B[i];
		C[i] = max(0ll, A[i] - B[i]);
//		cout << "YES " << i << ' ' << C[i] << '\n';
	}
	for (int i = 1; i <= m; i++){
		int v, u;
		cin >> v >> u;
		E.pb({v, u});
	}
//	cout << "YES\n";
	sort(all(E), cmp);
	for (int i = 1; i <= n; i++) par[i] = i, sz[i] = 1, sm[i] = B[i], ans[i] = C[i];
//	for (int i = 1; i <= n; i++) cout<<"Fuck " << ans[i] << '\n';
	for (auto u:E){
		merge(u.F, u.S);
	}	
	cout << ans[getpar(1)] + sm[getpar(1)];








	return 0;
}


Measured memory_bytes: 10284
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long N,K;
    cin >> N >> K;
    long long count = 0;
    long long p=K;
    
    while(1){
        count ++;
        
        if(N < K){
            
            break;
        }else if(N == K){
            count ++;
            break;}
        K *= p;
        
    }
    
    cout << count <<endl;
    
}


Measured memory_bytes: 256
from functools import reduce


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


n, x = map(int, (input().split()))
c = [int(i) for i in input().split()]
d = [abs(c[i] - x) for i in range(n)]

print(reduce(gcd, d))


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

ll dp[110][100100] = {};

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

  ll n, mx_w;
  cin >> n >> mx_w;
  vl w(n), v(n);
  rep(i,n) cin >> w[i] >> v[i];

  rep(i,n) {
    rep(j,mx_w+1) {
      if(j >= w[i]) chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  cout << dp[n][mx_w] << endl;
}


Measured memory_bytes: 79360
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    S,T = input().split()
    ans = ''
    for s,t in zip(S,T):
        ans += s
        ans += t
    print(ans)

if __name__ == '__main__':
    main()

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<"Draw"<<endl;
    return 0;
  }
  if(a==1)a+=13;
  if(b==1)b+=13;
  if(a>b)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
  return 0;
}


Measured memory_bytes: 3548
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    K = int(input())
    X = list(map(int, input().split()))
    
    ans = 0
    for x in X:
        ans += 2 * min(abs(x), abs(x-K))
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
x, n = map(int,input().split())
A = list(map(int,input().split()))

A = list(set([i for i in range(200)]) - set(A))
A.sort()
# print(A)

B = [[abs(i-x), i] for i in A]
B.sort(key=lambda x:x[1])
B.sort()
print(B[0][1])

Measured memory_bytes: 62084
s = input()

for i in range(1, len(s) + 1):
    if i % 2 == 1:
        if s[i - 1] == "R" or s[i - 1] == "U" or s[i - 1] == "D":
            continue
        else:
            print("No")
            break
    else:
        if s[i - 1] == "L" or s[i - 1] == "U" or s[i - 1] == "D":
            continue
        else:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 9052
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S == "RRS" || S == "SRR"){
        cout << 2;
    }else if(S == "RRR"){
        cout << 3;
    }else if(S == "SSS"){
        cout << 0;
    }else{
        cout << 1;
    }

    return 0;
}


Measured memory_bytes: 3248
#include <iostream>

#define int long long

using namespace std;

signed main(){
    int N;
    cin >> N;
    if(N%2==1){
        cout << 0 <<endl;
    }else{
        int counter = 5;
        int count = 0;
        while(counter < N){
            count += N/(counter*2);
            counter *=5;
        }
        cout << count <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int A[100001];
int main()
{
    int N,ans,cnt;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
        scanf("%d",&A[i]);
    sort(A,A+N);
    ans=0;
    cnt=1;
    for(int i=1;i<N;i++)
        if(A[i]==A[i-1])
            cnt++;
        else
        {
            ans+=cnt-1;
            cnt=1;
        }
    ans+=cnt-1;
    ans=N-ans;
    if(ans%2==0)
        ans--;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, = read_h()
    A = read_h()

    x1 = sum(A) - 2 * sum(a for i, a in enumerate(A) if i % 2 != 0)
    ans = [x1]

    for i in range(N - 1):
        ans.append(2 * A[i] - ans[i])

    print(*ans)


if __name__ == '__main__':
    main()


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

int main() {
    string s;
    cin >> s;
    bool a = false, b = false, c = false, d = false;
    for (char x : s) {
        a |= (x == 'N');
        b |= (x == 'E');
        c |= (x == 'W');
        d |= (x == 'S');
    }
    cout << ((a != d || b != c) ? "No" : "Yes") << '\n';
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    string ans;
    if (a1 + a2 + a3 > 21)
    {
        ans = "bust";
    }
    else
    {
        ans = "win";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int arr[n],ans[n];
    for(int i=0;i<n;++i)
    {
        cin >> arr[i];
    }
    for(int i=1;i<=n;++i)
    {
       ans[arr[i-1]]=i;
    }
    for(int i=1;i<=n;++i)
    {
        cout << ans[i] << " ";
    }
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<long long> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
        
    vector<long long> plus;//埋め立ててあげる余地
    long long sum = 0;//AとBの差の和
    int num = 0;//数を変更する数
    for (int i = 0; i < N; ++i) {
        long long dif = A[i] - B[i];
        if (dif < 0/*合格点に達していないなら*/) sum -= dif, ++num;
        else plus.push_back(dif);
    }
        
    if (num == 0) cout << 0 << endl; // マイナスがなかったら変更の必要なし
    else {
        sort(plus.begin(), plus.end(), greater<long long>());//より大きいのが埋め立ててくれると助かるから
        
        // 正の部分のうち、大きい方から優先的に削ってマイナスを埋め立てる
        long long p = 0;//埋め立ててあげる余地の和
        for (int i = 0; i < plus.size(); ++i) {
            p += plus[i];
            ++num;
            if (p >= sum) break;
        }
            
        if (p >= sum) cout << num << endl;
        else cout << -1 << endl;
    }
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    int N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int dp[N];
    dp[0]=0;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        h[i]=x;
        if(i==1){
            dp[i]=dp[0]+abs(x-h[0]);
        }
        else if(i>1){
            dp[i]=min(dp[i-1]+abs(x-h[i-1]),dp[i-2]+abs(x-h[i-2]));
        }
    }
    cout << dp[N-1];
    


}

/*



 */



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

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

    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> idx(N+1);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        idx[P[i]] = i;
    }
    set<int> S;
    int64_t cnt = 0;
    for (int x = N; x >= 1; x--) {
        int i = idx[x];
        S.insert(i);

        vector<int> ls(2, -1), rs(2, N);
        auto it = S.find(i);
        for (int j = 0; j < 2; j++) {
            if (it == S.begin()) break;
            it--;
            ls[j] = *it;
        }
        it = S.find(i);
        for (int j = 0; j < 2; j++) {
            it++;
            if (it == S.end()) break;
            rs[j] = *it;
        }
        cnt += ((int64_t) (i - ls[0]) * (rs[1] - rs[0]) +
                (int64_t) (ls[0] - ls[1]) * (rs[0] - i)) * x;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 5760