akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    using P = pair<int, int>;
    vector<P> v(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v[i].second, &v[i].first);
    }
    vector<int> u(m);
    for (auto &&j : u) scanf("%d", &j);
    sort(v.begin(),v.end(), greater<>());
    sort(u.begin(),u.end(), greater<>());
    int a = 0, b = 0;
    while(a < u.size() && b < v.size()){
        while(b < v.size() && v[b].second > u[a]) b++;
        if(b == v.size()) break;
        a++; b++;
    }
    cout << a << "\n";
    return 0;
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	ini(n1);
	vi a(n1);
	FOR(i, 0, n1) { in(a[i]); }
	int min1 = a[n1-1]-a[0];
	FOR(i,1,n1){
		min1 = min(min1,n-(a[i]-a[i-1]));
	}
	out(min1);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2e5+10;

int n,a[N];

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) a[i]-=i;
	sort(a+1,a+n+1);
	int mid=a[(1+n)/2];
	LL ans=0;
	for (int i=1;i<=n;i++) ans+=abs(a[i]-mid);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=1.0*a/b;
	printf("%d %d %.5lf\n",d,r,f);
	return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------------------------head--------------------------------------------------

const int inf=0x3f3f3f3f;
const int N=4005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m,k,dp[2][N<<1],ans;

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	read(n,m,k);
	int d=(n+m-1)/(k-1);
	debug(d);
	dp[0][0]=1;
	for(int i=1;i<=d;i++){
		for(int j=0;j<=n;j++) dp[i&1][j]=0;
		for(int j=0;j<=n;j++){
			int p=(n-j)%(k-1);if(!p) p+=k-1;
			if(!p||j+p>n||i*(k-1)-j-p+1>m) continue;
			ch(ans,dp[i-1&1][j]);
			for(int p=0;p<k;p++)
				ch(dp[i&1][j+p],dp[i-1&1][j]);
		}
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
abc = [list(map(int,input().split())) for i in range(n)]

dp_a = [abc[0][0]] + [0]*(n-1)
dp_b = [abc[0][1]] + [0]*(n-1)
dp_c = [abc[0][2]] + [0]*(n-1)

for i in range(n-1):
    dp_a[i+1] = max(        dp_b[i],dp_c[i]) + abc[i+1][0]
    dp_b[i+1] = max(dp_a[i],        dp_c[i]) + abc[i+1][1]
    dp_c[i+1] = max(dp_a[i],dp_b[i]        ) + abc[i+1][2]

ans = max(dp_a[-1],dp_b[-1],dp_c[-1])
print(ans)

Measured memory_bytes: 43984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

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

    ll MAX = 1000005;
    vector<ll> c;
    vector<ll> d(MAX, 0);
    ll dd;
    ll ans;

    //約数列挙
    ll tmp;
    for (ll i = 2; i*i <= N; i++) {
        if(N % i == 0){
            c.push_back(i);
            if(i * i != N){
                c.push_back(N / i);
            }
        }
    }

    //素因数分解
    tmp = N - 1;
    for (ll i = 2; i < MAX; i++) {
        while(tmp % i == 0){
            d[i]++;
            tmp = tmp / i;
        }
    }
    dd = tmp;

    //N-1の約数の個数(1をのぞく)
    tmp = 1;
    if(dd != 1){
        tmp = 2;
    }
    for (ll i = 2; i < MAX; i++) {
        if(d[i] != 0){
            tmp = tmp * (d[i] + 1);
        }
    }
    ans = tmp - 1; //1を引く

    //Nの約数パート
    for (ll K : c) {
        tmp = N;
        while(tmp >= K){
            if(tmp % K == 0){
                tmp = tmp / K;
            }
            else{
                tmp = tmp % K;
            }
        }
        if(tmp == 1){
            ans++;
        }
    }
    ans++; //N自体
    printf("%lld\n", ans);
}


Measured memory_bytes: 11160
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, K; cin >> N >> K;
  vector<int> h(N);
  rep(i, N) cin >> h[i];

  int ans = 0;
  rep(i, N){
    if (h[i] >= K) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e3+10;


int main() {
	int n = rd();
	map<int,int> s;
	REP(i,1,n) ++s[rd()];
	if (n<=2) return puts("Possible"),0;

	{
	int mi = s.begin()->x, ma = s.rbegin()->x;
	if (mi!=(ma+1)/2) return puts("Impossible"),0;
	REP(i,mi+1,ma) {
		int cnt = 0;
		if (!s.count(i)||s[i]==1) return puts("Impossible"),0;
	}
	if (s.begin()->y!=(ma&1)+1) return puts("Impossible"),0;
	}
	int len = s.rbegin()->x, L = 1, R = len+1;
	if (s.rbegin()->y<2) return puts("Impossible"),0;
	s.erase(len);
	int mi = 1e9;
	REP(i,2,len) {
		int d = max(abs(i-L),abs(i-R));
		if (s.count(d)) { 
			if (!--s[d]) s.erase(d);
		}
		else return puts("Impossible"),0;
		mi = min(mi, d+1);
	}


	puts("Possible");	
}









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

    const int dr[] = {0, 0, 1, -1};
    const int dc[] = {1, -1, 0, 0};

    queue<State> q;
    q.push({0, 0, 0});
    vector<vector<bool>> visited(H);
    rep(r, 0, H) visited[r].assign(W, false);
    visited[0][0] = true;

    int dist = -1;
    while (!q.empty())
    {
        State state = q.front();
        q.pop();

        if ((state.r == H - 1) && (state.c == W - 1))
        {
            dist = state.dist;
            break;
        }

        rep(i, 0, 4)
        {
            const int nr = state.r + dr[i];
            const int nc = state.c + dc[i];
            if (nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
            if (s[nr][nc] == '#') continue;
            if (visited[nr][nc]) continue;

            q.push({nr, nc, state.dist + 1});
            visited[nr][nc] = true;
        }
    }

    if (dist == -1)
    {
        cout << -1 << endl;
        return;
    }

    int blackNum = 0;
    rep(r, 0, H) rep(c, 0, W) if (s[r][c] == '#') ++blackNum;
    cout << (H * W - blackNum - (dist + 1)) << endl;
}


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

int main() {
  int count = 0;  
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if(S.at(0) == S.at(1) && S.at(2) == S.at(3)){
      count++;   
  }
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2) && S.at(1) == S.at(3)){
      cout << "No" << endl;
  }
   else if(count == 1){
      cout << "Yes" << endl;
    }
   
      else{
      cout << "No" << endl;
    }
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << '+' << endl;
	else if (a * b == 15) cout << '*' << endl;
	else cout << 'x' << endl;

    return 0;
}


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

int main(int argc, char const *argv[])
{
    int i = 1, x;
    while(true){
        cin >> x;
        if (x == 0) break;
        printf("Case %d: %d\n", i, x);
        i += 1;
    }
    return 0;
}



Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
int N;
double dp[301][301][301];
int fl[301][301][301];
double f(int a,int b,int c){
    if (fl[a][b][c]==1){
        return dp[a][b][c];
    }
    fl[a][b][c]=1;
    if (a+b+c==0){
        return dp[a][b][c]=0;
    }
    double fans=1/(1-(double)(N-a-b-c)/N);
    if (a>0){
        fans+=f(a-1,b,c)*a/N/(1-(double)(N-a-b-c)/N);
    }
    if (b>0){
        fans+=f(a+1,b-1,c)*b/N/(1-(double)(N-a-b-c)/N);
    }
    if (c>0){
        fans+=f(a,b+1,c-1)*c/N/(1-(double)(N-a-b-c)/N);
    }
    return dp[a][b][c]=fans;
}
int main(){
    cin>>N;
    int x=0,y=0,z=0;
    for(int i=0;i<N;i++){
        int a;
        cin >>a;
        if (a==1){
            x++;
        }
        else if(a==2){
            y++;
        }
        else{
            z++;
        }
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                fl[i][j][k]=0;
                dp[i][j][k]=0;
            }
        }
    }
    cout<<setprecision(13)<<f(x,y,z)<<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    int q;
    for (int i = 0; i < n; i++) {
        cin >> q;
        p[q - 1] = i;
    }
    for (int i = 1; i <= n; i++) {
        cout << (20001 * i) << (i != n ? " " : "\n");
    }
    for (int i = 1; i <= n; i++) {
        cout << (20001 * (n - i + 1) + p[i - 1]) << (i != n ? " " : "\n");
    }

}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

	string n;
	cin >> n;
	int digit = n.size();
	int sum = n[0] - '0' + 9 * (digit - 1);
	for (int i = 1; i < digit;i++) {
		if (n[i] < '9') {
			sum--;
			break;
		}
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n'
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
	ll i, n, k;
	map <ll, ll> m;
	map<ll, ll> ::iterator it;
	cin>>n>>k;
	FOR(i, 1, n+1)
	{
		int v  = i%k;
		it = m.find(v);
		if(it == m.end())
			m[v] = 1;
		else 
			it->ss++;
	}
	ll ans = 0;
	ll na;
	it = m.begin();
	while(it!=m.end())
	{
		if((it->ff)%k != (k - (it->ff)%k)%k)
		{
			it++;
			continue;
		}
		na = it->ss;
		ans += na*na*na;
		it++;
	}
	cout<<ans;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
const int M = 7e5 + 5;
long long n;
int m , q;
int mark[M];
int inp;
struct data{
	int top[7];
	int bot[7];
	long long ans;
	void compress(){
		map < int , int > mp;
		mp.clear();
		for(int i = 0 ; i < 7 ; ++i){
			if(top[i] != -1){
				mp[top[i]];
			}
			if(bot[i] != -1){
				mp[bot[i]];
			}
		}
		int val = 0;
		for(auto &it : mp){
			it.second = val++;
		}
		for(int i = 0 ; i < 7 ; ++i){
			if(top[i] != -1){
				top[i] = mp[top[i]];
			}
			if(bot[i] != -1){
				bot[i] = mp[bot[i]];
			}
		}
	}
};
int parent[M];
int find(int node){
	if(parent[node] == node){
		return node;
	}
	return parent[node] = find(parent[node]);
}
bool join(int a , int b){
	if(find(a) == find(b)){
		return 0;
	}
	parent[find(a)] = find(b);
	return 1;
}
data getbase(){
	for(int i = 0 ; i < m ; ++i){
		parent[i] = i;
	}
	int ans = m - q;
	for(int i = 0 ; i < m ; ++i){
		if(!mark[i]){
			if(i % 7 != 6 && !mark[i + 1]){
				ans -= join(i , i + 1);
			}
			if(i + 7 < m && !mark[i + 7]){
				ans -= join(i , i + 7);
			}
		}
	}
	data res;
	for(int i = 0 ; i < 7 ; ++i){
		if(mark[i]){
			res.top[i] = -1;
		}
		else{
			res.top[i] = find(i);
		}
	}
	for(int i = m - 7 ; i < m ; ++i){
		if(mark[i]){
			res.bot[i - m + 7] = -1;
		}
		else{
			res.bot[i - m + 7] = find(i);
		}
	}
	res.ans = ans;
	res.compress();
	return res;
}
data base;
data combine(data lft , data rgt){
	for(int i = 0 ; i < 30 ; ++i){
		parent[i] = i;
	}
	for(int i = 0 ; i < 7 ; ++i){
		if(rgt.top[i] != -1){
			rgt.top[i] += 14;
		}
		if(rgt.bot[i] != -1){
			rgt.bot[i] += 14;
		}
	}
	data res;
	res.ans = lft.ans + rgt.ans;
	for(int i = 0 ; i < 7 ; ++i){
		if(lft.bot[i] != -1 && rgt.top[i] != -1){
			res.ans -= join(lft.bot[i] , rgt.top[i]);
		}
	}
	for(int i = 0 ; i < 7 ; ++i){
		if(lft.top[i] == -1){
			res.top[i] = -1;
		}
		else{
			res.top[i] = find(lft.top[i]);
		}
		if(rgt.bot[i] == -1){
			res.bot[i] = -1;
		}
		else{
			res.bot[i] = find(rgt.bot[i]);
		}
	}
	res.compress();
	return res;
}
data solve(long long n){
	if(n == 1){
		return base;
	}
	if(n & 1){
		return combine(solve(n - 1) , base);
	}
	data tmp = solve(n >> 1);
	return combine(tmp , tmp);
}
int main(){
	scanf("%lld %d %d" , &n , &m , &q);
	for(int i = 1 ; i <= q ; ++i){
		scanf("%d" , &inp);
		mark[inp] = 1;
	}
	if(m % 7){
		for(int i = m ; i < m * 7 ; ++i){
			mark[i] = mark[i - m];
		}
		m *= 7;
		q *= 7;
	}
	base = getbase();
	printf("%lld\n" , solve((7 * n) / m).ans);
}

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

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795;

int main()
{
	ll N, L;
	cin >> N >> L;
	string S[N];
	rep(i, 0, N)cin >> S[i];
	sort(S, S+N);
	rep(i, 0, N){
		cout << S[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();

    vector<VL> dp(n + 1, VL(5, 0));
    dp[0][0] = 1;
    string t = "ABCX";
    FOR(i, 0, n)FOR(j, 0, 4) {
        if (s[i] == t[j] || s[i] == '?')(dp[i + 1][j + 1] += dp[i][j]) %= mod;
        if (s[i] == '?')(dp[i + 1][j] += dp[i][j] * 3) %= mod;
        else (dp[i + 1][j] += dp[i][j]) %= mod;
    }
    cout << dp[n][3] << "\n";
}


Measured memory_bytes: 7376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int mp[21][21];
  int w,h;
  int x[4]={1,-1,0,0};
  int y[4]={0,0,1,-1};
  int m;
  bool b;
  char s;
  int ans;
  while(1){
    cin>>w>>h;
    if(w==0 && h==0) break;
    ans=0;
    for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
	mp[i][j]=0;
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>s;
	if(s=='#') mp[i][j]=1;
	else if(s=='@') mp[i][j]=2;
      }
    }
    b=true;
    while(b){
      b=false;
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  if(mp[i][j]==2){
	    /*for(int k=0;k<4;k++){*/
	      if(mp[i+1][j]==0){
		mp[i+1][j]=2;
		b=true;
	      }
	      if(mp[i-1][j]==0){
		mp[i-1][j]=2;
		b=true;
	      }
	      if(mp[i][j+1]==0){
		mp[i][j+1]=2;
		b=true;
	      }
	      if(mp[i][j-1]==0){
		mp[i][j-1]=2;
		b=true;
	      }
	  }
	}
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	/*cout<<mp[i][j]<<" ";*/
	if(mp[i][j]==2) ans++;
      }
      /* cout<<endl;*/
    }
    cout<<ans<<endl;
  }
  return 0;
}
  
    



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll q,h,s,d,n;
  cin >> q >> h >> s >> d;
  cin >> n;
  q *=4;
  h *=2;
  s=min(min(q,h),s);
  if(n%2==0){
    cout << min(n*s,d*n/2) << endl;
  }
  else
    cout << min(n*s,d*(n-1)/2+s) << endl;
}

Measured memory_bytes: 256
/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"

//void add(int I, int value){seg[I += MAXN] = value;for (I >>= 1; I; I >>= 1){seg[I] = __gcd(seg[I << 1], seg[I << 1 | 1]);}}

//int query(int l, int r){int ans = seg[l + MAXN];for (l += MAXN, r += MAXN + 1; l < r; l >>= 1, r >>= 1){if(l & 1) ans = __gcd(ans, seg[l ++]);if(r & 1) ans = __gcd(ans, seg[-- r]);}return ans;}

const int MAXN = 1e6 + 10;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll mod)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % mod, b / 2, mod)) % mod : pw(a * a % mod, b / 2, mod))); }

int v[MAXN];

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n, m;
    cin >> n >> m;
    ld sum = 0, one = 1.0;
    for(int i = 1; i <= n; i++)
    {
            cin >> v[i];
            sum += v[i];
    }
    sort(v + 1, v + n + 1);
    for(int i = n; i > (n - m); i--)
    {
            if(v[i] < (sum / (4 * one * m)))
            {
                    return cout << "No", 0;
            }
    }
    cout << "Yes";
    return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;


int main(){
    string s;
    cin >>s;
    sort(all(s));
    ll n=s.size();
    ll co=0;
    char key='.';
    bool flg=true;
    for (int i = 0; i < n; ++i) {
        if(key==s[i]){
            co++;
        }
        else {
            if(co%2==1)flg=false;
            co=1;
            key=s[i];
        }
    }
    if(co%2==1)flg=false;
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  switch(n % 10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      puts("hon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      puts("pon");
      break;
    case 3:
      puts("bon");
      break;
  }
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ProductAndGCD | diff ProductAndGCD.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ProductAndGCD.cpp && ./a.out

/*
 
 6/8/2019
 
 16:00-
 
 */

vector<LL> primeFactors(LL n) {
  assert(n>=1);
  vector<LL> res;
  for(LL p=2; p*p<=n; ++p) while(n%p==0) {
    res.push_back(p);
    n/=p;
  }
  if(n>1) res.push_back(n);
  return res;
}

LL N;
LL P;

void solve() {
  vector<LL> ps=primeFactors(P);
  map<LL,LL> cnt;
  FORR(p,ps)cnt[p]++;
  LL res=1;
  FORR(kvp,cnt) {
    LL a=kvp.first,b=kvp.second;
    LL n=b/N;
    LL x=1;
    REP(_,n) x*=a;
    res*=x;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>P;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define EPS 1e-9
using namespace std;
string str;
int w[10], s[10];
int main() {
    int n;
    while (scanf("%d",&n)) {
        if (n==0) break;
        string h[n];
        int perm[n];
        for (int i=0; i<n; i++) {
            cin>>str>>w[i]>>s[i];
            h[i]=str;
            perm[i]=i;
        }
        double G=INT_MAX/2.0;
        string res[n];
        do {
            int sum=w[perm[0]];
            bool flag=true;
            for (int i=1; i<n; i++) {
                int x=perm[i];
                if (s[x]<sum) {
                    flag=false;
                    break;
                }
                sum+=w[x];
            }
            if (flag) {
                int sum2=0;
                for (int i=0; i<n; i++) sum2+=(n-i)*w[perm[i]];
                if (G-EPS>(double)sum2/(double)sum) {
                    G=(double)sum2/(double)sum;
                    for (int i=0; i<n; i++) res[i]=h[perm[i]];
                }
            }
        } while (next_permutation(perm, perm+n));
        for (int i=n-1; i>=0; i--) cout<<res[i]<<endl;
    }
}

Measured memory_bytes: 956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
ll gcd ( ll a, ll b ) {
    if ( a % b == 0 ) return b;
    return gcd(b, a % b);
}
int main() {
    ll x, y;
    cin >> x >> y;
    ll gcd_num = gcd(x, y);
    if ( y == gcd_num ) {
        cout << -1 << endl;
        return 0;
    }
    ll mult_num = 2;
    while ( 1 ) {
        if ( x * mult_num > 1e18 ) {
            cout << -1 << endl;
            return 0;
        }
        if ( ( x * mult_num ) % y != 0 ) break;
        ++mult_num;
    }
    cout << x * mult_num << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;


int main(){
    int k;
    cin >> k;
    ll sum=0;
    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            for(int l=1; l<=k; l++){
                sum += __gcd(__gcd(i, j), l);
            }
        }
    }
    out(sum);
}

Measured memory_bytes: 3608
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).ok();
    return word.trim().to_string();
}
 
fn main() {
	let mut s:Vec<char> = get_input().chars().collect();
	s.sort();
	s.dedup();
	println!("{}", if s.len() == 2 {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
// problem: "https://atcoder.jp/contests/abc156/tasks/abc156_e"

#include<bits/stdc++.h>
#define ll long long
#define p (ll)(1e9+7)

using namespace std;

void Fact (vector<ll>&V)
{
    ll i;
    V[0] = 1;
    for(i=1;i!=V.size();i++)
        V[i] = (V[i-1]*i)%p;
}

ll power(ll a,ll n)
{
    if(!n)
        return 1;

    ll b = 1;
    if(n%2)
        b = a;

    ll ans = power(a,n/2);
    ans = ((ans*ans)%p * b)%p;

    return ans;
}

ll nCr (ll n,ll r,vector<ll>&V)
{
    return (V[n] * power((V[r]*V[n-r])%p,p-2))%p;       // define
}

ll func(ll n,ll k)
{
    vector<ll>V(n+1);
    Fact(V);

    ll m = min(k,n-1);
    ll i,s;
    s = 1;

    for(i=1;i!=m+1;i++)
        s = (s + (nCr(n,i,V) * nCr(n-1,n-i-1,V))%p)%p;        // define

    return s;
}

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

    cout<<func(n,k);        // define

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int sumDigit(int n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n /=10;
    }
    return sum;
}

int main(){
    int n,a,b; cin >> n >> a >> b;
    
    int ans = 0;
    rep1(i,n){
        int x = sumDigit(i);
        if(x >= a and x<= b) ans += i;
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int i,j;
  int n,q,m;
  int S[20];
  int sum;
  char isYes[40001];
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d",S+i);
  for(i = 0; i < 40001; ++i) isYes[i] = 0;
  for(i = 0; i < (1<<n)-1; ++i) {
    sum = 0;
    for(j = 0; j < n; ++j) {
      if((i>>j)&1) sum += S[j];
    }
    isYes[sum] = 1;
  }
  scanf("%d", &q);
  while(q--) {
    scanf("%d", &m);
    if(isYes[m]) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2088
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll h,w; cin >> h >> w;
  vector<vector<char>> table(h+2,vector<char>(w+2,'#'));
  
  for(ll i=1; i <= h; i++){
    for(ll j=1; j <= w; j++){
      cin >> table[i][j];
    }
  }
  
  for(ll i=0; i <= h+1; i++){
    for(ll j=0; j <= w+1; j++){
      cout << table[i][j];
      if(j == w+1) cout << endl;
    }
  }
  
}

Measured memory_bytes: 3628
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    x,y,z = LI()
    a = ['a' for _ in range(x)] + ['b' for _ in range(y)] + ['c' for _ in range(z)]
    while len(a) > 1:
        a.sort()
        a[0] += a[-1]
        a = a[:-1]

    return a[0]


print(main())




Measured memory_bytes: 7692
n = int(input())
a = [i for i in map(int, input().split())]
a.append(0)
a.insert(0, 0)


def money(arr):
    now_x = 0
    total_score = 0

    for i in arr:
        total_score += abs(i-now_x)
        now_x = i

    total_score += abs(now_x)
    return total_score


total = money(a)


for i in range(len(a)-2):
    now_point = a[i]
    break_point = a[i+1]
    next_point = a[i+2]

    break_distance = abs(next_point-now_point)
    normal_distance = abs(break_point-now_point) + \
        abs(next_point - break_point)

    if(break_distance == normal_distance):
        print(total)
    else:
        print(total - abs(break_distance-normal_distance))


Measured memory_bytes: 14172
#include<iostream>
#include<string>
#include <cmath>
using namespace std;
int a, b;
int num[12] ={1,3,1,2,1,2,1,1,2,1,2,1};
int main() {
    cin >> a >> b;
    for(int i=1; i<=12; ++i){
        if(i==a) a=num[i-1]+100;
        if(i==b) b=num[i-1]+100;
    }
    if(a==b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

a,m=map(int,input().split())
A=list(map(lambda i:-int(i),input().split()))
heapq.heapify(A)
for i in range(m):
    e=heapq.heappop(A)
    e=(-e)//2
    heapq.heappush(A,-e)
print(-sum(A))



Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define pp pair<ll,ll>
#define mp make_pair
#define PI acos(-1.0)
#define all(v) v.begin(),v.end()
#define pb push_back
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FREV(i,a,b) for(i=a;i>=b;i--)
#define FORI(a) for(auto it=a.begin();it!=a.end();it++)
#define READ(a,i,n) FOR(i,0,n) { sll(a[i]);}
#define DEBUG(x) cerr<<"In file "<< __FILE__ <<" at line "<< __LINE__ <<" :: "<< #x <<" = "<<x<<endl
#define sll(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define INF 1e18
#define MOD 1000000007

using namespace std;
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    if(t==1)
    cout<<0<<"\n";
    else if(t==0) cout<<1<<"\n";
    //cout<<(t==1)?0:1<<"\n";
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

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

    ll c;
    cin >> c;
    string str;
    while (c > 0) {
        ll rem = c % 26;
        if (rem == 0) {
            str += 'z';
            c = (c / 26) - 1;
        } else {
            str += (char) ((rem - 1) + 'a');
            c = c / 26;
        }
    }
    reverse(str.begin(), str.end());
    cout << str;

    return 0;
}

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

const int d = 1000000007;
vector<int> memo(100001, -1);
int fact(int i) {
  if(i == 1) return 1;
  if(memo[i] != -1) return memo[i];
  int res = (ll(i) * ll(fact(i-1))) % d;
  memo[i] = res ;
  return res;
}

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

  int ans;
  if((n + m) % 2 == 1) {
    if(abs(n - m) != 1) {
      ans = 0;
    } else {
      ans = ll(fact(m)) * fact(n) % d;
    }
  } else {
    if(n != m) {
      ans = 0;
    } else {
      ans = ll(2) * fact(n) * fact(m) % d;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    ll c=a*b;
    cout<<c;
    return 0;
}



Measured memory_bytes: 3644
/**
  *  Worg
  */
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

//FILE *fin = freopen("main.in", "r", stdin); FILE *fout = freopen("main.out", "w", stdout);

using namespace std;

string s, t;

int main() {
    cin >> s;

    int ans = 0;
    int i = 0, j = (int)s.size() - 1, l = 0, r = 0;

    while(i < (int)s.size() && s[i] == 'x') {
        i ++; l++;
    }

    while(i < j && s[j] == 'x') {
        j --; r++;
    }

    for(int k = i; k <= j; k++) {
        t += s[k];
    }

    ans = s.size() - t.size();
    s = t;

    int add = 0;
    //cout << s;

    for(int i = 0, j = (int)s.size() - 1; i <= j; i++, j--) {
        if(s[i] != s[j]) {
            if(s[i] == 'x') {
                add ++; j ++;
            } else if(s[j] == 'x') {
                add ++; i --;
            } else {
                cout << "-1"; return 0;
            }
        }
    }

    if(ans == 0) {
        cout << add;
    } else {
        if(l != r && s.size() == 0) {
            cout << 0;
        } else {
            cout << add + max(l - r, r - l);
        }
    }
	return 0;
}


Measured memory_bytes: 512
n=int(input())
a,b=list(map(int,input().split()))
arr=list(map(int,input().split()))
ans1=[]
ans2=[]
ans3=[]
for num in arr:
    if num<=a:ans1+=[num]
    elif num>b:ans3+=[num]
    else:ans2+=[num]
print(min(len(ans1),len(ans2),len(ans3)))


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

int main() {
  string s;
  string p;
  getline(cin, s);
  getline(cin, p);
  string ss = s + s;

  if ((int)ss.find(p) == -1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 3220
#include<stdio.h>
#include<stdlib.h>
#define N 10000
#define NIL NULL
struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};
 
typedef struct node * Node;
Node root;
 
void insert(int k){
  Node x = root;
  Node y = NIL;
  Node z;

  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
   
  while(x != NIL){
    y = x;

    
    if(z->key < x->key)
      x = x->left;
    
    else{
      x = x->right;
    }
  }
  z->parent = y; 
    if(y==NIL){
      root=z;
    }
    else if(z->key < y -> key){
      y->left = z;
    }
    else{
      y->right =z;
    }
}
void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
  
}
void preorder(Node u){ 
    if (u != NIL) {
      printf(" ");
      printf("%d",u->key); 
      preorder(u->left);
      preorder(u->right);
     
    }
}
 
int main(){
  
  int n,m,i,j;
  char str[10];
  
  scanf("%d",&m);
  
  for(i=0;i<m;i++){
    scanf("%s",str);
    
    if(str[0]=='i'){  
      scanf("%d",&n);
      insert(n);}
    
    else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  
  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    int d,t,s;cin>>d>>t>>s;
    if(d<=t*s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y,a,b,c;cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
    for(int i=0;i<b;i++){
        cin >> q[i];
    }
    for(int i=0;i<c;i++){
        cin >> r[i];
    }
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    vector<ll> v;
    for(int i=0;i<x;i++){
        v.push_back(p[i]);
    }
    for(int i=0;i<y;i++){
        v.push_back(q[i]);
    }
    for(int i=0;i<c;i++){
        v.push_back(r[i]);
    }
    sort(v.begin(),v.end(),greater<ll>());
    ll ans=0;
    for(int i=0;i<x+y;i++){
        ans+=v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 8816
#include<stdio.h>
#include<string.h>
int main(void){
	int f = 0, i,o, j, l, z, q, k[6], s[100][6], n[6], n2[6];
	char c;
	scanf("%d",&q);
	for (z = 0; z < q; z++){
		for (i = 0; i < 6; i++){
			scanf("%d", &s[z][i]);
			n[i] = i;
		}
	}
	for (i = 0; i < q; i++){
		for (z = 0; z < q; z++){
			if (i != z){
				for (j = 0; j < 5000; j++){
					if (j % 6 < 3 && j % 5 == 4){
						n2[0] = n[1]; n2[1] = n[5]; n2[3] = n[3]; n2[4] = n[0]; n2[2] = n[2]; n2[5] = n[4];
					}
					else {
						n2[0] = n[3]; n2[1] = n[1]; n2[3] = n[5]; n2[4] = n[4]; n2[2] = n[0]; n2[5] = n[2];
					}
					for (o = 0; o < 6; o++){
						n[o] = n2[o];
					}
					for (l = 0; l < 6; l++){
						if (s[i][l] != s[z][n[l]])break;

					}
					if (l == 6){ f = 1; break; }

				}
			}
			if (f == 1)break;
		}
		if (f == 1)break;
	}
		if (f == 1)printf("No\n");
		else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 584
if __name__ == '__main__':
    N, M, X, Y = map(int, input().split())
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))

    x_max = max(x_list)
    y_min = min(y_list)

    if x_max + 1 <= y_min and X <= x_max and y_min <= Y:
        print("No War")
    else:
        print("War")

Measured memory_bytes: 3064
# フェルマーの小定理
def main():
    from builtins import pow

    K = int(input())
    S = input()

    m = 1000000007

    result = 0
    t = pow(26, K, m)
    u = pow(26, -1, m) * 25 % m
    l = len(S)
    for i in range(K + 1):
        # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m)
        result = (result + t) % m
        t = (t * u) % m * (l + i) * pow(i + 1, -1, m) % m
    print(result)


main()


Measured memory_bytes: 10980
#include <bits/stdc++.h>
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct SegmentTree{
private:
    int n;
    vector<ll> node;
public:
    SegmentTree(vector<ll> v){
        int sz=v.size();
        n=1;
        while(n<sz)n*=2;
        node.resize(2*n-1,LINF);
        for(int i=0;i<sz;i++){
            node[i+n-1]=v[i];
        }
        for(int i=n-2;i>=0;i--){
            node[i]=min(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int x,ll val){
        x+=(n-1);
        node[x]=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=min(node[2*x+1],node[2*x+2]);
        }
    }
    ll getmin(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return LINF;
        if(a<=l&&r<=b) return node[k];
        ll vl=getmin(a,b,2*k+1,l,(l+r)/2);
        ll vr=getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

int main() {
    int n,m;
    cin>>n>>m;
    vector<pair<pair<int,int>,ll>> vec(m);
    rep(i,m) {
        int l,r;
        ll c;
        cin>>l>>r>>c;
        l--;r--;
        vec[i]={{r,l},c};
    }
    sort(all(vec));
    
    vector<ll> v(n,LINF);
    SegmentTree st(v);
    st.update(0,0);
    rep(i,m) {
        int l=vec[i].first.second;
        int r=vec[i].first.first;
        ll c=vec[i].second;
        st.update(r,min(st.getmin(l,r)+c,st.getmin(r,r+1)));
    }
    cout<<(st.getmin(n-1,n)==LINF ? -1 : st.getmin(n-1,n))<<endl;
}



Measured memory_bytes: 5376