akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

bool d[1000000];

int main()
{
  int n;
  int ans;
  while(cin >> n)
  {
    n++;
    for(int i = 0; i < 1000000; i++)
      d[i] = false;
    d[0] = d[1] = true;
    ans = 0;
    for(int i = 2; i < n; i++)
    {
      if(d[i])
        continue;
      for(int j = i + i; j < n; j+= i)
        d[j] = true;
    }
    for(int i = 0; i < n; i++)
    {
      //cout << d[i] << endl;
      ans += !d[i] ? 1 : 0;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2136
// https://atcoder.jp/contests/abc178/tasks/abc178_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;
template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
    static int get_mod() { return mod; }
};
using mint = ModInt<MOD>;

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}
mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

void solve() {
    int N;
    cin >> N;
    mint ans = 0;
    // 3個ずつをiグループ作成し、残ったものを敷居(i-1)個で分割
    // 残り2個を4グループに分ける場合は敷居3つ「○|○||」
    FOR(i, 1, N / 3 + 1) { ans += C(N - i * 3 + i - 1, i - 1); }
    cout << ans << endl;
}
signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3700
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  string S;
  cin >> S;
  ll pos;
  ll ans = 0;
  ll pred;
  ll i,j;
  for(pos=0;pos<1<<S.length()-1;pos++){
    pred = 0;
    j=1;
    for(i=1;i<S.length();i++){
      if(pos&j){
        //cout << stoi(S.substr(pred,i-pred)) << endl;
        ans += stoll(S.substr(pred,i-pred));
      	pred = i;
      }
      j = j<<1;
    }
    //cout << stoi(S.substr(pred,i-pred)) << endl;
    ans += stoll(S.substr(pred,i-pred));
  }
  cout << ans;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,sub=0;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,most=0;
    int now,pre;
    //vector <int> v;
    //float f,g,h;
    //char now,pre;
    //string a;
    cin>>n;
    long long int a[ten5],b[ten5];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(i=n-1;i>=0;i--)
    {
        if((a[i]+sum)%b[i]==0) continue;
        else
        {
            sum+=b[i]-((a[i]+sum)%b[i]);
        }
    }
    cout<<sum;
    return 0;
}





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

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);

    long long Xor = 0;
    for(int i = 0;i < n;i++){
        cin>>a[i];
        if(i%2){
            Xor ^= (a[i]^a[i - 1]);
        }
    }

    for(int i = 0;i < n;i++)cout<<(Xor^a[i])<<" ";
    cout<<endl;
}

Measured memory_bytes: 4844
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        int ans=0;
        for (int i = 0; i < n; i++) {
            ans+=Integer.numberOfTrailingZeros(a[i]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 34252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
const ll INF = 1001001001;
int main()
{
    ll n;
    cin >> n;

    vector<ll> a(n), b(n + 1);
    rep(i, n)
    {
        cin >> a[i];
        b[i + 1] = b[i] + a[i];
    }
    ll ans = 0;
    rep(i, n)
    {
        ans += (b[n] - b[i + 1]) % MOD * a[i];
        ans %= MOD;
    }
    cout << ans << endl;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int l, r;
    cin >> l >> r;
    if((r - l + 1) / 2019){
        cout << "0\n";
        return 0;
    }
    int ans = INF;
    for(int i = l; i < r; ++i){
        for(int j = i+1; j <= r; ++j){
            ans = min((ll)ans, (ll)i * j % 2019);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

typedef pair<int,int> pii;

int main()
{
  while(1){
    int N;
    cin >> N;
    if(N == 0) break;
    int  t, b, r, l;
    t = b = r = l = 0;
    pii sq[N];
    sq[0].first = sq[0].second = 0;
    for(int i = 1; i < N; i++){
      int n, d;
      cin >> n >> d;
      if(d == 0){
        sq[i].first = sq[n].first - 1;
        sq[i].second = sq[n].second;
      }else if(d == 1){
        sq[i].first = sq[n].first;
        sq[i].second = sq[n].second - 1;
      }else if(d == 2){
        sq[i].first = sq[n].first + 1;
        sq[i].second = sq[n].second;
      }else if(d == 3){
        sq[i].first = sq[n].first;
        sq[i].second = sq[n].second + 1;
      }
      r = max(r, sq[i].first);
      l = min(l, sq[i].first);
      t = max(t, sq[i].second);
      b = min(b, sq[i].second);
    }
    cout << r - l + 1  << " " << t - b + 1 << endl;
  }
}

Measured memory_bytes: 1160
def search_right(h, w):
    if h < 0 or h >= H or w < 0 or w >= W or S[h][w] == "#":
        return
    if S[h][w] == "." and answer_right[h][w-1] > 0:
        answer_right[h][w] = answer_right[h][w-1]
        return

    for i in range(w, W):
        if S[h][i] == ".":
            answer_right[h][w] += 1
        else:
            break


def search_down(h, w):
    if h < 0 or h >= H or w < 0 or w >= W or S[h][w] == "#":
        return
    if S[h][w] == "." and answer_down[h-1][w] > 0:
        answer_down[h][w] = answer_down[h-1][w]
        return

    for i in range(h, H):
        if S[i][w] == ".":
            answer_down[h][w] += 1
        else:
            break

H, W = map(int, input().split())
S = [0] * H
answer_right = [[0] * W for _ in range(H)]
answer_down = [[0] * W for _ in range(H)]
answer = 0
for i in range(H):
    S[i] = input()
for h in range(H):
    for w in range(W):
        search_right(h, w)
        search_down(h, w)
        answer = max(answer, answer_down[h][w]+answer_right[h][w] - 1)

print(answer)

Measured memory_bytes: 125404
#include<bits/stdc++.h>
#define f first
#define s second
#define endl "\n"
#define M 1000000007
#define pb push_back
#define pf push_front
#define eb emplace_back
#define MM_PI 3.14159265358979323846
#define TEST_CASE int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T pow(T a, T b, long long m) {T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans % m; }

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;

const int maxn = 1e5 + 10;
vi g[maxn];
int dp[maxn], inc[maxn];
int n, m;
void dfs(int s) {
	inc[s] = 1;
	for (int i = 0; i < g[s].size(); i++) {
		if ((dp[s] + 1) > dp[g[s][i]]) {
			dp[g[s][i]] = dp[s] + 1;
		}
		dfs(g[s][i]);
	}
}
void solve() {

	int n, m;
	cin >> n >> m;
	vector<string> vp;
	string str;
	for (int i = 0; i < n; i++) {
		cin >> str;
		vp.pb(str);
	}
	int dp[n + 10][m + 10];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 1; i < n; i++) {
		if (vp[i][0] == '#')break;
		dp[i][0] = 1;

	}
	for (int i = 1; i < m; i++) {
		if (vp[0][i] == '#')break;
		dp[0][i] = 1;

	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			if (vp[i][j] == '#')dp[i][j] = 0;
			else {
				dp[i][j] = (dp[i - 1][j] % M + dp[i][j - 1] % M) % M;
			}
		}
	}
	cout << dp[n - 1][m - 1];



}
int main() {

	//IOS
	//make();
	//TEST_CASE
	solve();
	return 0;
}



Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N;
	cin >> N;
	vll X(N + 1);
	repn(i, N) cin >> X[i];

	vll Y(N + 1);
	repn(i, N) Y[i] = X[i];
	sort(++Y.begin(), Y.end());

	repn(i, N) {
		if (X[i] > Y[N / 2]) { cout << Y[N / 2] << endl; }
		else { cout << Y[(N / 2) + 1] << endl; }
	}
}

Measured memory_bytes: 6412
def print_ans(x,a,b):
    """Print min(abs(x-a),abs(x-b))

    Parameters
    --------------

    Examples
    ------------
    >>> print_ans(3,0,1)
    B
    >>> print_ans(3,2,5)
    A
    >>> print_ans(2,5,9)
    A
    """
    #print(min(abs(x-a),abs(x-b)))
    if min(abs(x-a),abs(x-b)) == abs(x-b):
      print("B")
    else:
      print("A")




if __name__ == '__main__':
    x,a,b = map(int,input().split())
    print_ans(x,a,b)


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

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


long N, K;

int main(){
	cin >> N >> K;
	vector<long> H(N);
	rep (i, N) cin >> H.at(i);
	
	//printf("H: \n");
	//rep(i, N) cout << H.at(i) << endl;
	//printf("\n");
	if( K >= N) cout << "0" << endl;
	else{
      	sort(H.begin(), H.end(), greater<long>());
      	//rep(i, N) cout << H.at(i) << endl;
      	//printf("\n");
      	H.erase(H.begin(), H.begin()+K);
   		//rep(i, N-K) cout << H.at(i) << endl;
		cout << accumulate(H.begin(), H.end(), 0LL) << endl;

	}	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int Longest_Path(map< int,vector< int > > &graph,vector< int >   &DP,int currentItem)
{
        if(graph.find(currentItem) == graph.end())   return 0;
        if(DP[currentItem] != -1) return DP[currentItem];
        int maxValue = 0;
        for(auto it2 = graph[currentItem].begin();it2 != graph[currentItem].end();it2++){
            maxValue = max(maxValue,Longest_Path(graph,DP,*it2) );
        }
        DP[currentItem] = maxValue + 1;
        return DP[currentItem];
}
int main()
{
        //freopen("in.txt","r",stdin);
        int n,m;
        cin >> n >> m;
        map< int,vector< int > > graph;
        for(int i=0;i<m;i++){
            int x,y;
            cin >> x >> y;
            graph[y].push_back(x);
        }
        vector< int >   DP(n+1,-1);
        int maxEdge = 0;
        for(auto it = graph.begin(); it !=graph.end(); it++){
            maxEdge = max(maxEdge,Longest_Path(graph,DP,it->first));
        }
        cout << maxEdge << endl;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define endl "\n"
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int ui;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

	FAST();
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];

	sort(a,a+n);
	bool f=0;
	ll ans=1, tm=1e18;
	if(a[0]==0)
	{
		cout<<0;
		f=1;
	}
	else
	{
		for(ll i=0;i<n;i++)
		{
			if((tm/ans)>=a[i]) 
				ans*=a[i];
			else
			{
				cout<<-1;
				f=1;
				break;
			}
		}
	}
	if(f==0)
		cout<<ans<<endl;
	
	//return 0;
}

Measured memory_bytes: 4364
n = int(input())
num=0
if n==1:
    print(1)
    exit()
else:
    for i in range(1,n+1):
        k=0
        c=i
        while True:
            if c%2==0:
                c/=2
                k+=1
            else:
                break
        if k>num:
            num=k
            ans=i
print(ans)

Measured memory_bytes: 3316
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
ans = []

for i in range(N, 0, -1):
  cnt = sum(B[(i-1)::i])%2
  B[i-1] = A[i-1] ^ cnt
  if B[i-1]:
    ans.append(i)

print(sum(B))
print(*ans)

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

int main(void){
    int a,b;
    cin >> a >> b;
    int sum = 0;
    if(a+b == 2)sum += 400000;
    if(a <= 3)sum += (4-a)*100000;
    if(b <= 3)sum += (4-b)*100000;
    cout << sum << endl;
}

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

#define Online 1
// #define multitest 1
// #define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif
int _n = 200005;
vector<ll> Fact(_n), Inv(_n);
int kmod = 1000000007;

ll power(ll base, int index)
{
	if (index == 0)
		return 1;
	ll temp = power(base, index / 2);
	temp *= temp;
	temp %= mod;
	if (index & 1)
		temp *= base;
	return temp % mod;
}

void pre()
{
	Fact[0] = 1;
	for (int i = 1; i < _n; ++i)
		Fact[i] = (Fact[i - 1] * i) % kmod;
	Inv[_n - 1] = power(Fact[_n - 1], mod - 2);
	for (int i = _n - 2; i >= 0; --i)
		Inv[i] = (Inv[i + 1] * (1 + i)) % kmod;
}
void solve()
{
	ll n, m, k;
	cin >> n >> m >> k;
	pre();
	vector<vector<ll>> Dp(n + 1, vector<ll>(m + 1));
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			Dp[i][j] = Dp[i - 1][j];
			db("Parent", i, j, Dp[i][j]);
			Dp[i][j] += ll(j) * (j - 1) / 2 % mod;
			db("Own Row", i, j, ll(j) * (j - 1) / 2 % mod);
			Dp[i][j] %= mod;
			Dp[i][j] += m * (i - 1) % mod;
			db("PrevRow Extra", i, j, m * (i - 1) % mod);
			Dp[i][j] %= mod;
			if (i != 1)
			{
				Dp[i][j] += (m - j + 1) * (m - j) / 2 % mod;
				db("PrevRow Sum", i, j, (m - j + 1) * (m - j) / 2 % mod);
			}
			else
				db("PrevRow Sum", i, j, 0);
			Dp[i][j] %= mod;
			db(Dp[i][j]);
			db("\n");
			ans += Dp[i][j];
			ans %= mod;
		}
	ans = (ans * Fact[n * m - 2]) % mod;
	ans = (ans * Inv[k - 2]) % mod;
	ans = (ans * Inv[n * m - k]) % mod;
	std::cout << ans << '\n';
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

Measured memory_bytes: 14336
#include <stdio.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, q, x;
  scanf("%lld%lld", &n, &q);
  ll a[n], sum[n], sum2[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) {
    if(i < 2) sum[i] = a[i];
    else sum[i] = sum[i - 2] + a[i];
    if(i) sum2[i] = sum2[i - 1] + a[i];
    else sum2[i] = a[i];
  }
  for(i = 0; i < q; ++i) {
    scanf("%lld", &x);
    ll l = lower_bound(a, a + n, x) - a;
    ll ht = 0, tt = 1e9;
    while(ht != tt - 1) {
      ll t = (ht + tt) / 2;
      ll lt = lower_bound(a, a + n, x + t) - a, ft = lower_bound(a, a + n, x - t) - a;
      if(n - 1 - lt < lt - ft) tt = t;
      else ht = t;
    }
    ll lt = upper_bound(a, a + n, x + ht) - a - 1, ft = lower_bound(a, a + n, x - ht) - a;
    if(lt - ft + 1 > n - lt - 1) {
      if(a[lt] - x >= x - a[ft]) lt--;
      else ft++;
    }
    ll ans = sum2[n - 1] - sum2[lt];
    if(lt - ft + 1 != n - lt - 1) {
      if(ft - 2 >= 0) ans += sum[ft - 2];
    } else {
      if(ft - 1 >= 0) ans += sum[ft - 1];
    }
    //printf("%lld %lld %lld ", ht, ft, lt);
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3968
<?php
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$i = 0;
$o = 0;
$e = 0;
$ee = 0;
while($i < $n){
if($a[$i] % 2 == 1){
++$o;
}elseif($a[$i] % 4 == 0){
++$ee;
}else{
++$e;
}
++$i;
}
 
if($e > 0){
++$o;
}

if($o <= $ee + 1){
echo "Yes";
}else{
echo "No";
}

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

int main() {
	string s;
	cin >> s;
	int k = 0,ss=s.size();
	for(int i=0;i<ss/2;i++)
	{
		if(s.at(i) != s.at(ss- 1 - i))
		{
			k++;
		}
	}
    cout << k << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 50;

long long dp[MAXN];

int main()
{
    long long n;
    scanf("%lld", &n);
    memset(dp, 0, sizeof(dp));
    long long m = n;
    int ans = 0;
    while (m)
    {
        m >>= 1;
        ans ++;
    }
    dp[1] = 1;
    for (int i = 2; i <= ans; i ++)
    {
        dp[i] = dp[i - 1] * (long long)2 + 1;
    }
    printf("%lld\n", dp[ans]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 5000000

int h;
int a[MAX + 1];

void swap(int *x, int *y) {
	int temp;
	temp = *x;
	*x = *y;
	*y = temp;
}

void maxH(int i) {
	int l, r, largest;
	int temp;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= h && a[l] > a[i]) largest = l;
	else largest = i;
	if (r <= h && a[r] > a[largest]) largest = r;

	if (largest != i) {
		swap(&a[i], &a[largest]);
		maxH(largest);
	}
}



int main() {
	int i;

	scanf("%d", &h);
	for (i = 1; i <= h; i++) scanf("%d", &a[i]);
	for (i = h / 2; i >= 1; i--) maxH(i);
	for (i = 1; i <= h; i++) printf(" %d", a[i]);
	printf("\n");

	return 0;
}


Measured memory_bytes: 3736
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;


enum FACE { NORTH, SOUTH, WEST, EAST, TOP, BOTTOM };

class dice {
private:
	int num[6];

	inline void roll(FACE a, FACE b, FACE c, FACE d) {
		swap(num[a], num[b]);
		swap(num[b], num[c]);
		swap(num[c], num[d]);
	}

public:
	dice() {
		num[TOP] = 1;
		num[BOTTOM] = 6;
		num[NORTH] = 3;
		num[SOUTH] = 4;
		num[EAST] = 5;
		num[WEST] = 2;
	}

	void set(int t, int f) {
		if(num[EAST] == t || num[WEST] == t) west();
		while(num[TOP] != t) north();
		while(num[NORTH] != f) ccw();
	}

	inline const int &operator[](FACE f) const { return num[f]; }

	inline void north() { roll(TOP, SOUTH, BOTTOM, NORTH); }
	inline void east()  { roll(TOP, WEST, BOTTOM, EAST); }
	inline void west()  { roll(TOP, EAST, BOTTOM, WEST); }
	inline void south() { roll(TOP, NORTH, BOTTOM, SOUTH); }

	inline void ccw() { roll(SOUTH, EAST, NORTH, WEST); }
	inline void cw()  { roll(SOUTH, WEST, NORTH, EAST); }
};

constexpr int SIZE = 30;
int top[SIZE][SIZE];
int height[SIZE][SIZE];

constexpr int dx[4] = {0, 0, -1, 1};
constexpr int dy[4] = {-1, 1, 0, 0};
void (dice::*func[4])() = {&dice::north, &dice::south, &dice::west, &dice::east};

void drop(int x, int y, dice d) {
	typedef pair<int, FACE> P;

	while(true) {
		vector<P> v{{d[NORTH], NORTH}, {d[SOUTH], SOUTH}, {d[EAST], EAST}, {d[WEST], WEST}};
		sort(begin(v), end(v), greater<P>());

		for(int i = 0; i < 3; ++i) {
			const int num = v[i].first;
			const int dir = v[i].second;

			if(num <= 3) break;

			const int nx = x + dx[dir];
			const int ny = y + dy[dir];
			if(height[y][x] > height[ny][nx]) {
				(d.*func[dir])();
				x = nx;
				y = ny;
				goto next;
			}
		}

		top[y][x] = d[TOP];
		++height[y][x];
		return;
	next:;
	}
}

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

	const int sx = SIZE / 2, sy = SIZE / 2;

	for(int n; cin >> n, n;) {
		memset(top, 0, sizeof(top));
		memset(height, 0, sizeof(height));

		for(int i = 0; i < n; ++i) {
			int t, f;
			cin >> t >> f;

			dice d;
			d.set(t, f);
			drop(sx, sy, d);
		}

		vector<int> cnt(7, 0);
		for(int i = 0; i < SIZE; ++i) {
			for(int j = 0; j < SIZE; ++j) {
				++cnt[top[i][j]];
			}
		}

		for(int i = 1; i <= 6; ++i) {
			cout << cnt[i] << (i == 6 ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1212
function Main(input) {
	var line = input.split('\n');
	var N = parseInt(line[0], 10);
	var K = parseInt(line[1], 10);
	var X = parseInt(line[2], 10);
	var Y = parseInt(line[3], 10);
	var anser = 0;
	for(var i=0; i<N; i++){
		if(i < K){
			anser += X;
		}else{
			anser += Y;
		}
	}
	console.log(anser);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
n = int(input())
a= []
result = []
for i in range(0,n):
	a.append(list(input().split()))
#print(n)
#print(a)

for j in ('S','H','C','D'):
	for k in range(1,14):
		if [j, str(k)] not in a:
			result.append([j, str(k)])

for l in result:
	print('{0} {1}'.format(l[0], l[1]))


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

using namespace std;

int main()
{
    int n;
    vector<pair<int, int> > a;

    cin >> n;

    a.resize(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i].first;
        a[i].second = i + 1;
    }

    sort(a.begin(), a.end());

    cout << a[0].second;
    for(int i = 1; i < n; ++i)
    {
        cout << " " << a[i].second;
    }
    cout << endl;
}

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

const int MAX=1e5+10;
int dp[MAX];
int main(){
    int N,K,i,j;
    cin >> N >> K;
    int a[N];
    int flag;
    for(i=0;i<N;i++)cin >> a[i];
    for(i=0;i<a[0];i++)dp[i]=-1;
    for(i=a[0];i<K+1;i++){
        flag=0;
        for(j=0;j<N;j++){
            if(i<a[j])break;
            else if(dp[i-a[j]]==-1){
               flag++;
               break;
            }
            }
        if(flag>0)dp[i]=1;
        else{dp[i]=-1;} 
        }
    if(dp[K]==1)cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define LSOne(i) (i&(-i))
#define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
#define BUG(x) {cout<<#x<<" = "<<x<<endl;}
#define left(x) (x<<1)
#define right(x) ((x<<1) +1)
#define middle(s,e)(s+(e-s)/2)
#define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
#define CL(A,I) (memset(A,I,sizeof(A)))
#define endl '\n'
#define PHAS(_n) (pbits[(_n)>>5] & (1u << ((_n) & 0x1f)))
#define PSET(_n) (pbits[(_n)>>5] |= (1u << ((_n) & 0x1f)))
//unsigned int pbits[200000000/32+1];

static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const long double epsilon = 1e-15;
static const long double pi = acos((long double) -1);
using namespace std;
inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef long long ll;
const int MAX_N = 300001;

/*
struct data{
  int l,r,c;
  data():l(0), r(0),c(0){};
  data(int w, int i, int c_) : l(w),r(i),c(c_){};
  bool operator < (data other) const {
	if(l==other.l)
		return r<other.r;
    return l < other.l;
  }
};
*/



int arr[MAX_N];
int alph[27];


int main()
{

        double n,k;
        cin>>n>>k;
        double ans = 0.0 ;
        ll num= 0;
        ll denum = 0;
        num = 1;
        denum = pow(2,ceil(log(k)/log(2)));
        rep(i,2,n+1){
                
                if(i>k)
                {
                    ans+=1;
                    continue;
                }
                num = num*pow(2,ceil(log(k/i)/log(2))) + denum;
                denum *= pow(2,ceil(log(k/i)/log(2)));
                int d; 
        		  d = __gcd(num, denum); 
  
              num = num / d; 
              denum = denum / d; 
        }
  if(denum !=0.0)
        ans += (1.0*num)/(1.0*denum);
        ans*=(1.0/(n*1.0));
        printf("%.10f",ans);



        return 0;
}


Measured memory_bytes: 384
// Don't Lose Hope, Nor Be Sad 

#include <bits/stdc++.h>
using namespace std;

  #define lp(start,finish) for(int i=start; i<finish; i++)
  #define read freopen("input.txt","r",stdin);
  #define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int main(){
	//read
	int a,b;
	cin >> a >> b;
	if(a>=10) cout << b <<endl;
	else{
		int temp = 100 * (10 - a);
		cout << b+temp <<endl;
	}	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N;
int x[10], y[10];
 
double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double ans = 0.0;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4296
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(ll i=0;i<(int)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(int)(n);i++)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
const ll MOD = 1000000007;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
int main(){
    ll x;cin>>x;
    ll c=sqrt(x);
    //cout<<c<<endl;
    bool flag=false;
    REP(i,1,c+3){
        if(flag)break;
        if(x%i==0){
            REP(b,-10001,10001){
                //cout<<b<<endl;
                ll k = x/i;
                ll a = i+b;
                ll d = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+pow(b,3)*a+pow(b,4);
                if(d==k){
                    cout<<a<<" "<<b<<endl;;
                    flag=true;
                    break;
                }
                a = k+b;
                d = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+pow(b,3)*a+pow(b,4);
                if(d==i){
                    cout<<a<<" "<<b<<endl;;
                    flag=true;
                    break;
                }
            }
        }
    }
}


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

int main(){
    int S;
    cin >> S;
    int h;
    int m;
    int s;
h = S / 60 / 60;
S = S - (h*60*60);
m = S / 60;
S = S - (m*60);
s = S;

    cout <<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;
#define MOD 1000000007

ll dp[5010][5010];

int main(){
    
    ll N,Ma,Mb;
    cin>>N>>Ma>>Mb;
    vector<ll> A(N),B(N),C(N);
    REP(i,N)cin>>A[i]>>B[i]>>C[i];
    
    if(Ma>Mb){
        bool flag=false;
        REP(i,N){
            if(A[i]>B[i])flag=true;
        }
        if(!flag){
            cout<<-1<<endl;
            return 0;
        }
    }else{
        bool flag=false;
        REP(i,N){
            if(A[i]<B[i])flag=true;
        }
        if(!flag){
            cout<<-1<<endl;
            return 0;
        }
    }
    
    REP(i,5000)REP(j,5000)dp[i][j]=1e18;
    dp[0][0] = 0;
    
    REP(kai,N){
        for(ll i=5000;i>=A[kai];i--){
            for(ll j=5000;j>=B[kai];j--){
                dp[i][j] = min(dp[i-A[kai]][j-B[kai]] + C[kai],dp[i][j]);
            }
        }
    }
    
    /*REP(i,5){
        REP(j,5)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    
    ll ans=1e18;
    for(int i=1;i*Ma<5000&&i*Mb<5000;i++){
        ans = min(ans,dp[Ma*i][Mb*i]);
    }
    
    if(ans==1e18)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

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

namespace Combinatorics {
vector<int> fat;
vector<int> ifat;

void precalculate(int n) {
  fat.resize(n + 1, 1);
  ifat.resize(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    fat[i] = mod(fat[i - 1] * i);
    ifat[i] = exp(fat[i], M - 2);
  }
}

int C(int n, int k) { return mod(mod(fat[n] * ifat[n - k]) * ifat[k]); }
}  // namespace Combinatorics

//#define MULTIPLE_TEST_CASE
void solution() {
  int n, m;
  cin >> n >> m;
  Combinatorics::precalculate(500000);
  int ans = 0;
  ans = mod(Combinatorics::C(m, n) * Combinatorics::fat[n]);
  int ans2 = 0;

  for (int i = 0; i <= n; i++) {
    // i numbers equal to A
    int tot = Combinatorics::C(n, i);
    tot = mod(tot * Combinatorics::C(m - i, n - i));
    tot = mod(tot * Combinatorics::fat[n - i]);
    if (i % 2)
      ans2 = mod(ans2 - tot);
    else
      ans2 = mod(ans2 + tot);
  }
  cout << mod(ans * ans2) << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 11148
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define W 100001
#define N 101
//binary heap 實作
int dp[2][W];
pair<int,int>data[N];//weight value
int dp_fun(int n,int w){
	for(int i=1;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(j<data[i].first)dp[i%2][j]=dp[(i+1)%2][j];
			else dp[i%2][j]=max(dp[(i+1)%2][j-data[i].first]+data[i].second,dp[(i+1)%2][j]);
		}
	}
	return dp[n%2][w];
}
main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,weight;
	cin>>n>>weight;
	for(int i=1;i<=n;i++)cin>>data[i].first>>data[i].second;
	cout<<dp_fun(n,weight)<<"\n";

}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
int main(void){
  int n,i,p[10][2],u=1;
  double s,ans=0;
  vector<int> v;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> p[i][0] >> p[i][1];
    v.push_back(i);
    u*=i+1;
  }
  do{
    double dx,dy;
    s=0;
    for (i=0;i<n-1;i++){
      int k=v[i],l=v[i+1];
      dx=p[k][0]-p[l][0];
      dy=p[k][1]-p[l][1];
      s+=sqrt(dx*dx+dy*dy);
    }
    ans+=s/u;
  }while (next_permutation(v.begin(),v.end()));
  printf("%.12lf\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn=2e5+500;
const int inf=0x3f3f3f3f;
const int p=1e9+7;
int n;
//int a[maxn],b[maxn];
int a,b;
int ar[maxn];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    while(cin>>a){
        for(int i=0;i<a;i++){
            cin>>ar[i];
        }
        int cnt=1,ans=a;
        for(int i=0;i<a;i++){
            if(cnt==ar[i]){
                ans--;
                cnt++;
            }
        }
        if(ans==a){
            cout<<-1<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int ans=0;
int n;
void dfs(ll cur, int mask){
  if(cur<=n){
    if(mask==7) ans++;
    dfs(cur*10+7,mask|4);
    dfs(cur*10+5,mask|2);
    dfs(cur*10+3,mask|1);
  }
}

int main(){
  cin >> n;
  int keta=0;
  dfs(0,0);
  //  int ka[3]={3,5,7};
  cout << ans << endl;
  

  
  /*  while(nt>0){
    nt/=10;
    keta++;   
  }

  
  int dp[8][keta];
  rep(i,8) rep(j,keta) dp[i][j]=0;
  for(int i=keta-1; i>=0; i--){
      rep(j,3){
	if(i==keta-1){
	  dp[1<<j][i]=1;
	}
	else{
	  rep(k,8){
	    int t = (1<<j)|k;
	    dp[t][i] += dp[k][i+1];      
	  }
	}
      }
      cout << dp[1][0] << endl;
  }
  cout  << dp[7][0] << endl;
  */  
  

  
  return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9+8
#define OO 1e18
#define EPS 1e-6
#define Endl '\n'
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;

int main()
{
    int a,b,x,y;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    printf("%d\n",(a*b)-(x*b)-((a-x)*y));
    re 0;
}

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

int main(void){
    
    int N,len;
    cin >> N;
    len = N * 0.9;
    
    for(int i=len;i<=N;i++){
        if((int)(i* 1.08) == N){
            cout << i <<endl;
            break;
        }
       
       if(i == N) cout << ":(" <<endl;
    }
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<30;


vector<LL> fact;
vector<LL> inver(3000001);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=3000000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[3000000]=fpow(fact[3000000],mod-2);
    for(int i=2999999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 
LL hcombi(int n,int r){
    return combi(n+r-1,r); 
}



int main(){
    set_combi();
    LL n,m;cin >> n >> m;
    LL ans = 0;
    for (int i = m; i >= 0; i-=2) {
        ans = (ans + hcombi(n,m+(m-i)/2) * combi(n,i))%mod;
    }
    for (int i = 2*m+1; i <= 3*m; i++) {
        ans = (ans - (n * hcombi(n-1,3*m-i))%mod + mod)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 58468
#include<iostream>
#include<string>
#include<cctype>
#include<cstdlib>
using namespace std;

int num[100];
int top = 0, result = 0;

int push(int x){
    if(top >= 100) return 1;
    num[top++] = x;
    return 0;
}

int pop(void){
    if(top <= 0) return 1;
    return num[--top];
}

int main(void){
    string input;
    int v;
    bool flag = false;

    while(1){
        cin >> input;
        if(cin.eof()) break;
        if(isdigit(input[0])) push(atoi(input.c_str()));
        else{
            switch (input[0])
            {
            case '+':
                v = pop() + pop();
                push(v);
                break;

            case '-':
                int w;
                w = pop();
                v = pop();
                v -= w;
                push(v);
                break;

            case '*':
                v = pop() * pop();
                push(v);
                break;

            default:
                flag = true;
                break;
            }
        }
        if(flag) break;
    }
    cout << pop() << endl;
    return 0;
}


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

int main() {
 int n;
 cin >> n;
 
  vector<int> s(n);
  int i =0;
  for (; i< n; ++i) {
      cin >> s[i];
  }
  i = 1;
  s[0]--;
  for (; i < n; ++i){
    if (s[i-1] > s[i]) break;
    if (s[i] - s[i-1]) s[i]--;
  }
  if (i == n) cout << "Yes\n";
  else cout << "No\n";
  
}

Measured memory_bytes: 640
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 +10 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
mp=defaultdict(int)
t=[]
for i in range(n):
    s=StoI()
    s.sort()
    tmp=0
    for i in s:
        tmp=tmp*100+i
    t.append(tmp)
    #mp[s]+=1
    
c=Counter(t)

ans=0
for i,j in c.items():
    ans+=j*(j-1)//2
print(ans)

Measured memory_bytes: 68440
'''A - Double Helix
https://atcoder.jp/contests/abc122/tasks/abc122_a

>>> main('A')
T
>>> main('G')
C
'''


def main(b):
    if b == 'A':
        print('T')
    elif b =='T':
        print('A')
    elif b == 'G':
        print('C')
    elif b == 'C':
        print('G')


if __name__ == '__main__':
    main(input())


Measured memory_bytes: 2940
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

map<int,int>cnt;

 main()

{
    fast
    int n,x;
    int mx=0,mn=inf;
    cin>>n;
    f(i,1,n)
    {
        cin>>x;
        cnt[x]++;
        mx=max(mx,x);
        mn=min(mn,x);
    }
    if(mx-mn>1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    if(mx==mn)
    {
       if(mx==(n-1))
       {
           cout<<"Yes"<<endl;
       }
       else if(n>=2*mx)
       {
           cout<<"Yes"<<endl;
       }
       else
       {
           cout<<"No"<<endl;
       }
    }
    else
    {
        int d=cnt[mn];
        int mcnt=cnt[mx];
        mcnt=mcnt/2;
        if(mx>= d+1  && mx<=d+mcnt)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }


















    return 0;

}













Measured memory_bytes: 6528
#include<iostream>
using namespace std;
typedef long long LL;
LL gcd(LL X,LL Y)
{
    return Y>0?gcd(Y,X%Y):X;
}
LL N,M,L,G,i;
char S[123456],T[123456];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>M;
    cin>>S;
    cin>>T;
    G=gcd(N,M);
    L=N/G*M;
    for(i=0;i<G;i++)
        if(S[N/G*i]!=T[M/G*i])
            return cout<<-1<<endl,0;
    cout<<L<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (k <= a) {
    cout << a - k << ' ' << b << endl;
  } else if (k - a >= b) {
    cout << "0 0" << endl;
  } else {
    cout << "0 " << b - (k - a) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
 
int main() {
    int h,a;
    cin >> h >> a;
    int c = 0;
    while(h > 0) {
        h -=a;
        c++;
    }
    cout << c << "\n";
}

Measured memory_bytes: 256