akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int cost[2100];
int ans[2100];
int main()
{
	int N, X, Y;
	cin >> N >> X >> Y;
	vector<vector<int>> K(N + 10);
	fx(N) {
		K[x + 1].push_back(x+2);
		K[x + 2].push_back(x + 1);
	}
	K[X].push_back(Y);
	K[Y].push_back(X);
	fx(N) {
		queue<int> Q;
		Q.push(x+1);
		fy(N) {
			cost[y + 1] = INT_MAX / 2;
		}
		cost[x + 1] = 0;
		while(!Q.empty()) {
			int z = Q.front(); Q.pop();
			fy(K[z].size()) {
				if (cost[K[z][y]]>cost[z]+1) {
					cost[K[z][y]] = cost[z] + 1;
					Q.push(K[z][y]);
				}
			}
		}
		fy(N) {
			ans[cost[y + 1]]++;
		}
	}
	fx(N-1) {
		ce(ans[x+1]/2)
	}

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll d[200200];
ll t[200200];
ll N,M;
int main(){
  cin >> N;
  rep(i,N){
    cin >> d[i];
  }
  cin >> M;
  rep(i,M){
    cin >> t[i];
  }
  if(N < M){
    cout << "NO" << endl;
    return 0;
  }
  sort(d,d+N);
  sort(t,t+M);
  ll k = 0;
  rep(i,M){
    ll tmp = t[i];
    while(1){
      if(d[k] == tmp){
        k++;
        break;
      }
      else if(d[k] > tmp){
        cout << "NO" << endl;
        return 0;
      }
      k++;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 3328
n = int(input())

canditates = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in range(len(canditates) - 1):
    if n < 111:
        print(111)
        exit()
    elif canditates[i] == n:
        print(n)
        exit()
    elif canditates[i] < n <= canditates[i + 1]:
        print(canditates[i + 1])
        exit()

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


int main()
{
    ll n,i,k,a[N],s=0,j;
    cin>>n>>k;
    for0(i,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1;i>=0;i--)
    {
        if(k>0)
            j=9;
        else
            s+=a[i];
        k--;
    }
    cout<<s<<endl;
    return 0;
}
































Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 1e5+1;
const ll VAL_MAX = 1e5+1;
const ll INF=1e14;

void solve(){
    int n;cin>>n;
    bool a[n][n];
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		cin>>a[i][j];
    	}
    }
    vector<ll> dp(1<<n,0);
    dp[0]=1;
    // cout<<1<<nl;
   	// cout<<dp[0]<<nl;
   	// dp[i]=number of ways to match men so far to women represented by mask.
	for(int mask=0;mask < (1<<n)-1;mask++){
		int i=0,tmp=mask;
		while(tmp>0){
			if(tmp%2){
				i++;
			}
			tmp/=2;
		}
		for(int j=0;j<n;j++){
			if(a[i][j]==1 && !(mask & (1<<j))){
				int x=mask ^ (1<<j);
				dp[x]+=dp[mask];
				dp[x]%=MOD;
			}
		}
	}
    cout<<dp[(1<<n)-1]<<nl;
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    string S;
    cin >> S;
    ll K;
    cin >> K;
    
    ll l;
    l = S.length();
    ll i;
    char ans = '1';
    for(i=0;i<l;i++){
        if(S[i] != '1'){
            ans = S[i];
            break;
        }
    }

    if(K-1 < i)
        cout << '1' << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
napzak_num, napzak_limit = gets.split(' ').map(&:to_i)
dP = Array.new(napzak_limit + 1, 0)
 
napzak_num.times do 
    
    dP_temp = dP.clone

    weight, value = gets.split(' ').map(&:to_i)
 
    weight.upto(napzak_limit) do |w|
        v = dP[w - weight] + value

        if v > dP[w]
            dP_temp[w] = v
        end
 
    end

    dP = dP_temp
    
end
 
p dP[napzak_limit]

Measured memory_bytes: 69004
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>

#define MOD 1000000007
#define REP(i,n) for ((i)=0;i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define LL long long
#define ULL unsigned long long

int compare_ll(const void *a, const void *b){
	return *(ULL*)b - *(ULL*)a;
}

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void) {

	int N,i,j,k,temp;
	char s[101],t[101];

	scanf("%d", &N);
	scanf("%s", &s);
	scanf("%s", &t);

	if(strlen(s)+strlen(t)<=N){
		printf("%d", N);
	}else{
		for(i=0;i<strlen(s);i++){
			temp = 0;
			for(j=0;j<strlen(s)-i;j++){
				if(s[i+j]==t[j]){
					temp++;
				}else{
					temp = 0;
					break;
				}
			}
			if(temp != 0){
				break;
			}
		}
		if(strlen(s)+strlen(t)-temp<=N){
			printf("%d", N);
		}else{
			printf("%d", strlen(s)+strlen(t)-temp);
		}
	}

	return 0;
}

/* 最後の改行忘れるな！！ */


Measured memory_bytes: 128
#include <algorithm>
#include <stdio.h>
#define MOD 1000000007
#define ll long long
#define maxf 200000

int f[maxf+1], invf[maxf+1];

inline int lgput (int a, int n) {
    int rez = 1;
    while (n) {
        if (n % 2 == 1)
            rez = (1LL * rez * a) % MOD;
        a = (1LL * a * a) % MOD, n /= 2;
    }
    return rez;
}

inline int combinari (int a, int b) {
    if(b < a) return 0;
    else return 1LL * f[b] % MOD * invf[a] % MOD * invf[b-a] % MOD;
}
int main() {
    int n, m, a, b, nr = 0;
    scanf("%d%d%d%d", &n, &m, &a, &b);

    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i <= maxf; i++) {
        f[i] = 1LL * i * f[i-1] % MOD;
        invf[i] = 1LL * lgput (f[i], MOD - 2);
    }

    for (int i = 1; i <= n - a; i++) {
        nr = (nr + 1LL * combinari(i - 1, b + i - 2) * combinari(m - b - 1, m + n - b - i - 1) % MOD)% MOD;
    }

    printf("%d", nr);

    return 0;
}


Measured memory_bytes: 1664
N=gets.to_i
s = N.times.map{gets.to_i}
ans = s.inject(&:+)
s.sort!
a,b=s.partition{|x| x % 10 != 0}
if ans % 10 != 0
  p ans
else
  if a.size > 0
    p ans - a[0]
  else
    p 0
  end
end


Measured memory_bytes: 3836
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    d = defaultdict(list)
    for i in range(N):
        s, p = readline().strip().split()
        p = int(p)
        d[s].append((p, i+1))

    for city, points in sorted(d.items()):
        points = sorted(points, reverse=True)
        for _, i in points:
            print(i)

    return


if __name__ == '__main__':
    main()


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  vector<int> x[26];
  for (int i = 0; i < 26; i++) x[i].emplace_back(0);
  for (int i = 0; i < s.size(); i++) x[s.at(i) - 'a'].emplace_back(i + 1);
  for (int i = 0; i < 26; i++) x[i].emplace_back(s.size() + 1);
  
  int ans = 100;
  for (int i = 0; i < 26; i++) {
    int keep = 0;
    for (int j = 1; j < x[i].size(); j++) {
      keep = max(keep, x[i].at(j) - x[i].at(j - 1) - 1);
    }
    ans = min(ans, keep);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int f[3005][3005],dp[3005][3005];
int a[N],b[N];
int main()
{
    int n,T,ans=0;read(n),read(T);
    for(re int i=1;i<=n;i++) read(a[i]),read(b[i]);
    for(re int i=1;i<=n;i++)
    {
        for(re int j=1;j<=T-1;j++)
        {
            f[i][j]=f[i-1][j];
            if(j>=a[i]) f[i][j]=max(f[i][j],f[i-1][j-a[i]]+b[i]);
        }
    }
    for(re int i=n;i>=1;i--)
    {
        for(re int j=1;j<=T-1;j++)
        {
            dp[i][j]=dp[i+1][j];
            if(j>=a[i]) dp[i][j]=max(dp[i][j],dp[i+1][j-a[i]]+b[i]);
        }
    }
    for(re int i=1;i<=n;i++)
    {
        for(re int j=0;j<=T-1;j++)
        {
            ans=max(f[i-1][j]+dp[i+1][T-j-1]+b[i],ans);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 74496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int ans=t.size();
	rep(i,s.size()){
		string now=s.substr(i,t.size());
		if(now.size()!=t.size()) break;
		int cnt=0;
		rep(j,t.size()){
			if(t[j]!=now[j]) cnt++;
		}
		chmin(ans,cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#define INF 1000000000;
using namespace std;
char mas[200500];
int main() {
	int a = 0,b=0;
	string manji;
	cin >> manji;
	for (int i = 0; i < manji.size(); i++) {
		if (manji[i] == 'A' || manji[i] == 'C' || manji[i] == 'G' || manji[i] == 'T') {
			a++;
		}
		else { a = 0; }
		b = max(a, b);
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
A,B,DEGREE = map(int,input().split())
 
rad = math.radians(DEGREE)
 
S = A*B*math.sin(rad)/2.0
C = math.sqrt(A*A+B*B-2*A*B*math.cos(rad))
h = 2*S/A
 
print("%.10f %.10f %.10f"%(S,A+B+C,h))


Measured memory_bytes: 6424
n=int(input())
xs=[int(s) for s in input().split()]
for i in range(1,n):
    xs[i]+=xs[i-1]
xs_last=xs[n-1]
ans=xs_last
l=0
r=2
for c in range(1,n-2):
    xs_center=xs[c]
    while l<c-1:
        if xs_center<xs[l+1]*2:
            if (xs[l+1]+xs[l])<xs_center:
                l+=1
            break
        l+=1
    while r<n-2:
        if xs_last+xs_center<2*xs[r+1]:
            if (xs[r+1]+xs[r])<xs_last+xs_center:
                r+=1
            break
        r+=1
    pqrs=[xs[l],xs_center-xs[l],xs[r]-xs_center,xs_last-xs[r]]
    ans=min(ans,max(pqrs)-min(pqrs))
print(ans)
            
    

Measured memory_bytes: 24672
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;


int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll a, b, x;
    cin >> a >> b >> x;
    ll ret = (b / x)  + 1ll - ((a - 1ll) / x + 1ll);
    if (a == 0)
    {
        cout << (b / x)  + 1ll << endl;
        return 0;
    }
    
    cout << ret << endl;

    return 0;
}

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

int main() {
	vector<int> v;
	int a,b,c;
	cin >> a >> b>> c;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(),v.end());
	for(int i=0;i<3;++i){
		if(i>0)cout<<" ";
		cout<<v[i];
	}
	cout<<endl;
	return 0;
}

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

int main() {
	int K, S;
	cin >> K >> S;
	int Z, counter = 0;
	for (int j =0; j <= K; j++) {
		for (int i = 0; i <= K; i++) {
			Z = S - (i + j);
			if (0 <= Z && Z <= K) {
				counter++;
			}
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
inline int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return f*k;
}
const int N=2005;
typedef pair<int,int> P;
priority_queue<P> q;
int n,m,tot,a[N],w[N][N],to[N*N],nextt[N*N],head[N],vis[N],de[N];
int gcd(int x,int y)
{
	if(!y) return x;
	return gcd(y,x%y);
}
void add(int a,int b)
{
	to[++tot]=b;
	nextt[tot]=head[a];
	head[a]=tot;
	de[b]++;
}
void dfs(int u)
{
	vis[u]=1;
	for(int i=1;i<=n;i++)
		if(!vis[i]&&w[u][i])
			add(u,i),dfs(i);
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(gcd(a[i],a[j])!=1)
				w[i][j]=w[j][i]=1;
	for(int i=1;i<=n;i++)
		if(!vis[i]) 	
			dfs(i);
	for(int i=1;i<=n;i++)
		if(!de[i])
			q.push(P(a[i],i));
	while(!q.empty())
	{
		P k=q.top();q.pop();
		int u=k.second;
		printf("%d ",a[u]);
		for(int i=head[u];i;i=nextt[i])
		{
			de[to[i]]--;
			if(!de[to[i]])
				q.push(P(a[to[i]],to[i]));
		}
	}
	return 0;
}


Measured memory_bytes: 18816
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def cmp_vec(u,v):   # u < v なる必要条件を記す
    if u[1] < v[1]:
        return  1
    elif u[1] == v[1]:
        if u[2] < v[2]:
            return 1
        elif u[2]==v[2]:
            return 0
        else:
            return -1
    else:
        return -1

def main():
    #
    n,m = map(int,input().strip().split())  # 市 in 県  # n個の県，m個の市
    l=[]
    for i in range(m):
        p,y = map(int,input().strip().split()) # 市iは県piに属しyi年に誕生した
        p = str(p).zfill(6) # p-=1 # i (y,p) 
        l.append(list((i,p,y)))
    l.sort(key=functools.cmp_to_key(cmp_vec),reverse = True)

    #
    eprint('l (i,p,y)',end=':\n')
    eprint(l)

    #
    cntr=1
    for i in range(m):
        if i>0 and l[i][1] != l[i-1][1]:
            cntr=1
        l[i][2] = str(cntr).zfill(6)
        cntr+=1

    #
    l.sort(key=lambda x:x[0])
    for xx in l:
        print(xx[1]+xx[2])
    #
    # eprint('l (i,p,y)',end=':\n')
    # eprint(l)
    # aaa=["asdfa",32, 15.3, True]
    # eprint('aaa ',end=':\n')
    # eprint(aaa)

if __name__ == '__main__':
    main()

Measured memory_bytes: 173144
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

string s, t;
char a[4001];
char b[4001];
int dp[4001][4001];

int main(){
	while(scanf("%s%s", a, b) != EOF){

		s = a;
		t = b;

		for(int i=0; i<4001; i++)
			for(int j=0; j<4001; j++)
				dp[i][j] = 0;

		int ans = 0;
		for(int i=1; i<s.size()+1; i++){
			for(int j=1; j<t.size()+1; j++){
				if(s[i-1] == t[j-1]){
					dp[i][j] = dp[i-1][j-1]+1;
				}else{
					dp[i][j] = 0;
				}
				ans = max(ans, dp[i][j]);
			}
		}

		printf("%d\n", ans);
	}
	return 0;
}

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

void solve(string s,string t,int m,int n)
{
    int L[m+1][n+1];
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0 || j==0)
            L[i][j]=0;
            else if(s[i-1]==t[j-1])
            L[i][j]=1+L[i-1][j-1];
            else
            L[i][j]=max(L[i-1][j],L[i][j-1]);
        }
    }
    int index=L[m][n];
    char ans[index+1];
    ans[index]='\0';
    int i=m,j=n;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans[index-1]=s[i-1];
            i--;
            j--;
            index--;
        }
        else if(L[i-1][j]>L[i][j-1])
        i--;
        else
        j--;
    }
    cout<<ans<<endl;
}

int main() {
	string s,t;
	cin>>s>>t;
	int m=s.size();
	int n=t.size();
	solve(s,t,m,n);
	return 0;
}

Measured memory_bytes: 35456
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPN(i,a,b) for(ll i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
#define ff first
#define ss second
const int M=1e9+7;


int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  
  int x,y;
  cin>>x>>y;
  string ans = "";
  if((y-2*x) <0 || (4*x-y) < 0)
  cout<<"No\n";
  else
  {
  	if((y-2*x)%2 != 0 && (4*x-y)%2 != 0)
  	cout<<"No\n";
  	else
  	cout<<"Yes\n";
  }
   return 0;
}


Measured memory_bytes: 3648
n = gets.to_i
xs = gets.split.map(&:to_i)

look_for = 1
ans = 0
ok = false

xs.each do |x|
  if x == look_for
    if x == 1
      ok = true
    end
    look_for += 1
  else
    ans += 1
  end
end

if ok
  puts ans
else
  puts -1
end


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

int main(){
    long n;
    cin >> n;
    long long a[n];
    for(long i=0; i<n; i++){
        cin >> a[i];
    }

    long long sum_pn, sum_np;
    long long count_pn, count_np, count;

    sum_pn=0;
    sum_np=0;
    count_pn=0; // sum[0] > 0, sum[1] < 0 ...
    count_np=0;

    for(long i=0; i<n; i++){
        sum_pn+= a[i];
        sum_np+= a[i];

        long long sign;
        sign = ((i)%2 *2 -1); // i== odd -> 1, i== even -> -1
        if( sum_pn * (sign) <=0 ){ //case 1, i==even -> sign<0, sum >0 
            count_pn = count_pn - sign*sum_pn + 1;
            sum_pn = sum_pn -  sum_pn +  sign;
        }

        if( sum_np * (-sign) <=0 ){ //case 2, i==even -> sign<0, sum <0
            count_np = count_np + sign*sum_np + 1;
            sum_np = sum_np -  sum_np - sign;
        }
        //cout << "i sum_pn sum_np " << i << " " << sum_pn << " " << sum_np << endl;
        //cout << " sign count_pn np " << sign << " " << count_pn << " " << count_np << endl;
    }

    if( count_pn < count_np ){
        count=count_pn;
    }else{
        count=count_np;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

#define MAX 11
string str;
int bit;

int iii;
void init() { iii = 0; }
char get() { return str[iii++]; }
void unget() { iii--; }

bool formula()
{
	char ch = get();

	if ('a' <= ch && ch <= 'k')
		return (bit>>(ch-'a'))&1;

	switch(ch) {
	case 'T': return true;
	case 'F': return false;
	case '-': return !formula();
	case '(':
		{
			bool a = formula();
			char op = get();
			if (op == '-') op = get();
			bool b = formula();
			get();

			switch(op) {
				case '*': return a&b;
				case '+': return a|b;
				case '>': return (!a)|b;
			}
		}
	}
}

bool check()
{
	init();
	bool a = formula();
	get();
	bool b = formula();
	return a==b;
}

int main(void)
{
	while (cin >> str, str != "#") {
		bool f = true;
		for (bit = 0; f && bit < (1<<MAX); bit++)
			f &= check();
		printf("%s\n", f?"YES":"NO");
	}
	return 0;
}

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

int main() {

	int n, m;
	cin >> n >> m;
	vector<pair<int, char>> a;

	int arr[3];
	// for(auto &s:arr)
	// {
	// 	cin>>s;
	// }
	// for(auto s1:arr)
	// {
	// 	cout<<s1<<" ";
	// }
	// for (auto &t : a) {
	// 	cin >> t.first >> t.second;
	// 	t.first--;
	// }
	int x;
	char y;
	for (int i = 0; i < m; ++i)
	{
		cin>>x>>y;
		x--;
		a.push_back(make_pair(x,y));
	}
	// for(auto &t : a){
	// 	cout<<t.first <<" "<< t.second<<endl;
	// }
	for (int i = 0; i < 1e4; i++) {
		string s = to_string(i);
		//cout<<s<<" "<<s.size()<<" ";
		if (s.size() != n) continue;
		int ok = 1;
		for (auto t : a) {
			ok &= (s[t.first] == t.second);
		}
		if (ok) {
			cout << s << endl;
			return 0;
		}
		//cout<<endl;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
import numpy as np

def main():
	n=II()
	A=np.array([0]+LI()+[10**6])
	B=np.array([0]+LI()+[10**6])
	Ar=(A[:-1]<A[1:])[1:]
	Al=(A[:-1]<A[1:])[:-1]
	Br=(B[:-1]<B[1:])[1:]
	Bl=(B[:-1]<B[1:])[:-1]
	
	A=A[1:-1]
	B=B[1:-1]
	
	#print(Al,Ar,Bl,Br)
	
	AAl=np.array([10**7]*(n+1))
	AAr=np.array([10**7]*(n+1))
	BBl=np.array([-10**7]*(n+1))
	BBr=np.array([-10**7]*(n+1))
	
	for i in range(n):
		if Al[i]==1:
			AAl[A[i]]=i
		if Ar[i]==1:
			AAr[A[i]]=i
		if Bl[i]==1:
			BBl[B[i]]=i
		if Br[i]==1:
			BBr[B[i]]=i
	
	L=AAl-BBr
	R=AAr-BBl
	R=R[R<10**6]
	#print(L)
	LL=L.min()
	
	try:
		RR=max(R)
	except:
		RR=0
	#print(LL)
	#print(RR)
	
	if RR-LL+2>n:
		print("No")
	else:
		print("Yes")
		C=np.concatenate([B[-LL+1:],B[:-LL+1]])
		print(*C)
	
	


	









if __name__=="__main__":
	main()


Measured memory_bytes: 50420
from collections import defaultdict
from math import log2
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline

def f(n,q):
    def dfs(i, oi=-1, dpt=0):
        depth[i] = dpt
        parent_2k[0][i] = oi
        for ki, c, d in to[i]:
            if ki == oi: continue
            dfs(ki, i, dpt + 1)
        return

    def make_parent(level):
        parent_2kk1 = parent_2k[0]
        for k in range(1, level):
            parent_2kk = parent_2k[k]
            for i in range(n):
                parent1 = parent_2kk1[i]
                if parent1 != -1:
                    parent_2kk[i] = parent_2kk1[parent1]
            parent_2kk1 = parent_2kk
        return

    def lca(u, v):
        dist_uv = depth[u] - depth[v]
        if dist_uv < 0:
            u, v = v, u
            dist_uv *= -1

        k = 0
        while dist_uv:
            if dist_uv & 1:
                u = parent_2k[k][u]
            dist_uv >>= 1
            k += 1

        if u == v:
            return u

        for k in range(int(log2(depth[u])) + 1, -1, -1):
            pu = parent_2k[k][u]
            pv = parent_2k[k][v]
            if pu != pv:
                u = pu
                v = pv
        return parent_2k[0][u]

    to = defaultdict(list)
    root = 0
    depth = [0] * n
    level = int(log2(n)) + 1
    parent_2k = [[-1] * n for _ in range(level)]

    for _ in range(n - 1):
        a, b, c, d = list(map(int, input().split()))
        to[a - 1] += [[b - 1, c - 1, d]]
        to[b - 1] += [[a - 1, c - 1, d]]

    dfs(root)
    make_parent(level)

    qs = [[] for _ in range(n)]
    for qi in range(q):
        x, y, u, v = map(int, input().split())
        qs[u - 1].append([qi, x - 1, y, 1])
        qs[v - 1].append([qi, x - 1, y, 1])
        qs[lca(u - 1, v - 1)].append([qi, x - 1, y, -2])

    cnt_c = [0] * n
    sum_c = [0] * n
    ans = [0] * q

    def dfs2(i, oi=-1, sum_d=0):
        for qi, qc, qd, qk in qs[i]:
            ans[qi] += (sum_d - sum_c[qc] + qd * cnt_c[qc]) * qk
        for ki, c, d in to[i]:
            if ki == oi: continue
            cnt_c[c] += 1
            sum_c[c] += d
            dfs2(ki, i, sum_d + d)
            cnt_c[c] -= 1
            sum_c[c] -= d
        return

    dfs2(root)
    for x in ans:
        print(x)

n, q = map(int, input().split())
f(n,q)


Measured memory_bytes: 226364
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
#define N 1000050 
  
int lpf[N], mobius[N]; 
  
// Function to calculate least 
// prime factor of each number 
void least_prime_factor() 
{ 
    for (int i = 2; i < N; i++) 
  
        // If it is a prime number 
        if (!lpf[i]) 
  
            for (int j = i; j < N; j += i) 
  
                // For all multiples which are not 
                // visited yet. 
                if (!lpf[j]) 
                    lpf[j] = i; 
} 
  
// Function to find the value of Mobius function 
// for all the numbers from 1 to n 
void Mobius() 
{ 
    for (int i = 1; i < N; i++) { 
  
        // If number is one 
        if (i == 1) 
            mobius[i] = 1; 
        else { 
  
            // If number has a squared prime factor 
            if (lpf[i / lpf[i]] == lpf[i]) 
                mobius[i] = 0; 
  
            // Multiply -1 with the previous number 
            else
                mobius[i] = -1 * mobius[i / lpf[i]]; 
        } 
    } 
} 
  
// Function to find the number of pairs 
// such that gcd equals to 1 
int gcd_pairs(int a[], int n) 
{ 
    //cout << "hello" << endl;
    // To store maximum number 
    int maxi = 0; 
  
    // To store frequency of each number 
    int fre[N] = { 0 }; 
  
    // Find frequency and maximum number 
    for (int i = 0; i < n; i++) { 
        fre[a[i]]++; 
        maxi = max(a[i], maxi); 
    } 
  
    least_prime_factor(); 
    Mobius(); 
  
    // To store number of pairs with gcd equals to 1 
    int ans = 0; 
  
    // Traverse through the all possible elements 
    for (int i = 1; i <= maxi; i++) { 
        if (!mobius[i]) 
            continue; 
  
        int temp = 0; 
        for (int j = i; j <= maxi; j += i) 
            temp += fre[j]; 
  
        ans += temp * (temp - 1) / 2 * mobius[i]; 
    } 
  
    // Return the number of pairs 
    return ans; 
} 
signed main() {
    int n;
    cin >> n;
    int arr[n];
    int i, g = 0;
    for(i=0;i<n;i++)
    {
        cin >> arr[i];
        g = __gcd(g, arr[i]);
    }
    int num = gcd_pairs(arr, n); 
    if(num == n*(n-1)/2)
        cout << "pairwise coprime";
    else if(g == 1)
        cout << "setwise coprime";
    else
        cout << "not coprime";
}

Measured memory_bytes: 34840
N,K = [int(i) for i in input().split()]
d = []
A = []
person = []
for i in range(K):
    a = int(input())
    d.append(a)
    b = [int(i) for i in input().split()]
    A.append(b)

for i in range(N):
    person.append(i+1)

for i in range(K):
    for j in range(d[i]):
            if A[i][j] in person:
                person.remove(A[i][j])

print(len(person))


Measured memory_bytes: 9152
import sys
import heapq

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    work = [None for _ in range(N)]
    q = []
    heapq.heapify(q)
    for i in range(N):
        a, b = map(int, input().split())
        work[i] = (a, -b)
    
    work.sort()
    ans = 0
    id = 0
    for i in range(M):
        while id < N:
            if work[id][0] <= i + 1:
                heapq.heappush(q, (work[id][1], work[id][0]))
                id += 1
            else: break
        
        if q:
            gain, day = heapq.heappop(q)
            ans -= gain

    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 24388
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define pb push_back
#define mk make_pair
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
int n,m,i,j,s[200005],fa[200005],sz[200005];
int fnd(int x)
{
	if(fa[x]==x) return x;
	return fa[x]=fnd(fa[x]);
}
struct ii
{
	int x,y,id;
}a[200005];
bool cmp(ii x,ii y)
{
	return x.x<y.x;
}
stack<int> stk;
int main()
{
	read(n);fz1(i,n){fa[i]=i;
		a[i].id=i;
		read(a[i].x);
		read(a[i].y);
	}
	sort(a+1,a+n+1,cmp);
	int mi=1;
	fz(i,2,n){
		if(a[i].y<a[mi].y){
			stk.push(mi);
			mi=i;
		}
		else{
			while(!stk.empty()&&a[i].y>a[stk.top()].y){
				fa[fnd(a[stk.top()].id)]=fnd(a[i].id);
				stk.pop();
			}
			fa[fnd(a[i].id)]=fnd(a[mi].id);
		}
	}
	fz1(i,n){
		sz[fnd(i)]++;
	}
	fz1(i,n) printf("%d\n",sz[fnd(i)]);
	return 0;
}

Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   int n,m;cin>>n>>m;
   VI a(n);
   rep(i,n)cin>>a[i];
   sort(ALL(a));
   vector<P> p(m);
   rep(i,m)cin>>p[i].se>>p[i].fi;
   sort(rALL(p));
   VI D;
   int j=0;
   rep(i,n){
      if(p[j].se==0)j++;
      if(j==m)break;
      D.emplace_back(p[j].fi);
      p[j].se--;
   }
   rep(i,min(n,sz(D))){
      if(a[i]<D[i])a[i]=D[i];
   }
   ll ans=0;
   rep(i,n)ans+=a[i];
   cout<<ans<<endl;
}

Measured memory_bytes: 6576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n;
  cin >> n;
  map<i64, i64> mp;
  for (i64 i = 2; i <= n; ++i) {
    i64 y = i;
    for (i64 x = 2; x <= i; ++x) {
      while (y % x == 0) {
        y /= x;
        mp[x]++;
      }
    }
  }
  i64 ans = 1;
  for (const auto& p : mp) {
    ans = ans * (p.second + 1) % i64(1e9 + 7);
  }
  cout << ans << '\n';
  return 0;
}


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int a,b;cin>>a>>b;
    string sa="",sb="";
    frepi(1,a,1)sa.push_back(b+'0');
    frepi(1,b,1)sb.push_back(a+'0');
    if(sa<sb)cout<<sa;
    else	cout<<sb;
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#define NIL -1

struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};

struct node *root,*NIL;

void insert(int k)
{
  struct node *y,*x,*z;

  y=NIL;    // x の親                                                           
  x=root;

  z=(struct node *)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){  // T が空の場合                                                  
    root=z;
  }else {
    if(z->key<y->key){
    y->left=z;  // z を y の左の子にする                                        
    }else{
    y->right=z;  // z を y の右の子にする                                       
    }
  }
}

void in_print(struct node *u) //中間から
{
  if(u==NIL) return;
  in_print(u->left);
  printf(" %d",u->key);
  in_print(u->right);
}

void pre_print(struct node *u)  //前から
{
  if(u==NIL) return;
  printf(" %d",u->key);
  pre_print(u->left);
  pre_print(u->right);
}

int main(){
  int i,m,k;
  char str[21];

  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",str);
    if(strcmp("insert",str)==0){
    scanf("%d",&k);
    insert(k);                                                                
    }else{
    in_print(root);
    printf("\n");
    pre_print(root);
    printf("\n");
    }
  }

  return 0;
}





Measured memory_bytes: 25140
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Feb 22 21:00:01 JST 2020
 **/

template <class T> T pow(T x, int n, const T UNION = 1) {
    T ret = UNION;
    while (n) {
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}

template <int MD> struct ModInt {
    int x;
    static unordered_map<int, int> to_inv;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % MD + MD) >= MD) x -= MD;
    }

    ModInt& operator+=(ModInt that) {
        if ((x += that.x) >= MD) x -= MD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        x = (unsigned long long)x * that.x % MD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        if ((x -= that.x) < 0) x += MD;
        return *this;
    }
    ModInt& operator/=(ModInt that) {
        x = (unsigned long long)x * that.inv().x % MD;
        return *this;
    }
    ModInt operator-() const { return -x < 0 ? MD - x : -x; }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt inv() const { return to_inv.count(this->x) ? to_inv[this->x] : (to_inv[this->x] = pow(*this, MD - 2).x); }

    friend ostream& operator<<(ostream& s, ModInt<MD> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<MD>& a) {
        long long tmp;
        s >> tmp;
        a = ModInt<MD>(tmp);
        return s;
    }
    friend string to_string(ModInt<MD> a) { return to_string(a.x); }
};
template <int MD> unordered_map<int, int> ModInt<MD>::to_inv;
using mint = ModInt<1000000007>;

vector<mint> fact, fact_inv;
void init_factorial(int n) {
    fact = vector<mint>(n + 1, 1);
    fact_inv = vector<mint>(n + 1);
    for (int i = 0; i < n; i++) fact[i + 1] = fact[i] * (i + 1);
    fact_inv[n] = mint(1) / fact[n];
    for (int i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1);
    // for (int i = 0; i < n + 1; i++) assert(fact[i] * fact_inv[i] == 1);
}
mint comb(int n, int r) { return fact[n] * fact_inv[r] * fact_inv[n - r]; }

signed main() {
    Int n, k;
    cin >> n >> k;
    init_factorial(2 * n + 1);
    mint ans = 0;
    REP(l, min(n, k + 1)) {
        Int r = n - l;
        ans += comb(n, l) * comb(r + l - 1, l);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
x1, y1, x2, y2=gets.split.map &:to_i
cos90=0
sin90=1
x4=(x2-x1)*cos90-(y2-y1)*sin90+x1
y4=(x2-x1)*sin90+(y2-y1)*cos90+y1
x3=(x1-x4)*cos90-(y1-y4)*sin90+x4
y3=(x1-x4)*sin90+(y1-y4)*cos90+y4
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
import sys
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
s_dic = {}
for _ in range(N):
    s_list = list(input())
    s_list.sort()
    s = ''.join(s_list)

    if s in s_dic:
        s_dic[s] += 1
    else:
        s_dic[s] = 1

ans = 0
for k, v in s_dic.items():
    if v >= 2:
        ans += cmb(v, 2)
print(ans)


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  ll a, b;
  cin >> a >> b;

  cout << (a * b - a - b + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 1000000007
typedef long long ll;



int main(){
  int x=0;
  string s;
  cin>>s;
  for(int i=0;i<4;i++){
    if(s[i]=='+') x++;
    else x--;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int n,ans;
char p[55];
int main()
{
	scanf("%d",&n);
	cin>>(p+1);
	for(int i=1;i<=n;i++)
		if(p[i]=='A'&&p[i+1]=='B'&&p[i+2]=='C')
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256