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

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

using ll = long long;

inline ll sum(ll a, ll b){
    return (a+b)*(b-a+1)/2;
}

int main(){
    int b;
    while(cin >> b, b){
        int x = 1;
        int y;
        {
            int ok = 0;
            int ng = b;
            while(ng-ok > 1){
                int m = (ok+ng)/2;

                //cout << "> " << ok << " " << ng << "  : " << m << "  : " << sum(1, m)  << endl;
                if(sum(1, m) > b){
                    ng = m;
                }else{
                    ok = m;
                }
            }
            y = ok;
        }
        int v = sum(x,y);
        for(;;){
            //cout << "# " << x << " " << y << "  : " << v << endl;
            if(v < b){
                while(v < b){
                    ++y;
                    v+=y;
                }
            } else if(v > b){
                while(v > b){
                    v-=y;
                    --y;
                }
            }
            if(v == b){
                cout << x << " " << y-x+1 << endl;
                break;
            }
            v-=x;
            ++x;


        }
    }
}


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

int main(){
    int i,n,x;
    cin >> n;
    for(i = 1;i <= n;i++){
        x = i;
        if(x % 3 == 0){
            cout << " " << i;
        }
        else{
            while(x){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}void _p() {cout << "]\n";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=========================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,t;








void sol()
{   
    cin>>n;
    in(a,n);
    int sm=0;
    
    mii m;
    for(auto c:a){m[c]++;sm+=c;}
    cin>>t;
    while (t--)
    {
        cin>>x>>y;
        sm+=(y-x)*m[x];
        cout<<sm<<endl;
        m[y]+=m[x];
        m[x]=0;
    }
    
    
    
    
    
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 10048
# from itertools import product, takewhile
def calc_min_path(current_c, next_c):
    x = abs(current_c[1]-next_c[1])
    y = abs(current_c[2]-next_c[2])
    return x+y


def is_movable(current_c, next_c):
    move_count = next_c[0] - current_c[0]
    min_path = calc_min_path(current_c, next_c)
    if move_count == min_path:
        return True
    if move_count < min_path:
        return False
    if move_count > min_path:
        must_move_count = move_count-min_path
        if must_move_count % 2 == 0:
            return True
        else:
            return False


def main():
    N = int(input())
    coordinate = [[int(x) for x in input().split(" ")] for _ in range(N)]
    coordinate.insert(0, [0, 0, 0])

    for i in range(N):
        if not is_movable(coordinate[i], coordinate[i+1]):
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 25512
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int arr[3005];
int dp[3005][3005];
int jiro;
int solve(int i,int j){

if(i>j)
return 0;
	
	if(dp[i][j]!=-1)
		return dp[i][j];

	int op1 = arr[i] + min(solve(i+2,j),solve(i+1,j-1));	
	int op2 = arr[j] + min(solve(i+1,j-1),solve(i,j-2));

	int ans = max(op1,op2);
	if(ans == op1)
		jiro = solve(i+1,j);
	else 
		jiro = solve(i,j-1);

return dp[i][j] = ans;

}

int32_t main(){
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	jiro = 0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			dp[i][j]=-1;

	cout<<solve(1,n)-jiro<<endl;
	//cout<<jiro<<endl;


}

Measured memory_bytes: 74148
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int q; cin >> q;
    vector<int> vec;
    for(int i = 0; i < q; ++i){
        int x; cin >> x;
        if(x == 2) vec.pop_back();
        else if(x == 1){
            int y; cin >> y;
            cout << vec[y] << endl;
        }
        else if(x == 0){
            int y; cin >> y;
            vec.push_back(y);
        }
    }
    return 0;
}


Measured memory_bytes: 3896
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(){
  long long N,ans;
  cin>>N;
  for(int i=1;i<=sqrt(N);i++){
    if(N%i!=0) continue;
    ans=log10(N/i)+1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

int main() {

    int h, w; cin >> h >> w;
    vector<vector<char>> v(h, vector<char>(w));

    vector<int> h_vec;
    vector<int> w_vec;

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> v.at(i).at(j);
            if (v.at(i).at(j)=='#') {
                h_vec.push_back(i);
                w_vec.push_back(j);
            }
        }
    }

    sort(h_vec.begin(), h_vec.end());
    h_vec.erase(unique(h_vec.begin(), h_vec.end()), h_vec.end());
    sort(w_vec.begin(), w_vec.end());
    w_vec.erase(unique(w_vec.begin(), w_vec.end()), w_vec.end());

    for (int i=0;i<(int)h_vec.size();i++) {
        for (int j=0;j<(int)w_vec.size();j++) {
            cout << v.at(h_vec[i]).at(w_vec[j]);
        }
        cout << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
double a,b,x;
double f(double d){
  if(a*tan(d)<=b){
    return a*a*b-a*a*a*tan(d)/2;
  }
  else{
    return a*b*b/tan(d)/2;
  }
}
int main(){
  cin >> a >> b >> x;
  double l=0,r=M_PI/2;
  for(int i=0;i<1000000;i++){
    double mid=(l+r)/2;
    if(f(mid)<x){
      r=mid;
    }
    else{
      l=mid;
    }
  }
  cout << fixed << setprecision(15) << l*180/M_PI << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
using namespace std;
int main(){
    int r;
    scanf("%d",&r);
    printf("%d",r*r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	ll a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}


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

  vector <int> a(n);
  rep(i,n) {
    a[i] = l+i;
  }
  
  int s = 0;
  rep(i,n) s+= a[i];
  int ans = 1e9;
  rep(i,n) {
    int t = s-a[i];
    if (abs(t-s) < abs(ans-s)) ans = t;
  }
  
  cout << ans << endl;
  return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, x;
  cin >> N >> x;
  vec a(2020);
  for (int i = 0; i < N; i++) cin >> a[i];

  int ans = INF;
  static int m[2020][2020]; //m[k][N];  m[k+1][i]=min(m[k][i],a[i-k]);
  for (int i = 0; i < N; i++) {
    m[0][i] = a[i];
  }
  for (int k = 0; k < N; k++) {

    int sum = k * x;
    for (int i = 0; i < N; i++) {

      if (k != 0) {
        if (i - k >= 0) {
          m[k][i] = min(m[k - 1][i], a[i - k]);
        } else {
          m[k][i] = min(m[k - 1][i], a[N + i - k]);
        }
      }

      sum += m[k][i];
    }

    chmin(ans, sum);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <math.h>

using namespace std;
 
int main(){
  string s;
  char a,b,c,d;
  cin>>s;
  if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){cout<<"Yes"<<endl;}
  else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){cout<<"Yes"<<endl;}
  else if(s[0]==s[3] && s[2]==s[1] && s[0]!=s[2]){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,Q = II()
a = [0]*(N-1)
b = [0]*(N-1)
p = [0]*Q
x = [0]*Q

for i in range(N-1):
    a1,b1 = II()
    a[i] = a1-1
    b[i] = b1-1

for i in range(Q):
    p1,x1 = II()
    p[i] = p1-1
    x[i] = x1


parent = defaultdict(list)
for i in range(N-1):
    parent[b[i]].append(a[i])

val = [0]*N
for i in range(Q):
    val[p[i]] += x[i]

for i in range(1,N):
    val[i] += val[parent[i][0]]

print(*val)

Measured memory_bytes: 100056
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
const int mod = 1e9+7;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> s(n);
    s = a;
    ll ans = 0;
    for(int i = 1; i < n; ++i){
        s[i] += s[i-1];
        s[i]%=mod;
    }

    rep(i,n-1) {
        int j = s[n-1]-s[i];
        if(j<0) j+=mod;
        ll x = a[i]*j%mod;
        ans+=x;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
typedef long long ll;
int n,m;

int main(){
    string s;
    cin>>s;
    if(s[s.length()-1]=='s') s+="es";
    else s+="s";
    cout<<s<<endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	int N, M;
	int num[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
	int A[9];

	cin >> N >> M;

	for (auto i = 0; i < M; ++i)
	{
		cin >> A[i];
	}

	vector<int> dp(10001);
	dp[0] = 0;
	for (auto i = 1; i <= N; ++i)
	{
		dp[i] = INT_MIN;
		for (auto j = 0; j < M; ++j)
		{
			if (i >= num[A[j]])
			{
				dp[i] = max(dp[i - num[A[j]]] + 1, dp[i]);
			}
		}
	}
	sort(A, A + M, greater<int>());
	auto index = N;
	string str;
	for (auto i = 0; i < dp[N]; ++i)
	{
		for (auto j = 0; j < M; ++j)
		{
			auto n = num[A[j]];
			if (index >= n && dp[index - n] == dp[index] - 1)
			{
				index -= n;
				str += A[j] + '0';
				break;
			}
		}
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 256
// AOJ 2002: X-Ray Screening System
// 2017.11.23 bal4u@uu

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

char m[51][52];
char tbl['Z'+1]; int sz;
int  rmin[7], rmax[7], cmin[7], cmax[7];
char f[7];

int rec(int k)
{
	int i, r, c, ii;
	char tmp[51][52];

	if (k == sz) return 1;
	for (ii = 1, i = 0; i < sz; i++, ii <<= 1) {
		if (f[i]) continue;
		f[i] = 1;
		for (r = rmin[i]; r <= rmax[i]; r++) for (c = cmin[i]; c <= cmax[i]; c++) {
			if (!(m[r][c] & ii)) goto next;
		}
		memcpy(tmp, m, sizeof(tmp));
		for (r = rmin[i]; r <= rmax[i]; r++) for (c = cmin[i]; c <= cmax[i]; c++) {
			m[r][c] = 0xff;
		}
		if (rec(k+1)) return 1;
		memcpy(m, tmp, sizeof(tmp));
next:	f[i] = 0;
	}
	return 0;
}

int main()
{
	int T, H, W, r, c, i, a;

	scanf("%d", &T);
	while (T--) {
		sz = 0, memset(tbl, -1, sizeof(tbl));
		for (i = 0; i < 7; i++) rmin[i] = cmin[i] = 50, rmax[i] = cmax[i] = 0, 
		scanf("%d%d", &H, &W);
		for (r = 0; r < H; r++) {
			scanf("%s", m[r]);
			for (c = 0; c < W; c++) {
				if (m[r][c] == '.') m[r][c] = 0;
				else {
					a = m[r][c];
					if ((i = tbl[a]) < 0) i = tbl[a] = sz++;
					m[r][c] = 1 << i;
					if (rmin[i] > r) rmin[i] = r;
					if (rmax[i] < r) rmax[i] = r;
					if (cmin[i] > c) cmin[i] = c;
					if (cmax[i] < c) cmax[i] = c;
				}
			}
		}
		memset(f, 0, sz);
		puts(rec(0) ? "SAFE" : "SUSPICIOUS");
	}
	return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) std::cerr<<#x<<":"<<(x)<<std::endl;
#define INIT ios::sync_with_stdio(false);cin.tie(0);

signed main() {
  INIT;
  int n;cin>>n;
  vector< pair<int,int> > a(n);
  for(int i=0;i<n;++i) {
    int p;cin>>p;
    a[i] = make_pair(p,i);
  }

  sort(a.begin(), a.end());
  for(int i=0;i<n;++i){
    if(i>0) cout<<" ";
    cout<<a[i].second+1;
  }
  cout<<endl;
  return 0;
}


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

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

	sort( p.begin(), p.end() );
	int ans = 0;
	for( int i = 0; i < K; i++ ) {
		ans += p[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using ll = long long;
using P = std::pair<ll, ll>;


#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(),i.end()
#define debug(i) std::cout << i << "\n"



const int INF = 100000000;
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;
    if(y%2){
        return (x*pow_mod(x,y-1,mod))%mod;
    }else{
        return pow_mod(x*x,y/2,mod);
    }
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
    ll n,cnt=0;
    std::cin >> n;
    std::vector<int> a(n),b(n,0);
    rep(i,0,n){
        std::cin >> a[i];
    }
    for (int i = n; i > 0;i--){
        ll temp = 0;
        for (int j = i; j <= n;j+=i){
            temp += b[j - 1];
            temp %= 2;
        }
        if(temp^a[i-1]){
            b[i - 1] = 1;
            cnt++;
        }else{
            b[i - 1] = 0;
        }
    }
    std::cout << cnt << "\n";
    rep(i,0,n){
        if(b[i]){
            std::cout << (i + 1) << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 2560
// ------------------------------------
// Date:2018/ 3/ 9
// Problem:ARC 073 Sentou c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

// static const int MOD = 1000000007;

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

  ll N, T;
  cin >> N >> T;

  vector< ll > t(N);
  REP(i, N) {
    cin >> t[i];
  }

  ll ans = 0ll;
  REP(i, N - 1) {
    ans += min(t[i + 1] - t[i], T);
  }

  // 最後の一回は必ずT秒出る
  ans += T;
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N], B[N], C[N-1];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    for(int i=0;i<N-1;i++){
        cin >> C[i];
    }
    
    int tmp = A[0] - 1;
    int S = B[tmp];
    for(int i=1;i<N;i++){
        if(A[i] == tmp + 2){
            S += C[tmp];
        }
        tmp = A[i] - 1;
        S += B[tmp];
    }
    cout << S << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100009],f[100009],sum;
long long ans;
vector<int>v[100009],other;
int getf(int x) {
	if(x!=f[x]) f[x]=getf(f[x]);
	return f[x];
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) f[i]=i;
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<m;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		int fx=getf(x),fy=getf(y);
		f[fy]=fx;
	}
	for(int i=0;i<n;i++) {
		v[getf(i)].push_back(a[i]);
		if(f[i]==i) sum++;
	}
	if(sum==1) {
		printf("0\n");
		return 0;
	}
	sum=sum*2-2;
	for(int i=0;i<n;i++)
		if(!v[i].empty()) {
			sort(v[i].begin(),v[i].end());
			ans+=1ll*v[i][0];
			sum--;
			for(int j=1;j<v[i].size();j++) other.push_back(v[i][j]);
		}
	if(sum>(int)other.size()) {
		printf("Impossible\n");
		return 0;
	}
	sort(other.begin(),other.end());
	for(int i=0;i<sum;i++) ans+=1ll*other[i];
	printf("%lld\n",ans);
	return 0;
}

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

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

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

    vector<int> C(n);
    int A[n][m] = {};
    for(int i = 0; i < n; i++){
        cin >> C[i];
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }

    int ans = 1e9;
    bool check = false;
    for(int i = 0; i < (1 << n); i++){
        int cost = 0;
        vector<int> Skill(m, 0);
        for(int j = 0; j < n; j++){
            if((i >> j) & 1){
                cost += C[j];
                for(int k = 0; k < m; k++){
                    Skill[k] += A[j][k];
                }
            }
        }
        bool f = true;
        for(int j = 0; j < m; j++){
            if(Skill[j] >= x);
            else{
                f = false;
                break;
            }
        }
        if(f){
            check = true;
            ans = min(ans, cost);
        }
    }

    if(check) cout << ans << endl;
    else cout << -1 << endl; 

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

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

int main(void){  
  int a,b,m,n;
  while(cin>>a>>b,a||b){
    m = max(a,b);
    n = min(a,b);
    int count = 0;
    while(n!=0){
      int tmp = n;
      n = m%n;
      m = tmp;
      count++;
    }
    cout << m << " " << count << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string s; cin >> s;
    int ans = 101;
    for(char c = 'a'; c <= 'z'; ++c) {
        string check = "";
        rep(i, s.size()) check += c;
        string tmp = s;
        int cnt = 0;
        while(tmp != check) {
            rep(i, tmp.size()) {
                if(tmp[i] == c && i != 0) {
                    tmp[i - 1] = c;
                }
            }
            tmp.pop_back();
            check.pop_back();
            ++cnt;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int fun(int a,int b){
	b=b%a;
	if(b==0) return a;
	else fun(b,a);
}

int main(){
	int a,b,c,gcd,lcm,mem;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
			mem=b;
			b=a;
			a=mem;
		}
	gcd=fun(b,a);
	lcm=a/gcd*b;
	for(int i=1;i<=lcm/a;i++){
		if((a*i-c)%b==0){
			printf("YES");
			break;
		}
		if(i==lcm/a){
			printf("NO");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y):x(x),y(y){}
  Point operator+(Point a){return Point(x+a.x,y+a.y);}
  Point operator-(Point a){return Point(x-a.x,y-a.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}
};
typedef Point Vector;
typedef vector<Point> Polygon;
struct Segment{
  Point p1,p2;
  Segment(){}
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;
 
struct multi{
  int po;
  Point p;
  Segment s;
  multi():po(-1){}
  multi(Point p):po(1),p(p){}
  multi(Segment s):po(0),s(s){}
};
 
double norm(Vector a){
  return a.x*a.x+a.y*a.y;
}
 
double abs(Vector a){
  return sqrt(norm(a));
}
 
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}
 
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}
 
#define EPS (1e-10)
 
int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>EPS) return 1;
  if(cross(a,b)<-EPS) return -1;
  if(dot(a,b)< -EPS) return 2;
  if(norm(a)<norm(b)) return -2;
  return 0;
}
 
Point getCrossPointLL(Line l1,Line l2){
  double a=cross(l1.p2-l1.p1,l2.p2-l2.p1);
  double b=cross(l1.p2-l1.p1,l1.p2-l2.p1);
  if(abs(a)<EPS&&abs(b)<EPS) return l2.p1;
  return l2.p1+(l2.p2-l2.p1)*(b/a);
}
 
Point project(Segment s,Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/norm(base);
  return s.p1+base*r;
}
Point reflect(Segment s,Point p){
  return p+(project(s,p)-p)*2.0;
}
 
multi ope(multi a,multi b){
  if(a.po==1&&b.po==1){
    return multi(Line(a.p,b.p));
  }
  if(a.po==0&&b.po==0){
    return multi(getCrossPointLL(a.s,b.s));
  }
  if(a.po) swap(a,b);
  return multi(reflect(a.s,b.p));
}
 
 
multi expr(string s,int &p);
multi factor(string s,int &p);
int number(string s,int &p);
 
multi expr(string s,int &p){
  //cout<<"e:"<<p<<endl;
  multi res=factor(s,p);
  while(p<(int)s.size()){
    if(s[p]=='@'){
      p++;
      multi tmp=factor(s,p);
      res=ope(res,tmp);
      continue;
    }
    break;
  }
  return res;
}
 
multi factor(string s,int &p){
  //cout<<"f:"<<p<<endl;
  multi res;
  assert(s[p]=='(');
  p++;
  if(isdigit(s[p])||s[p]=='-'){
    int x=number(s,p);
    assert(s[p]==',');
    p++;
    int y=number(s,p);
    res=multi(Point(x,y));
  }else{
    res=expr(s,p);
  }
  //cout<<"fe:"<<p<<endl;
  assert(s[p]==')');
  p++;
  return res;
}
 
int number(string s,int &p){
  int f=1;
  if(s[p]=='-') f=-1,p++;
  int res=0;
  while(isdigit(s[p])) res=res*10+s[p++]-'0';
  return f*res;
}
 
signed main(){
  string s;
  while(cin>>s,s!="#"){
    int p=0;
    multi ans=expr(s,p);
    printf("%.12f %.12f\n",ans.p.x,ans.p.y);
  }
  return 0;
}

Measured memory_bytes: 3300
N, M = map(int, input().split())
PS = [[x for x in input().split()] for _ in range(M)]
tmp = [0] * (10**5+1)
ac = wa = 0

for P, S in PS:
    if tmp[int(P)]==-1:
        continue
    if S=='WA':
        tmp[int(P)] += 1
    elif S=='AC':
        ac+=1
        wa+=tmp[int(P)]
        tmp[int(P)] = -1
        
print(ac,wa)

Measured memory_bytes: 26624
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
min=h[k-1]-h[0]
for i in range(n-k+1):
  if h[i+(k-1)]-h[i]<min:
    min=h[i+(k-1)]-h[i]
print(min)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
#include<set>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define sort(v)	sort(v.begin(),v.end());
#define rsort(v) sort(v.rbegin(),v.rend());
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int,long long int>
#define vpll vector<pair<long long int,long long int> >
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli mpower(lli a,lli b,lli m){lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

/******************************START********************************/
int main()
{
	char ch1,ch2,ch3;
	string s1,s2,s3;
    lli i,j,k,a,t,b,c,n,m,x,sum=0,ans=0,temp;
    db d1,d2;
    cin >> d1 >> d2;
    cout << ceil(d1/d2) << endl;
    
    
    
    
    
    return 0;
}





















/* UJJWAL KESHRI */

Measured memory_bytes: 256
n = int(input())
ni = n%100
da = n//100

if n < 100:
    print("0")
elif ni == 0:
    print("1")
else:
    for a in range(ni):
        for b in range(ni):
            for c in range(ni):
                for d in range(ni):
                    for e in range(ni):
                        if a + b*2 + c*3 + d*4 + e*5 == ni :
                            break
                    else:
                        continue
                    break
                else:
                    continue
                break
            else:
                continue
            break
        else:
            continue
        break
    if a+b+c+d+e <=da:
        print("1")
    else:
        print("0")


Measured memory_bytes: 3064
fn main(){
    let n: i32 = read();
    let a: i32 = read();
    let b: i32 = read();
    let s: String = read();
    let mut kokunai: i32 = 0;
    let mut kaigai: i32 = 0;
    for c in s.chars() {
        if c == 'a' {
            if a + b > kokunai + kaigai {
                kokunai += 1;
                println!("Yes");
            } else {
                println!("No");
            }
        } else if c == 'b' {
            if a + b > kokunai + kaigai && b > kaigai {
                kaigai += 1;
                println!("Yes");
            } else {
                println!("No");
            }
        } else {
            println!("No");
        }
    } 
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 2260
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1000000007
using namespace std;

int Adj[101][101];

int main(){
  int n,u,k,v;
  cin >> n;
  FOR(i,0,n){
    cin >> u >> k;
    FOR(j,0,k){
      cin >> v;
      Adj[u][v] = 1;
    }
  }
  FOR(i,1,n+1){
    FOR(j,1,n+1){
      if(j == n)cout << Adj[i][j];
      else cout << Adj[i][j] << " ";
    }
    cout << endl;
  }
}



Measured memory_bytes: 3116
N = int(input())
S = input()
ans = 0
d = [set() for _ in range(3)]
for i in range(N - 2):
    if S[i] in d[0]:
        continue
    d[0].add(S[i])
    for j in range(i + 1, N - 1):
        if S[i] + S[j] in d[1]:
            continue
        d[1].add(S[i] + S[j])
        for k in range(j + 1, N):
            if S[i] + S[j] + S[k] in d[2]:
                continue
            d[2].add(S[i] + S[j] + S[k])
print(len(d[2]))


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int v[110], w[110];
int dp[110][10010];
int main(void)
{
    int N, W;
    cin >> N >> W;

    for (int i = 0; i < N; ++i)
        cin >> v[i] >> w[i];

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j <= W; ++j)
        {
            if (j - w[i] >= 0)
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll X;
    cin >> X;
    ll time = 0;
    rep (i, 100000) {
        time += i;
        if (X <= time) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,cnt=1;
    string s;
    vector<string>p;
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>s;
    	p.push_back(s);
	}
	sort(p.begin(),p.end());
	for(int i=1;i<p.size();i++){
		if(p[i]!=p[i-1]){
			cnt++;
		}
	}
	cout<<cnt;
	

//system("pause");
return 0;

}


Measured memory_bytes: 11536
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if ( a >= 3200 )
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }
        }
    }
}


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

using namespace std;

#define N 100001

int parent[N];
int visited[N];
ll num[N];
vector<vector<int>> edge(N, vector<int>(0));
int findroot(int a){
  if (parent[a] == a)
    return a;

  int newparent = findroot(parent[a]);
  parent[a] = newparent;
  return newparent;
}

void init(){
  for (int i = 0; i < N; i++){
    parent[i] = i;
    num[i] = 1;
  }
}

int main(void){
  ll n;
  cin >> n;
  
  
  vector<pair<ll, int>> x(n), y(n);
  for (int i = 0; i < n; i++){
    cin >> x[i].first >> y[i].first;
    x[i].second = i;
    y[i].second = i;
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  priority_queue<pair<ll, pair<int, int>>, vector<pair<ll, pair<int, int>>>, greater<pair<ll, pair<int, int>>>> Q;
  for (int i = 0; i < n - 1; i++){
    Q.push(make_pair(x[i+1].first-x[i].first, make_pair(x[i+1].second, x[i].second)));
    Q.push(make_pair(y[i+1].first-y[i].first, make_pair(y[i+1].second, y[i].second)));
  }
  init();

  ll res = 0;
  for (int i = 0; i < n - 1; i++){
    while(true){
      pair<ll, pair<int, int>> p = Q.top();
      int u = findroot(p.second.first);
      int v = findroot(p.second.second);
      if (u == v){
        Q.pop();
        continue;
      }
      else {
        Q.pop();
        res += p.first;
        parent[u] = v;
        break;
      }
    }
  }

  cout << res << endl;

  return 0;
}


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

const int maxn = 1e5 + 10;
vector<int> G[maxn];
int p[maxn], sz[maxn];

void dfs(int now, int fa) {
    p[now] = fa; sz[now] = 1;
    for (int u : G[now]) if (u != fa) {
        dfs(u, now);
        sz[now] += sz[u];
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b); G[b].push_back(a);
    }
    dfs(1, 0);
    vector<int> pt; pt.push_back(n);
    int cur = n;
    while (p[cur]) {
        pt.push_back(p[cur]);
        cur = p[cur];
    }
    int ans1 = sz[1] - sz[pt[pt.size() / 2 - 1]], ans2 = sz[pt[pt.size() / 2 - 1]];
    cout << (ans1 > ans2 ? "Fennec" : "Snuke") << endl;
    return 0;
}

Measured memory_bytes: 13436
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

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

int main() {
  string S, T;
  cin >> S >> T;
  
  cout << T << S << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
candidates = []
for i, _ in enumerate(A):
    add_num = 0
    for a in A[i:]:
        add_num += a
        candidates.append(add_num)

ans = 0
for i in range(40, -1, -1):
    k_candidates = []
    for candidate in candidates:
        if candidate & (1 << i):
            k_candidates.append(candidate)
    if len(k_candidates) >= K:
        ans += 1 << i
        candidates = k_candidates
print(ans)

Measured memory_bytes: 65916
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;


using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	
	map<int,int>ma;
	int v[3][3],aux;
	bool t=false;

	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> v[i][j];
		}
	}
	
	int n;
	cin >> n;

	while(n--){
		cin >> aux;
		ma[aux]++;
	}

	for(int i=0;i<3;i++){
		if(ma[v[i][0]]!=0 and ma[v[i][1]]!=0 and ma[v[i][2]]!=0 or ma[v[0][i]]!=0 and ma[v[1][i]]!=0 and ma[v[2][i]]!=0)
			t = true;
	}

	if(v[0][0]!=0 and ma[v[1][1]]!=0 and ma[v[2][2]]!=0 or ma[v[0][2]]!=0 and ma[v[1][1]]!=0 and ma[v[2][0]]!=0)
		t=true;

	cout << ( t ?  "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
#define OUT(x) cout << x << endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

map<ll, int> mp;
void prime_factorization(ll n){
    for (ll i = 2LL; i * i <= n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;;
}

int main(){
  int n;
  cin >> n;
  for(int i=1;i<=n;i++) prime_factorization(i);
  ll ans=1;
  for(auto p : mp){
    (ans *= p.second + 1) %= MOD;
  }

  OUT(ans)
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int firstTurn = ceil((double)c / b);
    int secondTurn = ceil((double)a / d);

    if(firstTurn > secondTurn)
    	cout << "No" << endl;
    else
    	cout << "Yes" << endl; 
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

string a, b;
int id[3010][3010];
int mem[3010][3010];
int dp(int x, int y){
    if(x >= a.size() || y >= b.size()) return 0;
    if(mem[x][y] != -1){
        return mem[x][y];
    }
    if(a[x] == b[y]){
        return mem[x][y] = dp(x+1, y+1)+1;
    }
    int ans1 = dp(x+1, y);
    int ans2 = dp(x, y+1);
    if(ans1 > ans2){
        return mem[x][y] = ans1;
    }
    return mem[x][y] = ans2;
}

int main()
{
    cin.sync_with_stdio(false);
    cin >> a >> b;
    memset(id,0,sizeof(id));
    memset(mem,-1,sizeof(mem));
    int mx = dp(0,0);
    int i = 0;
    int x = 0;
    while(i<a.size()){
        while(x<b.size()){
            if(a[i] == b[x] && mem[i][x] == mx){
                cout << a[i];
                i++;
                x = 0;
                mx--;
            }
            x++;
        }
        i++;
        x = 0;
    }
    return 0;
}


Measured memory_bytes: 71296
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   //ll t;
   //cin>>t;
   //while(t--)
   //{
   ll a,b,c;
   cin>>a>>b>>c;
   if(a+b+c>=22)
    cout<<"bust"<<endl;
   else
    cout<<"win"<<endl;
   //}
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll res=0,N,W,w1,sum1[101],sum2[101],sum3[101],sum4[101];
  P wv[101];
  vector<ll> g1,g2,g3,g4;
  cin >> N >> W;
  REP(i,N)cin >> wv[i].first >> wv[i].second;
  w1 = wv[0].first;
  REP(i,N){
    if(wv[i].first -w1 == 0){
      g1.push_back(wv[i].second);
    }else if(wv[i].first - w1 == 1){
      g2.push_back(wv[i].second);
    }else if(wv[i].first - w1 == 2){
      g3.push_back(wv[i].second);
    }else
      g4.push_back(wv[i].second);
  }
  sort(g1.begin(),g1.end(),greater<int >());
  sort(g2.begin(),g2.end(),greater<int >());
  sort(g3.begin(),g3.end(),greater<int >());
  sort(g4.begin(),g4.end(),greater<int >());
  sum1[0] = 0;
  sum2[0] = 0;
  sum3[0] = 0;
  sum4[0] = 0;
  REP(i,g4.size()){sum4[i+1] = sum4[i] + g4[i];}
  REP(i,g3.size()){sum3[i+1] = sum3[i] + g3[i];}
  REP(i,g2.size()){sum2[i+1] = sum2[i] + g2[i];}
  REP(i,g1.size()){sum1[i+1] = sum1[i] + g1[i];}
          
  
  REP(i,g4.size()+1){
    REP(j,g3.size()+1){
      REP(k,g2.size()+1){
        REP(l,g1.size()+1){
          if((w1)*(l)+(w1+1)*(k)+(w1+2)*(j)+(w1+3)*(i) <= W){
            res = max(res,sum1[l]+sum2[k]+sum3[j]+sum4[i]);
            
          }
          
        }
      }
    }
  }
  
  cout << res << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

int main(){
    int a ,b;
    cin >> a >> b;
    if (a < 10 && b < 10) {
        cout << a * b << endl;
    }
    else cout << -1 << endl;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

def calc(x):
    return int(x / 10), x % 10

def func(x, ans):
    a, b = calc(x)
    ans += b
    if a == 0:
        return ans
    return func(a, ans)

ans = 0
for i in range(1, n+1):
    if a <= func(i, 0) <= b:
        ans += i

print(ans)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let y = read::<i64>();
  let a = [1, 3, 5, 7, 8, 10, 12];
  let b = [4, 6, 9, 11];
  let c = [2];

  if a.contains(&x) && a.contains(&y) {
    println!("Yes")
  } else if b.contains(&x) && b.contains(&y) {
    println!("Yes")
  } else if c.contains(&x) && c.contains(&y) {
    println!("Yes")
  } else {
    println!("No")
  }
}



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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--) {
		int n;
		cin >> n;
		cout << (n + n * n + n * n * n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    rep(i,n)if(v[i]!=i+1) sum++;
    if(sum==0||sum==2) YES;
    else NO;
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
int main(void){
	int a,b,c,d,h1,h2,k1,k2,h,k;
	scanf("%d %d %d %d %d %d %d %d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
	h=h1*a+h2*b+(h1/10)*c+(h2/20)*d;
	k=k1*a+k2*b+(k1/10)*c+(k2/20)*d;
	if(h>k){
		printf("hiroshi\n");
	}
	else if(h==k){
		printf("even\n");
	}
	else{
		printf("kenjiro\n");
	}
	return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>


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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	puts("square1001");
	return 0;

}



Measured memory_bytes: 3028