akhauriyash/Code-Regression huggingface dataset:
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])#reverse
wv.sort(key=lambda x:x[0])
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    z=wv[i][0]-w0
    k=wv[i][1]+x[z][-1]
    l=len(x[z])
    if l*wv[i][0]<=w:
        x[z].append(k)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
l0=len(x[0])
for i in range(l3):
    for j in range(l2):
        d=w-i*(w0+3)-j*(w0+2)
        if d>=0:
            for k in range(l1):
                d=w-i*(w0+3)-j*(w0+2)-k*(w0+1)
                if d>=0:
                    ma_sub=x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,l0-1)]
                    ma=max(ma,ma_sub)
                else:
                    break
        else:
            break

print(ma)


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

#define inn(n)         int n; cin >> n;
typedef long long      ll;
typedef vector<int>    vi;
typedef pair<int, int> pi;

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

    inn(m); inn(n);
    m = (m*m - m)/2;
    n = (n*n - n)/2;
	
    cout << m + n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main(){
    int D;
    cin >> D;
    if(D==22) cout << "Christmas Eve Eve Eve" << endl;
    if(D==23) cout << "Christmas Eve Eve" << endl;
    if(D==24) cout << "Christmas Eve" << endl;
    if(D==25) cout << "Christmas" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/
ll nx[2000000] = {0};
ll cur[2000000] = {0};
int main()
{
	//ll mod = (10e8)+7;
	ll mod = 1000000007;
	ll i,j,k,a,b;//,ans=0;
	char c;
	ll endi;
	ll N,M,T, X,Y;
	ll mp[64][64] = {0};
	ll bef[64]= {0};
	ll sets[64]={0};
	cin >> N;
	for(i=0;i<N-1;++i)
	{
		cin >> j >> k;
		mp[j-1][k-1] = i+1;
		mp[k-1][j-1] = i+1;
	}
	cin >> M;
	for(i=0;i<M;++i)
	{
		cin>>j>>k;
		--j;
		--k;
		for(a=0;a<64;++a)
			bef[a] = -1;
		queue<ll> q;
		q.push(j);
		bef[j] = j;
		while(!q.empty())
		{
			a = q.front();
			q.pop();
			for(b=0;b<N;++b)
			{
				if(mp[a][b] && bef[b] == -1)
				{
					bef[b] = a;
					if(b == k)
						break;
					q.push(b);
				}
			}
			if(b==k)
				break;
		}
		a = k;
		while(bef[a]!=a)
		{
			sets[mp[a][bef[a]]-1] |= 1 << i;
			a = bef[a];
		}
	}
	cur[0] = 1;
	T = 1 << M;
	for(i=0;i<N-1;++i)
	{
		for(j=0;j<T;++j)
		{
			nx[j|sets[i]] += cur[j];
		}
		for(j=0;j<T;++j)
		{
			cur[j]+=nx[j];
			nx[j] = 0;
		}
	}
	cout << cur[T-1] << endl;

	return 0;
}




















Measured memory_bytes: 20864
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans[] = {b, b/2, 0};
    int i = 1;
    if (a >= 13){
      i--;
    }else if (a <= 5){
      i++;
    }
    System.out.println(ans[i]);
  }
}


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

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int m = max( {A, B, C});
    int d = pow(2,K);
    cout << (A + B + C - m) + m * d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

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

	V<V<P>> e(n, V<P>(0));
	rep(i, n - 1)e[i + 1].push_back(make_pair(0, i));
	
	rep(i, m) {
		int l, r;
		ll c;
		cin >> l >> r >> c;
		l--;r--;
		e[l].push_back(make_pair(c, r));
	}

	V<ll> dist(n, LINF);dist[0] = 0;
	priority_queue<P, V<P>, greater<P>> pq;
	pq.push(make_pair(0, 0));
	
	while (!pq.empty()) {
		ll d = pq.top().first;
		int v = pq.top().second;pq.pop();
		if (dist[v] < d)continue;
		rep(i, e[v].size()) {
			int vv = e[v][i].second;
			ll dd = e[v][i].first;
			if (dist[vv] <= d + dd)continue;
			dist[vv] = d + dd;
			pq.push(make_pair(dist[vv], vv));
		}
	}

	if (dist[n - 1] == LINF)cout << -1 << endl;
	else cout << dist[n - 1] << endl;

}

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

int main(){
	int n;
	int all[100];
	for(int i=0; i<100; i++) all[i] = 0;
	while(cin>>n) all[n-1]++;
	int m = 0;
	for(int i=0; i<100; i++) m = max(m, all[i]);
	vector<int> ans;
	for(int i=0; i<100; i++){
		if(m==all[i]) ans.push_back(i+1);
	}
	for(int i=0; i<ans.size(); i++) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 0
// URL : https://atcoder.jp/contests/practice2/tasks/practice2_a
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

signed main() {
    int N, Q;
    cin >> N >> Q;
    dsu d(N);
    while (Q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            d.merge(u, v);
        else
            cout << d.same(u, v) << endl;
    }
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=1 && a<=9 && b>=1 && b<=9){
        cout<<a*b;
    }else{
        cout<<-1;
    }
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cout.tie(NULL);
    ll test = 1;
    //cin >> test;
    while(test--)
    {
		ll n;
		cin>>n;
		int arr[n];
		for(int i=0; i<n; i++)
		{
			cin>>arr[i];
		}
		vector<int> dp (n, 0);
		dp[0] = 0;
		dp[1] = abs(arr[1]-arr[0]);
		for(int i=2; i<n; i++)
		{
			dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
		}
		cout<<dp[n-1]<<"\n";
	}
    return 0;
}


Measured memory_bytes: 3964
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200005];
map<int,int>mm;
int pre[200005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here--------------------------------------------------------------------- 

	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]--;
		pre[i]=(pre[i-1]+a[i])%k;
		// cout<<pre[i]<<" ";
	}

	int ans=0;
	mm[0]++;
	for(int i=1;i<=min(k-1,n);i++)
	{
		ans+=mm[pre[i]];
		mm[pre[i]]++;
	}
	for(int i=k;i<=n;i++)
	{
		mm[pre[i-k]]--;
		ans+=mm[pre[i]];
		mm[pre[i]]++;
	}

	cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 15872
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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); }
// *max_element(all(d));
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n,-1){}
    int root(int x){
      if(par[x] < 0)return x;
      return par[x] = root(par[x]);
    }
    bool unite(int x,int y){
      x = root(x); y = root(y);
      if (x == y) return false;
      if (par[x] > par[y]) swap(x, y);
      par[x] += par[y];
      par[y] = x;
      return true;
    }
    bool same(int x,int y){
      return root(x) == root(y);
    }
    int size(int x) {
      return -par[root(x)];
    }
};
int solve(){ 
  ll l,r;
  cin >> l >> r;
  ll ans = INF;
  ll cnt = 0;
  REP(i,l,min(r,l+2019)+1)REP(j,i+1,min(r,l+2019)+1)ans = min(ans,(ll)i * j % 2019);
  cout << ans << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

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

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 31; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

const int MAX_N = 3000000;
const long long mod = 998244353LL;
long long fact[MAX_N + 9], factinv[MAX_N + 9];

void init() {
	fact[0] = 1;
	for (int i = 1; i <= MAX_N; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	for (int i = 0; i <= MAX_N; i++) factinv[i] = modpow(fact[i], mod - 2, mod);
}

long long ncr(long long n, long long r) {
	if (r < 0 || n < r) return 0;
	return (fact[n] * factinv[r] % mod) * factinv[n - r] % mod;
}

long long N, M;

long long solve(long long even, long long odd) {
	if (odd > M) return 0;
	long long sousa = (3LL * M - odd) / 2;
	long long sousa2 = sousa - (M + 1LL);
	long long sousa3 = sousa - (M);

	long long A1 = ncr(N, even);
	long long B1 = ncr(N + sousa - 1, sousa);
	long long B2 = 1LL * even * ncr(N + sousa2 - 1, sousa2); B2 %= mod;
	long long B3 = 1LL * odd * ncr(N + sousa3 - 1, sousa3); B3 %= mod;

	long long S = A1 * (B1 - B2 - B3 + 2LL * mod) % mod;
	return S;
}

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

	long long ans = 0;
	for (int i = M; i >= 0; i -= 2) ans += solve(N - i, i);
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 47232
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashMap;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		
		String[] s = new String[3];
		
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
			
		}
		
		System.out.println(s[0].charAt(0) + "" + s[1].charAt(1) + "" + s[2].charAt(2));
	}
		
}
	
	


Measured memory_bytes: 22864
/*
	好题，构造，从混乱到有序，再到循环 
	
	AtCoder - 2661
*/

# include <cstdio>

using namespace std;

int main()
{
	long long n;
	
	scanf("%lld",&n);
	printf("50\n");
	
	for(long long i = 0;i <= 49;i++)
	{
		printf("%lld ",49-i+((49-i+n)/50));
	}
	
	return 0;
} 

Measured memory_bytes: 128
a=input()
#b=reversed(a)
c=a[0:int((len(a)-1)/2)]
b=''.join(list(reversed(a)))
d=a[int((len(a)+3)/2)-1:]
 
if a!=b:
  print("No")
elif c!=d:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL A,B,C,D;
LL gcd(LL x,LL y) {
	return y?gcd(y,x%y):x;
}
int main()
{
	scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
	A--;
	LL a1=B/C-A/C;
	LL a2=B/D-A/D;
	LL a3=B/((C*D)/gcd(C,D))-A/((C*D)/gcd(C,D));
	printf("%lld",B-A-(a1+a2-a3));
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static long[] levelNum = new long[51];
        static long[] pattyNum = new long[51];
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NX = Sarray();
            var N = NX[0];
            var X = NX[1];
            levelNum[0] = 1;
            pattyNum[0] = 1;
            for (var i = 1; i <= N; ++i)
            {
                levelNum[i] = 3 + 2 * levelNum[i - 1];
                pattyNum[i] = 1 + 2 * pattyNum[i - 1];
            }
            var ans = lunlun(N, X);
            WriteLine(ans);
            //Out.Flush();
        }
        static long lunlun(long layer, long x)
        {
            //B L[i-1] P L[i-1] B
            var patty = 0L;
            --x;
            if (levelNum[layer - 1] <= x) patty += pattyNum[layer - 1];
            else if (0 < x) patty += lunlun(layer - 1, x);
            x -= levelNum[layer - 1];
            if (0 < x) ++patty;
            --x;
            if (levelNum[layer - 1] <= x) patty += pattyNum[layer - 1];
            else if (0 < x) patty += lunlun(layer - 1, x);
            return patty;
        }
    }
}

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

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

    int x, y;
    cin >> x >> y;

    int res = 0;
    if(x == 1 || y == 1) res += 300000 * (1 + (x == y));
    if(x == 2 || y == 2) res += 200000 * (1 + (x == y));
    if(x == 3 || y == 3) res += 100000 * (1 + (x == y));
    if(x+y == 2) res += 400000;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main() {
  long long n, a, b, c, d;
  int i;
  int flag = 0;
  scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
  for (i = 0; i < n; i++) {
    if (i*c - d*(n-i-1) <= b-a && b-a <= i*d - c*(n-i-1)) {
      flag = 1;
    }
  }
  if (flag == 1) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


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

int main(void){
    int N,M;
    cin >> N >> M;
    vector<int> height(N);
    vector<int> most_high(N);
    for(int i=0;i<N;i++){
        cin >> height.at(i);
    }
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        most_high.at(a-1)=max(most_high.at(a-1),height.at(b-1));
        most_high.at(b-1)=max(most_high.at(b-1),height.at(a-1));
    }
    int ans=0;
    for(int i=0;i<N;i++){
        if(height.at(i)>most_high.at(i))  ans++; 
    }
    cout << ans;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std ;
const double pi = acos(-1) ;
int main () {
  while(1) {
    int a , b ;
    cin >> a >> b ;
    if(a == 0 && b == 0 ) break;
    
    for(int i = 0 ; i < b ; i++)cout << '#' ;
    cout << endl ;
    for(int i = 0 ; i < a -2; i++){
      cout << '#' ;
      for(int j = 0 ; j < b-2 ; j++)cout << '.' ;
      cout << '#' << endl ;
    }
    for(int i = 0 ; i < b ; i++)cout << '#' ;
    cout << endl << endl ;
  }
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

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

  int d, e, f;
  if (a/100 == 9) {
    d = 1;
  } else if (a/100 == 1) {
    d = 9;
  } else {
    d = a/100;
  }
  if ((a/10)%10 == 9) {
    e = 1;
  } else if ((a/10)%10 == 1) {
    e = 9;
  } else {
    e = (a/10)%10;
  }
  if (a%10 == 9) {
    f = 1;
  } else if (a%10 == 1) {
    f = 9;
  } else {
    f = a%10;
  }

  cout << d*100 + e*10 + f << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
v1 = n%10
v2 = (n//10)%10
v3 = n//100

if v1 == v2 and v2 == v3:
    print(n)
elif v3 > v2:
    print(v3*111)
elif v3 == v2:
    if v2 > v1:
        print(v3*111)
    else:
        print((v3+1)*111)
else:
    print((v3+1)*111)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int maxx=-1;
	int flag=1;
	for(int i=1;i<=n;i++){
		int temp=i;
		int kount=0;
		while(temp%2==0){
			temp/=2;
			kount++;
		}
		if(kount>maxx){
			maxx=kount;
			flag=i;
		}
	}
	cout<<flag<<endl;
}

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

long long gcd(long long a, long long b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int i, N;
	long long A[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	long long g = A[1];
	for (i = 2; i <= N; i++) g = gcd(g, A[i]);
	
	printf("%lld\n", g);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

#define M 1000000007

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

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll g;
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] /= 2;
        if (i == 0) {
            g = a[i];
        } else {
            g = (g * a[i]) / gcd(g, a[i]);
        }
    }
    for (ll i = 0; i < n; ++i) {
        if ((g / a[i])%2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll res = m/g;
    ll ans = res / 2;
    if (res % 2 == 1) {
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,b;
    cin>>a;
    cout<<"A";
    if(a<1200)cout<<"B";
    if(a>=1200&&a<2800) cout<<"R";
    if(a>=2800) cout<<"G";
    cout<<"C\n";
    }

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

#define Online 1
// #define multitest 1
#define Debug 1
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
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool f(string &s, int a, int b)
{
	if (a == b)
		return true;
	if (a > b)
		return false;
	if (a == s.length() || s[a] == '#')
		return false;
	return f(s, a + 1, b) || f(s, a + 2, b);
}

void solve()
{
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;
	int cnt = 0, cnt2 = 0;
	// bool f = false;
	for (int i = a - 1; i < max(c, d); ++i)
	{
		if (s[i] == '#')
		{
			// cnt2 = 0;
			cnt++;
		}
		else
		{
			// cnt2++;
			cnt = 0;
		}
		if (cnt == 2)
		{
			cout << "No\n";
			return;
		}
	}
	// s[b - 1] = '#';
	if (f(s, b - 1, d - 1))
	{
		s[d - 1] = '#';
		// s[b - 1] = '.';
		if (f(s, a - 1, c - 1))
		{
			cout << "Yes\n";
			return;
		}
		s[d - 1] = '.';
	}
	s[b - 1] = '#';
	if (f(s, a - 1, c - 1))
	{
		s[c - 1] = '#';
		s[b - 1] = '.';
		// s[d - 1] = '#';
		if (f(s, b - 1, d - 1))
		{
			cout << "Yes\n";
			return;
		}
		// s[d - 1] = '.';
		s[c - 1] = '.';
	}
	s[b - 1] = '.';
	cnt = 0;
	for (int i = b - 2; i < d; ++i)
	{
		if (s[i] == '.')
			cnt++;
		else
			cnt = 0;
		if (cnt == 3)
		{
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\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: 2384
n = int(input())
w = set()
prev = ''
for i in range(n):
    s = input()
    if i!=0 and s[0]!=prev:
        print('No')
        exit()
    prev = s[-1]
    w.add(s)
if len(w)!=n:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  priority_queue<ld,vector<ld>,greater<ld>> q;
  for(ll i=0;i<N;i++){
    ld a;
    cin>>a;
    q.push(a);
  }
  while(q.size()>1){
    ld x=q.top();
    q.pop();
    ld y=q.top();
    q.pop();
    q.push((ld)((x+y)/2));
  }
  cout<<fixed<<setprecision(15)<<q.top()<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
  int N;
  int a[100000],c1,c2,c3;
  c1 = 0;
  c2 = 0;
  c3 = 0;
  cin >> N;
  
  for(int i = 0;i < N;++i){
    cin >> a[i];
    if(a[i] % 4 == 0)
      c1++;
    else if(a[i] % 2 == 0)
      c2++;
    else
      c3++;
  }
      
  if(c1 >= c3 || c2 == 0 && c1 + 1 == c3)
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
  
}

Measured memory_bytes: 768
import heapq

def main():
    n = int(input())
    arr = list(map(int,input().split()))
    arr.sort()
    total = 0
    heap = []
    while arr:
        x = arr.pop()
        if not heap:
            heapq.heappush(heap,(-x,x,x))
        else:
            val,left,right = heapq.heappop(heap)
            val = abs(val)
            total += val
            heapq.heappush(heap,(-min(x,left),left,x))
            heapq.heappush(heap,(-min(x,right),x,right))
            #print(left,right,val)

    print(total)
        
    

main()


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi b(n);

    {
        int j = 0;
        rep2(i, n / 2, n) {
            b[i] = a[j];
            j += 2;
        }
    }
    {
        int j = 1;
        for (int i = n / 2 - 1; i >= 0; i--) {
            b[i] = a[j];
            j += 2;
        }
    }

    if (n & 1) {
        reverse(all(b));
    }

    rep(i, n) {
        cout << (i ? " " : "") << b[i];
    }
    cout << endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> temp = a;
  sort(all(temp));
  int max = temp[n - 1];
  int max2 = temp[n - 2];
  for (int i = 0; i < n; i++) {
    if (a[i] == max)
      cout << max2 << endl;
    else
      cout << max << endl;
  }
  return 0;
}

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

int n, a[200005];
long long ans;
int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int i = n - 2, t = n - 2;
    while(t > 0) {
        ans += a[i];
        t--;
        if(t--) ans += a[i];
        i--;
    }
    if(n == 1) cout << 0;
    else cout << ans + a[n - 1];
}

Measured memory_bytes: 4408
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int time;
    double m,apow;
    int s[1000];
    while(1){
        cin>>time;
        if(time==0) break;
        apow=0;
        m=0;
        for(int i=0;i<time;++i){
            cin>>s[i];
            m+=s[i];
        }
        m/=(double)time;
        for(int i=0;i<time;++i) apow+=pow((double)s[i]-m,2.0);
        cout<<sqrt(apow/(double)time)<<endl;
    }
}

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



int main()
{
	int N, AC = 0, WA = 0, TLE = 0, RE = 0;
	string m;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> m;
		if (m=="AC")
		{
			AC++;
		}
		else if (m == "WA")
		{
			WA++;
		}
		else if (m == "TLE")
		{
			TLE++;
		}
		else {
			RE++;
		}
	}

	cout << "AC" << " x " << AC << endl;
	cout << "WA" << " x " << WA << endl;
	cout << "TLE" << " x " << TLE << endl;
	cout << "RE" << " x " << RE << endl;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    int n,h;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    int maxa = 0;
    int minb;
    ll sum = 0;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        maxa = max(maxa,x);
        a[i] = x;
        b[i] = y;
    }
    ll ans = 0;
    sort(all(a),greater<int>());
    sort(all(b),greater<int>());
    rep(i,n){
        if(maxa >= b[i]) continue;
        sum += b[i];
        ans++;
        if(sum >= h){
            cout << i+1 << endl;
            return 0;
        }
    }
    int remain = h - sum;
    while(remain > 0){
        remain -= a[0];
        ans++;
    }
    cout << ans << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 1000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define P pair<int,int> 
#define INF 1000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n,d,a;
    cin>>n>>d>>a;
    vector<P> x(n);
    REP(i,n){
        int s,t;
        cin>>s>>t;
        x[i]={s,t};
    }
    sort(ALL(x));
    vector<int> S(n+1);
    ll ans=0;
    REP(i,n){
        if(i>0)S[i]+=S[i-1];
        int q=upper_bound(ALL(x),make_pair(x[i].first+2*d,INF))-x.begin();
        int rest=x[i].second-S[i];
        if(rest<=0) continue;
        int cnt=(rest+a-1)/a;
        S[i]+=cnt*a;
        S[q]-=cnt*a;
        ans+=cnt;
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 2560
import numpy as np
N,L = map(int,input().split())
apple = np.array(range(N)) + 1
taste = apple + L - 1
taste_applepie = sum(taste)
if L <= 0 and abs(N) > abs(L):
    print(taste_applepie)
elif L > 0:
    print(taste_applepie - L)
else:
    print(taste_applepie - (N+L-1))

Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
int n,ma,mb,a,b,c,ans=1e9,f[406][406];
int main()
{
	scanf("%d%d%d",&n,&ma,&mb);
	memset(f,100,sizeof f);
	f[0][0]=0;
	for(int o=1;o<=n;o++){
		scanf("%d%d%d",&a,&b,&c);
		for(int i=400;i>=a;i--)
			for(int j=400;j>=b;j--)f[i][j]=min(f[i-a][j-b]+c,f[i][j]);
	}
	for(int i=1;i<=400;i++){
		if(ma*i>400)break;
		if(mb*i>400)break;
		ans=min(ans,f[ma*i][mb*i]);
	}
	if(ans<1e9)printf("%d",ans);else puts("-1");
}

Measured memory_bytes: 896
import java.util.*;

public class Main {
    static int INF=100000;
    public static int abs(int a){
        return (a>0)?a:(-a);
    }
    
    public static int min(int a,int b){
        return (a>b)?b:a;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[][] D=new int[N][N];
        int[][] Duse=new int[N][N];
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                D[i][j]=abs(i-j);
            }
        }
        
        int X=sc.nextInt();
        int Y=sc.nextInt();
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                Duse[i][j]=abs(i-X+1)+abs(j-Y+1)+1;
            }
        }
        
        int[][] min=new int[N][N];
        int[] ans=new int[N];
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                min[i][j]=min(D[i][j],Duse[i][j]);
            }
        }
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                min[i][j]=min(min[i][j],min[j][i]);
            }
        }
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                ans[min[i][j]]++;
            }
        }
        
        for(int i=1;i<N;i++){
            System.out.println(ans[i]/2);
        }
    }
}


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

int main(){
  ll a,b,c,l,r=0;cin>>a>>b>>c;
  if(c-a-b<0){
    cout<<"No"<<endl;
    return 0;
  }
  l=4*a*b;
  r+=c*(c-2*a);
  r+=a*(a+2*b);
  r+=b*(b-2*c);
  cout<<(l<r?"Yes":"No");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int N;

    cin >> N;

    long long mi = 1000000000;
    long long ma = 1;

    for(int i = 0; i < N; i++){
        long long a;
        cin >> a;

        mi = min(mi,a);
        ma = max(ma,a);
    }

    cout << ma - mi << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll a, b, c;
	cin >> a >> b >> c;
	if (c < a + b) {
		cout << "No" << endl;
	}
	else if (4 * a * b >= c * c + a * a + b * b - 2 * a * c - 2 * b * c + 2 * a * b) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


}


Measured memory_bytes: 3648
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

H, W = LI()
c = SR(H)
sy, sx = 0, 0
gy, gx = H-1, W-1

white_counts = 0
for i in range(H):
    for j in range(W):
        if (c[i][j]=="."):
            white_counts += 1

def bfs(sy, sx, gy, gx, c, road=".", blocks=["#"]):
    H = len(c)
    W = len(c[0])
    dire = [(1,0), (0,1), (-1,0), (0,-1)]
    dist = [[107]*W for i in range(H)]
    dist[sy][sx] = 0

    q = deque()
    q.append((sy, sx))

    while q:
        y, x = q.popleft()
        for dy, dx in dire:
            if (y+dy<H) and (y+dy>=0) and (x+dx<W) and (x+dx>=0):
                if (c[y+dy][x+dx] in blocks):
                    continue
                else:
                    if (y+dy==gy) and (x+dx==gx):
                        return (dist[y][x]+1)
                    elif (dist[y+dy][x+dx] > dist[y][x]+1):
                        dist[y+dy][x+dx] = dist[y][x]+1
                        q.append((y+dy, x+dx))
    return -1

path = bfs(sy, sx, gy, gx, c)
print(white_counts-path-1 if (path!=-1) else -1)

Measured memory_bytes: 40944
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n;
    int a[5];
    cin>>n;
    for(int i=0;i<5;i++) cin>>a[i];
    sort(a,a+5);
    if(n<=a[0]) cout<<5<<endl;
    else{
        if(n%a[0]==0) cout<<n/a[0]+4<<endl;
        else cout<<n/a[0]+5<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>


using namespace std;


int main() {
	vector<int>a(100002);
	int N, tmp;
	cin >> N;

	for (int i = 0; i <= 100001 ; i++) {
		a[i] = 0;
	}


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

	int MAX = 0;
	
	for (int i = 0; i <= 100001; i++) {
		MAX = max(a[i], MAX);
	}

	cout << MAX;

	return 0;
}


Measured memory_bytes: 640
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}
func main(){
  n := nextLine()
  i, _ := strconv.Atoi(n)
  fmt.Println(i*i*i)
}

Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let size: Vec<i32> = read_vec();
  let white_line: Vec<i32> = read_vec();
  println!("{}", size[0]*size[1] - (white_line[0]*size[1] + white_line[1]*size[0] - white_line[0]*white_line[1]));
}


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

int main(void)
{
	int X;
	cin >> X;

	long long i = 0;
	for(;;) {
		i++;
		long long sum = (1 + i) * i / 2;
		if (X <= sum) break;
	}
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <cassert>


using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n, n2;
	cin >> n2;
	n = n2;
	long long st = 0, st2 = 0;
	long long cur = 5, x = 1;
	while (cur <= n) {
		long long t = n / cur;
		if (n % 2 == 1) {
			st += (t + 1) / 2;
		}
		else {
			st += t / 2;
		}
		cur = cur * 5;
		x++;
	}
	if (n % 2 == 1) {
		cout << 0;
		return 0;
	}
	cur = 2;
	x = 1;
	while (cur <= n) {
		long long t = n / cur;
		st2 += t;
		cur = cur * 2;
		x++;
	}
	cout << min(st, st2);
	return 0;
}

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

int main() {
  int64_t H, count = 0, L, x;
  cin >> H;
  for (int i = 0; L <= H; i++) {
    L = std::pow(2, i);
    count = i;
  }
  
  x = std::pow(2, count) - 1;
  cout << x << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();

        if (A1 + A2 + A3 < 22) {
            System.out.println("win");
        } else {
            System.out.println("bust");
        }
    }
}

Measured memory_bytes: 35680
n,t=map(int, input().split( ))
L=[0 for i in range(t+1)]
R=[0 for i in range(t+1)]
for i in range(n):
    l,r=map(int, input().split( ))
    L[l]+=1
    R[r]+=1

mx=0
tmp=0
for i in range(t+1):
    tmp+=L[i]
    tmp-=R[i]
    if tmp>mx:
        mx=tmp
print(mx)



Measured memory_bytes: 7288
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  COUT((n+1)/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path;
//***********//
int main() {
	cin >> N;
	vs S(N);
	ll A = 0, B = 0, C = 0, D = 0;
	for (i = 0; i < N; i++) {
		cin >> S[i];
		if (S[i] == "AC") A++;
		else if (S[i] == "WA") B++;
		else if (S[i] == "TLE") C++;
		else if (S[i] == "RE") D++;
	}
	cout << "AC x " << A << endl;
	cout << "WA x " << B << endl;
	cout << "TLE x " << C << endl;
	cout << "RE x " << D << endl;
}

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

using namespace std;

typedef long long ll;

const int di[] = {0, 1, 0, -1};
const int dj[] = {1, 0, -1, 0};

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int H, W; cin >> H >> W;
  string str[H];
  int c[H][W];
  for(int i=0;i<H;i++){
    cin >> str[i];
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(str[i][j] == '#') c[i][j] = 1;
      else c[i][j] = 0;
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(c[i][j] == 1){
        bool impossible = true;
        for(int k=0;k<4;k++){
          if(i+di[k] < 0 || i+di[k] >= H || j+dj[k] < 0 || j+dj[k] >= W) continue;
          if(c[i+di[k]][j+dj[k]] == 1){
            impossible = false;
            break;
          }
        }
        if(impossible){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.ArrayDeque;
import java.awt.Point;
 
class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();

        for(int i=0; i<=x; i++) {
            if(i*2+(x-i)*4==y) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    } 
}

Measured memory_bytes: 35548
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N = int(input())
s = []
n = 0
for i in range(N):
    s.append(list(input()))
ans = 0


for i in range(N):
    s[i].sort()
s.sort()

for i in range(1,N):

    if s[i]==s[i-1]:
        n += 1
        if i == N-1:
            ans += cmb(n+1, 2)
    else:
        if n > 0:
            ans += cmb(n+1,2)
            n = 0
print(ans)


Measured memory_bytes: 26692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n,k;
    cin>>n>>k;
    vector <ll>  ans(0);
    ll x;
    for(ll i=1;i<=n;i++)    cin>>x,ans.push_back(x);
    sort(ans.begin(),ans.end());
    ll now=0;
    for(ll i=0;i<k;i++) now+=ans[i];
    cout<<now;
    return 0;
}


Measured memory_bytes: 3604
N,M = map(int,input().split())
mondai = [[0 for i in range(N)] for i in range(2)]
ans = 0
for i in range(M):
    p,s = input().split()
    if s == "WA":
        mondai[0][int(p)-1] += 1
    elif s == "AC":
        if mondai[1][int(p)-1]:
            continue
        ans += mondai[0][int(p)-1]
        mondai[1][int(p)-1] = 1
print(sum(mondai[1]),ans)


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

int t;
int num[10];

void sousa(int a, int b){
	for(num[a-1] = num[a]-1; num[a-1] >= 0; num[a-1]--){
		if(a-1 < 0 || b < 0){
			break;
		}
		else if(a-1 == 0 && b-num[a-1] == 0){
			t++;
			break;
		}
		else{
			sousa(a-1, b-num[a-1]);
		}
	}
}
int main(){
	vector<int> array;
	int n, m;
	while(cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		if(m > 45){
			array.push_back(0);
			continue;
		}
		t = 0;
		num[n] = 10;
		sousa(n, m);
		array.push_back(t);
	}
	for(int i = 0; i < array.size(); i++){
		cout << array[i] << endl;
	}
}

Measured memory_bytes: 1216