akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    H, N = map(int, input().split())
    A = list(map(int, input().split()))

    if H > sum(A):
        print("No")
    else:
        print("Yes")


def main():
    solve()


if __name__ == '__main__':
    main()


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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


int h, w, a[501][501];
vector<P> v1, v2;

int main(){
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
			a[i][j] %= 2;
		}
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(!a[i][j]) continue;
			if(i < h-1 && a[i+1][j]){
				a[i][j] = 0;
				a[i+1][j] = 0;
				v1.push_back(make_pair(i,j));
				v2.push_back(make_pair(i+1,j));
			}
			else if(j < w-1 && a[i][j+1]){
				a[i][j] = 0;
				a[i][j+1] = 0;
				v1.push_back(make_pair(i,j));
				v2.push_back(make_pair(i,j+1));
			}
			else if(i < h-1){
				a[i][j] = 0;
				a[i+1][j] = 1;
				v1.push_back(make_pair(i,j));
				v2.push_back(make_pair(i+1,j));
			}
			else if(j < w-1){
				a[i][j] = 0;
				a[i][j+1] = 1;
				v1.push_back(make_pair(i,j));
				v2.push_back(make_pair(i,j+1));
			}
		}
	}
	
	cout << v1.size() << endl;
	for(int i = 0; i < v1.size(); i++){
		cout << v1[i].first+1 << " " << v1[i].second+1 << " " << v2[i].first+1 << " " << v2[i].second+1 << endl;
	}
	
	return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<'\n'
int n, m, k;
int main(void) {
	cin>>n>>m>>k;
	if (k<0 || k>n*m) {
		cout<<"No";
		return 0;
	}
	for (int i=0; i<=m; i++) {
		for (int j=0; j<=n; j++) {
			if (n*i+m*j-2*i*j==k) {
			//	debug(i);
			//	debug(j);
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000009
#define PII pair<int, int>

const ll N=55;
ll n,a[N],b[N];
bool dp[N][N];

void build(ll mask) {
    memset(dp,0,sizeof(dp));
    for (ll i=0;i<=50;i++) dp[i][i]=1;
    for (ll i=49;i>=0;i--) {
        if (mask&(1ll<<i)) {
            for (ll j=1;j<=50;j++) {
                dp[j][j%(i+1)]=1;
            }
        }
    }
    for (ll k=1;k<=50;k++) {
        for (ll i=1;i<=50;i++) {
            for (ll j=0;j<=50;j++) {
                if (k!=i&&k!=j&&i!=j) {
                    if (dp[i][k]&&dp[k][j]) dp[i][j]=1;
                }
            }
        }
    }
}

bool check() {
    for (ll i=1;i<=n;i++) {
        if (!dp[a[i]][b[i]]) return false;
    }
    return true;
}

int main()
{
    scanf("%lld",&n);
    for (ll i=1;i<=n;i++) scanf("%lld",a+i);
    for (ll i=1;i<=n;i++) scanf("%lld",b+i);
    ll ans=(1ll<<50)-1;
    build(ans);
    if (!check()) {
        printf("-1\n");
        return 0;
    }
    for (ll i=49;i>=0;i--) {
        ans^=(1ll<<i);
        build(ans);
        if (!check()) ans^=(1ll<<i);
    }
    printf("%lld\n",ans<<1);
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        double sum = 0;
        for (int i = 0; i < N; i++)
        {
            string[] str = Console.ReadLine().Split(' ');
            if (str[1] == "BTC")
                sum += double.Parse(str[0]) * 380000.0;
            else
                sum += double.Parse(str[0]);
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n, q, a, b;
 	cin >> n >> q;
 	set <pll> ver, hor;
 	ll far = n - 1;
 	ll below = n - 1;
 	ll ans = (n - 2) * (n - 2);
 	map <ll, ll> horset;
 	map <ll, ll> verset;
 	while (q--) {	
 		cin >> a >> b;
 		if (a == 2) {
 			if (sz(hor) > 0) {
 				auto it = hor.lower_bound({b, 1e18});
 				if (it == hor.begin()) {
 					hor.insert({b, far});
 					ans -= (far - 1);
 					horset[b] = 1;
 				}
 				else {
 					it--;
 					if (horset[b] == 0) {
 						horset[b] = 1;
 						ans -= ((*it).se - 1);
 					}
 				}
 			}
 			else {
 				hor.insert({b, far});
 				ans -= (far - 1);
				horset[b] = 1;
 			}
 		}
 		else {
 			if (sz(ver) > 0) {
 				auto it = ver.lower_bound({b, 1e18});
 				if (it == ver.begin()) {
 					ver.insert({b, below});
 					ans -= (below - 1);
 					verset[b] = 1;
 				}
 				else {
 					it--;
 					if (verset[b] == 0) {
 						verset[b] = 1;
 						ans -= ((*it).se - 1);
 					}
 				}
 			}
 			else {
 				ver.insert({b, below});
 				ans -= (below - 1);
				verset[b] = 1;
 			}
 		}
 		if (sz(ver) > 0)
	 		far = (*ver.begin()).fi - 1;
	 	if (sz(hor) > 0)
	 		below = (*hor.begin()).fi - 1;
 	}   	
 	cout << ans << endl;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    ll N,K; cin >> N >> K;
    VL A(N); REP(i,N) cin >> A[i];
    REP(i,N-K){
        if(A[i]<A[i+K]) cout << "Yes" << en;
        else cout << "No" << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 4784
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

namespace A {
static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }

   public static int[] readIntArr() {
      return ReadLine().Split(' ').Select(int.Parse).ToArray();
   }

   public static void Fill<T>(this List<T> a, T b) {
      for (var i = 0; i < a.Capacity; i++) {
         a.Add(b);
      }
   } 
}

class Program {
   public static void Main(string[] args) {
      var n = ReadLine().ToInt();
      var h = Extensions.readIntArr();

      var dp = new List<int>(n);
      dp.Fill(System.Int32.MaxValue); 
      dp[0] = 0;
      dp[1] = Math.Abs(h[0] - h[1]);

      for (var i = 2; i < n; i++) {
         dp[i] = Math.Min(
            dp[i - 2] + Math.Abs(h[i - 2] - h[i]),
            dp[i - 1] + Math.Abs(h[i - 1] - h[i])
         );
      }

      WriteLine(dp[n - 1]);
   }
}

}


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

using ll = long long;
constexpr ll M = 1e9+7;

// calc x
// ax %% 1 (mod M)
ll inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}

int main() {
    ll N, D, X;
    while(cin >> N >> D >> X, N) {
        vector<vector<ll>> dp(N+1, vector<ll>(N+1));
        dp[0][0] = 1;
        vector<vector<ll>> dp_sum(N+1, vector<ll>(N+1));
        fill(dp_sum[0].begin(), dp_sum[0].end(), 1);
        for(int i=1; i<=N; ++i) {
            for(int j=i; j<=N; ++j) {
                if(j-X >= 0) {
                    dp[i][j] = (dp_sum[i-1][j-1] - dp_sum[i-1][j-X] + M) % M;
                } else {
                    dp[i][j] = dp_sum[i-1][j-1];
                }
            }
            for(int j=1; j<=N; ++j) {
                dp_sum[i][j] = (dp_sum[i][j-1] + dp[i][j]) % M;
            }
        }
        ll res = 0;
        ll cmb = 1;
        for(int i=1; i<=min(N, D); ++i) {
            cmb = (cmb * ((D-i+1) % M)) % M;
            cmb = (cmb * inv(i, M)) % M;
            res = (res + dp[i][N] * cmb) % M;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 65604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int ans[101][101];
vector<int> g[10001];
bool used[10001];
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int main(){
    int n,ai,bi;
    cin>>n;
    int m=2*n*n-2*n;
    rep(i,m){
        cin>>ai>>bi;
        --ai,--bi;
        g[ai].pb(bi);
        g[bi].pb(ai);
    }
    int cur=0;
    rep(i,m){
        if(g[i].size()==2){
            cur=i;break;
        }
    }
    int tx=0,ty=0,id=0;
    while(1){
        ans[ty][tx]=cur+1;
        used[cur]=true;
        ty=ty+dy[id],tx=tx+dx[id];
        rep(i,g[cur].size()){
            if(g[g[cur][i]].size()==2&&!used[g[cur][i]]){
                cur=g[cur][i];
                ++id;
                break;
            }
            else if(g[g[cur][i]].size()==3&&!used[g[cur][i]]){
                cur=g[cur][i];break;
            }
        }
        if(tx==0&&ty==0) break;
    }
    FOR(i,1,n-1)FOR(j,1,n-1){
        int t1=ans[i-1][j]-1,t2=ans[i][j-1]-1;
        map<int,int> mp;
        rep(k,g[t1].size()) ++mp[g[t1][k]];
        rep(k,g[t2].size()) ++mp[g[t2][k]];
        for(auto it:mp)if(it.second==2&&!used[it.first]){
            ans[i][j]=it.first+1;used[it.first]=true;
            break;
        }
    }
    rep(i,n){
        rep(j,n) cout<<ans[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3764
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int h, w;
vector<int> a;
ll d[400][400];
void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        if(d[i][k]==INF||d[k][i]==INF)continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h>>w;
    vector<string> s;
    for(int i=0;i<h*w;i++){
        for(int j=0;j<h*w;j++){
            d[i][j]=INF;
            if(i==j)d[i][j]=0;
        }
    }
    for (int i = 0; i < h; i++)
    {
        string temp;
        cin >> temp;
        s.push_back(temp);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                d[i*h+j][i*h+j]=INF;
                continue;}
            for(int k=0;k<4;k++){
                if(i+dx[k]<0||j+dy[k]<0||i+dx[k]>=h||j+dy[k]>=w)continue;
                if(s[i+dx[k]][j+dy[k]]=='.'){
                d[i*w+j][(i+dx[k])*w+j+dy[k]]=1;
                d[(i+dx[k])*w+j+dy[k]][i*w+j]=1;
                }
            }
        }
    }
    /*
    for(int i=0;i<h*w;i++){
        for(int j=0;j<h*w;j++){
            cout<<d[i][j]<<" ";
        }
        cout<<"\n";
    }
    */
    warshall_floyd(h*w);
    ll ans=0;
    /*
    for(int i=0;i<h*w;i++){
        for(int j=0;j<h*w;j++){
            cout<<d[i][j]<<" ";
        }
        cout<<"\n";
    }
    */
    for(int i=0;i<400;i++){
        for(int j=0;j<400;j++){
            if(d[i][j]>450)continue;
            ans=max(d[i][j],ans);
        }
    }

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



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define LEN(x) ((int)(x).length())
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &value) {
    std::fill((T *)array, (T *)(array + N), value);
}
#define PUTS(x) cout << (x) << endl;

const int MAX = 5100000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    auto ans = COM(c + d + 2, d + 1);
    ans += MOD - COM(a + d + 1, d + 1);
    ans %= MOD;
    ans += MOD - COM(b + c + 1, b);
    ans %= MOD;
    ans += COM(a + b, b);
    ans %= MOD;
    PUTS(ans);
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n), yui(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
        yui[data[i]-1] = i;
    }

//    rep(i, n) cout << yui[i] << " "; cout << endl;

    int ans = 1, pos = yui[0], tmp = 1;
    Rep(i, n) {
        if (pos < yui[i]) {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 1;
        }
        pos = yui[i];
    }
    ans = max(ans, tmp);

    cout << n - ans << endl;

    return 0;
}







Measured memory_bytes: 3456
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double d = scan.nextDouble();
		double v = (d/3)*(d/3)*(d/3);
		System.out.println(BigDecimal.valueOf(v).toPlainString());
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int N;
	cin >> N;
	int n = N;
	int add = 0;


	while (n > 0) {
		add += n % 10;
		n /= 10;
	}

	if (N%add == 0) cout << "Yes";
	else cout << "No";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n;cin>>n;
	vector<ll> l;
	rep(i,0,n-1){
	    ll x;cin>>x;
	    l.push_back(x);
	}
	sort(all(l));
	ll ans = 0;
	for(int i = n-1; 2<=i;--i){
	    for(int j = i-1;1<=j;--j){
	        ll x = l.end()-upper_bound(all(l),l[i]-l[j]);
	        ans += max(x - (n-j),0LL);
	    }
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
//#define int long long
#define INF 10000000
using namespace std;
//m=109 c=99 x=120 i=105
bool check(char x){
    for(int i=48; i<=57; i++){
        if(x == i) return true;
    }
    return false;
}
int main(){
    int n;
    cin >> n;
    rep(i,n){
        string a,b;
        cin >> a >> b;
        int flag = 1;
        int tmp,sum = 0;
        rep(j,a.size()){
            if(check((int)a[j])) flag = a[j]-'0';
            else {
                if(a[j] == 'm') tmp = 1000;
                else if(a[j] == 'c') tmp = 100;
                else if(a[j] == 'x') tmp = 10;
                else if(a[j] == 'i') tmp = 1;
                sum += tmp*flag;
                flag = 1;
            } 
        }
        rep(j,b.size()){
            if(check(b[j])) flag = b[j]-'0';
            else {
                if(b[j] == 'm') tmp = 1000;
                else if(b[j] == 'c') tmp = 100;
                else if(b[j] == 'x') tmp = 10;
                else if(b[j] == 'i') tmp = 1;
                sum += tmp*flag;
                flag = 1;
            }
        }
        //cout << sum << endl;
        if(sum/1000 !=0) {
            if(sum/1000 == 1) cout << 'm';
            else cout << sum/1000 << 'm';
            sum -= 1000*(sum/1000);
        }
        if(sum/100 !=0) {
            if(sum/100 == 1) cout << 'c';
            else cout << sum/100 << 'c';
            sum -= 100*(sum/100);
        }
        if(sum/10 !=0) {
            if(sum/10 == 1) cout << 'x';
            else cout << sum/10 << 'x';
            sum -= 10*(sum/10);
        }
        if(sum/1 !=0) {
            if(sum/1 == 1) cout << 'i';
            else cout << sum/1 << 'i';
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<vector<int>> ans[11];
set<string> se;

void solve(){
    cin >> n;
    ans[0].push_back(vector<int>());
    rep(i,n){
        for(vector<int> v:ans[i]){
            int ma=-1;
            for(int t:v){
                ma=max(ma,t);
            }
            rep(k,ma+2){
                vector<int> v_=v;
                v_.push_back(k);
                ans[i+1].push_back(v_);
            }
        }
    }
    //cout << "a" << endl;
    for(vector<int> v:ans[n]){
        string s="";
        rep(i,n){
            s+=v[i]+'a';
        }
        se.insert(s);
    }
    //cout << se.size() << endl;
    for(string s:se){
        cout << s << endl;
    }
    //cout << se.size() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 24240
#include<iostream>
#include<string.h>
using namespace std;

int m,n,w,h;
char b[102][102];
bool v[102][102];

void dfs(int y,int x){
    if(v[y][x]){
        cout<<"LOOP"<<endl;
        return;
    }
    v[y][x]=1;
    switch(b[y][x]){
        case '>':
            dfs(y,x+1);
            break;
        case 'v':
            dfs(y+1,x);
            break;
        case '<':
            dfs(y,x-1);
            break;
        case '^':
            dfs(y-1,x);
            break;
        default:
            cout<<x<<" "<<y<<endl;
    }
}

int main(){
    while(cin>>h>>w,w||h){
        for(int i=0;i<h;i++)
            cin>>b[i];
        memset(v,0,sizeof(v));
        dfs(0,0);
    }
}

Measured memory_bytes: 1192
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }

}



Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    char s[3];
    cin >> s;
    set<char> si;
    si.insert(s[0]);
    si.insert(s[1]);
    si.insert(s[2]);
    if(si.size() == 3) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << a * b - (a / c)*(b / d)*c*d << endl;
}


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

const int N=2e5+5;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
       ll n;
       cin>>n;
       int curr;
       string s="";
       while(n>0)
       {
           n--;
           curr=n%26;
           s=char('a'+curr)+s;
           n=n/26;
       }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    number = int(input())
    numbers=list(map(int,input().split()))
    sort_finished=0
    swap_count=0
    for idx in range(number-1):
        for sort_check_idx in reversed(range(number)[sort_finished+1:]):
            if numbers[sort_check_idx] < numbers[sort_check_idx-1]:
                numbers[sort_check_idx], numbers[sort_check_idx-1] = numbers[sort_check_idx-1], numbers[sort_check_idx]
                swap_count+=1
        sort_finished += 1
    print(*numbers)
    print(swap_count)

if __name__=="__main__":
    main()


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

int n, m, k;

const int maxn = 400005;
const long long mod = 998244353;
long long pre[maxn];
long long inv[maxn];
long long prei[maxn];
void build(int n){
    pre[1] = pre[0] = 1, inv[1] = inv[0] = 1, prei[1] = prei[0] = 1;
    for(int i = 2 ; i <= n ; i++){
        pre[i] = pre[i-1] * i % mod;
        inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
        prei[i] = prei[i-1] * inv[i] % mod;
    }
}
long long C(int n, int k){
   return pre[n] * prei[k] % mod * prei[n-k] % mod;
}
long long pm(int n,int p){
    long long ret = 1;
    long long now = n;
    while(p){
        if(p & 1){
            ret *= now;
            ret %= mod;
        }
        now *= now;
        now %= mod;
        p >>= 1;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    build(n);
    long long ans = 0;
    for (int i = 0; i <= k; i++){
        ans += pm(m-1, n-i-1) * m % mod * C(n-1, n-i-1) % mod;
        ans %= mod;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 8284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define vi vector<int>
#define vl vector<long long>
#define fio  cin.tie(nullptr); ios::sync_with_stdio(false); cout.tie(nullptr);
 
int main()
{
    fio;
    ll a,v,b,w;
    cin>>a>>v>>b>>w;
    ll t;cin>>t;
    if(w>v)
    cout<<"NO"<<endl;
    else if(abs(a-b) > (v-w)*t) 
    {
        cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;

    
    return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>

int edge[50][50];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    edge[a][b] = 1;
    edge[b][a] = 1;
  }

  int ans = 0;
  int visit[50];
  std::queue<int> q;
  for (int i = 0; i < n - 1; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      if (edge[i][j] == 0) continue;
      edge[i][j] = 0;
      edge[j][i] = 0;

      std::fill(visit, visit + n, 0);
      visit[0] = 1;
      q.emplace(0);
      while (q.size() > 0)
      {
        int cur = q.front();
        q.pop();
        for (int k = 0; k < n; ++k)
        {
          if (edge[cur][k] == 0) continue;
          if (visit[k] != 0) continue;
          visit[k] = 1;
          q.emplace(k);
        }
      }
      edge[i][j] = 1;
      edge[j][i] = 1;
      if (std::accumulate(visit, visit + n, 0) != n)
      {
        ++ans;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
ll a,b,c,d,ans;
int main(){
	SF("%lld%lld%lld%lld",&a,&b,&c,&d);
	ans=a*c;
	ans=max(ans,b*c);
	ans=max(ans,a*d);
	ans=max(ans,b*d);
	PF("%lld",ans);
}

Measured memory_bytes: 1736
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long INT;
double PI = 3.14159265;

const long long INF = 1LL << 60;
//---//


int main() {
    int s, w;

    cin >> s >> w;

    if(w>=s)cout <<"unsafe" <<endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
string s[300];
bool exist[300];
int a[300][300];
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		cin >> s[i];
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') exist[i] = 1;
		}
	}
	int k = 1;
	for (int i = 0; i < H; i++) {
		if (!exist[i]) continue;
		for (int j = 0; j < W; j++) {
			a[i][j] = k;
			if (s[i][j] == '#') k++;
		}
		for (int j = 0; j < W; j++) {
			if (a[i][j] == k) a[i][j]--;
		}
		for (int y = i - 1; y >= 0; y--) {
			if (exist[y]) break;
			for (int x = 0; x < W; x++) a[y][x] = a[i][x];
		}
		for (int y = i + 1; y < H; y++) {
			if (exist[y]) break;
			for (int x = 0; x < W; x++) a[y][x] = a[i][x];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cout << a[i][j] << " ";
		cout << endl;
	}
}


Measured memory_bytes: 1280
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

if (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[1][0] in b) and (A[1][1] in b) and (A[1][2] in b) or \
    (A[2][0] in b) and (A[2][1] in b) and (A[2][2] in b) or \
    (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[0][0] in b) and (A[1][0] in b) and (A[2][0] in b) or \
    (A[0][1] in b) and (A[1][1] in b) and (A[2][1] in b) or \
    (A[0][2] in b) and (A[1][2] in b) and (A[2][2] in b) or \
    (A[0][0] in b) and (A[1][1] in b) and (A[2][2] in b) or \
    (A[0][2] in b) and (A[1][1] in b) and (A[2][0] in b):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
l=[[(0..9).to_a,[0]]]
a=[[0]]
10.times{|i|
r=[]
a<<l.flat_map{|m,s|
m.flat_map{|n|
q=n*(i+1)
(r.assoc(u=m-[n])||(r<<[u,[]])[-1])[1]+=(b=s.map{|j|j+q})
b
}
}
l=r
}
$<.map{|l|c,d=l.split.map &:to_i
p a[c].count(d)
}

Measured memory_bytes: 220948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll m, k;
    cin >> m >> k;
    if (k == 0) {
        rrep(i, 1 << m) printf("%lld ", i);
        rep(i, 1 << m) printf("%lld%s", i, (i == ((1 << m) - 1)) ? "\n" : " ");
        return 0;
    }
    ll xv = 0;
    rep(i, 1 << m) {
        if (i != k) xv ^= i;
    }
    if (xv != k) {
        cout << -1 << endl;
        return 0;
    }
    vector<ll> ans(1 << (m + 1));
    ll idx = 0;
    rep(i, 1 << m) {
        if (i != k) ans[idx++] = i;
    }
    ans[idx++] = k;
    rrep(i, 1 << m) {
        if (i != k) ans[idx++] = i;
    }
    ans[idx++] = k;
    rep(i, sz(ans)) printf("%lld%s", ans[i], (i == (sz(ans) - 1)) ? "\n" : " ");
    return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

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

const int maxl = 1100000;
int t[maxl][26], w[maxl], term[maxl], par[maxl];
int sum[maxl][26];
int tc = 2;

int gett(int v, char c) {
    if (!t[v][c - 'a']) {
        t[v][c - 'a'] = tc++;
        par[t[v][c - 'a']] = v;
    }
    return t[v][c - 'a'];
}

void add(const string &s, int v = 1, int i = 0) {
    if (i == s.size()) {
        term[v] = 1;
        ++w[v];
        return;
    }
    int u = gett(v, s[i]);
    add(s, u, i + 1);
    ++w[v];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    forn(i, n) {
        string s;
        cin >> s;
        reverse(all(s));
        add(s);
    }

    i64 ans = 0;

    for (int v = tc - 1; v >= 1; --v) {
        forn(c, 26) {
            int u = t[v][c];
            if (!u) continue;
            forn(cc, 26) sum[v][cc] += c == cc ? w[u] : sum[u][cc];
        }
    }

    for1(v, tc - 1) {
        if (!term[v]) continue;
        int u = par[v];
        int c = find(t[u], t[u] + 26, v) - t[u];
        ans += sum[u][c] - 1;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 227248
N,*A = map(int,open(0).read().split())

m =1
ans = 0
#for a in A:
#  m *=a
#m-=1
#
#for a in A:
#  ans+=m%a
#  pass
#print(ans)

for a in A:
  ans += a-1
print(ans)

Measured memory_bytes: 9332
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split()
    n = int(token[0])
    d = int(token[1])

    return (n, d)


def solve(n, d):

    r = n // (2 * d + 1)
    if n % (2 * d + 1) == 0:
        return r
    else:
        return r + 1




def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int[][] a = new int[n][3];
                for(int i = 0 ; i < n ; i++){
                        for(int j = 0 ; j < 3 ; j++){
                                a[i][j] = sc.nextInt();
                        }
                }
                sc.close();
                int[][] q = new int[n][3];
                for(int i = 0 ; i < 3 ; i++){
                        q[0][i] = a[0][i];
                }
                for(int i = 1 ; i < n ; i++){
                        q[i][0] = Math.max(q[i - 1][1] , q[i - 1][2]) + a[i][0];
                        q[i][1] = Math.max(q[i - 1][2] , q[i - 1][0]) + a[i][1];
                        q[i][2] = Math.max(q[i - 1][0] , q[i - 1][1]) + a[i][2];
                }
                Arrays.sort(q[n - 1]);
                System.out.println(q[n - 1][2]);
        }
}

Measured memory_bytes: 64228
N = input()
ans="bon"
if int(N[-1])==2 or int(N[-1])==4 or int(N[-1])==5 or int(N[-1])==7 or int(N[-1])==9:
  ans = "hon"
elif int(N[-1])==0 or int(N[-1])==1 or int(N[-1])==6 or int(N[-1])==8:
  ans="pon"
print(ans)

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

typedef pair<int,int> P;

int main(){
  int h, w;
  P t[1000];

  while(cin >> h >> w, h || w){
    for(int i = 0; i < w; i++){
      t[i] = P(0, i + 1);
    }

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        int x;
        cin >> x;
        t[j].first -= x;
      }
    }
    sort(t, t + w);

    for(int i = 0; i < w; i++){
      if(i != 0) cout << " ";
      cout << t[i].second;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1172
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        FastReader in = new FastReader();
        FastWriter out = new FastWriter();
        long n = in.nextLong();
        double d = in.nextDouble();
        long x, y;
        int ans = 0;
        for (int i = 0; i < n; i++){
            x = in.nextLong();
            y = in.nextLong();
            long a = x*x, b = y*y;
            double c = Math.sqrt(a+b);
            if (c<=d){
                ans++;
            }
        }
        out.pl(ans);
        out.close();
    }
}
class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}
class FastWriter{
    PrintWriter out;
    FastWriter(){
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	out.flush();
    }
    void pl(Object o){
        out.write(o.toString());
	    out.write("\n");
        out.flush();
    }
    void pl(){
        out.write("\n");
    }
    void p(Object o){
        out.write(o.toString());
    }
    void close(){
        out.flush();
        out.close();
    }  
}


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

using namespace std;
typedef long long ll;
ll mod = 1e9+7;

ll modpaw(ll a,ll b,ll mod){
    ll res = 1;
    while(b){
        if(b&1)res = res * a %mod;        
        a = a* a %mod;
        b=b>>1;
    }
    return res;
}

//infは条件事に設定しておく. 
ll inf = 2e5+10;
vector<ll> fac(inf);
vector<ll> facu(inf);

//階乗の計算 O(N)
void modfac(){
    fac[0] = 1;
    for(ll i=1;i<inf;i++){
      fac[i] = (fac[i-1]*i)%mod;  
    }
}

void modfacu(int N){
    facu[0] = N;
    for(ll i=1;i<inf;i++){
      facu[i] = (facu[i-1]*(N-i))%mod;  
    }
}

//modの逆元の計算
ll modinv(ll a){
    ll b = mod, u=1,v=0;
    while(b){
        ll t = a/b;
        a -= t*b; swap(a,b);
        u -= t*v; swap(u,v);
    }
    u %= mod;
    if(u<0) u+= mod;
    return u;
}


int main(void)
{
  ll N,A,B;cin>>N>>A>>B;
  modfac();
  modfacu(N);
    ll Acomb = facu[A-1]*modinv(fac[A]) %mod;
  ll Bcomb = facu[B-1]*modinv(fac[B]) %mod;
  ll res = (modpaw(2,N,mod)-Acomb-Bcomb)%mod;
  res--;
  if(res<0)res+=mod;
  cout<<res<<endl;
}

Measured memory_bytes: 3328
#include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cstdlib>
    #include<cctype>
    #include<ctime>
    #include<iostream>
    #include<string>
    #include<map>
    #include<queue>
    #include<stack>
    #include<set>
    #include<vector>
    #include<iomanip>
    #include<list>
    #include<bitset>
    #include<sstream>
    #include<fstream>
    #include<complex>
    #include<algorithm>
    #if __cplusplus >= 201103L
    #include <unordered_map>
    #include <unordered_set>
    #endif
    #define ll long long
    using namespace std;
    const int INF = 0x3f3f3f3f;
    int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll t;
    if(n==1) {cout<<1<<endl;return 0;}
    for(ll i=1;i<=100;i++){
    if((1ll<<i)>n) {t=i;break;}
    }
    t--;
    ll sum=(1ll<<t)-1;
    //cout<<sum<<endl;
    cout<<sum+(1ll<<t)<<endl;
    return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define sf(i,s) for(i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define inf INT_MAX
#define pb push_back
#define mp make_pair
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    else
    {
        ll t=power(a,b/2);
        if(b%2==0)
        return ((t%mod)*(t%mod))%mod;
        else
        return ((((t%mod)*(t%mod))%mod)*((a%mod)%mod))%mod;
    }
}
void solve()
{
 ll n,ans,i,j;
 cin>>n;
 ll a[n+1][3],dp[n+1][3];
 f(i,0,n)
 {
     f(j,0,3)
     cin>>a[i][j];
 }
 dp[0][0]=a[0][0];
 dp[0][1]=a[0][1];
 dp[0][2]=a[0][2];
 f(i,1,n)
 {
     dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
     dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
     dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
 }
 ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
 cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 8296
A, B, C, K = map(int, input().split())

# A:1
# B:0
# C:-1
# K枚

def solve():
    sum = 0
    if A >= K:
        sum += K
        return sum
    else:
        sum += A

    if A + B >= K:
        return sum
    else:
        sum -= K - A - B
    
    return sum

print(solve())


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    ll n;
    cin>>n;
    ll arr[n];
    rep0(i,n) cin>>arr[i];
    int wh=-1;
    rep0(i,n){
        if(arr[i]==1){
            wh=i;
            break;
        }
    }
    if(wh<0){
        cout<<wh;
        return;
    }
    int xx=2;
    int x=wh+1;
    while(x<n){
        if(arr[x]==xx) xx++;
        x++;
    }
    cout<<(n-xx+1);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

const int N = 1e6+6;

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

    long long a,b;
    cin>>a>>b;
    long long ans = a*b;
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e6+10;
char p[maxn];
int n,Q;
char s[maxn];
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s+1;
	n=strlen(s+1);
	int l=200000,r=199999;
	for(int i=1;i<=n;i++) p[++r]=s[i];
	int o=0;
	cin>>Q;
	while(Q--){
		int t,f;
		char c;
		cin>>t;
		if(t==1) o^=1;
		else{
			cin>>f>>c;
			--f;
			if(o^f==0) p[--l]=c;
			else p[++r]=c;
		}
	}
	if(o==1){
		for(int i=r;i>=l;i--) cout<<p[i];
	}else{
		for(int i=l;i<=r;i++) cout<<p[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll a[1001], b[1001], c[1001], d[1000001];
int x, y, z, k;
int p, q;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> x >> y >> z >> k;
    for (int i = 0; i < x; ++i)
        cin >> a[i];
    for (int i = 0; i < y; ++i)
        cin >> b[i];
    for (int i = 0; i < z; ++i)
        cin >> c[i];

    for (int i = 0; i < x; ++i)
        for (int j = 0; j < y; ++j)
            d[i * y + j] = a[i] + b[j];

    sort(c, c + z, greater<ll>());
    sort(d, d + (x * y), greater<ll>());

    vector<ll> sol;
    for (int i = 0; i < min(k, x * y); ++i)
        for (int j = 0; j < z; ++j)
            sol.push_back(d[i] + c[j]);

    sort(all(sol), greater<ll>());
    for (int i = 0; i < k; ++i)
        cout << sol[i] << '\n';
}


Measured memory_bytes: 42980
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  //vector<int> dp(n+1,-1);
  int last=0;int res=0;
  rep(i,n){
    if(a[i]==last+1)last++;
    a[i]--;
    res+=a[i]/(last+1);
    if(i==0)last=1;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1024