akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

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

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


int gcd(int a,int b ,int c){
  int x=min(min(a,b),c);
  int div;
  for(int i=1 ; i <= x ;++i){
    if(a%i==0 && b%i==0 && c%i==0)div=i;
  }
  return div;
}

//Variables Declaration


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
  int count=0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        count+=gcd(i,j,k);
      }
    }
  }
  cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3604
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

vector<int> v[22];
int fn;
int M =1e9+7;

int dp[22][1<<21];

int fun(int ms, int n){
    // cout<<ms<<" "<<n<<endl;
    if(ms==fn)return 1;
    if(n==0)return 0;
    // cout<<ms <<" "<<n<<" "<<dp[n][ms]<<endl;
    if(dp[n][ms]!=-1)return dp[n][ms];
    
    long long int ans =0;
    
    // ans+=fun(ms,n-1);
    ans%=M;
    for(int i=0;i<v[n].size();i++){
        if(!(ms&(1<<(-1+v[n][i])))){
            ans+=fun(ms|(1<<(-1+v[n][i])),n-1);
            ans%=M;
        }
    }
    // cout<<ans<<" ans "<<endl;
    return dp[n][ms]=ans;
    
}

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    int a;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            cin>>a;
            if(a)v[i].push_back(j);
        }
    
    fn = 1<<n;fn--;
    
    for(int j=1;j<=n;j++) 
        for(int i=0;i<fn;i++)dp[j][i]=-1;
    
    // cout<<"here "<<endl;
    cout<<fun(0,n)<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;


ll st[8] = {1, 2, 3, 5, 8, 13, 21, 34};
ll s[8][9] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0},
{0, 2, 1, 2, 0, 0, 0, 0},
{0, 3, 2, 2, 3, 0, 0, 0},
{0, 5, 3, 4, 3, 5, 0, 0},
{0, 8, 5, 6, 6, 5, 8, 0},
{0, 13, 8, 10, 9, 10, 8, 13}};

int main() {
    const ll DIV(1000000007);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    int H, W, K;
    cin >> H >> W >> K;
    vector<ll> n(W+2);
    n[1] = 1;
    for (int i = 0; i < H; ++i) {
      vector<ll> nn(W+2);
      for (int j = 1; j <= W; ++j) {
        nn[j] = ((s[W-1][j-1] * n[j-1]) % DIV +
          ((st[W-1] - s[W-1][j-1] - s[W-1][j]) * n[j]) % DIV +
          (s[W-1][j] * n[j+1]) % DIV) % DIV;
      }
      n = nn;
    }
    cout << n[K] << endl;
}



Measured memory_bytes: 256
///                ..:: In The Name Of God ::..
#include<bits/stdc++.h>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define error(x) cerr << #x << " = " << (x) << endl;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define Size(x) (int)(x).size()
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    int ans = n - k;
    if (k == 1) ans = 0;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>

int main(void){
    double x1,y1,x2,y2;
    double kyori;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    kyori=sqrt((double)((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    printf("%f\n",(double)kyori);
    return 0;
    
}


Measured memory_bytes: 2104
#include <stdio.h>
#define maxn 105
int a[5][5],b[maxn],c[5][5];
int main()
{
    int i,j,n,k,flag=0;
    for(i=1; i<=3; i++)
        for(j=1; j<=3; j++)
            scanf("%d",&a[i][j]);
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&b[i]);
    for(i=1; i<=n; i++)
        for(j=1; j<=3; j++)
            for(k=1; k<=3; k++)
                if(b[i]==a[j][k])
                    c[j][k]=1;
    for(i=1; i<=3; i++)
        if(c[i][1]==1&&c[i][2]==1&&c[i][3]==1)
            flag=1;
    for(j=1; j<=3; j++)
        if(c[1][j]==1&&c[2][j]==1&&c[3][j]==1)
            flag=1;
    if(c[1][1]==1&&c[2][2]==1&&c[3][3]==1)
        flag=1;
    if(c[1][3]==1&&c[2][2]==1&&c[3][1]==1)
        flag=1;
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool used[100002];
main(){
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	while(s.size()<t.size())s+='a'-1;
	while(t.size()<s.size())t+='a'-1;
	if(s<t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist_cnt = [0] * N
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist_cnt[min(j - i, abs(X - i) + abs(j - Y) + 1)] += 1
    print("\n".join(map(str, dist_cnt[1:])))


if __name__ == "__main__":
    main()


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=0; i<=r; i+=d) {
        if(i>=l)
            ans++;
    }



    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int r = int.Parse(Console.ReadLine());
			Console.WriteLine(3 * Math.Pow(r, 2));
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,M;
int A[1010],B[1010],C[1010];
int d[110][110];
bool F[110][110];
set<P> U;

void Warshall_Floyd(int n){
	REP(i,n)REP(j,n)REP(k,n){
		d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
	}
}


signed main(){
	cin>>N>>M;
	REP(i,M){
		cin>>A[i]>>B[i]>>C[i];
	}
	REP(i,110)REP(j,110){
		d[i][j]=INF;
	}
	REP(i,110){
		d[i][i]=0;
	}
	REP(i,M){
		d[A[i]-1][B[i]-1]=C[i];
		d[B[i]-1][A[i]-1]=C[i];
	}
	int ans=0;
	Warshall_Floyd(N);
	REP(k,M){
		bool flag=false;
		REP(i,N){
			REP(j,N){
				if(d[i][A[k]-1]+C[k]+d[B[k]-1][j]==d[i][j]){
					flag=true;
				}
			}
		}
		if(flag==false){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = []
for i in range(M):
  x,y,c = map(int, input().split())
  xyc.append(a[x-1]+b[y-1]-c)

print(min([min(a)+min(b),min(xyc)]))

Measured memory_bytes: 73068
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


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

	vector<vector<ll>> counts(10, vector<ll>(10, 0));
	reple(i, 0, N)
	{
		string s = to_string(i);

		int first = s[0] - '0';
		int last = s[s.length() - 1] - '0';

		counts[first][last]++;
	}

	ll count = 0;

	reple(i, 1, 9)
	{
		reple(j, 1, 9)
		{
			count += counts[i][j] * counts[j][i];
		}
	}

	cout << count << endl;

	return 0;
}

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

int main(){
	ll x,y;
	cin >> x >> y;

	ll ans = 0;
	if(x>=0 && y>=0){
		if(x<=y) ans = abs(y-x);
		else { ans = abs(x-y)+2; if(y==0)ans--;}
	} else if(x<0 && y<0){
		if(x<y) ans = abs(y-x);
		else ans = abs(x-y)+2;
	} else {
		if(x<y) ans = min(abs(y-x),abs(-x-y)+1);
		else ans = abs(-x-y)+1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;
 
int main() {
        int n;
        scanf("%d", &n);
        vector<vector<int>> g(n);
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                scanf("%d %d", &a, &b);
                g[a].push_back(b);
                g[b].push_back(a);
        }
        bool path = true;
        for (int i = 0; i < n; i ++) {
                path &= (int) g[i].size() <= 2;
        }
        if (path) {
                printf("%d\n", 1);
                return 0;
        }
        vector<bool> is_path(n);
        function<void (int, int)> dfs = [&](int u, int prev) {
                is_path[u] = true;
                int cnt = 0;
                for (auto v : g[u]) if (v != prev) {
                        cnt ++;
                        dfs(v, u);
                        if (!is_path[v]) is_path[u] = false;
                }
                if (cnt > 1) is_path[u] = false;
        };
        dfs(0, -1);
        int ans = 0;
        //for (auto it : is_path) cerr << it << ' '; cerr << endl;
        function<void (int, int, int)> dfs2 = [&](int u, bool par_path, int prev) {
                int path_cnt = 0;
                int children = 0;
                vector<pair<bool, int>> ch;
                for (auto v : g[u]) {
                        if (v == prev) {
                                path_cnt += par_path;
                        } else {
                                path_cnt += is_path[v];
                                ch.emplace_back(is_path[v], v);
                                children ++;
                        }
                }
                ans += max(0, path_cnt - 1);
                for (auto v : g[u]) if (v != prev) {
                        bool this_path = par_path;
                        if (u != 0) {
                                this_path &= children <= 1;
                        } else {
                                if (ch.size() >= 3) {
                                        this_path = false;
                                } else if (ch.size() == 2) {
                                        if (ch[0].second == v) {
                                                this_path &= ch[1].first;
                                        } else {
                                                this_path &= ch[0].first;
                                        }
                                }
                        }
                        dfs2(v, this_path, u);
                }
        };
        dfs2(0, true, -1);
        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 18048
#include<stdio.h>

int main(){
	int i,j;
	int mt[10];
	int max[3]={0,0,0};
	int tmp1,tmp2;
	
	for(i=0;i<10;i++){
		scanf("%d",&mt[i]);
		for(j=0;j<3;j++){
			if(mt[i]>max[j]){
				tmp1=max[j];
				max[j]=mt[i];
				if(j==0){
					tmp2=max[j+1];
					max[j+1]=tmp1;
					max[j+2]=tmp2;
				}
				if(j==1) max[j+1]=tmp1;
				break;
			}
		}
	}
	for(j=0;j<3;j++){
		printf("%d\n",max[j]);
	}
	
	return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    int ans = 0;
    for (int k = 1; k <= min(K, N); k++) {
        for (int o = N - k; o <= N; o++) {
            //cout << "--" << endl;
            priority_queue<int, vector<int>, greater<int>> Q;
            int sum = 0;
            for (int i = 0; i < k; i++) {
                //cout << V[(o + i) % N] << endl;
                Q.push(V[(o + i) % N]);
                sum += V[(o + i) % N];
            }
            ans = max(ans, sum);
            int rest = K - k;
            for (int r = 0; r < rest; r++) {
                if (Q.empty()) break;
                int t = Q.top(); Q.pop();
                if (t >= 0) break;
                sum -= t;
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> pint;
bool cmp(pint a, pint b){ return a.first < b.first ;};
int N,M;
vector<pint> A;


int main() {
    cin >> N >> M;
    A.resize(M);

    rep(i, M){
        cin >> A[i].first >> A[i].second;
    }
    sort(A.begin(), A.end(), cmp);

    int ans = 0;
    int left = (1 << 31) - 1;
    for(int i = M - 1 ; i >= 0; i --){
        if(A[i].second <= left){
            left = A[i].first;
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
int main()
{
    long long k;
    cin >> k;
        long long a=7%k;
    REP(i,k){
      if(a%k == 0){
        cout << (i+1) << endl;
        return 0;
      }
      a = (a*10 + 7)%k;
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<queue>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define ll long long
using namespace std;
int n,a[2005],tot,du[2005],h[2005],to[4000005],nex[4000005];
bool bhz[2005][2005],pd[2005];
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
struct node{
    int fr,id;
}st;
bool operator <(node a,node b)
{
    return a.fr<b.fr;
}
priority_queue<node> q;
void add(int a,int b)
{
    du[b]++;
    to[++tot]=b;
    nex[tot]=h[a];
    h[a]=tot;
}
void dfs(int x)
{
    pd[x]=1;
    for(int i=1;i<=n;i++)
        if(bhz[x][i]&&!pd[i])
        {
            add(x,i);
            dfs(i);
        }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n-1;i++)
    for(int j=i+1;j<=n;j++)
    if(gcd(a[i],a[j])>1) bhz[i][j]=bhz[j][i]=1;
    for(int i=1;i<=n;i++) if(!pd[i]) dfs(i);
    for(int i=1;i<=n;i++) 
        if(!du[i])
        { 
            st.fr=a[i];
            st.id=i;
            q.push(st); 
        }
    for(int i=1;i<=n;i++)
    {
        st=q.top();
        q.pop();
        int now=st.id;
        cout<<a[now]<<" ";
//        for(int k=h[now];k;k=nex[k])
//        {
//            du[to[k]]--;
//            if(!du[to[k]])
//            {
//                st.fr=a[to[k]];
//                st.id=to[k];
//                q.push(st);
//            }
//        }
        int t=h[now];
        while (t){
            du[to[t]]--;
            if (!du[to[t]]){
                st.fr=a[to[t]];
                st.id=to[t];
                q.push(st);
            }
            t=nex[t];
        }
    }
    return 0;
}

Measured memory_bytes: 6656
H = int(input())
x = [[float('inf')]*2 for i in range(H)]

for i in range(H):
    X, L = map(int, input().split())
    x[i][0] = X - L
    x[i][1] = X + L

from operator import itemgetter
sf = sorted(x, key=itemgetter(1))

ans = 0
last = float('inf')*-1

for i in range(H):
    if last <= sf[i][0]:
        ans += 1
        last = sf[i][1]

print(ans)


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



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

    int n,u,ans=0;
    ll w,x;
    cin>>n>>x;
    
    vector<ll> s(114514,1e16);
    s[0]=0;
    
    rep(i,n){
        cin>>w>>u;
        
        for(int j=100000;j>=0;j--)
        if(s[j]<1e12)
            s[j+u]=min(s[j+u],s[j]+w);
        
    }
    
    rep(i,100010)if(s[i]<=x)
        ans=max(ans,i);
        
    cout<<ans<<endl;
        
    
    return 0;
}


Measured memory_bytes: 1788
// AOJ GRL_7_A Matching - Bipartite Matching
// 2018.4.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 202
int  hi[MAX], to[MAX][MAX];
char seen[MAX];
int  match[MAX];

int bpm(int u);
int bipartiteMatching(int m, int n)
{
	int u, max;

	memset(match, -1, (m+n)*sizeof(int));
	max = 0;
	for (u = 0; u < m; u++) {
		memset(seen, 0, m+n);
		if (bpm(u)) max++;
	}
	return max;
}

int bpm(int u)
{
	int i, v;

	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (seen[v]) continue;
		seen[v] = 1;
		if (match[v] < 0 || bpm(match[v])) {
			match[u] = v, match[v] = u;
			return 1;
		}
	}
	return 0;
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int main()
{
	int X, Y, E, x, y;

	X = in(), Y = in(), E = in();
	while (E--) {
		x = in(), y = in();
		to[x][hi[x]++] = X+y;
	}
	printf("%d\n", bipartiteMatching(X, Y));
	return 0;
}


Measured memory_bytes: 2100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt() * 3;
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		long ans = 0;
		for (int i = N - 2; i >= N / 3; i -= 2) {
			ans += a[i];
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 91480
N = int(input())

if N == 1:
    print(0)
    exit()

initial = 10
oneornine = 9
oneandnine = 8

for i in range (0, N-1):
    initial*=10
    initial = initial%(10**9+7)

for i in range (0, N-1):
    oneornine*=9
    oneornine = oneornine%(10**9+7)

for i in range (0, N-1):
    oneandnine*=8
    oneandnine = oneandnine%(10**9+7)

print((initial-2*oneornine+oneandnine)%(10**9+7))

Measured memory_bytes: 64320
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  cout << min(n % k, k - n % k) << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
D = 100

v0 = []
vm = []
vk = []
for i in range(D):
    n1 = 0
    for a in A:
        if a>>i &1: n1+=1
    v0.append(n1 * 2**i)
    vm.append(max(n1,N-n1) * 2**i)
    vk.append((N-n1) * 2**i if K>>i &1 else n1 * 2**i)

m = sum(vk)
for i in range(D):
    if K>>i &1: m = max(m, sum(vk[i+1:]) + v0[i] + sum(vm[:i]))

print(m)

Measured memory_bytes: 14828
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int [][] ab = new int[2][N];
        for(int i=0; i<2;i++){
            for(int j=0; j<N;j++){
                ab[i][j] = in.nextInt();
            }
        }
        int [] dif = new int[N];
        int index =0;
        for(int i =1; i<=N;i++){
            for(int j=0; j<=N-i;j++){
                dif[index]+=ab[0][j];
            }
            for(int j=N-1;j>=N-i;j--){
                dif[index]+=ab[1][j];
            }
            index++;
        }
        int max = dif[0];
        for(int i: dif){
            if(i>max){
                max = i;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <set>

std::set<int> ans;
int hand[12];
bool used[12] = { false, false, false, false, false, false, false, false, false, false, false, false };

void pattern(int now, int n, int k){
	// テァツオツづ、ツコツ?・ツ?ヲテァツ青?
	if (k <= 0){
		//printf("Pattern -> %d\n", now);

		//printf("use : ");
		//for (int i = 0; i < n; i++){
		//	if (used[i]){ printf("|%d|", hand[i]); }
		//}
		//printf("\n");

		ans.insert(now);
		return;
	}

	// ティツィツ暗ァツョツ?
	for (int i = 0; i < n; i++){
		if (used[i] == true){ continue; }

		int rank = (hand[i] >= 10) ? 100 : 10;
		now *= rank;
		now += hand[i];
		used[i] = true;
		pattern(now, n, k - 1);
		used[i] = false;
		now -= hand[i];
		now /= rank;
	}
}

int main(void){
	int n, k;

	while (true){
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0){ break; }

		// テ・ツ?・テ・ツ環?
		for (int i = 0; i < n; i++){ scanf("%d", &hand[i]); }
		
		// GO
		pattern(0, n, k);
		
		// テ・ツ?コテ・ツ環?
		printf("%d\n", ans.size());
		ans.clear();
	}


	return 0;
}

Measured memory_bytes: 1152
n = gets.to_i

l = n
c = 0
sum = 1

if l <= 1
  puts 1
  exit
end

loop do
  l = l / 2
  c += 1

  if l <= 1
    break
  end
end

(1..c).each do |i|
  sum += 2**i
end
puts sum

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
struct engine{
    int x,y;
    long double angle;
    engine(int _x, int _y){
        x = _x, y = _y;
        angle = atan((long double)y/x);
        if (x < 0){
            angle += 3.1415926535897932384626;
        }
    }
}*a[105];
long long calc(int x, int y){
    return ((long long)x)*x + ((long long)y)*y;

}
int main(){
    int n;
    scanf("%d",&n);
    int sumx = 0, sumy = 0;
    for (int i = 0; i < n; i++){
        int x,y;
        scanf("%d%d",&x,&y);
        a[i] = new engine(x,y);
        sumx += x; sumy += y;
    }
    sort(&a[0],&a[n],[](engine *a, engine *b){
        return a->angle < b->angle;
    });
    int px[n+1], py[n+1];
    px[0] = 0, py[0] = 0;
    long long ans = 0;
    for (int i = 1; i <= n; i++){
        //printf("%d %d\n",a[i]->x,a[i]->y);
        px[i] = px[i-1] + a[i-1]->x;
        py[i] = py[i-1] + a[i-1]->y;
        for (int j = 0; j < i; j++){
            int xx = px[i] - px[j];
            int yy = py[i] - py[j];
            //printf("%d %d %lld\n",xx,yy,calc(xx,yy));
            ans = max(ans,max(calc(xx,yy),calc(sumx-xx,sumy-yy)));
        }
    }
    //printf("%lld\n",ans);
    printf("%.10f",pow(ans,0.5));


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll   long long int   
#define pb push_back
using namespace std;
const int M=1e9 + 7;
int main()
{   
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b;
    cin>>a>>b;
    int ans=max(a+b,max(a-b,a*b));
    cout<<ans<<endl;

	return 0;
}
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	char e,f;
	int a,b,c;
	int t=0,h=0;
	while(cin>>a>>e>>b>>f>>c){
		if(a==b){
			h++;
		}
		else if((a*a)+(b*b)==(c*c)){
			t++;
		}
	}
	cout<<t<<endl;
	cout<<h<<endl;
	return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}



int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll ans =0;
	cin >>n;
	
	vector<VI> hj(10, VI(10));
	rep2(i, 1, n+1){
		int bk=i%10, fr=0;
		for(int w=i; w>0; w/=10) fr=w;
		//dbg(i, fr, bk);
		if(bk>0 && fr>0) hj[fr][bk]++;
	}
	
	rep2(i, 1, n+1){
		int bk=i%10, fr=0;
		for(int w=i; w>0; w/=10) fr=w;
		if(bk>0 && fr>0){
			ans += hj[bk][fr];
		}
	}
	cout << ans <<"\n";
	
	return 0;
	
	ll res=0;
	rep2(a, 1, n+1) rep2(b, 1, n+1){
		if(a%10==0 || b%10==0) continue;
		string sa = to_string(a);
		string sb = to_string(b);
		if(sa[0] == b%10 +'0' && sb[0] == a%10 +'0') res++;
	}
	cout <<res <<"\n";
	return 0;
}


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

using namespace std;

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if(y==NIL) root = z;
    else{
        if(y->key > z->key) y->left = z;
        else y->right = z;
    }

}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        string str;
        int d;
        cin>>str;
        if(str=="insert"){
            scanf("%d", &d);
            insert(d);
        }
        else{
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
        
    }
}



Measured memory_bytes: 26708
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        int count;

        while((n=sc.nextInt())!=0){
            count=0;
            while(n!=1){
                if(n%2==0){ n=n/2; }
                else{ n=3*n+1; }
                count++;
            }
            System.out.println(count);
        }
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, A, B;
	cin >> N >> A >> B;
	ll num = N / (A+B) * A;
	cout << num + min((N % (A+B)), A) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

#define M_PI       3.14159265358979323846   // pi

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

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll n;
	cin >> n;
	vector<ll> vs(n);
	rep(i, n) cin >> vs[i];
	vector<int> fo(n + 1, 0);
	fo[0] = 3;
	ll sum = 1;
	rep(i, n) {
		int id = vs[i];
		int prev = fo[id];
		sum *= prev;
		sum %= mod;
		fo[id+1]++;
		fo[id]--;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];
    double s = 0;
    rep(i, N) {
        s += 1.0 / double(A[i]);
    }
    printf("%20.8f\n", 1.0 / s);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int dp[3005][3005];

int main(){
  string s, t;
  cin >> s >> t;
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < t.size(); j++){
      if(s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      dp[i + 1][j + 1] = max({dp[i][j + 1], dp[i + 1][j], dp[i + 1][j + 1]});
      //cerr << dp[i + 1][j + 1] << " ";
    }
    //cerr << endl;
  }

  string ans = "";
  int x = s.size(), y = t.size();
  int dx[] = {0, -1};
  int dy[] = {-1, 0};
  while(1){
    if(dp[x][y] == 0){
      // ans += s[x];
      break;
    }
    bool update = false;
    for(int i = 0; i < 2; i++){
      int nx = x + dx[i], ny = y + dy[i];
      if(dp[x][y] == dp[nx][ny]){
	x = nx, y = ny, update = true;
	break;
      }
    }
    if(!update) {
      x--, y--;
      ans += s[x];
    }
  }
  
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35456
package main
import(
  "fmt"
)
func main(){
  var a, b, c, k, i int
  fmt.Scan(&a, &b, &c, &k)
  for i=1;i<=k;i++{
    if a>=b&&a>=c{
      a*=2
    }else if b>=a&&b>=c{
      b*=2
    }else{
      c*=2
    }
  }
  fmt.Println(a+b+c)
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

struct Lamp {
    int p;
    vi sw;
};

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

    int n, m;
    cin >> n >> m;

    vector<Lamp> lamp(m);
    rep(i, 0, m) {
        int k;
        cin >> k;
        rep(_, 0, k) {
            int s;
            cin >> s;
            lamp[i].sw.push_back(s - 1);
        }
    }
    rep(i, 0, m) { cin >> lamp[i].p; }

    int ans = 0;
    rep(bit, 0, 1 << n) {
        bool cnt = true;
        rep(i, 0, m) {
            int on = lamp[i].p;
            for (int sw : lamp[i].sw) {
                if (bit & (1 << sw)) { on ^= 1; }
            }
            if (on != 0) {
                cnt = false;
                break;
            }
        }
        if (cnt) { ++ans; }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<string> S(n);
    rep(i,n) cin >> S.at(i);
    map<char, int> abc;
    rep(i,S.at(0).size()) {
        ++abc[S.at(0).at(i)];
    }
    if (n > 1) {
        for (int i = 1; i < n; ++i) {
            map<char, int> tmp;
            rep(j,S.at(i).size()) {
                ++tmp[S.at(i).at(j)];
            }
            rep(j,26) {
                abc['a' + j] = min(abc['a' + j], tmp['a' + j]);
            }
        }
    }
    string ans;
    for (auto x : abc) {
        rep(i,x.second) ans.push_back(x.first);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>
#include <set>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll N, M, a, b;
    vector<ll> costs;
    vector<vector<ll>> opens;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        ll a,b;
        cin >> a >> b;
        costs.push_back(a);
        vector<ll> os;
        for(int i = 0;i<b;i++){
            ll o;
            cin >> o;
            os.push_back(o-1);
        }
        opens.push_back(os);
    }

    vector<ll> current_costs(1<<N,BASE_NUM);
    vector<ll> next_costs(1<<N,BASE_NUM);
    current_costs[0] = 0;
    next_costs[0] = 0;
    for(int i = 0;i<M;i++){
        ll open_doors = 0;
        for(auto c:opens[i]){
            open_doors |= 1<<c;
        }
        for(int j = 0;j< 1<<N;j++){
            next_costs[j|open_doors] = min(next_costs[j|open_doors],current_costs[j] + costs[i]);
        }
        copy(next_costs.begin(),next_costs.end(),current_costs.begin());
    }
    if (current_costs[(1<<N) - 1] == BASE_NUM){
        cout << -1 << endl;
    }else{
        cout << current_costs[(1<<N) - 1] << endl;
    }
   return 0;
}

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

using lint = int64_t;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
        cerr << fixed << setprecision(12);
    }
} iosetup;

template <typename T>
T gcd(T m, T n) {
    if (n == 0) return m;
    else return gcd(n, m % n);
}

template <typename T>
T lcm(T m, T n) {
    return m / gcd(m, n) * n;
}

lint num(lint n, lint c, lint d) {
    return n - n / c - n / d + n / lcm(c, d);
}

int main() {
    lint a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << num(b, c, d) - num(a - 1, c, d) << endl;

    return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":

    pd = input()

    pd_replace = pd.replace('?','D') 

    # count = 0
    # for i in range(len(pd_replace)):
    #     if (pd_replace[i] == 'P' and pd_replace[i+1] == 'D'):
    #         count += 1
    #     elif(pd_replace[i] == 'D'):
    #         count += 1

    print(pd_replace)
        


Measured memory_bytes: 9448
n, c, k = map(int, input().split())
times = []
for i in range(n):
    times.append(int(input()))
    
times.sort()

passenger = 0
number_of_unit = 1
waiting_time = times[0] + k
for t in times:
    if c == passenger:
        #print('c < passenger', t)
        passenger = 0
    elif waiting_time < t:
        #print('waiting_time < t', t)
        passenger = 0
    else:
        #print('else',t)
        passenger += 1
        
    if passenger == 0:
        waiting_time = t + k
        passenger += 1
        number_of_unit += 1
        #print('-------','new_bus',waiting_time,'-------')

print(number_of_unit)

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

int main() {
 
  string S, T;
  
  cin >> S;
  cin >> T;
  
  if ( T.find(S) == 0 && S.size() == T.size() - 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 3628
class stack:
    val = []
    def __init__(self,arg):
        self.val = arg

    def stack_push(self,a):
        self.val.append(a)

    def stack_pop(self):
        return self.val.pop()

N = input().split()
Output = stack([])

for a in N:
    if a.isdigit():
        Output.stack_push(a)
    else:
        temp1 = int(Output.stack_pop())
        temp2 = int(Output.stack_pop())
        if a == '+':
            Output.stack_push(temp2+temp1)
        elif a == '-':
            Output.stack_push(temp2-temp1)
        elif a == '*':
            Output.stack_push(temp2*temp1)
        elif a == '/':
            Output.stack_push(temp2/temp1)
print(Output.stack_pop())




Measured memory_bytes: 5596
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	var memo [114]int
	for i := a; i < b; i++ {
		memo[i]++
	}
	for i := c; i < d; i++ {
		memo[i]++
	}

	ans := 0
	for i := 0; i < 114; i++ {
        if memo[i] == 2{
            ans++
        }
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N;
  cin>>N;
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  vector<int> prime;
  prime.push_back(2);
  for(int i=3;i<=N;i+=2){
    bool flag=true;
    //cout<<"OK"<<endl;
    for(int j=0;j<prime.size();j++){
      if(i%prime[j]==0) flag=false;
    }
    if(flag) prime.push_back(i);
  }
  
  vector<ll> cnt(prime.size(),0);

  for(int i=2;i<=N;i++){
    for(int j=0;j<prime.size();j++){
      int tmp=i;
      while(tmp%prime[j]==0){
        cnt[j]++;
        tmp/=prime[j];
      }
    }
  }

  ll ans=1;
  for(int i=0;i<cnt.size();i++){
    (ans*=(cnt[i]+1))%=mod;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong()
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() }

fun main() {
    val n = readInt()
    val f = LongArray(n + 1)
    val isPrime = BooleanArray(n + 1) { true }
    val onePrimeFactor = IntArray(n + 1) { -1 }
    f[1] = 1
    val primes = mutableListOf<Int>()
    var ans = 1L
    for (i in 2..n) {
//        debug(i)
        if (isPrime[i]) {
            primes += i
            onePrimeFactor[i] = i
            for (j in i + i..n step i) {
                isPrime[j] = false
                onePrimeFactor[j] = i
            }
            ans += 2 * i
        } else {
            val primeFactors = mutableMapOf<Int, Int>()
            var j = i
            while (j > 1) {
                val k = onePrimeFactor[j]
                primeFactors.compute(k) { _, vv -> vv?.plus(1) ?: 1 }
                j /= k
            }
            var ans1 = 1L
            for (primeFactor in primeFactors) {
//                debug(i.toString() + " " + primeFactor.key + " " + primeFactor.value)
                ans1 *= primeFactor.value + 1
            }
            ans += ans1 * i
        }
    }
    println(ans)
}

fun debug(any: Any) {
    System.err.println(any)
}


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

using namespace std;

const int mod = 1e9 + 7;
int fact[100002], re_fact[100002];

int p(int a, int b)
{
	if (b == 0) 
		return 1;
	int tmp = p(a, b / 2);
	if (b%2 == 0) return (1LL * tmp * tmp)%mod;
	return ((1LL * tmp * tmp)%mod * a)%mod;
}

int comb(int k, int n)
{
	if (k < 0 || k > n) return 0;
	int tmp = ((1LL * fact[n] * re_fact[k])%mod * re_fact[n - k])%mod;
	return tmp;
}

int n;
int a[100002], pos[100002];    
int L, R;

int32_t main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	fact[0] = 1;
	for (int i=1;i<=100001;i++) fact[i] = (1LL * fact[i-1] * i)%mod;
	re_fact[100001] = p(fact[100001], mod - 2);
	for (int i=100001;i>=1;i--) re_fact[i-1] = (1LL* re_fact[i] * i)%mod;

	cin >> n;
	n++;
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
		if (pos[a[i]])
		{
			L = pos[a[i]] - 1;
			R = n - i;
		}
		pos[a[i]] = i;
	}	
	cout << n - 1 << '\n';
	for (int k=2;k<=n;k++)
	{
		int res = comb(k, n);
		res = ((res - comb(k - 1, L + R))%mod + mod)%mod;
		cout << res << '\n';
	}	
}

Measured memory_bytes: 2816
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int

void output(bool x) {
  if(x)cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main( ) {
  string s,t;
  cin >> s >> t;
  bool canMatch = false;
  for ( int i = 0; i < s.size() +  5; i++ ) {
    if( s == t ) canMatch = true;
    s = s[s.size() - 1] + s;
    s.pop_back();
  }
  output(canMatch);
  return 0;
}


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

int n, a[300000];

int main(){
  cin >> n;
  rep(i, n){
    cin >> a[i];
  }
  int right[300000], left[300000];
  int r = 0, l = 0;
  rep(i, n){
    if(i % 2 == 0){
      right[i/ 2] = a[i];
      r++;
    }else{
      left[i / 2] = a[i];
      l++;
    }
  }
  if(n % 2 == 0){
    for(int i = l - 1; i >= 0; i--){
      cout << left[i] << " ";
    }
    for(int i = 0; i < r; i++){
      cout << right[i] << " ";
    }
  }else{
    for(int i = r - 1; i >= 0; i--){
      cout << right[i] << " ";
    }
    for(int i = 0; i < l; i++){
      cout << left[i] << " ";
    }
  }
  cout << endl;
    
  
  return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,m;ll x[N],d[N],D[N];
int ans[N],now[N];
long long k;
void multiply(int *a,int *b,int *c){
	static int ans[N];
	for (int i=1;i<=n;i++) ans[i]=a[b[i]];
	for (int i=1;i<=n;i++) c[i]=ans[i];
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%lld",&x[i]);
		now[i]=ans[i]=i;
		d[i]=x[i]-x[i-1];
	}
	scanf("%d%lld",&m,&k);
	for (int i=1;i<=m;i++){
		int x;
		scanf("%d",&x);
		swap(now[x],now[x+1]);
	}
	for (;k;k>>=1,multiply(now,now,now))
		if (k&1) multiply(ans,now,ans);
	for (int i=1;i<=n;i++) D[i]=d[ans[i]];
	for (int i=1;i<=n;i++) x[i]=x[i-1]+D[i];
	for (int i=1;i<=n;i++) printf("%lld\n",x[i]);
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}
 
int main()
{
  boost
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif

  ll n;
  cin>>n;
  ll i=2;
  ll ans=0;
  ll prev=-1,lat=-1;
  ll t;
  
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    {
       t=i;
       prev=t;
       ll p=n;
       while(n%t==0)
       {
        n=n/t;
        t=t*i;
        ans++;
       }
       n=p;
       while(n%i==0)
        n=n/i;
       //cout<<n<<"\n";
    }
  }
  if(n!=1&&prev==-1)
   ans++;
  if(n!=1&prev!=n&&prev!=-1)
  {
    //cout<<"a";
    ans++;
}
cout<<ans;
}

Measured memory_bytes: 3652