akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n;

int rec(ll x, bool f7, bool f5, bool f3) {
  if (x > n) return 0;

  int res = 0;
  res += rec(10 * x + 7, true, f5, f3);
  res += rec(10 * x + 5, f7, true, f3);
  res += rec(10 * x + 3, f7, f5, true);
  res += (f7 && f5 && f3);
  return res;
}

int main() {
  cin >> n;
  cout << rec(0, false, false, false) << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  VI X,Y;
  rep(i,31) rep(j,31){
    if(A*100*i+B*100*j>F) continue;
    X.pb(A*100*i+B*100*j);
  }
  rep(i,3001) rep(j,3001){
    if(C*i+D*j>3000) continue;
    Y.pb(C*i+D*j);
  }
  ll ans1=0;
  ll ans2=1;
  int W=0,S=0;
  rep(i,X.size()) rep(j,Y.size()){
    if(X[i]/100*E<Y[j] or X[i]+Y[j]>F) continue;
    ll tmp1=X[i]+Y[j];
    ll tmp2=Y[j]*100;
    if(ans1*tmp1<ans2*tmp2){
      ans1=tmp2;
      ans2=tmp1;
      W=X[i]+Y[j];
      S=Y[j];
    }
  }
  if(S) cout<<W<<" "<<S<<endl;
  else cout<<A*100<<" "<<0<<endl;
}

Measured memory_bytes: 16872
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 100010
#define ll long long
using namespace std;
inline ll read() 
{ 
    ll x=0,f=1;char ch=getchar(); 
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 
    return x*f; 
}
ll k;
ll h[51];
int main()
{
	k=read();
	ll tmp=k/50;
	ll tmp2=k%50;
	for(int i=1;i<=50;i++)
	h[i]=50+tmp-1;
	for(int i=1;i<=tmp2;i++)
	{
		h[i]+=50;
		for(int j=1;j<=50;j++)
		{
			if(j!=i)h[j]--;
		}
	}
	puts("50");
	for(int i=1;i<=50;i++)
	printf("%lld ",h[i]);
}
/*
500000000000000000
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> l(q), r(q);
  vector<int> sum(n+1);
  rep(i,q) cin >> l.at(i) >> r.at(i);
  for(int i=1;i<n;i++) {
    sum.at(i+1) = sum.at(i);
    if(s.at(i-1) == 'A' && s.at(i) == 'C') 
      sum.at(i+1) = sum.at(i) +1;
  }
  rep(i,q) {
    int ans = sum.at(r.at(i)) - sum.at(l.at(i));
    cout << ans << endl;
  }
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << endl;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int a[n]; REP(i,n) cin >> a[i];
    int p[70]; p[0]=1; FOR(i,1,70)p[i]=p[i-1]*2%MOD;
    int ans = 0;
    REP(k,60){
        int x0 = 0 , x1 = 0;
        REP(i,n){
            int x = (a[i]>>k)&1;
            if(x==0) x0 += 1;
            else x1 += 1;
        }
        int count = (x0*x1)%MOD;
        ans += count * p[k];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

main()
{
	int n;
	scanf("%d",&n);
	
	if(n>=0&&n<=9)
	{
		if(n==3)
		{
			printf("bon");
		}
		else if(n==0||n==1||n==6||n==8)
		{
			printf("pon");
		}
		else if(n==2||n==4||n==5||n==7||n==9)
		{
			printf("hon");
		}
	}
	else if(n>=10&&n<=99)
	{
		if(n%10==3)
		{
			printf("bon");
		}
		else if(n%10==0||n%10==1||n%10==6||n%10==8)
		{
			printf("pon");
		}
		else if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
		{
			printf("hon");
		}
	}
	else if(n>=100&&n<=999)
	{
		if(n%10==3)
		{
			printf("bon");
		}
		else if(n%10==0||n%10==1||n%10==6||n%10==8)
		{
			printf("pon");
		}
		else if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
		{
			printf("hon");
		}
	}		
}


Measured memory_bytes: 1732
N,A,B=input().split()
n=int(N)
a=int(A)
b=int(B)
m=int(n%(a+b))
l=int((n-m)/(a+b))
if m>a:
  y=a
else:
  y=m
x=a*l+y
x=int(x)
print(x)

Measured memory_bytes: 3060
/*
	
	@Raghul
*/
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
ll ans[100005];
ll fastpow(ll a,ll b){
	if(b==0)
		return 1LL;
	ll temp=fastpow(a,b/2);
	temp=temp*temp;
	if(b%2==1)
		temp=temp*a;
	return temp;
}	
void solve(){
	int d;
	cin>>d;
	if(d==25)	cout<<"Christmas";
	if(d==24)	cout<<"Christmas Eve";
	if(d==23)	cout<<"Christmas Eve Eve";
	if(d==22)	cout<<"Christmas Eve Eve Eve";
	return;
}
int main(){ 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll T;
    T = 1;
    while(T--){
    	solve();
    }
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

struct UnionFind
{
    vector<int> par, rank, sz;
    UnionFind(int N) : par(N), rank(N), sz(N)
    {
        REP(i, N)
        {
            par[i] = i;  //the parent of the node
            rank[i] = 0; //the rank of the tree
            sz[i] = 1;
        }
    }
    int find(int x)
    { //Find the root of x
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = find(par[x]);
        }
    }
    int size(int x)
    {
        return sz[find(x)];
    }
    void unite(int x, int y)
    { //Unite (the set of x) and (the set of y)
        x = find(x), y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y])
        { //larger rank is above
            sz[y] += sz[x];
            par[x] = y;
        }
        else
        {
            sz[x] += sz[y];
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    ciosup;
    ll n, m;
    cin >> n >> m;
    int A[m], B[m];
    REP(i, m)
    {
        int a,b;
        cin >> a >> b;
        A[i] = a - 1;
        B[i] = b - 1;
    }
    ll par[n];
    REP(i,n)par[i]=1;

    ll huar[m], hu = n * (n - 1) / 2;
    huar[m - 1] = hu;
    UnionFind s(n);
    IFOR(i, 1, m)
    {
        if (!s.same(A[i],B[i]))
        {
            hu -= s.size(A[i])*s.size(B[i]);
            s.unite(A[i], B[i]);
        }
        huar[i - 1] = hu;
    }
    REP(i,m)cout << huar[i] << endl;
}

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

int main() {
    ll N;
    cin>>N;
    ll len=1;
    ll pow26=26;
    while(1){
        if(N-pow26>0){
            N-=pow26;
            len++;
            pow26*=26;
        }else{
            break;
        }
    }
    N--;
    string name;
    pow26=1;
    for (int i = 0; i < len-1; i++){
        pow26*=26;
    }
    for (ll i = len; i > 0; i--){
        ll tmp=N/pow26;
        name.push_back((char)((int)'a'+tmp));
        N%=pow26;
        pow26/=26;
    }
    cout<<name<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9+7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

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

  vector<ll> dp(s+1,0);
  dp[0] = 1;
  for(int i = 1; i < s+1; i++){
    for(int j = 0; j <= i - 3; j++){
      dp[i] += dp[j];
      dp[i] %= M;
    }
  }
  cout << dp[s] << endl;

  return 0;
}


Measured memory_bytes: 3624
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
s = a[0]
ans = 0
for i in range(1, n):
    s += a[i]
    if s > x:
        ans += s - x
        s = max(a[i] - (s - x), 0)
    else:
        s = a[i]
print(ans)

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

struct node{
	int x,y;
}st,ed;


int n,m,dis[N][N];
int dx[5]={-1,0,1,0},dy[5]={0,1,0,-1};
char mp[N][N];


bool bfs() {
	memset(dis,0x3f,sizeof(dis));
	dis[st.x][st.y]=0;
	deque<node> q;
	q.push_back(st);
	while(q.size()) {
		node now=q.front();q.pop_front();
		int x=now.x,y=now.y;
		//printf("%d %d\n",x,y);
		if(x==ed.x&&y==ed.y) return 1;
		for(int i=0;i<4;i++) {
			int tx=x+dx[i],ty=y+dy[i];
			if(tx<=0||tx>n||ty<=0||ty>m) continue;
			if(dis[x][y]<dis[tx][ty]&&mp[tx][ty]=='.') {
				q.push_front((node){tx,ty});
				dis[tx][ty]=dis[x][y];
			}
		}
		for(int i=x-2;i<=x+2;i++) {
			for(int j=y-2;j<=y+2;j++) {
				if(i<=0||i>n||j<=0||j>m) continue;
				if(dis[x][y]+1<dis[i][j]&&mp[i][j]=='.') {
				    q.push_back((node){i,j});
				    dis[i][j]=dis[x][y]+1;
			    }
			}
		}
	}
	return 0;
}

int main() {
	scanf("%d%d",&n,&m);
	scanf("%d%d%d%d",&st.x,&st.y,&ed.x,&ed.y);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			cin>>mp[i][j];
		}
	}
	if(bfs()) printf("%d",dis[ed.x][ed.y]);
	else printf("-1");
}

Measured memory_bytes: 8700
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int a, b;
int main() {
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	
	return 0;
}

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

string get(const string& S) {
	const int n = S.size();
	for (int i = 1; i < n; i++) if (n % i == 0) {
		bool ng = false;
		for (int j = 0; j < n; j++) if (S[j % i] != S[j]) {
			ng = true;
			break;
		}
		if (!ng) return S.substr(0, i);
	}
	return S;
}

vector<int> knuth_morris_pratt(const string& S) {
	int N = S.size();
	vector<int> A(N + 1);
	A[0] = -1;
	for (int i = 0, j = -1; i < N; i++) {
		while (j >= 0 && S[i] != S[j]) {
			j = A[j];
		}
		j++;
		A[i + 1] = (i + 1 == N ? '*' : S[i + 1]) == (j == N ? '*' : S[j]) ? A[j] : j;
	}
	return A;
}

vector<int> string_search(const string& S, const string& T) {
	auto A = knuth_morris_pratt(T);
	int N = T.size();
	vector<int> res;
	for (int i = 0, j = 0; i < (int)S.size(); i++) {
		while (j >= 0 && S[i] != T[j]) {
			j = A[j];
		}
		j++;
		if (j == N) {
			res.push_back(i + 1);
			j = A[j];
		}
	}
	return res;
}

bool comp(string s, string t) {
	if (s.size() != t.size()) return false;
	s += s;
	return !string_search(s, t).empty();
}

int calc(const string& s, const string& t) {
	auto ids = string_search(s, t);
	vector<int> dp(s.size() + 1);
	for (auto id : ids) {
		dp[id] = dp[id - t.size()] + 1;
	}
	return *max_element(dp.begin(), dp.end());
}

int main()
{
	string s, t;
	cin >> s >> t;
	auto ss = get(s);
	auto tt = get(t);
	if (comp(ss, tt)) {
		cout << -1 << endl;
		return 0;
	}
	string x = s;
	while (x.size() < tt.size()) {
		x += s;
	}
	x += s;
	x += x;
	int c = t.size() / tt.size();
	cout << (calc(x, tt) / c) << endl;
	return 0;
}


Measured memory_bytes: 19880
#include<bits/stdc++.h>
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl;
using namespace std;

int main(){
    int x, y;
    int ans[6005];

    int cnt=1;
    while(true){
        cin>>x>>y;
        if(x==0 && y==0) break;
        if(x>y) swap(x, y);
        ans[cnt-1]=x;
        ans[cnt]=y;
        cout<<ans[cnt-1]<<" "<<ans[cnt]<<endl;

    }

    for(int i=1; i<cnt; i+=2){
        cout<<ans[i-1]<<" "<<ans[i]<<endl;
    }
}



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

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

	int32_t A, B, C, five, seven;

	cin >> A >> B >> C;

	vector<int32_t> v;

	v.push_back(A);
	v.push_back(B);
	v.push_back(C);

	for (size_t i=0; i<v.size(); ++i)
    {
		 if (v[i]==5)
		 {
			 ++five;
		 } else if (v[i]==7)
		 {
			 ++seven;
		 }
	}
  
  	 if (five == 2 and seven==1)
     {
       cout << "YES" << "\n";
       } else {
         cout << "NO" << "\n";
     }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define FI first
#define SC second
using namespace std;

typedef pair<LL,LL> ii;

LL n,x,y,ans=1e9;

LL count(LL x){
	LL ret = 0;
	while(x!=0){
		x/=10;
		ret++;
	}
	return ret;
}

int main() {
	cin>>n;
	for(LL i=1;i*i<=n;i++){
		if(n%i==0){
			x = i, y = n/i;
			ans = min(ans, max(count(x), count(y)));
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[111];
int K;

LL dpE[111][5], dpL[111][5];

void MAIN() {
    scanf("%s%d", S, &K);
    N = strlen(S);

    REP (i, N) {
	int C = S[i] - '0';
	if (i == 0) {
	    for (int d=1; d<C; d++) dpL[1][1] += 1;
	    dpE[1][1] += 1;
	} else {
	    for (int d=1; d<10; d++) dpL[i+1][1] += 1;

	    REP (k, K+1) {
		dpE[i+1][k + (C==0?0:1)] += dpE[i][k];

		REP (d, C) dpL[i+1][k + (d==0?0:1)] += dpE[i][k];
		REP (d, 10) dpL[i+1][k + (d==0?0:1)] += dpL[i][k];
	    }
	}
    }

    LL ans = 0;
    ans += dpE[N][K];
    ans += dpL[N][K];
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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


void Egriiiiiiiii()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}



int main()
{
     Egriiiiiiiii() ;

     /*
    int n,m ;
    cin>>n>>m;
for(int i=0 ;i<m ;i++){
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y) ;
}
for(int i=1;i<=n;i++){
    dfs(i) ;
}
for(int i=0 ;i<v.size() ;i++)
    cout<<v[i]<<" ";

*/

int n,m ;
cin>>n>>m ;
priority_queue<int>pq;
int a ;
for(int i=0 ;i<n ;i++)
     cin>>a, pq.push(a) ;
for(int i=0 ;i<m ;i++){
     int y=pq.top() ;
     pq.pop() ;
     pq.push(y/2) ;
}
ll ans=0 ;
while(!pq.empty()){
    ans+=pq.top() ;
    pq.pop()  ;
}
cout<<ans ;

     return 0;
}


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

int main(void){
    
    int A, B;
    int count = 0;
    cin >> A >>B;
    
    for(int i = A; i <= B; i++){
        if(i / 10000 == (i % 10) && (i / 1000) % 10 == (i / 10 ) % 10)
            count++;
    }
    cout << count << endl;
}



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

int main() {
	string S;
	cin >> S;
	string s[] = {
		"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
	};
	for (int i = 0; i < 7; i++) {
		if (S == s[i]) {
			cout << (7 - i) << endl;
			return 0;
		}
	}
	return 0;
}


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

#define DIV 1000000007
using namespace std;

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

    vector<long long> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
        cin >> B[i];
    for (int i = 0; i < N; i++)
        cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int left = 0;
    vector<long long> BtoA(N);
    for (int i = 0; i < N; i++) {
        if (i != 0)BtoA[i] = BtoA[i - 1];
        for (int j = left; j < N; j++) {
            //cout << "left=" << left << endl;
            if (B[i] > A[j]) {
                BtoA[i]++;
            }
            else {
                left = j ;
                break;
            }
            if (j == N - 1)left = N ;
        }
    }
    left = 0;
    vector<long long> CtoB(N);
    for (int i = 0; i < N; i++) {
        if (i != 0)CtoB[i] = CtoB[i - 1];
        for (int j = left; j < N; j++) {
            if (C[i] > B[j]) {
                CtoB[i] += BtoA[j];
            }
            else {
                left = j;
                break;
            }
            if (j == N - 1)left = N;
        }
    }
    /*
    for (int i = 0; i < N; i++) {
        cout << "i:cnt=" << BtoA[i] << "  ";
    }
    cout << endl;
    */
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        //cout << "i:cnt=" << CtoB[i] <<"  ";
        ans += CtoB[i];
    }

    cout << ans << endl;
     
}


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

int main() {
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(M)]
i = 0

while len(str(i))<=N:
  k = 0
  if len(str(i))!=N:
    i += 1
    continue
  for el in sc:
    if str(i)[el[0]-1] == str(el[1]):
      k += 1
  if k == M:
    print(i)
    exit()
  i += 1
  
print(-1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a1 = scan.nextInt();
        int a2 = scan.nextInt();
        int a3 = scan.nextInt();

        if (a1 + a2 + a3 >= 22) {
            System.out.println("bust");
            return;
        }
        System.out.println("win");
    }
}


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

class Cards {
public:
  char m;
  int n;
};

int main(void) {
  int n, min;
  bool f = false;
  Cards b[36], s[36];
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> b[i].m >> b[i].n;
    s[i] = b[i];
  }
  for (int i=0; i<n-1; i++) {
    for (int j=n-1; j>i; j--) {
      if (b[j-1].n > b[j].n) {
        swap(b[j-1],b[j]);
      }
    }
  }
  for (int i=0; i<n; i++) {
    min = i;
    for (int j=i; j<n; j++) {
      if (s[j].n < s[min].n) {
        min = j;
      }
    }
    swap(s[i],s[min]);
  }
  for (int i=0; i<n; i++) {
    cout << (i==0?"":" ") << b[i].m << b[i].n << flush;
  }
  cout << endl;
  cout << "Stable" << endl;
  for (int i=0; i<n; i++) {
    if (b[i].m != s[i].m) {
      f = true;
    }
    cout << (i==0?"":" ") << s[i].m << s[i].n << flush;
  }
  cout << endl;
  if (f) {
    cout << "Not stable" << endl;
  } else {
    cout << "Stable" << endl;
  }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    sort(ALL(S));
    UNIQUE(S);
    if (S.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		String b  = sc.next();
		b = b.replace(".","");
		int bb = Integer.parseInt(b);
		System.out.println(a*bb/100);
	}
}

Measured memory_bytes: 35780
class binarytree:
    def __init__(self, num_parts, parts):
        self.num_parts = num_parts
        self.nodes = [None]*self.num_parts
        self.root = 0
        for i in range(self.num_parts):
            self.nodes[parts[i][0]] = binarynode(parts[i][0],parts[i][1],parts[i][2])

    def set_families(self):
        for i in range(self.num_parts):
            if self.nodes[i].left != -1:
                self.nodes[self.nodes[i].left].set_parent(i)
                self.nodes[self.nodes[i].left].set_sibling(self.nodes[i].right)
            if self.nodes[i].right != -1:
                self.nodes[self.nodes[i].right].set_parent(i)
                self.nodes[self.nodes[i].right].set_sibling(self.nodes[i].left)
        for i in range(self.num_parts):
            if self.nodes[i].parent == -1:
                self.root = i
            
    def set_type(self):
        for i in range(self.num_parts):
            self.nodes[i].check_type()

    def set_depth(self, pos, depth):
        self.nodes[pos].set_depth(depth)
        if self.nodes[pos].left != -1:
            self.set_depth(self.nodes[pos].left, depth+1)
        if self.nodes[pos].right != -1:
            self.set_depth(self.nodes[pos].right, depth+1)

    def set_height(self, pos, height):
        self.nodes[pos].set_height(height)
        if self.nodes[pos].parent != -1:
            self.set_height(self.nodes[pos].parent, height+1)
        return
            
class binarynode:
    def __init__(self, id, left, right):
        self.id = id
        self.parent = -1
        self.left = left
        self.right = right
        self.sibling = -1
        self.degree = 2
        self.depth = 0
        self.height = 0
        self.type = "internal node"

        if self.left == -1:
            self.degree -= 1
        if self.right == -1:
            self.degree -= 1
        
    def set_parent(self,parent):
        self.parent = parent
        return
    def set_sibling(self,sibling):
        self.sibling = sibling
        return
        
    def check_type(self):
        if self.parent == -1:
            self.type = "root"
        elif self.left == -1 and self.right == -1:
            self.type = "leaf"
        else:
            self.type = "internal node"
        return
            
    def set_depth(self,depth):
        self.depth = depth
        return
    def set_height(self,height):
        self.height = max(self.height, height)
        return
        
n = int(input())
obj = []
for i in range(n):
    obj.append(list(map(int, input().split())))

new_tree = binarytree(n, obj)
new_tree.set_families()
new_tree.set_type()
new_tree.set_depth(new_tree.root, 0)
for i in range(n):
    if new_tree.nodes[i].type == "leaf":
        new_tree.set_height(i, 0)

for i in range(n):
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(i, new_tree.nodes[i].parent, new_tree.nodes[i].sibling, new_tree.nodes[i].degree, new_tree.nodes[i].depth, new_tree.nodes[i].height, new_tree.nodes[i].type))


Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll n,m; cin>>n>>m;
    map<pair<ll,ll>,ll >mp;
    vector<ll>v;
    for(ll i=2;i<n;i++)
    {
        mp.insert({{1,i},1});
        mp.insert({{i,n},1});
    }
    while(m--)
    {
        ll a,b; cin>>a>>b; if(a>b) swap(a,b);
        if(mp[{a,b}]==1) mp[{a,b}]=2;
    }
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(it->second) v.pb(it->second);
    }
    for(ll i=0;i<v.size()/2;i++)
    {
        if(v[i]==2 && v[i+v.size()/2]==2)
        {
            cout<<"POSSIBLE"; return 0;
        }
    }
    cout<<"IMPOSSIBLE";
}




Measured memory_bytes: 44908
#include <cstdio>
const int mod = 1000000007;
char a[3010];
long long dp[3010][3010];
int main() {
	int n;
	scanf("%d%s", &n, a);
	dp[0][1] = 1;
	for (int i = 1; i < n; i++) {
		if (a[i-1] == '<') {
			long long s = 0;
			for (int j = 1; j <= i + 1; j++) {
				dp[i][j] = s;
				s = (s + dp[i-1][j]) % mod;
			}
		} else {
			long long s = 0;
			for (int j = i; j >= 1; j--) {
				s = (s + dp[i-1][j]) % mod;
				dp[i][j] = s;
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[n-1][i];
	}
	printf("%lld\n", ans % mod);
	return 0;
}


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

using namespace std;

const int N = 50 + 2;
const int INF = 1e9;

int w, d, low[N][N];
int n;
int ax[N], ay[N], az[N];

int main()
{
    cin >> w >> d >> n;
    for (int i = 1; i <= w; ++i)
        fill(low[i] + 1, low[i] + 1 + d, -INF);
    for (int i = 0; i < n; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        ax[i] = x, ay[i] = y, az[i] = z;

        for (int j = 1; j <= w; ++j)
            for (int k = 1; k <= d; ++k) {
                int d = abs(x - j) + abs(y - k);
                low[j][k] = max(low[j][k], z - d);
            }
    }

    for (int i = 0; i < n; ++i) 
        if (az[i] < low[ax[i]][ay[i]]) {
            cout << "No\n";
            return 0;
        }
    
    long long sum = 0;
    for (int i = 1; i <= w; ++i)
        for (int j = 1; j <= d; ++j)
            sum += low[i][j];
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
    int d; cin >> d;
    if (d==25) cout << "Christmas" << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=1e5+5;

int main(){
	//ios_base::sync_with_stdio(false);cin.tie(NULL);
	double n;cin >> n;
	if(((int)n)%2==0){
		printf("%.15f",(n/2)/n);
	}
	else{
		printf("%.15f",((int(n/2))+1)/n);
	}


}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	l := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n-1; i++ {
		if aa[i] >= l-aa[i+1] {
			fmt.Fprintln(writer, "Possible")
			for j := 0; j < i; j++ {
				fmt.Fprintln(writer, j+1)
			}
			for j := n - 2; j > i; j-- {
				fmt.Fprintln(writer, j+1)
			}
			fmt.Fprintln(writer, i+1)
			return
		}
	}
	fmt.Fprintln(writer, "Impossible")
}


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

using ll = long long;
using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

string A, B;

vector<vector<int>> dp(1010, vector<int>(1010, 10000));

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

    cin >> A >> B;


    for (int i = 0; i < A.size(); i++) {
        dp[i][0] = i;
    }


    for (int i = 0; i < B.size(); i++) {
        dp[0][i] = i;
    }

    for (int i = 0; i < A.size(); i++) {
        for (int j = 0; j < B.size(); j++) {
            if (A[i] == B[j]) {
                dp[i + 1][j + 1] = dp[i][j];
            }
            chmin(dp[i + 1][j + 1],dp[i][j + 1] + 1);
            chmin(dp[i + 1][j + 1], dp[i + 1][j] + 1);
            chmin(dp[i + 1][j + 1], dp[i][j] + 1);
        }
    }

    cout << dp[A.size()][B.size()] << endl;





    return 0;
}


Measured memory_bytes: 7244
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	string s[1024];
	while(1){
		cin>>n;
		if(n==0)break;
		REP(i,n)cin>>s[i];
		REP(i,n){
			int c=0;
			while(s[i][c]=='.'){
				s[i][c]=' ';
				c++;
			}
			if(c==0)continue;
			s[i][--c]='+';
			for(int j=i-1;j>=0&&s[j][c]==' ';j--){
				s[j][c]='|';
			}
		}
		REP(i,n)cout<<s[i]<<endl;
	}
}


Measured memory_bytes: 3860
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    string S;
    cin >> S;
    loop(i, 8) S.pop_back();
    cout << S << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	string s;

	cin >> s;

	s.replace(5, 1, " ");
	s.replace(13, 1, " ");

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
        c[i] = a[i] + b[i];
    }
    sort(c.rbegin(), c.rend());
    ll ans = 0;
    rep(i, n) if (~i&1) ans += c[i];
    rep(i, n) ans -= b[i];
    cout << ans << endl;
}

Measured memory_bytes: 2560
a, v = gets.split.map(&:to_i)
b, w = gets.split.map(&:to_i)
t = gets.to_i
if (a < b)
  aa = a + v * t
  bb = b + w * t
  if aa >= bb
    puts 'YES'
  else
    puts 'NO'
  end
else
  aa = a - v * t
  bb = b - w * t
  if aa <= bb
    puts 'YES'
  else
    puts 'NO'
  end
end


Measured memory_bytes: 14372
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n := scanInt(stdin)
	stdin.Scan()
	minv := scanInt(stdin)
	gap := -2000000000

	for stdin.Scan() {
		r := scanInt(stdin)
		gap = max(gap, r-minv)
		minv = min(minv, r)
		n = n - 1
		if n == 0 {
			break
		}
	}
	fmt.Println(gap)
}

func scanInt(sc *bufio.Scanner) int {
	t := sc.Text()
	i, err := strconv.Atoi(t)
	if err != nil {
		panic(err)
	}
	return i
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}



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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N, M, K;
    cin >> N >> M >> K;
    vll A(N + 1, 0);
    vll B(M + 1, 0);
    ll asum = 0;
    for(i = 0; i < N; i++) {
        ll a;
        cin >> a;
        asum += a;
        A[i + 1] = asum;
    }
    ll bsum = 0;
    for(i = 0; i < M; i++) {
        ll b;
        cin >> b;
        bsum += b;
        B[i + 1] = bsum;
    }
    ll ans = 0;
    for(i = 0; i < N + 1; i++) {
        ll r = K - A[i];
        if(r < 0) {
            break;
        }
        auto p = upper_bound(B.begin(), B.end(), r);
        ll subans = i + (p - B.begin() - 1);
        ans = max(ans, subans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    int A, B;
    cin >> A >>B;

    cout << max(max(A+B,A-B),A*B) << endl;
}

Measured memory_bytes: 3612
#include<cstdio>

const int MOD = 998244353;
int n, s, a[3000];
int dp[3001];

int po(int x, int y) {
    int ans = 1;
    while (y > 0) {
        if (y & 1) ans = static_cast<long>(ans) * x % MOD;
        x = static_cast<long>(x) * x % MOD;
        y >>= 1;
    }
    return ans;
}

int main() {
    scanf("%d %d", &n, &s);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    int inv2 = po(2, MOD - 2);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = s; j >= a[i]; j--) {
            dp[j] = (dp[j] + static_cast<long>(dp[j - a[i]]) * inv2 % MOD) % MOD;
        }
    }

    printf("%ld\n", static_cast<long>(dp[s]) * po(2, n) % MOD);
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000003ull
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)

template <typename T>
void calcFactional_mod( size_t size, 
	vector<T>& fac, vector<T>& inv, vector<T>& facInv, T mod )
{
	for( T i = 2; i < size; ++i )
	{
		fac[i] = fac[i - 1] * i % mod; // n! % mod
		inv[i] = mod - inv[mod % i] * ( mod / i ) % mod; // 逆元計算 (n)^-1 % mod
		facInv[i] = facInv[i - 1] * inv[i] % mod; // (n!)^-1 % mod
 	}
}
template <typename T>
T pow_mod(T x, T n, T mod)
{
	T res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

int main()
{
	ull q; cin>>q;

	const ll maxN = 1000010;
	vector<ll> fac( maxN, 1 ), inv( maxN, 1 ), facInv( maxN, 1 );
	calcFactional_mod<ll>( maxN, fac, inv, facInv, cMOD);
	auto add = []( ll a, ll b) { return ( a + b ) % cMOD; };
	auto sub = []( ll a, ll b) { return ( a + cMOD -b ) % cMOD; };
	auto mul = []( ll a, ll b) { return a * b % cMOD; };
	auto div = [&inv]( ll a, ll b) { return a * inv[b] % cMOD; };
	auto pow = []( ll a, ll b ) { return pow_mod<ll>( a, b, cMOD ); };
	
	REP(i,q)
	{
		ll x,d,n;cin>>x>>d>>n;
		if(d==0) cout << pow(x,n) << endl;
		else
		{
			auto xx = div(x,d);
			if(xx==0 || xx+n-1 >= cMOD) cout << 0 << endl;
			else
			{
				auto ans = mul(fac[xx+n-1],facInv[xx-1]);
				ans = mul(ans,pow(d,n));
				cout << ans << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 24320
import sys

def f(g, d, P, C):
  if d <= 0:
    return float('inf')
  
  n = min(g//(100*d), P[d-1])
  s = 100*d*n

  if n == P[d-1]:
    s += C[d-1]
  
  if g > s:
    n += f(g-s, d-1, P, C)
  
  return min(n, f(g, d-1, P, C))
  

def main():
  input = sys.stdin.readline
  D, G = map(int, input().split())
  P = []
  C = []
  for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

  ans = f(G, D, P, C)
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
N, x = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0
for i in range(len(a[:-1])):
    sumv = a[i] + a[i+1]
    if x < sumv:
        delta = sumv - x
        if a[i+1] > delta:
            a[i+1] -= (sumv - x)
            cnt += (sumv - x)
        else:
            ddelta = delta - a[i+1]
            a[i+1] = 0
            cnt += delta
print(cnt)


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

int main() {
    string s;
    cin >> s;
    int ans = 1000000000;
    for(int i = 0; i < s.length() - 2; i++){
        ans = min(abs(stoi(s.substr(i, 3)) - 753), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#157 b
a=[]
call_num=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
n=int(input())
for i in range(n):
    x=int(input())
    if x in a:
        call_num.append(a.index(x))
bingo=False
ans=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for x in ans:
    flag=True
    for y in x:
        if y not in call_num:
            flag=False
    if flag:
        print("Yes")
        bingo=True
        break
if bingo!=True:
    print("No")

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

int main() {
  string n;
  cin >> n;
  int sum = 0;
  
  for (int i = 0; i < n.length(); i++){
    int a;
    a = n[i] - '0';
    sum += a;
  }
  
  if (sum % 9 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int d,ans[365],c[26],s[365][26],last[26],tlast[26],S[365][26];
const int INF=1e9;

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

void FIN(int a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]<<"\n";
    fout.close();
    return;
  }
  REP(i,d)cout<<ans[i]<<"\n";
  return;
}

int score(){
  int res=0;
  memset(tlast,-1,sizeof(tlast));
  REP(day,d){
    res+=S[day][ans[day]-1];
    tlast[ans[day]-1]=day;
    REP(i,26)res-=c[i]*(day-tlast[i]);
  }
  return res;
}

signed main(){
  memset(last,-1,sizeof(last));
  cin>>d;
  REP(i,26)cin>>c[i];
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(i,d)REP(j,26)S[i][j]=s[i][j];
  REP(j,26){
    int now=-INF;
    for(int i=364;i>=0;i--){
      if(now>15000)s[i][j]-=(now-15000);
      if(now<s[i][j])now=s[i][j];
      now-=c[j];
    }
  }
  REP(day,d){
    int Sc=-INF,now;
    if(day<d-1){
      REP(i,26){
        REP(j,26){
          if(i==j)continue;
          int tmp=s[day][i]+s[day+1][j];
          REP(k,26){
            if(i!=k&&j!=k)tmp-=c[k]*(day-last[k]+day+1-last[k]);
            if(i==k)tmp-=c[k];
            if(j==k)tmp-=c[k]*(day-last[k]);
          }
          if(Sc<tmp)Sc=tmp,now=i;
        }
      }
      ans[day]=now+1;
      last[now]=day;
    }
    else{
      REP(i,26){
        ans[day]=i+1;
        int R=score();
        if(Sc<R)Sc=R,now=i+1;
        else ans[day]=now;
      }
    }
  }/*
  REP(day,d){
    vector<int> minus(26);
    REP(j,26)minus[j]=c[j]*(day-last[j]);
    int A=-INF,idx=0;
    REP(j,26){
      int tmp=s[day][j]+minus[j];
      if(A<tmp)A=tmp,idx=j;
    }
    ans[day]=idx+1;
    last[idx]=day;
  }
  */
  /*
  REP(_,480){
    int day1=rand()%365,day2=rand()%365;
    if(day1==day2)day2++;if(day2==365)day2=0;
    int Sc=-INF,now1=ans[day1],now2=ans[day2];
    REP(i,26){
      REP(j,26){
        ans[day1]=i+1;
        ans[day2]=j+1;
        int R=score();
        if(Sc<R)Sc=R,now1=i+1,now2=j+1;
        else ans[day1]=now1,ans[day2]=now2;
      }
    }
  }
  */
  /*
  REP(_,1000){
    int day1=_%360;
    int now[5],Sc=-INF;
    vector<int> v(5);
    REP(i,5)v[i]=ans[day1+i];
    sort(v.begin(),v.end());
    do{
      REP(i,5)ans[day1+i]=v[i];
      int R=score();
      if(Sc<R){
        REP(i,5)now[i]=v[i];
        Sc=R;
      }
      else REP(i,5)ans[day1+i]=now[i];
    }while(next_permutation(v.begin(),v.end()));
  }
  */
  REP(__,5){
    REP(_,1000){
      int day=rand()%365,Sc=-INF,now=ans[day];
      REP(i,26){
        ans[day]=i+1;
        int R=score();
        if(Sc<R)now=i+1,Sc=R;
        else ans[day]=now;
      }
    }
    REP(_,1000){
      int day1=rand()%360;
      int day2=day1+rand()%4+1;
      int R=score();
      swap(ans[day1],ans[day2]);
      if(R>score())swap(ans[day1],ans[day2]);
    }
  }

  FIN(0);
}


Measured memory_bytes: 3692
import heapq
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
f = list(map(int, input().split()))
f.sort(reverse=True)

asum = sum(a)

def test(x):
    t = [min(a[i], x//f[i]) for i in range(n)]
    return asum - sum(t)


ng = -1
ok = 10**13
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if test(mid) <= k:
        ok = mid
    else:
        ng = mid

print(ok)


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

int main() {
  /* code */
  int a,b,c;
  int key;

  cin >> a >> b >> c;
  if (a > b) {
    /* code */
    key = a;
    a = b;
    b = key;
  }
  if (b > c) {
    /* code */
    key = b;
    b = c;
    c = key;
  }
  if (a > b) {
    /* code */
    key = a;
    a = b;
    b = key;
  }
  cout << a << " " << b << " "<< c << '\n';
  return 0;
}



Measured memory_bytes: 3096
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int a, b;
	cin >> a >> b;
	int m = max(a, b);
	if (a == b) {
		cout << m + m;
	}
	else {
		cout << m + m - 1;
	}
	return 0;
}

Measured memory_bytes: 256