akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		BigDecimal sum = new BigDecimal(1);
		BigDecimal max = new BigDecimal(Math.pow(10, 18));
		int n = sc.nextInt();
		List<BigDecimal> bd = new ArrayList<>();
		
		for(int i = 0;i < n;i++) {
			BigDecimal x = new BigDecimal(sc.nextLong());
			if(x.equals(BigDecimal.ZERO)) {
				System.out.println(0);
				return;
			}
			bd.add(x);
		}
		
		for(BigDecimal x : bd) {
			sum = sum.multiply(x);
			if(max.compareTo(sum) == -1) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(sum);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 36128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	long int N;
	cin >> N;
	vector<long int>A(N);

	int mcount = 0;
	long long  int ans = 0;
	vector<long int>B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] < 0) {
			mcount++;
			A[i] *= -1;
			B[i] = A[i];
		}
		else {
			B[i] = A[i];
		}
		ans += B[i];
	}
	//cout << ans << endl;
	sort(B.begin(), B.end());
	mcount %= 2;
	for (int j = 0; j < mcount; j++) {
		ans -= B[j]*2;
	}

	cout << ans << endl;


}

Measured memory_bytes: 1792
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class UnionFind:
    def __init__(self,arg_V):
        self.V = arg_V
        self.boss = [None]*arg_V
        self.height = [None]*arg_V

    def init(self):
        for i in range(self.V):
            self.boss[i] = i
            self.height[i] = 0

    def get_boss(self,index):
        if index == self.boss[index]:
            return index
        else:
            self.boss[index] = self.get_boss(self.boss[index])
            return self.boss[index]


    def is_same_group(self,a,b):
        return self.get_boss(a) == self.get_boss(b)

    def unite(self,x,y):
        boss_x = self.get_boss(x)
        boss_y = self.get_boss(y)

        if boss_x == boss_y:
            return

        if self.height[x] > self.height[y]:

            self.boss[boss_y] = boss_x

        elif self.height[x] < self.height[y]:

            self.boss[boss_x] = boss_y

        else:
            self.boss[boss_y] = boss_x
            self.height[x] += 1

class Edge:
    def __init__(self,arg_FROM,arg_TO,arg_WEIGHT):
        self.FROM = arg_FROM
        self.TO = arg_TO
        self.WEIGHT = arg_WEIGHT

    def __lt__(self,arg):
        return self.WEIGHT < arg.WEIGHT



V,num_query = map(int,input().split())

UF = UnionFind(V)
UF.init()

for loop in range(num_query):

    command,A,B = map(int,input().split())
    if command == 0:
        UF.unite(A, B)
    else:
        if UF.is_same_group(A, B) == True:
            print("1")
        else:
            print("0")


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m;
    a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2, HELL)

int32_t main() { fastio;
    int n, k;
    cin >> n >> k;
    cout << min((n % k), (k - (n % k)) % k) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    map<string, int> m;
    ll ans = 0;
    rep(i, n){
        string s;
        cin >> s;
        sort(all(s));
        if (m.find(s) != m.end()){
            ans += m[s];
        }
        m[s]++;
    }
    // for(auto mm = m.begin(); mm != m.end(); mm++){
    //     ans += (mm->second * (mm->second-1))/2;
    // }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
// #define int long long

const int K = 1e5 + 5, N = 105;

int dp[K][2];
int n, a[N], k;
				
int32_t main() {
	fast_cin();  
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int cur_stones = 0; cur_stones <= k; cur_stones++) {
		for (int cur_player = 0; cur_player < 2; cur_player++) {
			int &ans = dp[cur_stones][cur_player];
			ans = cur_player ^ 1;
			bool ok = false;
			for (int i = 1; i <= n; i++) {
				if (cur_stones - a[i] >= 0) {
					ok |= (dp[cur_stones - a[i]][cur_player ^ 1] == cur_player);
				}
			}
			if (ok) ans = cur_player;
		}
	}
	int ans = dp[k][0];
	if (ans == 0) {
		cout << "First";
	} else {
		cout << "Second";
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

bool isPrime(int x) {
  int max = sqrt(x);
  for (int i = 2; i <= max; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n, x, c = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (isPrime(x)) {
      ++c;
    }
  }
  cout << c << endl;
}



Measured memory_bytes: 3104
#include <iostream>

using namespace std;

string str;

bool check(int i, string de) {
    bool ret=true;
    for(int j=0; j<de.size()-1; j++) {
        if(str[i-1-j]!=de[de.size()-2-j]) {
            ret=false;
            break;
        }
    }
    return ret;
}

int main() {
    cin >> str;
    
    string dm="dream", dmr="dreamer", es="erase", esr="eraser";
    bool flag=true;
    for(int i=str.size()-1; i>=0; i--) {
        if(str[i]=='m') {
            flag=check(i, dm);
            i -= 4;
        } else if(str[i]=='e') {
            flag=check(i, es);
            i -= 4;
        } else if(str[i]=='r') {
            if(i-2>=0) {
                if(str[i-2]=='m') {
                    flag=check(i, dmr);
                    i -= 6;
                } else if(str[i-2]=='s') {
                    flag=check(i, esr);
                    i -= 5;
                } else {
                    flag=false;
                }
            } else {
                flag=false;
            }
        } else {
            flag=false;
        }
        if(!flag) {
            break;
        }
    }
    if(flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
    
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> v(n);
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    //tupleのsortはfirstでsortされる
    sort(v.begin(), v.end());
    priority_queue<int> q;
    int ind = 0;
    int ans = 0;
    for (int i = 1; i < m+1; ++i) {
        //残りi日かつindが[0,n-1]の時,qにtupleのsecondを追加
        while ((v[ind].first == i) && (ind < n)) {
            q.push(v[ind].second);
            ind += 1;
        }
        //qが空じゃなければ最大値をpop
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
from collections import deque
H,W = map(int, input().split())
s = [input() for _ in range(H)]
visited = [[False]*W for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        stk = deque([(i,j)]) # stack
        visited[i][j] = True
        black,white = 0,0
        while stk: # なくなるまで
            y,x = stk.popleft()
            # print("now: ",y,x)
            from_ = s[y][x]
            if from_==".": white += 1
            else:          black += 1
            for dy,dx in ([1,0],[0,1],[-1,0],[0,-1]): 
                if not (0<=y+dy<H and 0<=x+dx<W):
                    continue
                to_   = s[y+dy][x+dx]
                if ((from_=="." and to_ == "#")
                 or (from_=="#" and to_ == ".") ):
                    if visited[y+dy][x+dx]: continue
                    stk.append([y+dy,x+dx])
                    visited[y+dy][x+dx] = True
        # print("black:{}, white:{}".format(black,white))
        ans += black*white
print(ans)

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


int main(){
    ll a;cin>>a;
    float b;cin>>b;
    ll b100 = b*100;
    ll ans = a*b100/100;
    cout<<ans<<endl;

}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, H; cin >> N >> H;
    ll ma=0;
    priority_queue<ll> q;
    rep(i, N){
        ll a, b; cin >> a >> b;
        ma = max(ma, a);
        q.push(b);
    }
    ll cnt = 0;
    while(H > 0 && !q.empty()){
        ll t = q.top(); q.pop();
        if(t <= ma) break;
        H -= t;
        cnt++;
    }
    if(H>0) cnt += (H-1)/ma + 1;
    cout << cnt << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5496
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

	int N; cin >> N;
	cout << (N+1) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 10100000
#define INF 1e15
#define MAP 110
#define initial_value -1
#define LINF 1LL << 60
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int H,W,h,w; cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <random>
#define INF 1000000007
using namespace std;

int main(void){
	int n,k;
	cin >> n >> k;
	cout << (n-1)/(k-1)+((n-1)%(k-1)?1:0) << endl; 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
char mp[15][1005];
int a[15],pos[15];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) cin>>mp[i]+1;
    int ans = 1<<30;
    for(int s=0;s<(1<<(n-1));s++)
    {
        vector<int> row;
        row.push_back(0);
        for(int i=0;i<n-1;i++) if(s&(1<<i)) row.push_back(i+1);
        row.push_back(n);
        for(int i=1;i<=n;i++) pos[i] = *lower_bound(row.begin(),row.end(),i);
        int cnt = row.size()-2;
        memset(a,0,sizeof(a));
        int flag = 0;
        for(int i=1;i<=m;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(mp[j][i]=='1')a[pos[j]]++;
                if(a[pos[j]]>k)
                {
                    cnt++;
                    memset(a,0,sizeof(a));
                    for(int o=1;o<=n;o++)
                    {
                        if(mp[o][i]=='1')a[pos[o]]++;
                        if(a[pos[o]]>k) flag = 1;
                    }
                    break;
                }
            }
            if(flag == 1) break;
        }
        if(!flag) ans = min(ans,cnt);
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

#define INF 2000000000
#define SIZE 1000000
#define pb push_back
#define showint(x) cerr<<#x<<" is "<<x<<endl;
#define showarr(x,n) for(int I=0;I<n;I++) {cerr<<#x<<"["<<I<<"]"<<" is "<<x[I]<<endl;}
//#define fin cin

int main()
{
  ifstream fin("input.txt",ios::in);
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
  cout<<setprecision(10);
  cout<<fixed;
  string s;
  cin>>s;
  string f="keyence";
  for(int i=0;i<s.size();i++)
  {
    for(int j=0;j<s.size()-i+1;j++)
    {
      string t=s;
      t.erase(i,j);
      if(t==f)
      {
        return cout<<"YES",0;
      }
    }
  }
  cout<<"NO";
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> 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;
}

int32 n;

map<int32,int32> cache;
int32 query(int32 i){
  if(i == n)i = 0;
  if(cache.count(i))return cache[i];
  cout << i << endl;
  string res;
  cin >> res;
  auto &ret = cache[i];
  if(res == "Vacant"){
    ret = 2;
  }else if(res == "Male"){
    ret = 0;
  }else{
    ret = 1;
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int32 l = 0,r = n/2;
  if(r%2)++r;
  if(query(l) == 2)return 0;
  if(query(r) == 2)return 0;
  if(query(l) == query(r)){
    l = r;
    r = n;
  }
  while(r - l > 2){
    // cout << l << " " << r << endl;
    int32 m = (l + r) / 2;
    if((m-l)%2)++m;
    if(query(m) == 2)return 0;
    if(query(l) == query(m)){
      l = m;
    }else{
      r = m;
    }
  }
  query((l+r)/2);
  return 0;
}

Measured memory_bytes: 3844
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod

int main(){
	ll n,k; cin>>n>>k;
	ll ans=0;
	while(n>0){
		n/=k;
		ans++;
	}
	cout<<ans<<endl;
}




Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int M1, M2, D1, D2;

    //入力
    cin >> M1 >> D1 >> M2 >> D2;

    if(D2==1)   cout << "1" << endl;
    else        cout << "0" << endl;

    return 0;
}

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

int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int a;
	cin >> a;
	cout << pow(a, 3)+pow(a, 2)+a;

	return 0;
}

Measured memory_bytes: 4228
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=10001;
int N;
LL l1,l2,l3;
LL gcd(LL a,LL b){
	if(b==0) return a;
	return gcd(b,a%b);
} 

int main(){
    N=read();
    for(int i=1;i<=3500;i++){
    	for(int j=i;j<=3500;j++){
    		l1=gcd(i,j);
    		l2=gcd(l1,N);
    		l3=i*j/l1*N/l2;
    		LL b=l3;
    		LL a=(4*(l3/N))-(l3/i)-(l3/j);
    		if(!a||a<0) continue;
    		LL f=gcd(a,b);
    		b/=f; a/=f;
    		if(a!=1&&a) continue;
    		printf("%lld %lld %lld\n",i,j,b);
    		return 0;
		}
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> s(N); 
  for (int i = 0; i < N; i++)
    cin >> s.at(i);
  
  int M;
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++)
    cin >> t.at(i);
  
  int s_count;
  int t_count;
  int max = 0;
  
  for (int i = 0; i < N; i++) {
    s_count = 0;
    t_count = 0;
    
  	for (int j = 0; j < N; j++) {
      if (s.at(i) == s.at(j))
        s_count++;
    }
    
    for (int j = 0; j < M; j++) {
      if (s.at(i) == t.at(j))
        t_count++;
    }
    
    if (s_count - t_count > max)
      max = s_count - t_count;
  } 
  
  cout << max << endl;
}


Measured memory_bytes: 256
/*********** Template Starts Here ***********/

/*************** Shadman Taqi ***************/
#include<bits/stdc++.h>
using namespace std;

#define MAX 500
#define ll long long
#define ull unsigned long long
#define ___   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = b; i >= a; i--)
#define debug(x) cout << #x << " " << x << endl;
#define in(x) cin>>x;
#define out(x) cout<<x;
#define gap cout<<" ";
#define nl cout<<endl;
#define cs(x) cout<<"Case "<<x<<": ";

/*********** Template Ends Here ***********/

/** ################################## Code starts here ################################### **/

int main()
{
    ___
    ll X,hp;
    in(X)
    hp=1000*(X/500)+5*((X%500)/5);
    out(hp) nl
    return 0;
}

/** ################################## Happy Coding ################################### **/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int sop(int k);
int32_t main()
{
      IOS;
      ll i,n,flag=0,nut=1,jump=1,q,j,cnt=0,cnt1=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0,m,x,y,h,l,z,k,h1,h2,m1,m2,t;
      string s;
      cin>>n;
      cin>>s;
      if(n>=3200)
      {
          cout<<s;
      }
      else
      {
          cout<<"red";
      }



    return 0;
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M, E;
	static int[] from;
	static long[] cost;

	static boolean disjoint() {
		UnionFind uf = new UnionFind(N);
		for (int i = 0; i < N; ++i) {
			if (from[i] != -1) uf.union(i, from[i]);
		}
		return uf.size(0) != N;
	}

	static long solve() {
		if (E <= N - 2) return 0;
		if (disjoint()) return 0;
		long ret = Long.MAX_VALUE;
		for (int i = 0; i < N; ++i) {
			if (from[i] == -1) continue;
			for (int j = i + 1; j < N; ++j) {
				if (from[j] == -1) continue;
				ret = Math.min(ret, cost[i] + cost[j]);
			}
		}
		for (int i = 0; i < N; ++i) {
			if (from[i] == -1) continue;
			int tmp = from[i];
			from[i] = -1;
			if (disjoint()) ret = Math.min(ret, cost[i]);
			from[i] = tmp;
		}
		return ret;
	}

	public static void main(String[] args) throws Exception {
		while (true) {
			N = sc.nextInt();
			M = sc.nextInt();
			if (N == 0) break;
			from = new int[N];
			cost = new long[N];
			Arrays.fill(from, -1);
			long minus = 0;
			E = 0;
			for (int i = 0; i < M; ++i) {
				int X = sc.nextInt();
				int Y = sc.nextInt();
				long C = sc.nextLong();
				if (C <= 0) {
					minus += C;
				} else {
					from[Y] = X;
					cost[Y] = C;
					++E;
				}
			}
			System.out.println(solve() + minus);
		}
	}

	static class UnionFind {
		int[] set;

		UnionFind(int n) {
			set = new int[n];
			Arrays.fill(set, -1);
		}

		void union(int a, int b) {
			int rtA = root(a);
			int rtb = root(b);
			if (rtA == rtb) {
				return;
			}
			set[rtA] += set[rtb];
			set[rtb] = rtA;
		}

		boolean find(int a, int b) {
			return root(a) == root(b);
		}

		int root(int a) {
			if (set[a] < 0) {
				return a;
			} else {
				set[a] = root(set[a]);
				return set[a];
			}
		}

		int size(int a) {
			return -set[root(a)];
		}
	}

}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC081
{
    class C
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();

            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Dictionary<int, int> dict = new Dictionary<int, int>();

            for (int i = 0; i < N; i++)
            {
                if (!dict.ContainsKey(A[i])) { dict.Add(A[i], 0); }
                if (dict.ContainsKey(A[i])) { dict[A[i]]++; }
            }
            if (dict.Count <= K) { Console.WriteLine(0); }
            else
            {
                int count = 0;
                var res = dict.OrderBy(x => x.Value);
                int index = 0;
                foreach (var item in res)
                {
                    if (index == dict.Count - K) break;
                    count += item.Value;
                    index++;
                }
                Console.WriteLine(count);
            }
        }
    }
}


Measured memory_bytes: 44752
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	int n; cin >> n;

    cout << (n*(n+1))/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++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 cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
#define PP pair<pair<ll,ll>,pair<pair<ll,ll>,ll>>
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	// cases
	ll n;
	cin >> n;
	vl a(n), ans(n);
	ain(a, n);
	ll xr = 0;
	loop(i, n)	xr ^= a[i];
	loop(i, n)	ans[i] = xr ^ a[i];
	loop(i, n)	cout << ans[i] << " ";
	cout << END;


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

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

using ll = int64_t;

int main()
{
        ll T;
        ll mul = 1;
        ll cnt = 0;

        cin >> T;
        

        while ( T != 0 ) {
                T -= mul, cnt++;
                if ( mul == 1 && T / mul >= 3 || T / mul >= 4 ) {
                        if ( mul == 1 || (T / mul) % 3 != 0 ) mul *= 3;
                } else break;
        }
        
        //cout << mul << " " << cnt << " " << T << endl;

        while ( mul > 3 ) {
                ll value = T / (mul / 3);
                ll plus = (value - 1) / 3;

                cnt += plus;
                T -= plus * mul;
                //cout << " " << mul << " " << cnt << " " << T << endl;
                mul /= 3;
        }
        
        if ( mul == 3 ) {
                cout << cnt + T / 3 + T % 3 << endl;
        } else {
                cout << cnt + T << endl;
        }

        return ( 0 );
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
#define all(x) (x).begin(), (x).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
#define pii pair<int, int>

using namespace std;

void solve()
{
    int n, x, y;
    cin >> n >> x >> y;
    cout << y * (int)ceil((float)n / x);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner

object Main extends App {
  var sc = new Scanner(System.in)
  var n = sc.nextInt
  var t = (0 until n).map(_ => sc.nextLong)

  var gcd: (Long, Long) => Long = (a, b) => if (b == 0) a else gcd(b, a % b)
  var lcm: (Long, Long) => Long = (a, b) => a / gcd(a, b) * b

  println(t.reduce(lcm))
}

Measured memory_bytes: 25540
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    for (auto& e : v) std::cin >> e;

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r, k;
        std::cin >> l >> r >> k;
        std::cout << std::count(v.begin() + l, v.begin() + r, k) << std::endl;
    }
}


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

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

    int n;
    cin >> n;

    int res = 0;
    rep(i, n) {
        int a;
        cin >> a;
        res += a-1;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n;
vector<vp> g;

void solve(){
    vi d(n,inf);
    priority_queue<pi,vp,greater<pi>> q;
    d[0]=0;
    q.push({0,0});
    while(!q.empty()){
        pi p=q.top();
        q.pop();
        int v=p.se;
        if(d[v]<p.fi)continue;
        for(pi e:g[v]){
            if(d[e.se]>d[v]+e.fi){
                d[e.se]=d[v]+e.fi;
                q.push({d[e.se],e.se});
            }
        }
    }
    rep(i,n){
        cout<<i<<sp<<d[i]<<endl;
    }
}

void run(){
    cin>>n;
    g.resize(n);
    rep(i,n){
        int u,k;
        cin>>u>>k;
        rep(j,k){
            int v,c;
            cin>>v>>c;
            g[u].eb(pi(c,v));
        }
    }
    solve();
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<pair<char, int>> runLengthEncoding(string s) {
    int n = s.length();

    vector<pair<char, int>> res;
    char pre = s[0];
    int cnt = 1;
    rep(i, 1, n) {
        if (pre != s[i]) {
            res.push_back({ pre, cnt });
            pre = s[i];
            cnt = 1;
        }
        else cnt++;
    }

    res.push_back({ pre, cnt });
    return res;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, K;
string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K >> S;
    auto rl = runLengthEncoding(S);
    int gr = rl.size();
    rep(k, 0, K) {
        if(3 <= gr)
            gr -= 2;
        else if(gr == 2)
            gr = 1;
    }
    int ans = N - gr;
    cout << ans << endl;
}



Measured memory_bytes: 1608
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        long a = int.Parse(str[0]);
        long b = int.Parse(str[1]);
        long aa = 1;
        long ab = 0;
        long ba = 0;
        long bb = 1;
        while(b != 0){
            long ca = ba;
            long cb = bb;
            ba = aa - a/b*ba;
            bb = ab - a/b*bb;
            aa = ca;
            ab = cb;
            long c = b;
            b = a % b;
            a = c;
        }
        sb.Append(aa+" "+ab+"\n");
    }
}

Measured memory_bytes: 9184
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeMap<String,Integer> map = new TreeMap<String,Integer>();
        char[] first = sc.next().toCharArray();
        for(char c : first){
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(int i = 1; i < n; i++){
            String tmp = sc.next();
            int len = tmp.length();
            HashSet<String> del = new HashSet<String>();
            for(Map.Entry<String, Integer> e : map.entrySet()){
                String k = e.getKey();
                int v = e.getValue();
                int cnt = 0;
                int index = 0;
                while(index < len){
                    int chk = tmp.indexOf(k,index);
                    if(chk == -1){
                        break;
                    }else{
                        cnt++;
                        index = chk+1;
                    }
                }
                if(cnt != 0){
                    map.put(k,Math.min(v,cnt));
                }else{
                    del.add(k);
                }
            }
            for(String s : del){
                map.remove(s);
            }
        }
        StringBuilder sb = new StringBuilder();
        for(Map.Entry<String, Integer> e : map.entrySet()){
            String k = e.getKey();
            int v = e.getValue();
            for(int i = 0; i < v; i++){
                sb.append(k);
            }
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()





//UnionFind Template
struct UnionFind{ //構造体の定義
    vector<int> d; //メンバ変数
    UnionFind(int n=0): d(n,-1) {} //コンストラクタ（構造体が呼ばれたときにすぐに実行される処理）
    int find(int x){
        if(d[x]<0) return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return false;
        if(d[x]<d[y]) swap(x,y);//d[x] is smaller. Then, connect d[x] to d[y].
        d[y]+=d[x];
        d[x]=y;
        return true;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -(d[find(x)]);   
    }
    int rootsize(){
        int cnt=0;
        for(auto& v: d){
            if(v<0) cnt++;
        }
        return cnt;
    }
};
//How to use
//UnionFind uf(n); などと書けば使えるようになる.ufというobjectが生成される
//uf.unite(a,b);などで中の関数を使える



int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--; y--;
        uf.unite(x,y);
    }
    int ans=uf.rootsize();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll num = 0;
    if(N==1){
        if(S[0] == '0'){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
        return 0;
    }
    rep(i,N){
        if(S[i] == '1') num++;
    }
    vector<ll> dp(200010);
    rep(i,200010){
        ll n = i;
        ll cnt = 0;
        while(n != 0){
            ll d = __builtin_popcountll(n);
            n = n % d;
            cnt++;
        }
        dp[i] = cnt;
    }
    vector<ll> bm(N+1), bp(N+1);
    ll mem=0;
    ll mep=0;
    bool flag = 0;
    if(num == 1){
        flag = 1;
        num += 2;
    }

    bm[N] = 1%(num-1);
    bp[N] = 1%(num+1);
    rep(i,N){
        mem *= 2;
        mep *= 2;
        if(S[i] == '1'){
            mem++;
            mep++;
            mem %= num-1;
            mep %= num+1;
        }
        mem %= num-1;
        mep %= num+1;
        bm[N-i-1] = (bm[N-i]*2) % (num-1);
        bp[N-i-1] = (bp[N-i]*2) % (num+1);
    }
    //cout << mem << " " << mep << endl;
    //PR(bm, N+1);
    //PR(bp, N+1);
    vector<ll> ans(N);
    if(flag){
        rep(i,N){
            if(S[i] == '1'){
                cout << 0 << endl;
            }else{
                ll tm = (mem + bm[i+1]) % (num-1); 
                cout << dp[tm] + 1 << endl;
            }
        }
        return 0;
    }
    rep(i,N){
        if(S[i] == '1'){
            ans[i] = ((mem - bm[i+1]) + num - 1) % (num-1); 
        }else{
            ans[i] = (mep + bp[i+1]) % (num+1);
        }
    }
    rep(i,N){
        cout << dp[ans[i]]+1 << endl;
    }
}

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

int main(void) {
  ll A, B;
  string b;
  cin >> A >> b;

  B = stoi(b.erase(b.find("."), 1));

  ll answer = (A * B) / 100;

  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 3612
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int N=100000;
const int MOD=1e9+7;
class BIT{
	int bit[N+10]={0};
	int sum(int i){
		int s=0;
		while(i>0){
			s=(s+bit[i])%MOD;
			i-=i&(-i);
		}
		return s;
	}
	public:
	void add(int i,int x=1){
		while(i<=N){
			bit[i]=(bit[i]+x)%MOD;
			i+=i&(-i);	
		}
	}
	public:
		int query(int l,int r){
			if(l>r) return 0;
			return (sum(r)-sum(l-1)+MOD)%MOD;
		}
}bit[2];
int n;
LL a,b,s[100000+1];
int far[N+1][2],f[2];
/*
f_{i,0}=\sum f_{i\prime,1},(i\prime < i\ and \ s_{i+1}-s_{i\prime}>=A/B)
*/
int main(){
	fastio;
	cin>>n>>a>>b;
	rb(i,1,n)
		R(s[i]);
	rb(i,1,n){
		far[i][0]=far[i][1]=i;
		if(s[i]-s[i-1]>=a){
			far[i][0]=far[i-1][0];
		}
		if(s[i]-s[i-1]>=b){
			far[i][1]=far[i-1][1];
		}
		check_max(far[i][0],1);
		check_max(far[i][1],1);	
	}
	int p1=0,p0=0;
	rb(i,1,n){
		f[0]=f[1]=0;
		if(i!=n){
			while(s[i+1]-s[p0+1]>=a){
//				cout<<p0<<endl;
				p0++;	
			} 
			while(s[i+1]-s[p1+1]>=b){
//				cout<<p1<<endl;
				p1++;	
			} 
		}
		else{
			p0=p1=n;
		}
		int l,r;
		l=far[i][0]-1;
		r=p1;
		check_max(l,1);
		f[0]=bit[1].query(l,r);
		if(far[i][0]==1){
			f[0]++;
		}
		l=far[i][1]-1;
		r=p0;
		check_max(l,1);
		f[1]=bit[0].query(l,r);
		if(far[i][1]==1){
			f[1]++;
		}
		rep(j,2){
			bit[j].add(i,f[j]);
		}
	}
	cout<<(f[1]+f[0])%MOD<<endl;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
using namespace std;

int main(){
    int H,W;
    while(1<2){
    cin>>H>>W;
    if(H==0&&W==0)break;
    rep(i,W)cout<<"#";
    cout<<endl;
    rep(i,H-2){
    cout<<"#";
    rep(i,W-2){
    cout<<".";
    }
    cout<<"#"<<endl;
    }
    rep(i,W)cout<<"#";
    cout<<endl;
    cout<<endl;
}
}





Measured memory_bytes: 3104
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  cout<<(N==M?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    string s; cin >> s;
    long long k; cin >> k;

    long long temp;
    for(int i=0; i<s.size(); i++){
        if(s[i] != '1'){
            temp = i;
            break;  
        }
    }

    if(k > temp){
        cout << s[temp] << endl;
    }
    else{
        cout << '1' << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
from math import factorial
from operator import mul
from functools import reduce

MOD = 10 ** 9 + 7


def pow_mod(a, x, mod=MOD):
    return pow(a, x, mod) if x != -1 else pow(a, mod - 2, mod)


def factorial_mod(n, mod=MOD):
    if n == 1:
        return 1
    return n * factorial(n - 1) % mod


def comb_mod(n, k, mod=MOD):
    return reduce(lambda x, y: x * y % mod, range(n, n - k, -1)) * pow_mod(factorial_mod(k), -1, mod) % mod


n, a, b = map(int, input().split())

print((pow_mod(2, n, MOD) - comb_mod(n, a) - comb_mod(n, b) - 1) % MOD)


Measured memory_bytes: 5976