akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{

    lint n;
    scanf("%lld", &n);

    std::vector<std::pair<lint, lint>> balls(n);

    for (int i = 0; i < n; ++i)
    {
        lint x, y;
        scanf("%lld", &x);
        scanf("%lld", &y);

        balls[i] = std::make_pair(x, y);
    }

    std::map<std::pair<lint, lint>, lint> dict;

    for (auto ball1 = balls.begin(); ball1 != (balls.end() - 1); ball1++)
    {
        for (auto ball2 = ball1 + 1; ball2 != balls.end(); ball2++)
        {
            lint x_dif = ball1->first - ball2->first;
            lint y_dif = ball1->second - ball2->second;
            if (x_dif < 0)
            {
                x_dif *= -1;
                y_dif *= -1;
            }
            else if (x_dif == 0)
            {
                y_dif = abs(y_dif);
            }
            auto cur_pair = std::make_pair(x_dif, y_dif);
            if (dict.find(cur_pair) == dict.end())
            {
                dict[cur_pair] = 1;
            }
            else
            {
                dict[cur_pair] += 1;
            }
        }
    }

    lint max_step = 0;

    for (auto step = dict.begin(); step != dict.end(); step++)
    {
        if (step->second > max_step)
        {
            max_step = step->second;
        }
    }

    printf("%lld", n - max_step);

    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
	"sort"
)

func divs(n, m int) (div []int) {
	min := int(math.Min(float64(n), float64(m)))
	if min == 1 {
		div = []int{1}
		return div
	}
	for i := 1; i < min+1; i++ {
		if n%i == 0 && m%i == 0 {
			div = append(div, i)
		}
	}
	return div
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	divs := divs(a, b)
	sort.Sort(sort.Reverse(sort.IntSlice(divs)))

	fmt.Println(divs[k-1])
}


Measured memory_bytes: 512
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n


for i in range(1,n):
    a = []
    if i-k < 0:
        start = 0
    else:
        start = i-k
    
    for j in range(start,i):
        a.append(dp[j] + abs(h[i] - h[j]))    
    
    dp[i] = min(a)
    
print(dp[-1])
                 


Measured memory_bytes: 52448
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
		if (a + b>= c) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	
}


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

int main() {
	double x1, x2, x3, y1, y2, y3, xp, yp, v1, v2, v3;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		v1 = (x2 - x1)*(yp - y1) - (y2 - y1)*(xp - x1);
		v2 = (x3 - x2)*(yp - y2) - (y3 - y2)*(xp - x2);
		v3 = (x1 - x3)*(yp - y3) - (y1 - y3)*(xp - x3);
		if ((v1 > 0 && v2 > 0 && v3 > 0) || (v1 < 0 && v2 < 0 && v3 < 0))cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	int N, *d, x;

	cin >> N;

	d = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}

	sort(d, d + N, greater <int>());


	if (d[N / 2 - 1] == d[N / 2]) {
		cout << 0;
	}
	else {
		cout << d[N / 2- 1] - d[N / 2];
	}
	
	return 0;
}


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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

# 累積和
acc = [0] + list(accumulate(A))

dp = list2d(N+1, N+1, INF)
for i in range(N):
    dp[i][i+1] = 0
for d in range(2, N+1):
    for l in range(N+1-d):
        r = l + d
        for m in range(l+1, r):
            dp[l][r] = min(dp[l][r], dp[l][m]+dp[m][r])
        # この先切った分の最小値に、今回のlとrを合体させる分を足す
        dp[l][r] += acc[r] - acc[l]
print(dp[0][N])


Measured memory_bytes: 46812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
const ll mod=1000000007;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yes(T b){if(b)out("yes");else out("no");}
template<class T> void Yes(T b){if(b)out("Yes");else out("No");}
template<class T> void YES(T b){if(b)out("YES");else out("NO");}
template<class T> void no(T b){if(b)out("no");else out("yes");}
template<class T> void No(T b){if(b)out("No");else out("Yes");}
template<class T> void NO(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
 


int main(){
    ll n;
    cin>>n;
    ll ans[201010]={};
    ll a[201010]={};
    ll xo=0;
    rep(i,n){
        cin>>a[i];
        xo=xo^a[i];
        //cout<<xo;
    }
    rep(i,n){
        cout<<(a[i]^xo)<<" ";
    }
    //cout<<(0^20)<<endl;
    EN;


    
}


Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[400000], f[400000];
signed main(){
	int n, x;
	scanf("%lld%lld", &n, &x);
	if(x == 1 or x == 2*n-1){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	if(n == 2){
		printf("1\n2\n3\n");
		return 0;
	}
	
	a[n-1] = x-1;
	a[n] = x;
	a[n+1] = x+1;
	f[x-1] = f[x] = f[x+1] = 1;
	if(x == 2*n-2){a[n+2] = x-2;f[x-2] = 1;}
	else{a[n-2] = x+2;f[x+2] = 1;}
	int p = 1;
	rrep(i,2*n-1){
		while(f[p])p++;
		if(a[i])continue;
		a[i] = p;
		f[p] = 1;
	}
	rrep(i,2*n-1)printf("%lld\n", a[i]);
	return 0;
}






Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	char c;
	cin >> c;
	++c;
	cout << c << '\n';
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
int H, W, K;
int s[303][303];
int a[303][303];
void solve() {
    int h = -1, w = -1;
    FOR(i, 0, H) {
        FOR(j, 0, W) {
            if (s[i][j]) {
                h = i;
                w = j;
                break;
            }
        }
        if (h >= 0) {
            break;
        }
    }
    int t = 0;
    FOR(i, h, H) {
        FOR(j, 0, W) {
            if (s[i][j]) {
                t++;
                int l = j;
                while (l >= 0) {
                    if (!a[i][l]) {
                        a[i][l] = t;
                    } else
                        break;
                    l--;
                }
            }
        }
    }
    FOR(i, 0, H) {
        FOR(j, 1, W) {
            if (a[i][j] == 0) {
                a[i][j] = a[i][j - 1];
            }
        }
    }
    FOR(i, 0, H) {
        FOR(j, 0, W) {
            if (a[i][j] == 0) {
                if (i >= 1) {
                    a[i][j] = a[i - 1][j];
                }
            }
        }
    }
    for (int i = H - 1; i >= 0; i--) {
        FOR(j, 0, W) {
            if (a[i][j] == 0) {
                a[i][j] = a[i + 1][j];
            }
        }
    }
    FOR(i, 0, H) {
        FOR(j, 0, W) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> H >> W >> K;
    FOR(i, 0, H) {
        FOR(j, 0, W) {
            char c;
            cin >> c;
            if (c == '#')
                s[i][j] = 1;
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 2176
from functools import lru_cache
class cmbs(object):
    def __init__(self, mod):
        self.mod = mod
        self.g1 = [1, 1]
        self.g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, 10 ** 6 + 1):
            self.g1.append((self.g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            self.g2.append((self.g2[-1] * inverse[-1]) % mod)
    @lru_cache(maxsize=None)
    def cmb(self, n, r):
        if n > 10 ** 6:
            return self.cmbl(n, r)
        return self.cmbr(n, r)

    def cmbr(self, n, r):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.mod

    def cmbl(self, n, r):
        t = 1
        r = min(r, n-r)
        for i in range(n - r + 1, n + 1):
            t = t * i % self.mod
        return t * self.g2[r] % self.mod
def main():
    S = input()
    mod = 10**9 + 7
    n = len(S)
    A = [0] * n
    B = [0] * n
    C = [0] * n
    Q = [0] * n
    d = {'A':0, 'B':0, 'C':0, '?':0}
    for i, v in enumerate(S):
        d[v] += 1
        A[i] = d['A']
        B[i] = d['B']
        C[i] = d['C']
        Q[i] = d['?']
    r = 0
    c = cmbs(mod)
    t = d['?']
    # ???
    if t >= 3:
        r += c.cmb(t, 3) * pow(3, t - 3)
        r %= mod
    if t >= 2:
        r2 = 0
        for i in range(n):
            p = t - Q[i]
            # A??
            if S[i] == 'A' and p >= 2:
                r2 += c.cmb(p, 2)
            # ?B?
            if S[i] == 'B' and Q[i] >= 1 and p >= 1:
                r2 += Q[i] * p
            # ??C
            if S[i] == 'C' and Q[i] >= 2:
                r2 += c.cmb(Q[i], 2)
        r2 *= pow(3, t-2)
        r += r2
        r %= mod
    if t >= 1:
        r1 = 0
        for i in range(n):
            if S[i] == 'B':
                #AB?
                r1 += A[i] * (t - Q[i])
                #?BC
                r1 += Q[i] * (d['C']-C[i])
            if S[i] == '?':
                #A?C
                r1 += A[i] * (d['C']-C[i])
        r1 *=  pow(3, t-1)
        r += r1
        r %= mod
    r0 = 0
    for i in range(n):
        if S[i] == 'B':
            r0 += A[i] * (d['C'] - C[i])
    r0 *= pow(3, t)
    r += r0
    r %= mod
    return r
print(main())


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

int dp[N][N];
string a,b;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,0,sizeof(dp));

	cin>>a>>b;
	int n = a.size();
	int m = b.size();

	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
		{
			if(i) dp[i][j] = max(dp[i][j],dp[i-1][j]);

			if(j) dp[i][j] = max(dp[i][j],dp[i][j-1]);

			if(i && j)
			{
				if(a[i-1] == b[j-1]) dp[i][j] = max(dp[i][j],dp[i-1][j-1] + 1);
				else dp[i][j] = max(dp[i][j],dp[i-1][j-1]);
			}
		}

	string ans = "";
	int i = n,j = m;

	while(i > 0 && j> 0)
	{
		int x = i - 1,y = j - 1;		

		if(a[x] == b[y]) i = x,j = y,ans += a[x];
		else
		{
			if(dp[x][j] < dp[i][y]) j = y;
			else i = x;
		}
	}

	reverse(ans.begin(),ans.end());
	cout<<ans<<"\n";	
}

Measured memory_bytes: 144744
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p){int res = 1; x = x % p;while (y > 0){    if (y & 1)        res = (res * x) % p;y = y >> 1;    x = (x * x) % p; } return res % p;}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
vector<pair<int, int>> ve;
int a[100], b[100], c[100],d[100];
int mx;
int n, m, q;
int solve(int in, vector<int> v,int f){
    
    if(in>=n){
         
        int ans = 0;
        for (int i = 0; i < q;i++){
           if(v[b[i]]-v[a[i]]==c[i]){
               ans += d[i];
           }
        }
        mx = max(mx, ans);
        return 0;
    }
    if(f>m){
        return 0;
    }
    vector<int> tmp=v;
    tmp[in] = f;
    solve(in + 1, tmp, f);
    solve(in, v, f + 1);
    return 0;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {

        cin >> n >> m >> q;
        for (int i = 0; i < q;i++){
            cin >> a[i] >> b[i] >> c[i];
            cin >> d[i];
            a[i]--;
            b[i]--;
        }
        vector<int> v(n, 0);
        solve(0, v, 1);
        cout << mx << endl;
    }

    return 0;
}

Measured memory_bytes: 3664
n = gets.chomp.to_i
arr = []
(1..n).each do |i|
    x = []
    a,b = gets.chomp.split(" ")
    b = b.to_i
    x << a
    x << b
    x << i
    arr << x
end
 arr.sort_by!{|x| [x[0],-x[1]]}

arr.each do |i|
    puts i[-1]
end

    
# end
# ar = []

Measured memory_bytes: 14140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    string s,t; cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        s: usize
    }

    if k == n {
        for _ in 0..k - 1 {
            print!("{} ", s)
        }
        println!("{}", s)
    } else {
        for _ in 0..k {
            print!("{} ", s)
        }

        let ans = {
            let mut ans = 2;
            while s % ans == 0 {
                ans += 1;
            }
            ans
        };

        for _ in k..n-1 {
            print!("{} ", ans)
        }
        println!("{}", ans)
    }
}


Measured memory_bytes: 2104
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

int ctoi(char c) { return c - '0'; }

void solve() {
    string N;
    int K;
    cin >> N >> K;
    int digit = N.size();

    /*------------------------------------------------------------------------------*/
    /*dp0[i][j]=上からi桁まで決めて,0でない桁がj個あり,Nより小さい事が確定している  */
    /*dp0[i][j]=上からi桁まで決めて,0でない桁がj個あり,Nより小さい事が確定していない*/
    /*------------------------------------------------------------------------------*/
    vector<vector<int>>dp0(digit + 1, vector<int>(digit + 1, 0));
    vector<vector<int>>dp1(digit + 1, vector<int>(digit + 1, 0));
    dp1[0][0] = 1;

    for (int i = 0; i < digit ; i++){
        int dmax = ctoi(N[i]);
        for (int j = 0; j <= i; j++) {
            if (dmax == 0) {
                dp0[i + 1][j + 1] += dp0[i][j] * 9;
                dp0[i + 1][j] += dp0[i][j];
                dp1[i + 1][j] += dp1[i][j];
            }
            else {
                dp0[i + 1][j] += dp0[i][j] + dp1[i][j];
                dp0[i + 1][j + 1] += dp0[i][j] * 9 + dp1[i][j] * (dmax - 1);
                dp1[i + 1][j + 1] += dp1[i][j];
            }
        }
    }
    cout << dp0[digit][K] + dp1[digit][K];

}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = [0] * 2
for k, v in a.items():
    if 4 <= v:
        b.append(k)
    if 2 <= v:
        b.append(k)
else:
    b.sort()
    print(b[-1] * b[-2])

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

int main()
{
	int step, dig;
	double x, y, angle;

	x = 0;
	y = 0;
	angle = 0;

	while(1){
		scanf("%d,%d", &step, &dig);

		if(step == 0 && dig == 0) break;

		x += (double)step * sin(angle * (M_PI / 180));
		y += (double)step * cos(angle * (M_PI / 180));

		angle += (double)dig;
	}

	printf("%d\n%d\n", (int)x, (int)y);
	
	return 0;
}

Measured memory_bytes: 604
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    cout << x % b << endl;

    return 0;
}



Measured memory_bytes: 888
x, y = list(map(int,input().split()))
if x in [1, 3, 5, 7, 8, 10] and y in [3, 5, 7, 8, 10, 12]:
    print('Yes')
elif x in [4, 6, 9] and y in [6, 9, 11]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>

int solve(int,int);

int n,A[2000];
int main(){
  int i,q,m[2000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<q;i++){
    if(solve(0,m[i]) == 1)printf("yes\n");
    else  printf("no\n");
    
  }

  return 0;
}

int solve(int i,int m){
  int a=0;
  if(m==0)return 1;
  if(i>=n)return 0;
  a = solve(i+1,m) || solve(i+1,m-A[i]);
  return a;
}



Measured memory_bytes: 2104
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

   int n;
   cin>>n;
   
   cout<<48-n;
   
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long a = 0L;
        long bc = 0L;
        long count = 0;
        int i = 0;
        while (i < s.length()) {
            boolean isA = false;
            boolean isBc = false;
            while (i < s.length() && s.charAt(i) == 'A') {
                ++a;
                ++i;
                isA = true;
            }
            if (isA == false) {
                ++i;
                a = 0;
                continue;
            }
            bc = 0;
            while (i + 1 < s.length() && s.charAt(i) == 'B' && s.charAt(i + 1) == 'C') {
                ++bc;
                i += 2;
                isBc = true;
            }
            if (bc == 0) {
               // ++i;
                a = 0;
                continue;
            }
            count += bc * a;

        }
        System.out.println(count);
    }
}


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

int main(){
    int n; cin >> n;
    vector<double> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = a[n-1];
    double b = ans*1.00 / 2;
    double mid = 1000000009;
    int ans2;
    for(int i = 0; i < n; i++){
        if(mid > abs(a[i] - b)){
            ans2 = a[i];
            mid = abs(a[i] - b);
        }
    }

    cout << ans << " " << ans2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;

int main() {
	double r, n, m;
	cin >> r;
	n = r * 2 * 3.141592653589;
	m = r * r * 3.141592653589;
	cout << fixed << setprecision(10) << m << " " << n;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    int d[N];
    for(int i=0;i<N;i++) cin >> d[i];
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(i!=j){
                ans+=d[i]*d[j];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
h,w,m=map(int,input().split())

st=set()
h_b=[0 for i in range(h)]
w_b=[0 for i in range(w)]
for i in range(m):
  th,tw=map(int,input().split())
  th-=1
  tw-=1
  st.add((th,tw))
  h_b[th]+=1
  w_b[tw]+=1

h_max=max(h_b)
w_max=max(w_b)

h_cand=[i for i in range(h) if h_b[i]==h_max]
w_cand=[i for i in range(w) if w_b[i]==w_max]

for i in h_cand:
  for j in w_cand:
    if (i,j) not in st:
      print(h_max+w_max)
      exit()

print(h_max+w_max-1)

Measured memory_bytes: 83408
#include<cstdio>
#include<algorithm>
using namespace std;
int a[4033][4033],b[2022][2022];int n,k;
int main(){
	char c[5];int x,y;
	scanf("%d%d",&n,&k);
	for(int i=0; i<n; i++){
		scanf("%d%d%s",&x,&y,&c);
		if(*c == 'W')x += k;
		x %= 2 * k;
		y %= 2 * k;
		a[x][y] ++;
		a[x][y+k] --;
		a[x+k][y] --;
		a[x+k][y+k] ++;

		a[x+k][y+k] ++;
		a[x+k][y+2*k] --;
		a[x+2*k][y+k] --;
		a[x+2*k][y+2*k] ++;
	}
	for(int i=1; i<4*k; i++)for(int j=0; j<4*k; j++)
		a[i][j] += a[i-1][j];
	for(int i=0; i<4*k; i++)for(int j=1; j<4*k; j++) 
		a[i][j] += a[i][j-1];
	for(int i=0; i<4*k; i++)for(int j=0; j<4*k; j++)
		b[i%(2*k)][j%(2*k)] += a[i][j];
	int res = 0;
	for(int i=0; i<2*k; i++)for(int j=0; j<2*k; j++)
		res = max(res,b[i][j]);
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	H[0] -= 1;
	for (int i = 1; i < N; ++i) {
		if (H[i] > H[i - 1]) { H[i] -= 1; }
	}

	bool ok = true;
	for (int i = 1; i < N; ++i) {
		if (H[i] < H[i - 1]) { ok = false; }
	}

	if (ok) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
	}
	else if (1200 <= n && n < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	return 0;
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    /*
    ll num = 2;
    ll nn = n;
    while (nn <= k) {
        if ( nn >= m && nn <= k ) {
            ans = 1;
            break;
        }
        nn = n*num;
        // cout << "n" << nn << endl;
        num++;
    }*/
    for (ll i = m; i <= k; ++i) {
        if ( i%n == 0 ) {
            ans = 1;
        }
    }
    cout << ( ans ? "OK" : "NG" ) << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
set < ll> primes;
 int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n;
bool isvalid(int x,int y){
  return (x>=0 and x<n and y>=0 and y<n);
}
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.insert(p);  
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}

 
 

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
  
    
    
    int l;
    cin>>l;
    
    double len1=((double)l)/3;
    double len2=((double)l)/3;
    double len3=((double)l)/3;
    
    
    cout<<fixed<<setprecision(15)<<(double)len1*len2*len3;
   
}

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

int main(){
    long long H;
    cin >> H;

    long long cnt = 0;
    long long num = 1;

    while(H > 0) {
        H = H / 2;
        cnt += num;
        num = num * 2;
    }

    cout << cnt << endl;
}

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

typedef long long int ll;

typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision(i) cout << fixed << setprecision(i)

const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;


int main() {

  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  ll answer;
  if(a+b<=2*c){
    answer = x*a+y*b;
  }else{
    if(x>=y){
      if(a>=2*c){
        answer = x*2*c;
      }else{
        answer = y*2*c+(x-y)*a;
      }
    }else{
      if(b>=2*c){
        answer = y*2*c;
      }else{
        answer = x*2*c+(y-x)*b;
      }
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b,c,d;
  cin>>n;
  a=(n/500);
  b=(n%500);
  c=(b/5);
  d=(a*1000)+(c*5);
  cout<<d;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll t;
    cin >> t;
    for (int iyya = 0; iyya < t; iyya++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (a < b) {
            cout << "No" << endl;
            continue;
        }

        ll n = ll_gcd(b, d);
        if (b > d) {
            cout << "No" << endl;
            continue;
        }
        if (c >= b) {
            cout << "Yes" << endl;
            continue;
        }
        if ((((c+1 + n - (a % n))+n-1) / n * n - (n - (a % n)) >= b)){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 3524
import sys

sys.setrecursionlimit(10 ** 6)
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]



def main():
    a=LI()
    x=a[0]
    y=a[1]
    b=a[3]
    c=a[4]
    a=a[2]
    pa=LI()
    pb=LI()
    pc=LI()
    pa.sort()
    pb.sort()
    pc.sort()
    pa.reverse()
    pb.reverse()
    pc.reverse()
    pa=pa[0:x]
    pb=pb[0:y]
    pa+=pb
    pa.sort()
    pa.reverse()
    j=len(pa)-1
    summ=0
    for i in range(0, len(pa)):
        summ+=pa[i]
    for i in range(0, len(pc)):
        if j>=0 and pc[i]<=pa[j]:
            break
        else:
            summ-=pa[j]
            summ+=pc[i]
            j-=1
    print(summ)
main()


Measured memory_bytes: 23312
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int x;
	int ans=0;
	rep(i,0,5){
		ll x;
		cin>>x;
		if(x==0){
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3652
n, k, q = map(int,input().split())

wins =[int(input()) for i in range(q)]

points =[k- q] * n

for win in wins:
    points[win-1] += 1
    
for i in range(n):
    if points[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

inline ll func(ll a){
    return a*(a+1)/2;
}

int main()
{
    ll N;
    cin >> N;
    for(ll i=0; i<=N; i++){
        if(func(i) >= N){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3540
import collections
import sys

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())

Z = prime_factorize(N)

if not Z:
    print(0)
    sys.exit(0)

P = collections.Counter(Z)

#print(P)

x = 0

for i in P.values():
    #print(i)
    y = 0
    z = 0
    for j in range(1, i+1):
        y = y + j
        z += 1
        #print(i, y, z)
        if y >= i:
            if y > i:
                z -= 1
            break
    
    x = x + z

print(x)



Measured memory_bytes: 9472
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        bool debugFlg = false;
        if (debugFlg)
        {
            var exStdIn = new System.IO.StreamReader("stdin.txt");
            System.Console.SetIn(exStdIn);
        }
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        int[] H = cin.ArrayInt(N);
        string ans = "Yes";

        // 単調非減少 n1 < n2 → f(n1) <= f(n2)
        // 左側を操作する
        // 初期値
        for (int i = N - 1; i > 0; i--)
        {
            // 一つ前の高さと比較して、パターンわけ
            // H[i] - befH == -3, -2, -1, 0, 1, 2, 3...
            // -2以下:befHを1低くしてもダメ。No
            // -1:befHを1低くするとOKだけど連続するとダメ
            // 0以上:継続
            if (H[i] - H[i - 1] <= -2)
            {
                ans = "No";
                break;
            }
            else if (H[i] - H[i - 1] == -1)
            {
                H[i - 1] -= 1;
            }
        }
        for (int i = 1; i < N; i++)
        {
            if (H[i] < H[i - 1])
            {
                ans = "No";
                break;
            }
        }

        Console.WriteLine($"{ans}");
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 26844
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let stdin = std::io::stdin();
    let n = read::<u32>(&mut stdin.lock()).unwrap();

    let mut d = [0u32; 200000];
    for i in 0..n {
        unsafe {
            let baka = d.get_unchecked_mut(i as usize);
            *baka = read::<u32>(&mut stdin.lock()).unwrap();
        }
    }

    let mut ddd = d;
    ddd.sort();

    for i in 0..n {
        unsafe {
            let iine = d.get_unchecked(i as usize);
            let last = ddd.get_unchecked(199999);
            let last2 = ddd.get_unchecked(199998);
            if iine == last {
                println!("{}", last2);
            } else {
                println!("{}", last);
            }
        }
    }
}


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

int main() {
  string a; cin >> a;
  if(a=="abc"||a=="bca"||a=="cab"||a=="acb"||a=="cba"||a=="bac") cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define ti tuple<int, int, int>

int main() {

    ll H;
    cin >> H;

    ll tmp=1;
    while(tmp <= H) {
        tmp *= 2;
    }

    cout << tmp-1 << endl;

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd

a, b, c, d = map(int, input().split())
x = b-a+1
l = c//gcd(c, d)*d
ans = (b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//l - (a-1)//l)
print(x-ans)

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

import sys
import os


N = int(sys.stdin.readline())
lines = sys.stdin.readlines()
d = {}
for s in lines:
    command, word = s.split()
    if command == 'insert':
        d[word] = True
    elif command == 'find':
        if word in d.keys():
            print('yes')
        else:
            print('no')

Measured memory_bytes: 112228
#include <stdio.h>
#include <utility>
#define INF 0x7FFFFFFF

using namespace std;

int main(void){
	int i, j, n, m, sumt, sumh, ttmp, htmp, min;
	int taro[100], hanako[100];
	pair<int,int> p;
	scanf("%d%d",&n,&m);
	while(n != 0 || m != 0){
		min = INF;
		for(i = 0,sumt = 0;i < n;sumt += taro[i],i++)
			scanf("%d",&taro[i]);
		for(i = 0,sumh = 0;i < m;sumh += hanako[i],i++)
			scanf("%d",&hanako[i]);
		for(i = 0;i < n;i++){
			ttmp = sumt - taro[i];
			for(j = 0;j < m;j++){
				htmp = sumh - hanako[j];
				if(ttmp + hanako[j] == htmp + taro[i] && min > taro[i] + hanako[j]){
					p.first = taro[i]; p.second = hanako[j];
					min = taro[i] + hanako[j];
				}
			}
		}
		if(min == INF)
			printf("-1\n");
		else
			printf("%d %d\n",p.first,p.second);
		scanf("%d%d",&n,&m);
	}
	return 0;
}

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




int main() {
  
 int A, B, C;
 A = 0;
 B = 0;
 C = 0;
  
 cin >> A >> B >> C;
  
 if(A - B >= C) {
   
   C = 0;
   
 } else {
   
   C -= (A - B);
   
 }
  
 cout << C << endl;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> vectH(n);

	int max_H = 0;
	int count = 0;
	for(int i=0;i<n;++i){
		cin >> vectH[i];
		if(max_H <= vectH[i]){
			count++;
			max_H = vectH[i];
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict as ddf
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]

dd=ddf(lambda:0)
for e in s: dd[e]+=1
for e in t: dd[e]-=1
print(max(0,max(dd.values())))

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

using namespace std;

using int64 = long long;
constexpr int mod = 1e9 + 7;

template< int mod >
struct Combination {
  vector< int64_t > mfact, rfact;

  Combination(int sz) : mfact(sz + 1), rfact(sz + 1) {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

int main() {
  int N, A[200000], B[200000];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  int tap[4005][4005] = {{}};
  for(int i = 0; i < N; i++) {
    tap[2000 - A[i]][2000 - B[i]]++;
  }
  for(int i = 0; i <= 4000; i++) {
    for(int j = 0; j <= 4000; j++) {
      if(i) (tap[i][j] += tap[i - 1][j]) %= mod;
      if(j) (tap[i][j] += tap[i][j - 1]) %= mod;
    }
  }
  int ret = 0;
  Combination< mod > tapi(8005);
  for(int i = 0; i < N; i++) {
    (ret += tap[2000 + A[i]][2000 + B[i]]) %= mod;
    (ret += mod - tapi.C(A[i] + B[i] + A[i] + B[i], A[i] + A[i])) %= mod;
  }
  cout << ret * tapi.inv(2) % mod << endl;
}


Measured memory_bytes: 64640
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	cin >> N;
	bool ok=false;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a%2){
			ok=true;
		}
	}
	if(ok){
		cout << "first" << endl;
	}
	else{
		cout << "second" << endl;
	}

	return 0;
}



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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) if (i % 2 == 0) cout << s[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>

#define max 2000001
#define maxvalue 10000


int main(){
  unsigned short *Aarray,*Barray;

  int Carray[maxvalue + 1];
  int num,j,i;

  scanf("%d",&num);

  Aarray = malloc(sizeof(short) * num + 1);
  Barray = malloc(sizeof(short) * num + 1);

  for(i = 0;i < maxvalue;i++){
    Carray[i] = 0;
  }
  for(i = 0;i < num;i++){
    scanf("%hu",&Aarray[i + 1]);
    Carray[Aarray[i + 1]]++;
  }
  for(i = 1;i <= maxvalue;i++){
    Carray[i] = Carray[i] + Carray[i - 1];
  }
  for(j = 1;j <= num;j++){
    Barray[Carray[Aarray[j]]] = Aarray[j];
    Carray[Aarray[j]]--;
  }
  for(i = 1;i <= num;i++){
    if(i > 1){
      printf(" ");
    }
    printf("%d",Barray[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9712