akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
using tr = tree<P, null_type, greater<P>, rb_tree_tag,
                tree_order_statistics_node_update>;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    tr st;
    int n, q;
    cin >> n >> q;
    vector<ll> sc(n);
    for (int i = 0; i < n; i++) {
        st.insert(P(sc[i], -i));
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            ll a, b;
            cin >> a >> b;
            --a;
            st.erase(P(sc[a], -a));
            sc[a] += b;
            st.insert(P(sc[a], -a));
        } else {
            int m;
            cin >> m;
            --m;
            auto p = st.find_by_order(m);
            cout << -(*p).second + 1 << " " << (*p).first << endl;
        }
    }
}



Measured memory_bytes: 9960
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "RESORT"
#define pll pair<int, int>
#define fi first
#define se second
using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;
const int N = 1000005;
ll n, m, a[N], k, tong, t, d[N];
ll ans;
void dfs(int i, int j, ll tong)
{
    ans = max(ans, tong + d[(i-1) * m + j]);
    if(i > 1 && a[(i-2)*m+j] > a[(i-1)*m+j])
        dfs(i-1, j, tong + d[(i-1) * m + j]);
    if(j > 1 && a[(i-1)*m+j-1] > a[(i-1)*m+j])
        dfs(i, j-1, tong + d[(i-1) * m + j]);
    if(i < n && a[(i)*m+j] > a[(i-1)*m+j])
        dfs(i+1, j, tong + d[(i-1) * m + j]);
    if(j < m && a[(i-1)*m+j+1] > a[(i-1)*m+j])
        dfs(i, j+1, tong + d[(i-1) * m + j]);
}
inline void sol()
{
	cin >> n;
	long double dd;
	cin >> dd;
	dd = (long double) dd *n ;
	m = ((ll)dd);
    cout << m;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
	sol();
}










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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pipipii = pair<ll, pair<int, pii>>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<vector<vector<vector<int>>>> dp(n+1, vector<vector<vector<int>>>(4, vector<vector<int>>(4, vector<int>(4))));
    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 4; ++j){
            for(int k = 0; k < 4; ++k){
                dp[3][i][j][k] = 1;
                if(i == 0 && j == 1 && k == 2) dp[3][i][j][k] = 0;
                if(i == 0 && j == 2 && k == 1) dp[3][i][j][k] = 0;
                if(i == 2 && j == 0 && k == 1) dp[3][i][j][k] = 0;
            }
        }
    }
    for(int i = 3; i <= n; ++i){
        for(int c = 0; c < 4; ++c){
            for(int d = 0; d < 4; ++d){
                for(int e = 0; e < 4; ++e){
                    if(c == 0 && d == 1 && e == 2) continue;
                    if(c == 0 && d == 2 && e == 1) continue;
                    if(c == 2 && d == 0 && e == 1) continue;
                    for(int k = 0; k < 4; ++k){
                        if(k == 0 && c == 1 && d == 2) continue;
                        if(k == 0 && c == 2 && d == 1) continue;
                        if(k == 2 && c == 0 && d == 1) continue;
                        if(k == 0 && d == 2 && e == 1) continue;
                        if(k == 0 && c == 2 && e == 1) continue;
                        dp[i][c][d][e] = ((ll)dp[i][c][d][e] + dp[i-1][k][c][d]) % MOD;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 4; ++j){
            for(int k = 0; k < 4; ++k){
                ans += dp[n][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
use proconio::input;

fn main() {
	input!(n: usize);
	input!(t: [usize; n]);
	input!(m: usize);
	input!(px: [(usize, usize); m]);

	let mut sum = 0;
	for i in 0..n {
		sum += t[i];
	}

	for i in 0..m {
		println!("{}", sum - t[px[i].0-1] + px[i].1);
	}
}



Measured memory_bytes: 2164
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main(){
    cin >> s;
    int abso = INF<int>();
    REP(i, (int)s.size() - 2){
        int n = (s[i] - '0')*100 + (s[i + 1] - '0')*10 + (s[i + 2] - '0');
        if(abs(753 - n) < abso){
            abso = abs(753 - n);
        }
    }
    cout << abso << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main(){
	double A,B,H,M; 
	cin>>A>>B>>H>>M;
    double p=M_PI*(60.0*H+M)/360.0;
    double q=M_PI*M/30.0;
    double ans=sqrt(A*A+B*B-2.0*A*B*cos(p-q));
    cout << fixed << setprecision(10);
    cout<<ans<<endl;
	
}

Measured memory_bytes: 4228
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    ll ans = 1e18;
    for(ll div_h = 1; div_h < h; ++div_h){
        ll cho1 = div_h * w, cho2 = (h-div_h) * w;
        ll cho3 = (div_h / 2) * w;
        ll cho4 = cho1 - cho3;
        chmin(ans, max({cho2, cho3, cho4}) - min({cho2, cho3, cho4}));
        ll cho5 = div_h * (w / 2);
        ll cho6 = cho1 - cho5;
        chmin(ans, max({cho2, cho5, cho6}) - min({cho2, cho5, cho6}));
    }
    for(ll div_w = 1; div_w < w; ++div_w){
        ll cho1 = h * div_w, cho2 = h * (w-div_w);
        ll cho3 = h * (div_w / 2);
        ll cho4 = cho1 - cho3;
        chmin(ans, max({cho2, cho3, cho4}) - min({cho2, cho3, cho4}));
        ll cho5 = (h / 2) * div_w;
        ll cho6 = cho1 - cho5;
        chmin(ans, max({cho2, cho5, cho6}) - min({cho2, cho5, cho6}));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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 gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

void solve()
{
	int n;
	string x;
	cin>>n>>x;
	// int n=2e5;
	// string x="";
	// rep(i,n)x+='1';
	int num=0;
	rep(i,n){
		if(x[i]=='1')++num;
	}
	ll m=0;
	rep(i,n){
		if(x[i]=='1'){
			m+=mod_pow<ll>(2LL,n-1-i,num);
			if(num>0)m%=num;
		}
	}
	ll ma=0,mb=0;
	int a=num+1,b=num-1;
	if(a<=n)rep(i,n){
		if(x[i]=='1'){
			ma+=mod_pow<ll>(2LL,n-1-i,a);
			if(a>0)ma%=a;
		}
	}
	else a=-1;
	if(b>=0)rep(i,n){
		if(x[i]=='1'){
			if(b!=0)mb+=mod_pow<ll>(2LL,n-1-i,b);
			else {
				b=0;
				mb=0;
				break;
			}
			if(b>0)mb%=b;
		}
	}
	else b=-1;
	//cout<<b<<endl;
	rep(i,n){
		ll mma=ma,mmb=mb;
		int ans=0;
		if(x[i]=='0'){
			mma+=mod_pow<ll>(2LL,n-1-i,a);
			if(a>0)mma%=a;
			++ans;
			while(mma>0){
				++ans;
				ll cnt=popcount(mma);
				mma%=cnt;
			}
			cout<<ans<<"\n";
		}
		else{
			if(b==0){
				cout<<0<<"\n";
				continue;
			}
			mmb-=mod_pow<ll>(2LL,n-1-i,b);
			mmb+=b;
			if(b>0)mmb%=b;
			++ans;
			while(mmb>0){
				++ans;
				ll cnt=popcount(mmb);
				mmb%=cnt;
			}
			cout<<ans<<"\n";
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
const int N = 10;

int n;
long double x[N], y[N];
int a[N];

long double dist(long double x1, long double y1, long double x2, long double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main()
{
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i] >> y[i];
        a[i] = i;
    }
    long double ans = 0;
    long long q = 0;
    do
    {
        for (int i = 0; i < n - 1; ++i)
        {
            ans += dist(x[a[i]], y[a[i]], x[a[i + 1]], y[a[i + 1]]);
        }
        ++q;
    } while (next_permutation(a, a + n));
    ans /= q;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
ll fact(ll n){
    if(n==0)return 1;
    else return n*fact(n-1)%MOD;
}
ll calc(ll n,ll k){
    if(k==0)return 1;
    ll m=n*n%MOD;
    if(k%2)return n*calc(m,k/2)%MOD;
    else return calc(m,k/2)%MOD;
}
ll comb(ll n,ll k){
    ll ret=fact(n);
    ret=ret*calc(fact(k),MOD-2)%MOD;
    ret=ret*calc(fact(n-k),MOD-2)%MOD;
    return ret;
}

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


   vector<ll> s;
   for(int i=2;i<=m;i++){
       ll c=0;
       while(m%i==0){
           m/=i;
           c++;
       }
       if(c!=0)s.push_back(c);
       if(m==1)break;
   }

   ll ans=1;
   rep(i,s.size()){
       //cout<<s[i]<<endl;
    ans*=comb(s[i]+n-1,s[i]);
    ans%=MOD;

   }
   cout<<ans<<endl;







    return 0;
}


Measured memory_bytes: 1792
def make_chess(H,W):
    lst =[["#"]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            if (i+j)%2==1:
                lst[i][j]="."
    return lst

while True:
    H,W = [int(x) for x in input().split()]
    if H==0 and W==0:
        break
    board =make_chess(H,W)
    for i,row in enumerate(board):
        print("".join(row))
    print()
            


Measured memory_bytes: 5740
#include <stdio.h>
int s[10005], t[500];
int main(int argc, char const *argv[])
{
	int c = 0;
	int n,q;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for (int i = 0; i < q; ++i)
	{
		scanf("%d",&t[i]);
	}
	int j = 0;
	for (int i = 0; i < q; ++i)
	{
		s[n] = t[i];
		j = 0;
		while(s[j] != s[n])
		{
			j++;
		}
		if(j!=n) c++;
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 2648
#include "bits/stdc++.h"
using namespace std;
const int N=1e2+20;
int n,a[N];
double num=1,den;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		num*=a[i];
	}

	for(int i=0;i<n;i++)
	{
		double p=1;
		for(int j=0;j<n;j++)
			if(j!=i)
				p*=a[j];
		den+=p;
	}

	cout<<fixed<<setprecision(12)<<num/den;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
  int r,g,m,n;
  int ans=0,cnt=0;
  cin>>r>>g>>m>>n;
  for(int i=0;i<n/r+1;i++){
    ans+=r*i;
    for(int j=0;j<n/g+1;j++){
      ans+=j*g;
      if((n-ans)%m==0 and n-ans>=0){
        cnt++;
      }
      ans-=j*g;
    }
    ans=0;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main()
{
  string S;
  cin >> S;
  REP(i,S.size())if(S[i] == '1')S[i] = '9';
  else if(S[i] == '9')S[i] = '1';
  cout << S << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int isPrime(int x) {
  if(x == 2) return 1;
  if(x < 2 || x%2 == 0) return 0;
  int i = 3;
  while(i <= sqrt((double)x)) {
    if(x%i == 0) return 0;
    i = i + 2;   
  }
  return 1;
}

int main() {
  int i, k, n, count=0;
  scanf("%d", &n);
  int A[n];
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    k = isPrime(A[i]);
    if(k == 1) count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
const ll mod=1e+9+7;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    ll res=0;
    for(ll i=k;i<=n+1;i++){
        //数字をi個選んだ時の和の組み合わせ
        ll now=(n*2-i+1)*i/2;
        ll buf=(i-1)*i/2;
        //cout<<now<<" "<<buf<<endl;
        now-=buf;
        now++;
        now%=mod;
        res+=now;
        res%=mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

static const int MAX =200000;
int main()
{

	int n, buff[MAX];
	cin >> n;

	for(int i=0;i<n;i++) cin >> buff[i];
	
	int minv=buff[0],maxv=-2000000000;

	for(int j=1;j<n;j++){
		if(maxv<buff[j]-minv) maxv=buff[j]-minv;
		if(buff[j]<minv) minv=buff[j];
	}

	cout <<maxv <<endl;
}



Measured memory_bytes: 3904
#include <cstdio>

int g[120000];
int i,n;
long long l,r;

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&g[i]);
	l=r=2;
	for (i=n;i>0;i--)
	{
		if (r/g[i]==(l-1)/g[i])
		{
			printf("-1");
			return 0;
		}
		l=((l-1)/g[i]+1)*g[i];
		r=r/g[i]*g[i]+g[i]-1;
	}
	printf("%lld %lld",l,r);
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> d(N);
    int ans = 0;

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

    sort(d.begin(), d.end());

    if(d[(N/2)-1] != d[N/2]){
        ans = d[N/2] - d[(N/2)-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,X; cin>>N>>X;
    vint a(N);
    REP(i,N) cin>>a[i];

    int ans=0;
    if(a[0]>X){
        ans+=a[0]-X;
        a[0]=X;
    }
    for(int i=0;i<N-1;i++){
        if(a[i]+a[i+1]>X){
            ans+=a[i]+a[i+1]-X;
            a[i+1]=X-a[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import math

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

a,b,c,d,L=[],[],[],[],[]
for i in range(N):
    f,g=map(int,input().split())
    a.append(f)
    b.append(g)

for i in range(M):
    f,g=map(int,input().split())
    c.append(f)
    d.append(g)

for i in range(N):
    L.clear()
    for j in range(M):
        L.append(int(math.fabs(a[i]-c[j])+math.fabs(b[i]-d[j])))
    for k in range(M):
        if L[k]==min(L):
            print(k+1)
            break

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 100000;
ll const MOD = 1000000007;

// 約数の列挙 O(√n)
vector<ll> divisor(ll n) {
    vector<ll> res;

    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }

    return res;
}

// 素因数分解 O(√n)
map<int, int> prime_factor(int n) {
    map<int, int> res;

    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }

    if (n != 1) res[n] = 1;

    return res;
}

// 約数の個数を列挙 O(N)
void divisor_count(vector<ll> &dp, ll n) {
    dp[0] = 0;
    dp[1] = 1;

    for (ll i = 2; i < n / 2 + 1; i++) {
        ll j = 2;
        while (i * j <= n) {
            dp[i * j]++;
            j++;
        }
    }
}

int main() {
    ll N;
    cin >> N;

    vector<ll> dp(N + 1, 2);
    ll ans = 0;

    divisor_count(dp, N);
    rep(i, N + 1) { ans += i * dp[i]; }

    cout << ans << endl;

    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 mod_inverse(i64 a, i64 m) {
    i64 x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    return 0;
}

vector<i64> fact;
void init_fact(i64 n, i64 m) {
    fact.resize(n + 1);
    fact[0] = fact[1] = 1;
    for (i64 i = 2; i <= n; ++i) fact[i] = (i * fact[i - 1]) % m;
}


i64 mod_comb(i64 n, i64 k, i64 p) {
    if (n < 0 or k < 0 or n < k) return 0;
    i64 num=fact[n]*mod_inverse(fact[n-k],p)%p,den=fact[k];
    return num * mod_inverse(den, p) % p;
}


void solve() {
    const i64 mod = 1'000'000'007;
    init_fact(200010,mod);

    i64 N,A,B,C;
    cin >> N >> A >> B >> C;

    vector<i64> p(N+1),q(N+1);
    p[0]=1;
    rep(i,1,N+1){
        p[i]=p[i-1]*A%mod*mod_inverse(A+B,mod)%mod;
    }

    q[0]=1;
    rep(i,1,N+1){
        q[i]=q[i-1]*B%mod*mod_inverse(A+B,mod)%mod;
    }

    i64 ans=0;
    rep(i,0,N){
        i64 tmp=mod_comb(N+i-1,i,mod)*p[N]%mod*q[i]%mod;
        ans+=tmp*(((N+i)+(N+i)*C%mod*mod_inverse(100-C,mod)%mod)%mod)%mod;
        ans%=mod;
    }
    rep(i,0,N){
        i64 tmp=mod_comb(N+i-1,i,mod)*q[N]%mod*p[i]%mod;
        ans+=tmp*(((N+i)+(N+i)*C%mod*mod_inverse(100-C,mod)%mod)%mod)%mod;
        ans%=mod;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

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


Measured memory_bytes: 21204
#include <cstdio>
using namespace std;

int main()
{
	int N;
	scanf("%d", &N);
	while(N--)
	{
		int x=0, y=0,dx,dy;
		int ansx=0, ansy=0;
		while(scanf("%d%d", &dx,&dy), (dx||dy))
		{
			x+=dx; y+=dy;
			int d=ansx*ansx+ansy*ansy;
			int nd=x*x+y*y;
			if(d==nd&&x>ansx||d<nd)
			{
				ansx=x;
				ansy=y;
			}
		}
		
		printf("%d %d\n", ansx,ansy);
	}
}

Measured memory_bytes: 0
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static int  rukja(int p,boolean[] arr)
    {for(int i=p;i<arr.length;i++)
        if(!arr[i]) return i;
        return -1;
    }
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int m=sc.nextInt();
	     ArrayList<Integer>[] arr = new ArrayList[n]; 
  
        // initializing 
        for (int i = 0; i < n; i++) { 
            arr[i] = new ArrayList<Integer>(); 
        } 
	    boolean[] trav= new boolean[n];
	    for (int i = 0; i < n; i++) { 
           trav[i]=false;
        } 
	    
	    // each travelled node is marked true (don't check below again)
	    //a queue to check each time ki kitne hogye...
	    //then a loop to find the niggas unconnected
	    // loop stops at unconnected=0;
	    for(int i =0;i<m;i++)
	    {int a=sc.nextInt();
	    int b=sc.nextInt();
	        arr[a-1].add(b-1); 
	    arr[b-1].add(a-1); 
	    }
	    int p=0,res=0;
	    int curr=0;
	    int tot=-1;
	    Queue<Integer> q 
            = new LinkedList<>(); 
	    
	    
            
            
	    while(res!=-1)
        { // here to implement the queue and mark the few)
        trav[res]=true;
        for(int j=0;j<arr[res].size();j++)
            {//ek node k saare relatives ko add krre
            if(trav[arr[res].get(j)]==false)
            {q.add(arr[res].get(j));
            trav[arr[res].get(j)]=true;}}
            
            while(q.peek()!=null)
            {curr = q.poll();
            for(int j=0;j<arr[curr].size();j++)
                {//ek node k saare relatives ko add krre
                if(trav[arr[curr].get(j)]==false)
                {q.add(arr[curr].get(j));
                trav[arr[curr].get(j)]=true;}
                }
                
           }
            //ek bar ka hogya sara... now we gotta add the first unconnected element and start the drill;
            
            
            
          
          
          res=rukja(p,trav);
          p=res; tot++;
          //loop will repeat
        } 
	    
	    
	    
	    
	    
	  System.out.println(tot);
            
	    
	    
	}
}


Measured memory_bytes: 72304
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int K[100010];
vector<int> L[100010];
struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
vector<int> s[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			int l; cin >> l; l--;
			s[l].push_back(i);
		}
	}
	for (int i = 0; i < M; i++) {
		if (s[i].size() == 0) s[i].push_back(-1);
	}
	for (int i = 0; i < M; i++) {
		//cout << i << " " << s[i].size() <<  endl;
		for (int j = 0; j < s[i].size() - 1; j++) {
			//cout << s[i][j] << " " << s[i][j + 1] << endl;
			uf.merge(s[i][j], s[i][j + 1]);
		}
	}
	if (uf.size(0) == N) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 9208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[])
{
	char s[100000];
	scanf("%s",s);
	for (int i = 0; i < strlen(s); i += 2){
		printf("%c",s[i]);
	}
	return 0;
}

Measured memory_bytes: 256
def read_tree(a)
  def parent(array, index)
		if(index != 1)
		  "parent key = #{array[index/2]}, "
		end
	end
	def keys(array, index)
		left = 2*index
		right = 2*index + 1
		if(left < array.length && right < array.length)
			"left key = #{array[left]}, right key = #{array[right]}, "
		elsif(left < array.length && right >= array.length)
			"left key = #{array[left]}, " 
		elsif(right < array.length && left >= array.length)
			"right key = #{array[right]}, " 
		end 
	end
  a.insert(0,0)
	for i in 1...(a.length)
   puts "node #{i}: key = #{a[i]}, #{parent(a, i)}#{keys(a, i)}"
  end
end

array = gets.chomp
array = gets.chomp
array = array.split().map(&:to_i)
read_tree(array);

Measured memory_bytes: 8656
kth=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K=int(input())
print(kth[K-1])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
map<int,bool>mp;
int n,ans;
int main()
{
	cin>>n;
	while(n--)
	{
		int a;
		cin>>a;
		mp[a]=!mp[a];
	}
	for(map<int,bool>::iterator it=mp.begin();it!=mp.end();it++)ans+=it->second;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var aa = parseInt(line[0]);
    var bb = parseInt(line[1]);
    
    if(aa+bb>9){
        console.log("error");
    } else {
        console.log(aa+bb);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a,b;
        a=sc.nextInt();b=sc.nextInt();
        while(b!=0){
            int c=a%b;
            a=b;
            b=c;
        }
        System.out.println(a);
}
}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'
#define int ll

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

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    int a[100005];
    cin>>n>>k;
    int i;
    fi(i,1,n+1){
        cin>>a[i];
    }
     ll ans=(ll)1e18;
    fi(i,1,n-k+2){
        int mn=a[i];
        int mx=a[i+k-1];
        //cout<<mn<<" "<<mx<<endl;
        int d=0;
        if(mx<0) d+=abs(mn);
        if(mx>0) d+=(mx);
        if(mx>0&&mn<0){
            auto val=mx-mn;
            d=min(abs(mn)+val,mx+val);
        }
        ans=min(ans,d); 
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
n, m = list(map(int, input().split()))
ans = dict(zip(range(1, n+1), [0]*n))
for _ in range(m):
    a, b = list(map(int, input().split()))
    ans[a] += 1
    ans[b] += 1

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


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll x,y; cin>>x>>y;
  ll now=x;
  ll ans=0;
  while(now<=y){
    now*=2;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
#define fast            ios_base::sync_with_stdio(false)
#define mems(x, y)      memset(x, y, sizeof x)
#define pii             pair < int, int >
#define prec(x)         << fixed << setprecision(x)
#define itf             it->first
#define its             it->second
#define it(x)           it = x.begin(); it != x.end(); it++
#define pq_max(x)       priority_queue < x >
#define pq_min(x)       priority_queue < x, vector < x >, greater < x > >
#define ll              long long
#define nl              << "\n"
#define spc             << " "
#define pb              push_back
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define EPS             1e-9
#define toint(st, x)    stringstream ss(st); ss >> x
// =======Debug========//
#define watch(x)        cout << (#x) spc << x nl
//int fx[] = {1, -1, 0, 0};
//int fy[] = {0, 0, 1, -1};
const int mod=1e9+7;
const int mxn=1e5+9;
int cases = 1;
//ll BigMod(ll n,ll power) {ll ans=1;assert(power>=0);n%=mod;while(power>0){if(power&1) ans=(ans*n)%mod;n=(n*n)%mod;power>>=1;}return ans%mod;}
//ll ModInverse(int n)  { return BigMod(n, mod - 2); }
int sz1, sz2;
int dp[3004][3004];
bool fl[3004][4004];
string st1, st2;
int func(int i, int j)
{
    if(i >= sz1 || j >= sz2)    return 0;
    if(fl[i][j])    return dp[i][j];
  	fl[i][j] = 1;
    if(st1[i] == st2[j])    return dp[i][j] = 1 + func(i + 1, j + 1);
    else    return dp[i][j] = max(func(i + 1, j), func(i, j + 1));
}
int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

    cin >> st1 >> st2;
    sz1 = st1.size(), sz2 = st2.size();
    int ans = func(0, 0);

//    for(int i = 0; i < sz1; i++)    { for(int j = 0; j < sz2; j++)    cout << dp[i][j] spc; cout nl; }
    if(ans > 0) {
        string res = "";
        int i = 0, j = 0;
        while(i < sz1 && j < sz2) {
            if(st1[i] == st2[j])    res += st1[i], i++, j++;
            else {
                if(dp[i + 1][j] > dp[i][j + 1]) i++;
                else    j++;
            }
        }
        cout << res nl;
    }

    return 0;
}


Measured memory_bytes: 47488
N = int(input())
A = list(map(int,input().split()))
exc = []
ls = []
for a in A:
    if a < 3200:
        ls.append(a)
    else:
        exc.append(a)
rates = [list(range(1,400))]+[list(range(400*i,400*i+400)) for i in range(1, 8)]
vars = [False]*8
for r in ls:
    for j in range(8):
        if r in rates[j]:
            vars[j] = True
ans = vars.count(True)
if ans == 0:
    print(1, ans+len(exc))
else:
    print(ans, ans+len(exc))

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string s; cin >> s;

    if (s == "Sunny") {
        puts("Cloudy");
        return 0;
    }

    if (s == "Cloudy") {
        puts("Rainy");
        return 0;
    }

    if (s == "Rainy") {
        puts("Sunny");
        return 0;
    }
}

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

int main() {
	int n;
	cin >> n;
	int taro_count = 0;
	int hanako_count = 0;
	for (int i = 0; i < n; ++i) {
		string taro, hanako;
		cin >> taro >> hanako;
		if (taro > hanako) {
			taro_count += 3;
		}
		else if (taro == hanako) {
			taro_count++;
			hanako_count++;
		}
		else if (taro < hanako) {
			hanako_count += 3;
		}
	}
	cout << taro_count << ' ' << hanako_count << endl;
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

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

    vector<int> x(N);
    for (int i = 0; i < N; i++)
        cin >> x[i];

    long long ans = 1e12;
    for (int i = K-1; i < N; i++) {
        long long cost;
        if (x[i - (K - 1)] < 0 && x[i]>0) {
            long long lower = abs(x[i - (K - 1)]);
            long long upper = abs(x[i]);
            cost = 2 * min(lower, upper) + max(lower, upper);
            //cout << "lower= " << lower << endl;
            //cout << "upper= " << upper << endl;
        }
        else {
            long long lower = abs(x[i - (K - 1)]);
            long long upper = abs(x[i]);
            cost = max(lower, upper);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,k,i=0;cin>>n>>k;
  while(n!=0){
    i++;
    n/=k;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    //求める答えは、1*(1~1を約数にもつ数の個数までの自然数和)
    //+ 2*(1~2を約数にもつ数の個数までの自然数和)
    //+ ...
    //+ N*(1~Nを約数にもつ数の個数までの自然数和)
    //()内はN/iで出せるのでO(N)で求められた。証明は割愛
    long long ans=0;
    rep2(i,1,N+1){
        long long tmp=N/i;
        ans=ans+i*(tmp*(tmp+1)/2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

// ABC 84-D
// https://beta.atcoder.jp/contests/abc084/tasks/abc084_d

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int max = 100001;
		boolean[] isPrime = new boolean[max];
		Arrays.fill(isPrime, true);
		isPrime[0] = false;
		isPrime[1] = false;
		isPrime[2] = true;
		for (int i = 2; i <= Math.sqrt(max); i++) {
			if (i != 2 && i % 2 == 0) {
				isPrime[i] = false;
			} else if (isPrime[i] && isPrime(i)) {
				for (int j = i * 2; j < max; j += i) {
					isPrime[j] = false;
				}
			}
		}
		
		int[] nums = new int[max];
		for (int i = 1; i < max; i++) {
			if (isPrime[i] && isPrime[(i + 1) / 2]) {
				nums[i] = nums[i - 1] + 1;
			} else {
				nums[i] = nums[i - 1];
			}
		}
		
		int Q = in.nextInt();
		
		for (int i = 0; i < Q; i++) {
			int l = in.nextInt();
			int r = in.nextInt();
			System.out.println(nums[r] - nums[l - 1]);
		}
	}
	
	public static boolean isPrime(int n) {
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 69868
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()

if len(A) % 2 == 1:
    order1 = [-1, -1]
    for i in range(len(A)-2):
        if i % 2 == 0:
            order1.append(2)
        else:
            order1.append(-2)

    order2 = [1, 1]
    for i in range(len(A)-2):
        if i % 2 == 0:
            order2.append(-2)
        else:
            order2.append(2)
else:
    order1 = [-1, 1]
    for i in range(len(A) - 2):
        if i % 2 == 0:
            order1.append(2)
        else:
            order1.append(-2)

    order2 = [-1, 1]
    for i in range(len(A) - 2):
        if i % 2 == 0:
            order2.append(-2)
        else:
            order2.append(2)


order1.sort()
order2.sort()

sum1 = 0
sum2 = 0
for x, y, z in zip(A, order1, order2):
    sum1 += x * y
    sum2 += x * z

print(max(sum1, sum2))

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

int main()
{
  int n, m;
  cin >> n >> m;
  
  long long a[100];
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  
  int l = (sum + (4 * m) - 1) / (4 * m);
  int c = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= l) c++;
  }
  if (c >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def>pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf=1000000019;
int sosu[10000010]={1,1};
int main(){
	ll n;
	cin>>n;
	for(int i=2;i*i<10000010;i++)if(sosu[i]==0)
		for(int j=i*2;j<10000010;j+=i)sosu[j]=1;
	
	int co=0;
	loop(i,2,n+1)co+=(!sosu[i])*(!sosu[i+2]);
	cout<<co*2<<endl;
	
}







Measured memory_bytes: 42148
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int dx[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
int dy[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
const ll MOD = 1000000007;
const ll INF = 1000000;
const int MAX = 10000000;

int n;
ll use[5];
int main() {
    cin >> n;
    for (int i = 0; i < 5; i++) use[i] = 0;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        if (s[0] == 'M') use[0]++;
        else if (s[0] == 'A') use[1]++;
        else if (s[0] == 'R') use[2]++;
        else if (s[0] == 'C') use[3]++;
        else if (s[0] == 'H') use[4]++;
    }

   //for(int i=0;i<5;i++) cout<<use[i]<<' ';
    ll ans = 0;
    for (int i = 0; i < 5; i++){
        for (int j = i + 1; j < 5; j++){
            for (int k = j + 1; k < 5; k++){
                ans += use[i] * use[j] * use[k];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
using namespace std;
const int MAXN=1e5+7;
int n,ans;
int h[MAXN][5],f[MAXN][5][5];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) 
		cin>>h[i][1]>>h[i][2]>>h[i][3];
	memset(f,127,sizeof(f));
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++) f[1][i][j]=h[1][i];
	for(int i=2;i<=n;i++)
		for(int j=1;j<=3;j++)
			for(int k=1;k<=3;k++)
			{
				int maxx=0;
				for(int l=1;l<=3;l++)
					if(j!=k&&k!=l) maxx=max(maxx,f[i-1][k][l]);
				f[i][j][k]=maxx+h[i][j];
			}
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++) ans=max(ans,f[n][i][j]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15316
#include <stdio.h>

using namespace std;

int main(int argc, char *argv[])
{
    char c;
    int r=0,b=0;
    while((c=getchar())!='\n') {
        if (c == '0') r++;
        else b++;
    }
    printf("%d", (r+b) - (r>b? r-b: b-r));
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  set<string> goods;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    goods.insert(s);
  }
  cout << goods.size() << endl;
  return 0;
}

Measured memory_bytes: 19120
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
cin >> x >> y;
while(x!=0||y!=0){
if(x-y>=0){
cout << y << " " << x <<endl;
cin >> x >> y ;
}
else{
cout << x << " "<< y <<endl;
cin >> x >> y;
}
}
}




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

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

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

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

  vector<ll> t(n);
  rep(i,n) cin >> t.at(i);

  ll ans=t.at(0);
  rep(i,n) ans=lcm(ans, t.at(i));

  cout << ans;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 200005
#define L 29
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int bta[L+2][MN],btb[L+2][MN];
int a[MN],b[MN],sa[L+2],sb[L+2],n,la,lb,ra,rb,res,xsm;
int main()
{
	n=in();
	for (int i=1;i<=n;++i){
		a[i]=in();
		for (int j=0;j<L;++j) sa[j]+=a[i]&(1<<j),bta[j][i]=a[i]&((1<<(j+1))-1);
	}
	for (int i=1;i<=n;++i){
		b[i]=in();
		for (int j=0;j<L;++j) sb[j]+=b[i]&(1<<j),btb[j][i]=b[i]&((1<<(j+1))-1);
	}
	for (int j=0;j<L;++j){
		sort(btb[j]+1,btb[j]+n+1);xsm=0; 
		for (int i=1;i<=n;++i){
			la=lower_bound(btb[j]+1,btb[j]+n+1,(1<<j)-bta[j][i])-btb[j];
			ra=lower_bound(btb[j]+1,btb[j]+n+1,((1<<j)<<1)-bta[j][i])-btb[j]-1;
			lb=lower_bound(btb[j]+1,btb[j]+n+1,(1<<j)+((1<<j)<<1)-bta[j][i])-btb[j];rb=n;
			xsm^=((ra+rb-la-lb+2)&1);
		}res+=(1<<j)*xsm;
	}printf("%d",res);return 0;
}

Measured memory_bytes: 49408