akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
int n;
char c[6];
inline void putsaidai() {
	for (int i = n - 1; i >= 0; i--)* di++ = c[i];
	*di++ = '\n';
}

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


	int N = getint();
	int A[200000];

	int saidai = 0;
	int niban = 0;
	rep(i, N) {
		A[i] = getint();
		if (niban < A[i]) {
			niban = A[i];
			if (niban > saidai) swap(niban, saidai);
		}
	}

	int kari = saidai;
	while (kari) {
		*(c + n) = '0' + kari % 10;
		kari /= 10;
		n++;
	}

	if (saidai == niban) {
		rep(i, N) putsaidai();
	}
	else {
		rep(i, N) {
			if (A[i] == saidai) putint(niban);
			else putsaidai();
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3840
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}

const int mod = 1e9+7;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = (531441+1)*3;
int go[maxn*3][3], lz[maxn], pid[maxn];
int K, n, pw[13];
void build(int x, int lv, int id)
{
	if (lv==K)
	{
		pid[x] = id;
		return;
	}
	for (int i=0; i<3; i++)
	{
		go[x][i] = x*3+i;
		build(x*3+i, lv+1, id+i*pw[lv]);
	}
}
void pushdown(int x)
{
	if (lz[x])
	{
		swap(go[x][1], go[x][2]);
		lz[go[x][0]] ^= 1;
		lz[go[x][1]] ^= 1;
		lz[go[x][2]] ^= 1;
		lz[x] = 0;
	}
}
void add(int x, int lv)
{
	if (lv==K) return;
	pushdown(x);
	add(go[x][2], lv+1);
	swap(go[x][1], go[x][2]);
	swap(go[x][0], go[x][1]);
}
int ans[maxn];
void dfs(int x, int lv, int pos)
{
	if (lv==K)
	{
		ans[pid[x]] = pos;
		return;
	}
	pushdown(x);
	for (int i=0; i<3; i++)
	{
		dfs(go[x][i], lv+1, pos+pw[lv]*i);
	}
}
int main()
{
	pw[0] = 1;
	for (int i=1; i<=12; i++) pw[i] = pw[i-1]*3;
	scanf("%d", &K);
	n = pw[K];
	build(1, 0, 0);
	static char s[200111];
	scanf("%s", s);
	int len = strlen(s);
	for (int i=0; i<len; i++)
	{
		if (s[i]=='S')
		{
			lz[1] ^= 1;
		}
		else
		{
			add(1, 0);
		}
	}
	dfs(1, 0, 0);
	for (int i=0; i<n; i++) puti(ans[i]);
	return 0;
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int x,y; cin >> x >> y;
    bool ok = false;
    for(int i = 0; i <= x; i++){
        if(i*2+(x-i)*4 == y) ok = true;
    }
    if(ok) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3636
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

stack<int> st;

int n,a,b,top;
bool bo[10010];
char s[233];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	a=rd();b=rd();n=a+b;top=1;
	if (a<=b) { puts("Impossible");return 0; }
	st.push(0);
	for (int i=1;i<n;i++)
	{
		if (st.empty()) { st.push(i);continue; }
		printf("? %d %d\n",st.top(),i);
		fflush(stdout);
		scanf("%s",s);
		if (s[0]=='Y') st.push(i);
		else st.pop();
	}
	for (int i=0;i<n;i++)
	{
		printf("? %d %d\n",st.top(),i);
		fflush(stdout);
		scanf("%s",s);
		if (s[0]=='Y') bo[i]=true;
	}
	printf("! ");
	for (int i=0;i<n;i++) putchar(bo[i]?'1':'0');
	puts("");
	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(var) var.begin(), var.end()
#define vi vector<int>
int const MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
int main(){
    int L;
    cin >> L;
    
    if(L%3==0) cout << setprecision(12) << fixed << pow((L/3), 3) << endl;
    else cout << setprecision(12) << fixed<< pow(L, 3)/(double)27 << endl;
}


Measured memory_bytes: 384
n, k = map(int, input().split())

counter = 0

for i in range(k, n+2):
    min_sum = i * (i-1) / 2
    max_sum = i * (n + (n - i + 1)) / 2
    
    counter += (max_sum - min_sum + 1) % (10**9 + 7)


print(int(counter % (10**9 + 7)))


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int A, B, M; cin >> A >> B >> M;

	vi c1 (A); F0R(i, A) cin >> c1[i];
	vi c2 (B); F0R(i, B) cin >> c2[i];

	int b1 = c1[0];
	F0R(i, A) b1 = min(b1, c1[i]);
	int b2 = c2[0];
	F0R(i, B) b2 = min(b2, c2[i]);

	int best = b1 + b2;
	F0R(i, M) {
		int x, y, c; cin >> x >> y >> c;
		--x; --y;
		best = min(best, c1[x] + c2[y] - c);

	}

	print(best);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ac,wa,tle,re;
  	ac = wa = tle = re = 0;
  
  	cin >> n;
  
  	vector<string> s(n);
  
  	for(int i = 0; i < n;i++){
      cin >> s.at(i);
      if(s.at(i) == "AC")
        ac++;
      else if(s.at(i) == "WA")
        wa++;
      else if(s.at(i) == "TLE")
        tle++;
      else if(s.at(i) == "RE")
        re++;
    }
  
  	cout << "AC x " << ac << endl;  
  	cout << "WA x " << wa << endl;  
  	cout << "TLE x " << tle << endl;  
  	cout << "RE x " << re << endl;  
}

Measured memory_bytes: 6420
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n; ll x;
    scanf("%d%lld", &n, &x);
    vector<ll> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    ll ans = LINF;
    int j;
    for (i = 0; i < n; i++) {
        ll s = x * i;
        for (j = 0; j < n; j++) {
            s += a[j];
        }
        ans = MIN(ans, s);

        {
            vector<ll> b(n);
            for (j = 0; j < n; j++) {
                int k = (j - 1 + n) % n;
                b[j] = MIN(a[j], a[k]);
            }
            a.swap(b);
        }
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
favorite_foods = []
for i in range(N):
    favorite_foods.extend(list(map(int, input().split()))[1:])
count = 0
for i in range(1, M + 1):
    if favorite_foods.count(i) == N:
        count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
bool a[105];
int n,k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int d;
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			int b;
			cin>>b;
			a[b]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==0)	ans++;
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int N = 705;
const int M = 490005;
int n, m, u, v, ans = 0x7fffffff;
bool g[N][N], s[N], t[N];
int col[N], cnt[2];

void dfs(int x, int c){
	col[x] = c;
	cnt[c == 1]++;
	for(int i = 1; i <= n; i++){
		if(i == x || g[x][i])	continue;
		if(!col[i])	dfs(i, -c);
		else if(col[i] == c){
			puts("-1");
			exit(0);
		}
	}
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++){
		scanf("%d%d", &u, &v);
		g[u][v] = g[v][u] = 1;
	}
	s[0] = 1;
	for(int i = 1; i <= n; i++){
		if(col[i])	continue;
		cnt[0] = cnt[1] = 0;
		dfs(i, 1);
		memset(t, 0, sizeof t);
		for(int j = 0; j <= n; j++){
			t[j+cnt[0]] |= s[j];
			t[j+cnt[1]] |= s[j];
		}
		for(int j = 0; j <= n; j++)
			s[j] = t[j];
	}
	for(int i = 0; i <= n; i++)
		if(s[i])
			ans = min(ans, i*(i-1)/2 + (n-i)*(n-i-1)/2);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
a, b, c, x, y=map(int,input().split())
ans = max(a,b,2*c)*100000
for i in range(100001):
    if i*2*c + max(0,x-i)*a + max(0,y-i)*b < ans:
        ans = i*2*c + max(0,x-i)*a + max(0,y-i)*b
print(ans)

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

template <typename T>
inline T read(){
    T x=0,f=1;char c=getchar();
    while(!isdigit(c)){ if(c=='-') f=-f;c=getchar();}
    while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
    return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=2e5+1e1;

lint a[MAXN];
int n,k;

int main(void){

    // freopen("testdata.in","r",stdin);
    // freopen("testdata.out","w",stdout);

    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) a[i]=readlint;
    for(int i=1;i<=n-k;i++){
        if(a[i]<a[i+k]) puts("Yes");
        else puts("No");
    }

    return 0;
}

Measured memory_bytes: 5268
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int height[n+1];
    for(int i=1;i<=n;i++) cin>>height[i];
    vector<int> adj[n+1];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int count=0;
    for(int i=1;i<=n;i++){
        if(adj[i].size()==0) count++;
        else{
            bool flag=true;
            for(int j=0;j<adj[i].size();j++){
                int p=adj[i][j];
                if(height[p]>=height[i]){
                    flag=false;
                    break;
                }
            }
            if(flag) count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl;

#define iosbase ios_base::sync_with_stdio(false)
#define tie cin.tie();cout.tie();

#define endl '\n'

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

int n, m;
int main(){
  iosbase;
  tie;

  long long int x; cin >> x;
  long long int ans = 99999999999999999;
  for(long long int i = 1; i * i <= x; i++){
    if( x % i == 0){
      ans = min(ans, ( i - 1 + (x/i) - 1));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  long long bn = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B')
      bn++;
    else
      ans += bn;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

const int MAX_N = 100005;
const int BASE = 200;

int add(int x,int y)
{
    return (x + y)%MOD;
}

int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int dp[201][201];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vs s(n);
    rep(i,n){
        cin >> s[i];
    }
    dp[0][0] = 1;
    rep(i,n){
        rep(j,i+1){
            if(!dp[i][j]) continue;
            if(s[i] == "U"){
                dp[i+1][j] = add(dp[i+1][j],dp[i][j]);
                dp[i+1][j+1] = add(dp[i+1][j+1],mul(dp[i][j],i-j));
            }else if(s[i] == "D"){
                dp[i+1][j+1] = add(dp[i+1][j+1],mul(dp[i][j],i-j));
                dp[i+1][j+2] = add(dp[i+1][j+2],mul(dp[i][j],mul(i-j,i-j)));
            }else{
                dp[i+1][j+1] = add(dp[i+1][j+1],dp[i][j]);
            }
        }
    }
    cout << dp[n][n] << "\n";
    return 0;
}



Measured memory_bytes: 3376
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = LLONG_MAX;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	Int H; cin >> H;
	if (H == 1) {
		cout << 1 << endl;
		return 0;
	}

	Int log = (Int)log2(H);
	Int num = 1;
	Int ans = 0;
	for (Int i = 0; i <= log; ++i) {
		ans += num;
		num *= 2;
	}

	cout << ans << endl;

}

Measured memory_bytes: 512
sub f{my$x=$a[$_]=1;$a[$_]or$x+=$t=&f,$z+=1-$p[$t]for@$_;$z+=$p[-2]-$p[-$x-1];$x}@p=(1,map{($d*=5e8+4)%=$%=1e9+7;$.=$.*2%$%}++$d..<>);f$_=map{push@$_,$_[--$|]for@_=split}<>;print$z%$%*$d%$%

Measured memory_bytes: 352896
#include <iostream>
#include <vector>

const long mod = 1000000007l;

int main(){
  long N, K;
  std::cin >> N >> K;
  std::vector<long> sum(K, 0l);
  for(long k = K; k >= 1; --k){
    long el = K/k;
    long num = 1l;
    std::vector<long> bit(64, K/k);
    for(int i = 0; i < 64; ++i){
      for(int j = 0; j < i; ++j){
        bit[i] *= bit[i];
        bit[i] %= mod;
      }
    }
    for(int i = 0; i < 64; ++i){
      if((N >> i) & 1l){
        num *= bit[i];
        num %= mod;
      }
    }
    sum[k-1] = num;
    for(long i = 2; i*k <= K; ++i){
      sum[k-1] -= sum[i*k - 1];
    }
  }
  long count = 0;
  for(long i = 0; i < K; ++i){
    count += sum[i] * (i+1);
    count %= mod;
  }
  std::cout << count << std::endl;
  return 0;
}

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

int main() {
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)){
    cout<<"Bad"<<endl;
  }
  else if(s.at(1)==s.at(2)){
    cout<<"Bad"<<endl;
  }
  else if(s.at(2)==s.at(3)){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
  
}


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

int main(void){
  while(true){
    int n, p;
    cin >> n >> p;
    if(n == 0)
      break;

    vector<int> stone(n, 0);
    int man = 0, wan = p;
    
    while(true){
      if(wan != 0){
	wan--;
	stone[man]++;

	if(wan == 0){
	  bool flag = true;
	  for(int i=0; i<n; i++){
	    if(i != man && stone[i] != 0)
	      flag = false;
	  }
	  if(flag == true)
	    break;
	}
      }else{
	wan = stone[man];
	stone[man] = 0;
      }

      man = (man+1)%n;
    }

    cout << man << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3040
N,k = gets.split.map(&:to_i)
h={}
N.times do |i|
    a,b = gets.split.map(&:to_i)
    if h.has_key?(a)
        h[a]+=b
    else
        h[a]=b
    end
end
res = 0
h.sort.each do |price,num|
    if num <= k
        res += price * num
        k-=num
    else
        res += price * k
        k=0
    end
    break if k==0
end
puts res

Measured memory_bytes: 14840
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    ll x,y;
    cin>>x>>y;
    int c=0;
    while (x){
        x/=y;
        c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder alphabet = new StringBuilder("abcdefghijklmnopqrstuvwxyz");
		String s = sc.nextLine();
		while(sc.hasNextLine()){
			s += sc.nextLine();
		}
		int[] ans = new int[26];
		int count;

		for(int i=0;i<alphabet.length();i++) {
			count = 0;
			for(int j=0;j<s.length();j++) {

				if(alphabet.substring(i, i+1).equalsIgnoreCase(s.substring(j,j+1))) {
					count++;
				}

			}
			ans[i] = count;
		}

		for(int i=0;i<ans.length;i++) {
			System.out.println(Character.toLowerCase(alphabet.charAt(i)) + " : " + ans[i]);
		}

		sc.close();
	}

}


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

int main() {
    int h, n; cin >> h >> n;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        sum += x;
    }

    if(sum >= h) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    int64_t tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (int64_t)value;
    return output;
}

int128_t imax(const int128_t a, const int128_t b) { return std::max(a, b); } // std::max, std::min は型が違うとエラーになるため、ラッパーを作る。
int128_t imin(const int128_t a, const int128_t b) { return std::min(a, b); }

#define rep(i, begin, end) for(int64_t i = ((int64_t)begin); i <= ((int64_t)end); i++) // (int64_t)end としておくと、end = v.size() - 2 みたいな入力で、v.size()が1でも正常(end = -1になる）に挙動する。
#define rev(i, begin, end) for(int64_t i = ((int64_t)begin); ((int64_t)end) <= i; i--)

#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; }
#define input2(begin, end, v1, v2) v1.resize((end)+1); v2.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i]; } 
#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; } 

std::vector<int> irange(const int begin, const int end) {
    std::vector<int> ret; for (int i = begin; i <= end; i++) { ret.push_back(i); }
    return ret;
}

template <typename T>
void printvec(const std::vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int N;
//int128_t ;
std::vector<int128_t> a;
//std::vector<int128_t> A, B;
//std::string ;
//std::vector<std::string> ;
//double ;
//std::vector<double> ;

//const int MAX_N = 5010;

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

    input1(1, N, a);

    int ret = 0;

    rep (i, 2, N) {
        if (a[i] == a[i-1]) {
            ret++;
            a[i] = 0;
        }
    }
    
    std::cout << ret << std::endl;
    return 0;
}



Measured memory_bytes: 256
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var line = Console.ReadLine().Split(' ');
                var n = int.Parse(line[0]);
                var x = int.Parse(line[1]);

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

                var lower1 = x / 3 + 1;
                var upper1 = (x - 3 < n) ? x - 3 : n;
                var cnt = 0;
                for (var n1 = lower1; n1 <= upper1; n1++)
                {
                    var rest = x - n1;
                    var lower2 = rest / 2 + 1;
                    var upper2 = (n1 - 1 < rest - 1) ? n1 - 1 : rest - 1;
                    cnt += upper2 - lower2 + 1;
                }

                Console.WriteLine(cnt);
            }
        }
    }
}



Measured memory_bytes: 17724
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-10, pi = acos(-1.0);

const double G = 9.8;
int N,V,X,Y;
vector<int> L(N),B(N),R(N),T(N);
ld calcv(ld vy,ld t){
  return vy*t-G*t*t/2;
}

int cmp(ld lb,ld ub,ld a){
  return a< lb+eps ? -1 : a>ub-eps ? 1 :0;
}
bool check(ld qX,ld qY){
  //solve g^2/4*t^4 + (g*qY-V)*t^2 + (qX^2+qY^2) = 0;
  ld a = G*G/4; ld b = G*qY-V*V; ld c = qX*qX+qY*qY;
  ld D = b*b-4*a*c;
  //cout << D << endl;
  if((D<0)&&(D>-eps)) D=0;
  if(D<0) return false;
  for(int k=-1;k<=1;k+=2){
    //find t
    ld t2 = (-1*b+k*sqrt(D))/(2*a);
    if(t2<=0) continue;
    ld t = sqrt(t2);
    ld vx = qX/t; ld vy = (qY+G*t*t/2)/t;

    //can reach Y?
    double reachy = calcv(vy,X/vx);
    if(reachy<Y-eps) return false;

    bool ok = true;
    //find colision
    REP(i,N){
      if(L[i] >= X) continue;//ignore
      if(R[i]==X && Y<=T[i] && B[i]<=reachy) ok = false;
      //cout << vx << " : " << vy << endl;
      int yL = cmp(B[i],T[i],calcv(vy,L[i]/vx));
      int yR = cmp(B[i],T[i],calcv(vy,R[i]/vx));
      int xH = cmp(L[i],R[i],vx*(vy/G));
      int yH = cmp(B[i],T[i],calcv(vy,vy/G));
      if(xH==0 && yH >= 0 && yL < 0) ok = false;
      if(yL * yR <= 0) ok = false;
    }
    if(ok) return true;
  } 
  return false;
}
int main(){
  cin >> N >> V >> X >> Y;
  REP(i,N){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    L.push_back(a); B.push_back(b); R.push_back(c); T.push_back(d);
    //cin >> L[i] >> B[i] >> R[i] >> T[i];

    R[i] = min(R[i],X);
  }
  bool ok = check(X,Y);
  REP(i,N){
    ok |= check(L[i],T[i]);
    ok |= check(R[i],T[i]);
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, q; std::cin >> n >> q;
    std::vector<std::vector<int>> edg(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; std::cin >> a >> b;
        a--; b--;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    std::vector<int> ans(n);
    for (int i = 0; i < q; i++) {
        int p, x; std::cin >> p >> x;
        p--;
        ans[p] += x;
    }
    auto func = [&](auto &self, int pos = 0, int prev = -1) -> void {
        for (int u : edg[pos]) {
            if (u == prev) continue;
            ans[u] += ans[pos];
            self(self, u, pos);
        }
    };
    func(func);
    for (int i = 0; i < n; i++) std::cout << ans[i] << " \n"[i == n - 1];
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            char c; scanf(" %c", &c);
            if (i == j) putchar(c);
        }
    }
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int a,b,c;
int main(void){
    scanf("%d %d %d",&a,&b,&c);
    if((a==c)||((a==b)||(b==c))){
        if(!((a==b)&&(b==c))){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
int main(void)
{
	int n,uri,aic[10],i,j;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<10;i++)	aic[i]=0;
		for(i=0;i<n;i++){
			scanf("%d",&uri);
			aic[uri]++;
		}
		for(i=0;i<10;i++){
			if(aic[i]==0)
				printf("-\n");
			else{
				for(j=0;j<aic[i];j++){
					printf("*");
				}
				printf("\n");
			}
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1000
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t H, W;
	cin >> H >> W;

	vector<string> canvas(H);

	for (int32_t h = 0; h < H; h++) {
		cin >> canvas[h];
	}

	int32_t dh[] = {0, 0, 1, -1};
	int32_t dw[] = {1, -1, 0, 0};
	for (int32_t h = 0; h < H; h++) {
		for (int32_t w = 0; w < W; w++) {
			if (canvas[h][w] != '#')
				continue;

			bool nei_exists = false;
			for (int32_t pos = 0; pos < 4; pos++) {
				int32_t nei_h = h + dh[pos];
				int32_t nei_w = w + dw[pos];
				if (nei_h < 0 || nei_h >= H || nei_w < 0 || nei_w >= W)
					continue;
				if (canvas[nei_h][nei_w] == '#') {
					nei_exists = true;
					break;
				}
			}
			if (!nei_exists) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    char s;
    char before = 0;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        cin >> s;
        if (s == 'S') {
        } else {
            if (cnt == 0) {
                cnt++;
            } else {
                if (before == 'R') {
                    cnt++;
                }
            }
        }
        before = s;
    }
    cout << cnt <<endl;
    return 0;
}


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

int main() {
  int n;
  scanf("%d", &n);
  vector<vector<vector<int>>> data(4, vector<vector<int>>(3, vector<int>(10, 0)));
  for(int i = 0; i < n; i++) {
    int b, f, r, v;
    scanf("%d %d %d %d", &b, &f, &r, &v);
    data[b-1][f-1][r-1] += v;
  }
  for(int i = 0; i < 4; i++) {
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 10; k++) {
        printf(" %d", data[i][j][k]);
        if(k == 9) printf("\n");
      }
    }
    if(i != 3) printf("####################\n");
  }
}


Measured memory_bytes: 3292
N, M = map(int, input().split())
X = [0 for i in range(N)]
Y = [0 for i in range(N)]
Z = [0 for i in range(N)]

PPP = [0 for i in range(N)]
PPM = [0 for i in range(N)]
PMP = [0 for i in range(N)]
PMM = [0 for i in range(N)]
MPP = [0 for i in range(N)]
MPM = [0 for i in range(N)]
MMP = [0 for i in range(N)]
MMM = [0 for i in range(N)]

for i in range(0, N):
	X[i], Y[i], Z[i] = map(int, input().split())
	PPP[i] =   X[i] + Y[i] + Z[i]
	PPM[i] =   X[i] + Y[i] - Z[i]
	PMP[i] =   X[i] - Y[i] + Z[i]
	PMM[i] =   X[i] - Y[i] - Z[i]
	MPP[i] = - X[i] + Y[i] + Z[i]
	MPM[i] = - X[i] + Y[i] - Z[i]
	MMP[i] = - X[i] - Y[i] + Z[i]
	MMM[i] = - X[i] - Y[i] - Z[i]

nPPP = sorted(PPP, reverse=True)
nPPM = sorted(PPM, reverse=True)
nPMP = sorted(PMP, reverse=True)
nPMM = sorted(PMM, reverse=True)
nMPP = sorted(MPP, reverse=True)
nMPM = sorted(MPM, reverse=True)
nMMP = sorted(MMP, reverse=True)
nMMM = sorted(MMM, reverse=True)

mPPP = 0
mPPM = 0
mPMP = 0
mPMM = 0
mMPP = 0
mMPM = 0
mMMP = 0
mMMM = 0

for i in range(0, M):
	mPPP += nPPP[i]
	mPPM += nPPM[i]
	mPMP += nPMP[i]
	mPMM += nPMM[i]
	mMPP += nMPP[i]
	mMPM += nMPM[i]
	mMMP += nMMP[i]
	mMMM += nMMM[i]

print(max(mPPP, mPPM, mPMP, mPMM, mMPP, mMPM, mMMP, mMMM))


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int A = 1;
        int B = 0;
        int C = -1;
        int a,b,c;
        int n;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        n = sc.nextInt();
        if(a + b >= n)
        {
            System.out.println(Math.min(a,n)*A);
        }
        else
        {
            System.out.println((n-(a+b))*C+ a*A);
        }
    }
}


Measured memory_bytes: 35732
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}
 
void solve(){
    ll a,b; cin>>a>>b;
    cout<<(a*(a-1))/2 + (b*(b-1))/2<<endl;
}
 
int main(){
    ffast
    ll t=1;
    //cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
typedef pair<int,int> pii;
typedef pair<double,pii> P;
typedef long long ll;
#define mkp make_pair
#define F first
#define S second
// #define int long long
// struct P {
// 	double first;
// 	pii second;
// 	P(double f, pii s) {
// 		first = f;
// 		second = s;
// 	}

// 	bool operator<(const P & obj) const {
// 		return this->S.S * obj.S.F > this->S.F * obj.S.S;
// 	}
// };

signed main(){
	int n;
	cin>>n;
	long long ans=0;
	n++;
	vector<int> h(n),a(n),d(n),s(n);
	rep(i,n) cin>>h[i]>>a[i]>>d[i]>>s[i];
	reep(i,1,n){
		a[i]=max(a[i]-d[0],0);
	}
	vector<int> atack(n);
	reep(i,1,n){
		atack[i]=max(a[0]-d[i],0);
	}
	vector<P> v;
	reep(i,1,n){
		if(a[i]==0){
			continue;
		}
		if(s[i]>s[0]) ans+=a[i];
		if(atack[i]==0){
			puts("-1");
			return 0;
		}
		int tmp=h[i]/atack[i];
		if(h[i]%atack[i]) tmp++;
		// v.push_back(mkp( (double)a[i]/tmp, pii(a[i],tmp)) );
		v.push_back(mkp( (double)a[i]/tmp, pii(a[i],tmp)) );
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	ll turn=0;
	rep(i,v.size()){
		// acout << ans << endl;
		turn+=v[i].S.S;
		ans+=(turn-1LL)*v[i].S.F;
		if(ans>=h[0]){
			puts("-1");
			return 0;
		}
	}
	// if(ans>=(ll)h[0]) puts("-1");
	cout<<ans<<endl;
	// rep(i,v.size()){
		// cout<<v[i].F<<" "<<v[i].S.F<<" "<<v[i].S.S<<endl;
	// }
	// ll ans1=LLONG_MAX;
	// do{
	// 	ll tmp=0;
	// 	turn=0;
	// 	rep(i,v.size()){
	// 		turn+=v[i].S.S;
	// 		tmp+=(turn-1)*v[i].S.F;
	// 	}
	// 	ans1=min(ans1,tmp+ans);
	// }while(next_permutation(v.begin(),v.end()));
	// if(ans1!=ans){
		// cout<<"NO"<<endl;
	// }
}

Measured memory_bytes: 2804
#include <stdio.h>
  
int main()
{
   int w,h,x,y,r;
   scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
   if(w-r>=x&&r<=x&&h-r>=y&&r<=y){
    printf("Yes\n");
   }else{
    printf("No\n");
    }
}


Measured memory_bytes: 2696
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(num(n))
}

func num(n int) int {
	var max int
	key := 1
	for ; n > 0; n-- {
		var c int
		for t := n; t%2 == 0; t /= 2 {
			c++
		}
		if c > max {
			max = c
			key = n
		}
	}
	return key
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    int X[105];
    rep(i, N) cin >> X[i];
    int S1 = 0, S2 = 0;
    rep(i, N) {
        S1 += X[i];
        S2 += X[i] * X[i];
    }
    int mn_P = S1 / N;
    int ans;
    if (mn_P * N == S1) {
        ans = S2 - S1*S1/N;
    } else {
        int ans1 = N*mn_P*mn_P - 2*S1*mn_P + S2;
        mn_P++;
        int ans2 = N*mn_P*mn_P - 2*S1*mn_P + S2;
        ans = min(ans1, ans2);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans=0;
  
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x) ans++;
      }
    }
  }
  
  cout << ans << endl;
}
  

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

long long ipow(long long b, long long e) {
	if (e == 0) {
		return 1;
	} else if (e % 2 == 0) {
		return ipow(b * b, e / 2);
	} else {
		return ipow(b * b, e / 2) * b;
	}
}

int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 1;; i++) {
		if (ipow(K, i - 1) <= N && N < ipow(K, i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
    
        if temp!=1:
            arr.append([temp, 1])
    
        if arr==[]:
            arr.append([n, 1])
        arr = [(i,j) for i,j in arr]
        return arr
    
    a,b = map(int,input().split())
    fa = dict(factorization(a))
    fb = dict(factorization(b))
    fak = set(fa.keys())
    fbk = set(fb.keys())
    if a == 1 and b == 1:
        print(1)
    else:
        print(len(fak&fbk)+1)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define endl "\n"
#include <map>
#include <numeric>
#include <stack>
#define ll long long int
using namespace std;

bool containsDuplicate(vector<int>& nums) {
        int n=nums.size();
        nums.erase(unique(nums.begin(), nums.end()), nums.end());
        int m=nums.size();
        for(int i: nums)
        {
            cout << i << endl;
        }
        if(n==m){
            return false;
        }return true;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    cout << r/d-(l-1)/d;

	return 0;
}


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

n, k = map(int, input().split())
mod = 10**9+7

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

for i in range(1, k+1):
    print((comb(n-k+1, i, mod) * comb(k-1, i-1, mod))%mod)

Measured memory_bytes: 3444
N = int(input())
H = list(map(int, input().split()))
H.append(0) #H[-1]の処理専用
ans = 0

#0が見つかるまで0ではないindexをmemoに残して、0が見つかったらmemoの要素を-1する。
#最後の要素のみ、-1するタイミングがなくなるので、H.append(0)しておいた。
while sum(H) > 0:
    i = 0
    memo = []
    while i < N+1:
        if H[i] > 0:
            memo.append(i)
        if H[i] == 0:
            if len(memo):
                for i in memo:
                    H[i] -= 1
                memo = []
                ans += 1
        i += 1

print(ans)


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int min=10000, sum=0;

  for(int i=0; i<m.size(); i++) {
    cin >> m.at(i);
    sum += m.at(i);
    if(m.at(i)<min) min = m.at(i);
  }

  cout << N+(X-sum)/min << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char a[12];
    scanf("%s",a);
    int b=0,c=0;
    for(int i=0;a[i]!='\0';i++){
        if(a[i]=='A'){
            c++;
            if(c>b){
                b=c;
            }
            continue;
        }else if(a[i]=='C'){
            c++;
            if(c>b){
                b=c;
            }
            continue;
        }else if(a[i]=='G'){
            c++;
            if(c>b){
                b=c;
            }
            continue;
        }else if(a[i]=='T'){
            c++;
            if(c>b){
                b=c;
            }
            continue;
        }else{
            c=0;
        }    
    }

    printf("%d",b);
    return 0;
}

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

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

	vector<int> p(N);
	for (int i = 0; i < N; i++) cin >> p.at(i);

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

	int ans = 0;

	for (int j = 0; j < K; j++) {
		ans += p.at(j);
	}

	cout << ans << endl;
}

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

using namespace std;

int main ()
{
    char arr[3][3];
    string s;
    for(int i=0 ; i<3 ; ++i)
    {
        for(int j=0 ; j<3 ; ++j)
        {
            cin>>arr[i][j];
            if(i == j) s+=arr[i][j];
        }
    }
    cout<<s;
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	bool flag = true;
	for (int i = 0; i < s.length() - 1; ++i){
		if (s[i] == s[i+1]){
			flag = false;
			break;
		}
	}
	cout << (flag ? "Good" : "Bad");
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        Integer[] antenna = {Integer.parseInt(sc.next()),
                Integer.parseInt(sc.next()),
                Integer.parseInt(sc.next()),
                Integer.parseInt(sc.next()),
                Integer.parseInt(sc.next())};
        int range = Integer.parseInt(sc.next());

        boolean result = true;
        for (int i = 0; i < antenna.length - 1; i++) {
            for (int j = i + 1; j < antenna.length; j++) {
                if (Math.abs(antenna[i] - antenna[j]) > range) {
                    result = false;
                }
            }
        }

        System.out.println(result ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int a=0;
    int sum=0;
    for(int i=0;i<n;i++){
        a*=10;
        a+=s[i]-'0';
    }
    for(int i=0;i<n;i++){
        sum+=s[i]-'0';
    }
    if (a%sum==0){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println((n*a>b)?b:n*a);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    int cont;
    long long sum = 0;
    int N = S.size();
    int M = N - 1;
    string sumS = "";
    string st;
    for(int bit = 0; bit < (1<<M);++bit){
        cont = 1;
        
        for(int i = 0; i < N;i++){
            sumS += string(S.substr(i,1));
            
            
            if(bit & (1<<i)){
                //cout << sumS << endl;
                if(sumS!=""){
                    st = string(sumS);
                    sum += stoll(st);   
                    sumS = "";
                }
            }
        }
        
        //cout << sumS << endl;
        if(sumS!=""){
            st = string(sumS);
            sum += stoll(st);   
            sumS = "";
        }
    }
    
    cout << sum << endl;
    
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, L := nextInt(), []int{}
	for i := 0; i < N; i++ {
		L = append(L, nextInt())
	}

	fmt.Printf("%s\n", ABC117B(L))
}

// ABC117B ...
func ABC117B(L []int) string {
	sum, max := 0, -1
	for _, l := range L {
		if max < l {
			max = l
		}
		sum += l
	}

	if max < sum-max {
		return "Yes"
	}

	return "No"
}

Measured memory_bytes: 1776
N,Q=map(int,input().split())
import sys
def input(): return sys.stdin.readline().strip()
STX=[list(map(int,input().split())) for i in range(N)]
D=[int(input()) for i in range(Q)]
X=[]
for s,t,x in STX:
    X.append((s-x,1,x))
    X.append((t-x,-1,x))
X.sort(key=lambda x:x[0])
a=0
k=[]
from heapq import heappop,heappush
kd={}
for x in X:
    while a<Q and D[a]<x[0]:
        if len(k)>0:
            print(k[0])
        else:
            print(-1)
        a+=1
    if x[1]==1:
        heappush(k,x[2])
        if x[2] in kd:
            kd[x[2]]=0
    else:
        kd[x[2]]=1
        while len(k)>0 and k[0] in kd and kd[k[0]]==1:
            heappop(k)
while a<Q:
    print(-1)
    a+=1

Measured memory_bytes: 131748
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = Array(3) { sc.nextInt() }
    println(a.distinct().count())
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 39252