akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define l long 
#define ll long long 
#define ld long double 
#define INF 1000000000000000
#define MOD 1000000007
#define MAX_N 1000006
#define f first
#define s second
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULLL);
using namespace std;
ll cnt_path[50][50],w[50][50];
void matexpo(ll k)
{
    if(k==1)
        return;
    matexpo(k/2);
    ll dk[50][50];
    for(l i=0;i<50;i++)
    {
        for(l j=0;j<50;j++)
        {
            dk[i][j]=0LL;
            for(l p=0;p<50;p++)
            {
                dk[i][j]=(dk[i][j]+cnt_path[i][p]*cnt_path[p][j])%MOD;
            }
        }
    }
    if(k%2==1)
    {
        for(l i=0;i<50;i++)
        {
            for(l j=0;j<50;j++)
            {
                cnt_path[i][j]=0LL;
                for(l p=0;p<50;p++)
                {
                    cnt_path[i][j]=(cnt_path[i][j]+dk[i][p]*w[p][j])%MOD;
                }
            }
        }
    }
    else 
    {
        for(l i=0;i<50;i++)
        {
            for(l j=0;j<50;j++)
            {
                cnt_path[i][j]=dk[i][j];
            }
        }
    }
    return;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    l n;
    ll k;
    cin>>n>>k;
    for(l i=0;i<50;i++)
    {
        for(l j=0;j<50;j++)
        {
            cnt_path[i][j]=0;
            w[i][j]=0;
        }
    }
    for(l i=0;i<n;i++)
    {
        for(l j=0;j<n;j++)
        {
            cin>>w[i][j];
            cnt_path[i][j]=w[i][j];
        }
    }
    matexpo(k);
    ll ans=0LL;
    for(l i=0;i<n;i++)
    {
        for(l j=0;j<n;j++)
        {
            ans=(ans+cnt_path[i][j])%MOD;
        }
    }
    if(ans<0)
    ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
const int maxn=105;
string ma[maxn];
int x[maxn],y[maxn];
int h,w;
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>ma[i];
	}
	for(int i=0;i<h;i++){
		int yes=1;
		for(int j=0;j<w;j++){
			if(ma[i][j]!='.'){
				yes=0;
			}
		}
		y[i]=yes;
	}
	for(int i=0;i<w;i++){
		int yes=1;
		for(int j=0;j<h;j++){
			if(ma[j][i]!='.'){
				yes=0;
			}
		}
		x[i]=yes;
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(y[i]==1) break;
			if(x[j]==1) ;
			else cout<<ma[i][j];
		}
		if (y[i]!=1)cout<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

//typedef pair<int, int> P;

const int MAX_V = 2020;
const int MAX_LOG_V = 30;
vector<int> G[MAX_V];
int root;

int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];

void dfs(int v, int p, int d) {
	parent[0][v] = p;
	depth[v] = d;
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] != p)dfs(G[v][i], v, d + 1);
	}
}

void init(int V) {
	dfs(root, -1, 0);
	for (int k = 0; k + 1 < MAX_LOG_V; k++) {
		for (int v = 0; v < V; v++) {
			if (parent[k][v] < 0)parent[k + 1][v] = -1;
			else parent[k + 1][v] = parent[k][parent[k][v]];
		}
	}
}

int lca(int u, int v) {
	if (depth[u] > depth[v]) {
		swap(u, v);
	}
	for (int k = 0; k < MAX_LOG_V; k++) {
		if ((depth[v] - depth[u]) >> k & 1) {
			v = parent[k][v];
		}
	}
	if (u == v)return u;
	for (int k = MAX_LOG_V - 1; k >= 0; k--) {
		if (parent[k][u] != parent[k][v]) {
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}
int dist(int a, int b) {
	int par = lca(a, b);
	return depth[a] + depth[b] - 2 * depth[par];
}


int N, K;
int A[100010], B[100010];
signed main() {
	cin >> N >> K;
	
	REP(i, N-1) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		G[A[i]].pb(B[i]);
		G[B[i]].pb(A[i]);
	}
	root = 0;
	init(N);
	int ans = INF;
	if (K % 2 == 0) {
		REP(i, N) {
			int res = 0;
			REP(j, N) {
				if (j == i)continue;
				if (dist(i, j) > K / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	else {
		REP(i, N - 1) {
			int res = 0;
			int l = A[i], r = B[i];
			REP(j, N) {
				if (j == l || j == r)continue;
				int d = min(dist(l, j), dist(r, j));
				if (d > (K - 1) / 2)res++;
			}
			ans = min(ans, res);
		}
	}
	print(ans);
	/*while (true) {
		int x, y; cin >> x >> y;
		pe(depth[x]); print(depth[y]);
		print(lca(x, y));
	}*/
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    double x,t;
    cin >> t >> x;

    cout << std::fixed << std::setprecision(10) << t/x <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0

#define S 1
#define W -1

using namespace std;

void show(int *data,int n){
	REP(i,n){
		cout<<data[i];
	}
	cout<<endl;
}

string ans(int *data,int n){
	string str="";
	REP(i,n){
		if(data[i]==S){
			str+="S";
		}else{
			str+="W";
		}
	}
	return str;
}


int func(char c,int *data,int n){
	int num;
	if(c =='o'){
		num=1;
	}else{
		num=-1;
	}
	if(DEBUG)show(data,n);
	return num*data[n-1]*data[n];
}

int calc(int *data,int n,string str){
	for(int i=1;i<n-2;i++){
		data[i+1]= func(str.at(i),data,i);
	}
	if(data[n-1] == func(str.at(n-2),data,n-2) && data[0] == func(str.at(n-1),data,n-1)){
		cout<<ans(data,n)<<endl;
		return 1;
	}
	return -1;
}

lli min(lli a,lli b){
	return a <= b ? a : b;
}

void init(int *data,int n,int i,char c){
	int num;
	if(c =='o'){
		num=1;
	}else{
		num=-1;
	}
	int first[4] = {S,S,W,W};
	int second[4]= {S,W,S,W};
	REP(j,n){
		data[j]=0;
	}
	data[0]=first[i];
	data[1]=second[i];
	data[n-1]=num*data[0]*data[1];
}

int main(){
	int n;
	int *data;
	string str;
	cin>>n>>str;
	data = new int[n];
	REP(i,4){
		init(data,n,i,str.at(0));
		if(calc(data,n,str)==1){
			return 0;
		}
	}

	cout<<"-1"<<endl;
	return 0;

}

Measured memory_bytes: 1152
# include <cstdio>
# include <cstring>

using namespace std;

const int MAX_N = 2e5 + 10;

int n;
char s[MAX_N];

int dp[MAX_N];
char f[MAX_N];
int nt[MAX_N];
int last[26];

int main ()
{
    int i, j;
    scanf ("%s", s + 1);
    n = strlen (s + 1);

    for (i = 0; i < 26; i ++)
        last[i] = n + 1;

    dp[n + 1] = (1 << 30);
    dp[n + 2] = 0;

    for (i = n; i >= 1; i --)
    {
        dp[i] = (1 << 30);
        last[s[i] - 'a'] = i;
        for (j = 0; j < 26; j ++)
        {
            if (dp[i] > (dp[last[j] + 1] + 1))
            {
                dp[i] = dp[last[j] + 1] + 1;
                f[i] = char (j + 'a');
                nt[i] = last[j] + 1;
            }
        }
    }

    int x = 1;

    while (x <= n)
    {
        printf ("%c", f[x]);
        x = nt[x];
    }
    printf ("\n");

    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
        int main()
        {
        	char a[4], s = '\0', k = '\0';
        	gets(a);
        	s = a[0];
        	for (int i = 1; i < 4; i++)
        	{
        		if (a[i] != s && k == '\0')
        			k = a[i];
        		else if (a[i] != s && a[i] != k)
        		{
        			printf("No");
        			return 0;
        		}
         
        	}
        	if (k == '\0')
        	{
        		printf("No");
        	}
         
        	else
        	{
        		printf("Yes");
        	}
         
        }

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <stack>
#include <map>

#define pii pair<int, int>

using namespace std;

bool comp(pii a, pii b){
    return a.first - a.second < b.first - b.second;
}

int main() {
    int n;
    cin >> n;
    vector <pii> a(n);
    for(int i = 0; i < n; i++) cin >> a[i].first;
    for(int j = 0; j < n; j++) cin >> a[j].second;
    sort(begin(a), end(a), comp);
    
    int ans = 0;
    
    for(int i = 0; i < n; i++){
        //cout << a[i].first << ' ' << a[i].second << endl;
        if(a[i].first > a[i].second) ans += a[i].first - a[i].second;
    }
    cout << ans;
}



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

long long int N, M, K, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	map<long long int, int>m;
	for (int i = 0; i < N; i++) {
		cin >> M;
		m[M]++;
	}
	vector<long long int>v;
	for (auto i : m) {
		if (i.second >3) {
			v.push_back(i.first);
			v.push_back(i.first);
		}
		else if (i.second >1) {
			v.push_back(i.first);
		}
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	if (v.size() < 2) {
		cout << "0\n";
	}
	else {
		cout << v[0] * v[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  map<string, bool> mp;

  char last = '0';
  while (n--) {
    string s;
    cin >> s;
    if (mp.size()) {
      if (mp.count(s) || s[0] != last) {
        cout << "No" << endl;
        return 0;
      }
    }
    last = s[s.size() - 1];
    mp[s] = true;
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: "List[int]"):
    s = sorted(Ai - i - 1 for i, Ai in enumerate(A))
    b = s[N // 2]
    print(sum(abs(Ai - i - 1 - b) for i, Ai in enumerate(A)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36188
n,x=map(int,input().split())
m=[]
kai=n
for i in range(n):
  m.append(int(input()))
m.sort()
x=x-sum(m)
while x:
  if x >= m[0]:
    x=x-m[0]
    kai+=1
  else:
    break
print(kai)

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


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

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

    vi y(1000001, 0);
    rep(i, n) {
        for (int j = 2; j * j <= a[i]; j++) {
            if (a[i] % j == 0) {
                y[j]++;

                while (a[i] % j == 0)
                    a[i] /= j;
            }
        }
        if (a[i] != 1)
            y[a[i]]++;
    }

    ll m = *max_element(rng(y));

    if (m <= 1) {
        prt("pairwise coprime");
    } else if (m == n) {
        prt("not coprime");
    } else {
        prt("setwise coprime");
    }

    return 0;
}


Measured memory_bytes: 11116
from collections import deque
n, q = map(int, input().split())
t = [[] for _ in range(n)]
for _ in range(n - 1):
  a, b = map(lambda x: int(x) - 1, input().split())
  t[a].append(b)
  t[b].append(a)
c = [0] * n
for _ in range(q):
  p, x = map(int, input().split())
  c[p - 1] += x
stk = deque()
stk.appendleft((0, -1))
while len(stk) != 0:
  i, p = stk.popleft()
  for j in t[i]:
    if j == p:
      continue
    c[j] += c[i]
    stk.appendleft((j, i))
print(*c)


Measured memory_bytes: 62224
D,G = map(int,input().split())
L = []
for i in range(D) :
    L.append(list(map(int,input().split())))

ans = float("inf")
for bit in range(1 << D) :
    AC = 0
    score = 0
    for k in range(D) :
        if bit & (1 << k) :
            score += 100*(k+1)*L[k][0]+L[k][1]
            AC += L[k][0]
    if score >= G :
        ans = min(ans,AC)
        continue
    for k in range(D-1,-1,-1) :
        if bit & (1 << k) :
            continue
        if (score + 100*(k+1)*L[k][0]) < G :
            score += 100*(k+1)*L[k][0]
            AC += L[k][0]
        else :
            res = G - score
            while res > 0 :
                res -= 100*(k+1)
                AC += 1
            ans = min(ans,AC)
            break
print(ans)


Measured memory_bytes: 3064
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=0,a;
  cin >> n;
  map<int,int> m;
  for(int i=0; i<n; i++) {
    cin >> a;
    m[a]++;
  }
  for(auto p:m) {
    if(p.second>p.first) {
      ans+=p.second-p.first;
    }
    else if(p.second<p.first) {
      ans+=p.second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

num = int(input())

divisors = make_divisors(num)

min = float('inf')

for n in reversed(divisors):
    temp = num / n
    temp_result = (n-1) + (temp-1)
    if temp_result < min:
        min = temp_result

print(int(min))


Measured memory_bytes: 3268
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

int main(void)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a<b&&b<c){
printf("Yes\n");
}else{
printf("No\n");
}
  return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,A;
    cin >> N;
    string ans="APPROVED";
    for(int i=0; i<N; i++){
        cin >> A;
        if(A%2==0){
            if((A%3!=0)&&(A%5!=0)){
                ans="DENIED";
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);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;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	int cnt = 0, ans = 0;
	if (s[0] == 'R') {
		cnt++;
		ans = max(ans, cnt);
	}
	else cnt = 0;
	if (s[1] == 'R') {
		cnt++;
		ans = max(ans, cnt);
	}
	else cnt = 0;
	if (s[2] == 'R') {
		cnt++;
		ans = max(ans, cnt);
	}
	else cnt = 0;
	cout << ans << endl;

}

Measured memory_bytes: 3620
n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

X.sort()
Y.sort()

if X[-1] >= y or Y[0] <= x:
    print("War")
elif X[-1] >= Y[0]:
    print("War")
else:
    print("No War")


Measured memory_bytes: 3060
n, c, k = gets.split.map(&:to_i)
t = Array.new(n) { gets.to_i }.sort
count = 0

until t.empty?
  first = t[0]
  size = t.take_while { |e| e <= first + k }.take(c).size
  t = t.drop(size)
  count += 1
end

puts count

Measured memory_bytes: 16536
import java.util.Scanner;

public class Main {
	static int max = 2000001;
	static int length = 0;
	static int[] A = new int[max];
	
	
	static int left(int i) {
		return (i * 2);
	}
	static int right(int i) {
		return (i * 2 + 1);
	}
	static int parent(int i) {
		return (i/2);
	}
	
	void buildMaxHeap(int[] A) {
		for (int i = ((length - 1)/2); i >= 1; i--) {
			MaxHeapify(A, i);
		}
	}
	
	static void MaxHeapify(int[] A,int i) {
		int largest = i;
		int left = left(i);
		int right = right(i);
		int tmp;
		
		if (left <= length && A[left] > A[i]) {
			largest = left;
		}
		
		if (right <= length && A[right] > A[largest]) {
			largest = right;
		}
		if (largest != i) { //Swap 
			tmp = A[i];
			A[i] = A[largest];
			A[largest] = tmp;
			MaxHeapify(A, largest);
		}
	}
	static void insert(int i) {
		length++;
		inserter(i, length);
	}
	static void inserter(int element, int i) {
		if (element < 0) {
			return;
		}
		A[i] = element;
		while (i > 1 && A[i/2] < element) {
			A[i] = A[i/2];
			A[i/2] = element;
			i = i/2;
		}
	}
	
	static int extract() {
		int max = A[1];
		A[1] = A[length];
		length--;
		MaxHeapify(A, 1);
		return max;
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String st = "";
		while (! (st.equals("end"))) {
			st = in.next();
			if (st.equals("insert")) {
				int i = in.nextInt();
				insert(i);
			}
			else if (st.equals("extract")) {
				System.out.println(extract());
			}
			print();
		}
	}
	static void print() {
		/*
		for (int i = 1; i < length+3; i++) {
			System.out.print(A[i] + " ");
			
		}
		System.out.println();
		System.out.println(length);
		*/
	}
	
}



Measured memory_bytes: 556240
function Main(input) {
  const setting = input.trim().split(' ')
  const animal_sum = setting[0] - 0
  const leg_sum = setting[1] - 0

  let answer = false

  for (let crane = 0; crane <= animal_sum; crane++) {
    let turtle = animal_sum - crane
    if (((crane * 2) + (turtle * 4)) === leg_sum) {
      answer = true
      break
    }
  }

  if (answer) {
    console.log('Yes')
  } else {
    console.log('No')
  }
  }

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30840
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n/2){
        if(s[i]!=s[n-1-i]) ans++;
    }
    cout << ans << endl;
}

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

int n,m;
ll a[100001],b[100001];
int main(){
    cin>>n>>m;
    rep(i,n) cin>>a[i],b[i]=a[i];
    int pre=__builtin_ctz(b[0]);
    a[0]/=2;
    FOR(i,1,n){
        if(pre!=__builtin_ctz(b[i])){
            cout<<0<<endl;
            return 0;
        }
        a[i]/=2;
    }
    ll lcm=a[0];
    FOR(i,1,n){
        lcm=lcm*a[i]/__gcd(a[i],lcm);
        if(lcm>m){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<((m/lcm)+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
	ll n,sumi=0,i=1;
	ll res=0;
	ll resi=0;
	cin >> n;
	while(1){
		sumi += i;
		if(n < sumi){
			res = sumi;
			resi = i;
			break;
		}
		i++;
	}
	rep(j,i+1){
		if(j==(sumi-n)||j==0){
			continue;
		}
		cout << j << "\n";
	}
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_chars {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
    ($n:expr) => {
        {
            (0..$n)
                .map(|_| get_chars!())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let x = get!(i64);

    for a in -200..200 {
        for b in -200..200 {
            if a * a * a * a * a - b * b * b * b * b == x {
                println!("{} {}", a, b);
                std::process::exit(0);
            }
        }
    }
}


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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        int bucket[256] = {};
        rep(i, n){
            bucket[in()] = 1;
        }
        lep(i, 2 * n){
            if (!bucket[i]) bucket[i] = 2;
        }
        int field = -1; // empty
        int tarou, hanako;
        tarou = hanako = n;
        while (1){
            lep(i, 2 * n){
                if (bucket[i] == 1 && field < i){
                    bucket[i] = 0;
                    field = i;
                    tarou--;
                    break;
                }
                if (i == 2 * n){
                    field = -1;
                }
            }
            if (!tarou) break;
            lep(i, 2 * n){
                if (bucket[i] == 2 && field < i){
                    bucket[i] = 0;
                    field = i;
                    hanako--;
                    break;
                }
                if (i == 2 * n){
                    field = -1;
                }
            }
            if (!hanako) break;
        }
        tarou = hanako = 0;
        lep(i, 2 * n){
            if (bucket[i] == 1) tarou++;
            if (bucket[i] == 2) hanako++;
        }
        printf("%d\n%d\n", hanako, tarou);
    }
    return (0);
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str0[105]={0};
    char str1[105]={0};
    scanf("%s", str0);
    scanf("%s", str1);

    long len0=strlen(str0);
    long len1=strlen(str1);
    if(len0>len1) {
        printf("GREATER\n"); return 0;
    }
    else if (len0<len1) {
        printf("LESS\n"); return 0;
    }

    long i;
    for(i=0; i<len0; i++) {
        if( str0[i] > str1[i] ) {
            printf("GREATER\n"); return 0;
        }
        else if ( str0[i] < str1[i] ) {
            printf("LESS\n"); return 0;
        }
    }
    printf("EQUAL\n");

    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,i,p,sum=0;
    vector<long long int>k;
    cin>>a>>b;
    for(i=0;i<a;i++)
    {
        cin>>p;
        k.push_back(p);
    }
    sort(k.begin(),k.end());
    for(i=0;i<b;i++)
    {
        sum=sum+k[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3608
import sys

N = int(input())

W = []
for i in range(N):
    w = str(input())
    if w in W:
        print("No")
        sys.exit()
    if i != 0 and w[0] != W[i-1][-1]:
        print("No")
        sys.exit()
    W.append(w)

print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long D;
vector<long> c(26);
vector<vector<long>> s(365,vector<long>(26));
vector<long> t(365);

void INPUT(){
  cin >> D;
  rep(i,26) cin >> c.at(i);
  rep(i,D){
    rep(j,26) cin >> s.at(i).at(j);
  }
}

long greedy(){
  vector<long> lastday(26,-1);

  long ans = 0;
  rep(i,D){
    vector<long> tmpscore(26,ans);
    rep(j,26){
      tmpscore.at(j) += s.at(i).at(j);
      rep(k,26){
        if(j != k){
          tmpscore.at(j) -= (i - lastday.at(k))*c.at(k);
        }
      }
    }
    long day = 0;
    long maxi = tmpscore.at(0);
    rep(j,26){
      if(tmpscore.at(j) > maxi){
        maxi = tmpscore.at(j);
        day = j;
      }
    }
    ans = maxi;
    //cout << day+1 << endl;
    t.at(i) = day;
    lastday.at(day) = i;
  }
  return ans;
}

long calc(){
  vector<long> lastday(26,-1);
  long ans = 0;
  rep(i,D){
    long tt = t.at(i);
    ans += s.at(i).at(tt);
    lastday.at(tt) = i;
    rep(j,26){
      ans -= (i - lastday.at(j)) * c.at(j);
    }
    //cout << ans << endl;
  }
  return ans;
}

void OUTPUT(){
  rep(i,D){
    if(t.at(i)+1 <= 0 || t.at(i)+1 > 26) cout << 1 << endl;
    else cout << t.at(i)+1 << endl;
  }
}

int main(){
  INPUT();
  long now = greedy();
  srand(time(NULL));
  rep(i,5000){
    long d = rand() % D;
    long q = rand() % 26;
    long prev_q = t.at(d);
    t.at(d) = q;
    long res = calc();
    if(res > now){
      now = res;
    }else{
      t.at(d) = prev_q;
    }
  }
  OUTPUT();
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    int x;
    cin >> x;
    puts((x >= 30 ? "Yes" : "No"));
}

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


Measured memory_bytes: 3620
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res
 
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
def pow_k(x, n):
 
    if n == 0:
        return 1
 
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
 
    return K * x
def main():  #startline-------------------------------------------
    n = int(input())
    s = input()
    print(s.count("R")-s[:s.count("R")].count("R"))
        
                
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 38708
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  2 21:02:01 2020

@author: NEC-PCuser
"""

N, D = map(int, input().split())

count = 0

for i in range(N):
	X, Y = map(int, input().split())
	if (X * X + Y * Y <= D * D):
		count += 1

print(count)

Measured memory_bytes: 9180
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 c = sc.nextInt();
    if (a == b || a == c || b == c) {
      if (a == b && a == c && b == c) {
        System.out.println("No");        
      } else {
        System.out.println("Yes");                
      }
    } else {
      System.out.println("No");
    }
  }
}




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

int main(){
  
  string a;
  cin >> a;
  
  if( a.at(0) == a.at(1) || a.at(1) == a.at(2) || a.at(2) == a.at(3) ){
  
    cout << "Bad" << endl;
    
  }
  
  else{
    
    cout << "Good" << endl;
    
  }
  
}


Measured memory_bytes: 3540
N = int(input())
Astr = input().split()
A = []
for A_i in Astr:
    A.append(int(A_i))

candidate = 0
end = 0
while end == 0:
    for A_i in A:
        if (A_i/2**(candidate))%2 != 0:
            end = 1
            break
    else:
        candidate += 1
print(candidate)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int unsigned long long 

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;

const int  M    =  998244353;
const int  maxn =  100001   ;
const int  inf  =  1e16     ;

int32_t main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int m , n ; 
      cin >> m >> n ; 
      int t = m*n;
      if(m==1 or n==1){
          cout << 1 ;
          return 0 ;
      }
      if(t%2==0)
         cout << t/2 ; 
       else
       {
           cout << (t/2)+1 ;
       }
       

   
return 0;
}  

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

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG
/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#else
#define print(...)
#endif


template<class Monoid>
class SegmentTree {

public:
    /**
     * @param N size
     * @param e identity element
     * @param operation operation to merge `data`
     * @param updater operation to update `data`
     */
    SegmentTree(size_t N, Monoid e, function<Monoid(Monoid, Monoid)> operation,
                function<Monoid(Monoid, Monoid)> updater)
            : e(e), operation(operation), updater(move(updater)) {
        n = 1;
        while (n < N) {
            n *= 2;
        }
        data = vector<Monoid>(2 * n - 1, e);
        for (int i = n - 2; i >= 0; i--) {
            data[i] = operation(data[2 * i + 1], data[2 * i + 2]);
        }
    }

    /**
     * iの値をxに更新 ( 0-indexed )
     */
    void update(int i, Monoid x) {
        i += n - 1;
        data[i] = updater(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    Monoid query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス( 0-indexed )
     */
    Monoid operator[](int i) {
        return data[i + n - 1];
    }

private:
    int n;
    vector<Monoid> data;
    Monoid e;
    function<Monoid(Monoid, Monoid)> operation;
    function<Monoid(Monoid, Monoid)> updater;

    Monoid query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return e;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        Monoid c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        Monoid c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }
};

void solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    SegmentTree<ll> segmentTree(700000, 0, [](ll a, ll b) { return max(a, b); },
                                [](ll a, ll b) { return max(a, b); });
    rep(i, N) {
        ll a = A[i];
        ll m1 = max(0LL, a - K);
        ll m2 = a + K;
        ll v = segmentTree.query(m1, m2 + 1);
        print(a, v);
        segmentTree.update(a, v + 1);
    }
//    rep(i, 10) {
//        cout << segmentTree.query(i, i + 1) << '\n';
//    }
    cout << segmentTree.query(0, 700000) << '\n';
}

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


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  h, n;
    cin >> h >> n;
    ivec a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    ivec dp(h+1, inf);
    dp[0] = 0;
    for (int i = 1; i < h+1; i++){
        for (int j = 0; j < n; j++) dp[i] = fmin(dp[i], dp[fmax(0, i-a[j])] + b[j]);
    }
    cout << dp[h] << endl;

}

Measured memory_bytes: 512
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;

    cout << (H - h) * (W - w) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main() {
  ll n, cnt = 0LL, ans = 1LL;
  ll x[100000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < n; i++) {
    cnt++;
    if (x[i] < cnt * 2LL - 1LL) {
      ans *= cnt;
      ans %= MOD;
      cnt--;
    }
  }
  while (cnt) {
    ans *= cnt;
    ans %= MOD;
    cnt--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
//Picture Frame

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,0,h)cin>>s[i];
    rep(i,0,w+2)cout<<"#";
    cout<<endl;
    rep(i,0,h){
        cout<<"#"<<s[i]<<"#"<<endl;
    }
    rep(i,0,w+2)cout<<"#";
    cout<<endl;
    return 0;
}

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

using namespace std;

constexpr static int MAXN = 1e6;
int n, L;
int64_t t[MAXN], v[MAXN];
pair <int64_t, int> ti[MAXN];
int idx[MAXN];

int main() {
    scanf("%d%d", &n, &L);
    for (int i = 0; i < n; i++) {
        scanf("%lld%lld", &t[i], &v[i]);
        ti[i] = {-t[i], i};
    }
    sort(ti, ti + n);
    for (int i = 0; i < n; i++)
        idx[ti[i].second] = i;

    // maintain the cumulative best f(v) = tvsum (convex, piecewise-linear)
    // m contains (slope, len) where slope is decreasing
    deque <pair <double, int64_t>> m; // (slope, len)
    // v[0] == L
    m.push_back({t[0], v[0]});
    double tvsum = 1.0 * t[0] * v[0];
    printf("%.10lf\n", tvsum / L);
    for (int i = 1; i < n; i++) {
        // cut down from L to L - v[i]
        int64_t del = v[i];
        while (true) {
            int64_t len = m.back().second;
            if (len <= del) {
                del -= len;
                tvsum -= m.back().first * len;
                m.pop_back();
                if (del == 0)
                    break;
            }
            else {
                tvsum -= m.back().first * del;
                m.back().second -= del;
                break;
            }
        }

        // add v[i] block
        tvsum += 1.0 * t[i] * v[i];
        m.push_front({t[i], v[i]});
        printf("%.10lf\n", tvsum / L);

        // convexify
        while (m.size() > 1 && m[0].first < m[1].first) {
            double tv = m[0].first * m[0].second + m[1].first * m[1].second;
            int64_t len = m[0].second + m[1].second;
            m.pop_front();
            m.pop_front();
            m.push_front({tv / len, len});
        }
    }
}


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

#define be(v) (v).rbegin(),(v).rend()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,w,a,b,ans=0,w1,dp[4][101]={0};
    vector<ll> v[4];
    cin>>n>>w;
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        if(i==0){
            w1=a;
            v[0].pb(b);
        }
        else if(a==w1){
            v[0].pb(b);
        }
        else if(a==w1+1){
            v[1].pb(b);
        }
        else if(a==w1+2){
            v[2].pb(b);
        }
        else{
            v[3].pb(b);
        }
    }
    for(int i=0;i<4;i++){
        sort(be(v[i]));
    }
    for(int i=0;i<4;i++){
        for(ll j=0;j<v[i].size();j++){
            dp[i][j+1]=dp[i][j]+v[i][j];
        }
    }
    for(ll i=0;i<=v[0].size();i++){
        for(ll j=0;j<=v[1].size();j++){
            for(ll k=0;k<=v[2].size();k++){
                for(ll m=0;m<=v[3].size();m++){
                    a=w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*m;
                    b=dp[0][i]+dp[1][j]+dp[2][k]+dp[3][m];
                    if(w>=a){
                        ans=max(ans,b);
                    }
                }
            }
        }
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
class Dice:
    def __init__(self):
        self.number = [i for i in range(6)]
        self.tmp = [i for i in range(6)]
        self.set_cmd = 'NNNNWNNNWNNNENNNENNNWNNN'


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def next(self,direction):
        for i in range(6):
            self.tmp[i] = self.number[i]

        if direction == 'E':
            self.setNumber(self.tmp[3], self.tmp[1], self.tmp[0], self.tmp[5], self.tmp[4], self.tmp[2])
        elif direction == 'N':
            self.setNumber(self.tmp[1], self.tmp[5], self.tmp[2], self.tmp[3], self.tmp[0], self.tmp[4])
        elif direction == 'S':
            self.setNumber(self.tmp[4], self.tmp[0], self.tmp[2], self.tmp[3], self.tmp[5], self.tmp[1])
        elif direction == 'W':
            self.setNumber(self.tmp[2], self.tmp[1], self.tmp[5], self.tmp[0], self.tmp[4], self.tmp[3])
    def get_result(self):
        return self.number[0]



    def search(self,top,forword):

        self.search_arr = [i for i in range(6)]
        for i in range(len(self.number)):
            self.search_arr[i] = self.number[i]


        for i in range(len(self.set_cmd)):
            self.next(self.set_cmd[i])

            right = 40

            if self.number[0] == top and self.number[1] == forword:
                right = self.number[2]
                break
        for i in range(len(self.number)):
            self.number[i] = self.search_arr[i]


        return right

dice = Dice()
fig = list(map(int,input().split()))
dice.setNumber(fig[0],fig[1],fig[2],fig[3],fig[4],fig[5])

cmd_fig = int(input())
for i in range(cmd_fig):
    top , forword = map(int,input().split())
    right_side = dice.search(top,forword)
    print("{}".format(right_side))











Measured memory_bytes: 5620