akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) gcd(b, a);
	long long  r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
namespace NTT {
	const int MOD = 998244353;  // to be set appropriately
	const long long PR = 3;     // to be set appropriately

	void trans(vector<long long> &v, bool inv = false) {
		int n = (int)v.size();
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k >(i ^= k); k >>= 1);
			if (i > j) swap(v[i], v[j]);
		}
		for (int t = 2; t <= n; t <<= 1) {
			long long bw = modpow(PR, (MOD - 1) / t, MOD);
			if (inv) bw = modinv(bw, MOD);
			for (int i = 0; i < n; i += t) {
				long long w = 1;
				for (int j = 0; j < t / 2; ++j) {
					int j1 = i + j, j2 = i + j + t / 2;
					long long c1 = v[j1], c2 = v[j2] * w % MOD;
					v[j1] = c1 + c2;
					v[j2] = c1 - c2 + MOD;
					while (v[j1] >= MOD) v[j1] -= MOD;
					while (v[j2] >= MOD) v[j2] -= MOD;
					w = w * bw % MOD;
				}
			}
		}
		if (inv) {
			long long inv_n = modinv(n, MOD);
			for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD;
		}
	}

	// C is A*B
	vector<long long> mult(vector<long long> A, vector<long long> B) {
		int size_a = 1; while (size_a < A.size()) size_a <<= 1;
		int size_b = 1; while (size_b < B.size()) size_b <<= 1;
		int size_fft = max(size_a, size_b) << 1;

		vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
		for (int i = 0; i < A.size(); ++i) cA[i] = A[i];
		for (int i = 0; i < B.size(); ++i) cB[i] = B[i];

		trans(cA); trans(cB);
		for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD;
		trans(cC, true);

		vector<long long> res((int)A.size() + (int)B.size() - 1);
		for (int i = 0; i < res.size(); ++i) res[i] = cC[i];
		return res;
	}
};
typedef pair<int, int> p;
typedef pair<int, p> pai;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << n*(n +1)/2;
}

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

using namespace std;

const int mxn = 1e5;

char s[mxn + 11];

int main(){
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    for (int i = 1; i <= len; i++){
        if (i + 1 <= len && s[i] == s[i + 1]){
            printf("%d %d\n", i, i + 1);
            return 0;
        }
        if (i + 2 <= len && s[i] == s[i + 2]){
            printf("%d %d\n", i, i + 2);
            return 0;
        }
    }
    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 384
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i, j;
	int N;
	int zetta = 0;
	int maxabs= 0;
	cin >> N;
	int A[200] = {};
	for (i = 0; i < N; ++i) {
		cin >> A[i];
	}

	for (i = 0; i < N; ++i) {

		for (j = i; j < N; ++j) {
			if (i != j) {
				zetta = abs(A[i] - A[j]);
				maxabs = max(zetta, maxabs);
			}

		}
	}

	cout << maxabs << endl;
}



Measured memory_bytes: 256
#include <cstdio>

int N;
int main() {
	scanf("%d",&N);
	int sol=1;
	int cur;
	int vec=0;
	scanf("%d",&cur);
	for(int i=1;i<N;i++) {
		int next;
		scanf("%d",&next);
		if(vec==1) {
			if(cur>next) {
				sol++;
				vec=0;
			}
			cur=next;
		} else if(vec==-1) {
			if(cur<next) {
				sol++;
				vec=0;
			}
			cur=next;
		} else {
			if(cur<next) vec=1;
			if(cur>next) vec=-1;
			cur=next;
		}
	}
	printf("%d\n",sol);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define mod 1000000007


void get_prime_vector(vector<int> *v, int n)
{
  (*v).push_back(2);
  for (int i=3; i<n+1; i++){
    bool flag=true;
    for (int j=2; j<i; j++){
      if (i%j == 0){
	flag=false;
	break;
      }
    }
    if (flag){
      (*v).push_back(i);
    }
  }
}


int main()
{
  map<int, int> m;
  vector<int> v;
  int n, t, k, cnt, tmp[1000]={0};

  cin >> n;
  get_prime_vector(&v, n);

  for (int i=0; i<v.size(); i++){
    t = v[i];
    cnt = 0;
    for (int j=2; j<n+1; j++){
      k = j;
      while (k > 1){
	if (k%t == 0){
	  cnt++;
	  k = k / t;
	} else {
	  k = 0;
	}
      }
    }
    tmp[t] = cnt;
  }

  long long ans=1;
  for (int i=0; i<1000; i++){
    if (tmp[i] != 0){
      ans = ans * (tmp[i]+1) % mod;
    }
  }
  cout << ans << endl;
	
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    ll n,a,b,c,d,e;
    cin >>n>>a>>b>>c>>d>>e;
    ll mn = min({a,b,c,d,e});
    cout <<  (n+mn-1)/mn + 4<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int partition(int *A,int p,int r);

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

  x=partition(&A,0,n-1);
  for(i=0;i<x;i++){printf("%d ",A[i]);}
  printf("[%d]",A[i]);
  i++;
  for(i;i<n;i++){printf(" %d",A[i]);}
  printf("\n");
}

int partition(int *A,int p,int r){
  int i,j,tmp,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}


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

const int INF = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector <int> a(h), b(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i] >> b[i];
        a[i]--;
    }
    vector <int> f(w);
    vector <int> nxt(w);
    for (int i = 0; i < w; ++i) {
        f[i] = i;
        nxt[i] = i;
    }
    function<int(int)> find_next = [&](int i) {
        if (nxt[i] == i)
            return i;
        nxt[i] = find_next(nxt[i]);
        return nxt[i];
    };
    multiset<int> st;
    for (int i = 0; i < w; ++i)
        st.insert(f[i] - i);
    for (int i = 0; i < h; ++i) {
        int l = -1, r = w;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (f[find_next(m)] < a[i])
                l = m;
            else
                r = m;
        }
        if (r != w && f[find_next(r)] < b[i]) {
            int pos = r;
            while (pos < w) {
                pos = find_next(pos);
                if (f[pos] != w)
                    st.erase(st.find(f[pos] - pos));
                if (pos + 1 < w && f[find_next(pos + 1)] < b[i]) {
                    nxt[pos] = pos + 1;
                    pos++;
                } else
                    break;
            }
            f[pos] = b[i];
            if (f[pos] != w)
                st.insert(f[pos] - pos);
        }
        if (st.empty())
            cout << "-1\n";
        else
            cout << *st.begin() + i + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 15792
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
string W;
int main(){ //srand((unsigned)time(NULL));
  cin >> W;
  vector<string> T;
  while(1){
    string temp;
    cin >> temp;
    if(temp == "END_OF_TEXT")break;
    for (int i = 0; i < temp.length(); i++) {
      if('A' <= temp[i] && temp[i] <= 'Z')temp[i] = tolower(temp[i]);
    }
    T.pb(temp);
  }
  ll ans = 0;
  for (int i = 0; i < T.size(); i++) {
    if(T[i] == W)ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3204
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  ll h, n;
  std::cin >> h >> n;

  ll sum = 0;
  for(int i=0; i<n; i++){
    int temp;
    std::cin >> temp;
    sum += temp;
  }

  if( sum >= h ){
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }

  return 0;
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll a,b;
	cin>>a>>b;
    string ans="";
    if(a<b){
        rep(i,b){
            ans = ans + to_string(a);
        }
    }else{
        rep(i,a){
            ans = ans + to_string(b);
        }
    }
    cout<<ans<<"\n";
	
	return 0;
}


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

#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

//===== グラフ受け取り =====//
/*
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);

        // 無向グラフの場合は以下を追加
        // G[b].push_back(a);
    }
    
    // == 重み付きグラフ == //
    
    struct Edge {
        int to; 
        int weight; 
        Edge(int t, int w) : to(t), weight(w) { }
    };
    using Graph = vector<vector<Edge>>;
    int main() {
        int N, M; cin >> N >> M;
        Graph G(N);
        for (int i = 0; i < M; ++i) {
            int from, to, weight;
            cin >> from >> to >> weight;
            G[from].push_back(Edge(to, weight));
        }
    }
*/    

using namespace std;
// using Edge = pair<int, int>;
// using Graph = vector<vector<Edge>>;
// using pll = pair<long long, long long>;

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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { 
    return (a.second < b.second); 
} 


int main() {
    int N, X; cin >> N >> X;
    int D = 0;
    vector<int> bound(N+1);
    bound[0] = 0;
    int cnt = 1;
    for (int i = 1; i < N + 1; i++) {
        int L; cin >> L;
        bound[i] = L + bound[i-1];
        if(bound[i] > X) break;
        cnt++;
    }
    cout << cnt << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

void no_cost_graphmake(ll E,mat &G){
  rep(i,E){
    ll a,b;
    cin >> a >> b;
    G.at(a-1).push_back(b-1);
    G.at(b-1).push_back(a-1);//有向なら消す
  }
}
//vec d(N);
void no_cost_dijkstra(ll s,vec &d, mat &G,ll V){
  queue<ll> que;
  rep(i,V) d.at(i)=INF;
  d.at(s)=0;
  que.push(s);
  while(!que.empty()){
    ll p=que.front();
    que.pop();
    rep(i,G.at(p).size()){
      ll e=G.at(p).at(i);
      if(d.at(e)>d.at(p)+1){
        d.at(e)=d.at(p)+1;
        que.push(e);
      }
    }
  }
}

int main(){
  ll N,a=0,b=0;
  cin >> N;
  mat G(N);
  no_cost_graphmake(N-1,G);
  vec dA(N),dB(N);
  no_cost_dijkstra(0,dA,G,N);
  no_cost_dijkstra(N-1,dB,G,N);
  rep(i,N){
    if(dA.at(i)<=dB.at(i)){
      a++;
    }else{
      b++;
    }
  }
  if(a>b){
    cout << "Fennec" << endl;
  }else{
    cout << "Snuke" << endl;
  }
}

Measured memory_bytes: 10936
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int calc_score(int D, const vector<int>& C, const vector<vector<int>>& S, const vector<int>& T) {
    vector<int> last_day(26, 0);
    int score = 0;
    rep(i, 0, D) {
        score += S[i][T[i] - 1];
        last_day[T[i] - 1] = i + 1;
        rep(j, 0, 26) {
            score -= C[j] * (i + 1 - last_day[j]);
        }
    }
    return score;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    vector<int> C(26);
    for (auto& c : C) {
        cin >> c;
    }
    vector<vector<int>> S(D, vector<int>(26));
    rep(i, 0, D) rep(j, 0, 26) {
        cin >> S[i][j];
    }
    vector<int> T(D);
    for (auto& t : T) {
        cin >> t;
    }
    int M;
    cin >> M;
    vector<int> d(M), q(M);
    rep(i, 0, M) {
        cin >> d[i] >> q[i];
    }
    int score = calc_score(D, C, S, T);
    rep(i, 0, M) {
        score -= S[d[i] - 1][T[d[i] - 1] - 1];
        {
            int ld = d[i] - 1;
            while (ld >= 1 && T[ld - 1] != T[d[i] - 1]) {
                --ld;
            }
            int rd = d[i] + 1;
            score -= C[T[d[i] - 1] - 1] * (d[i] - ld);
            while (rd <= D && T[rd - 1] != T[d[i] - 1]) {
                score -= C[T[d[i] - 1] - 1] * (d[i] - ld);
                ++rd;
            }
        }
        score += S[d[i] - 1][q[i] - 1];
        {
            int ld = d[i] - 1;
            while (ld >= 1 && T[ld - 1] != q[i]) {
                --ld;
            }
            int rd = d[i] + 1;
            score += C[q[i] - 1] * (d[i] - ld);
            while (rd <= D && T[rd - 1] != q[i]) {
                score += C[q[i] - 1] * (d[i] - ld);
                ++rd;
            }
        }
        cout << score << endl;
        T[d[i] - 1] = q[i];
    }
    return 0;
}

Measured memory_bytes: 3916
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int DP[310][90010];
int DP2[310][90010];


signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	const int MOD = 998244353;
	
	DP[0][0] = 1;
	DP2[0][0] = 1;

	int N, A;
	int sum = 0;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A;
		sum += A;
		rep(j, 0, 90010)
		{
			if (DP[i][j] > 0)
			{
				DP[i + 1][j] += 2 * DP[i][j];
				DP[i + 1][j + A] += DP[i][j];
				DP[i + 1][j] %= MOD;
				DP[i + 1][j + A] %= MOD;
			}
			if (DP2[i][j] > 0)
			{
				DP2[i + 1][j] += DP2[i][j];
				DP2[i + 1][j + A] += DP2[i][j];
				DP2[i + 1][j] %= MOD;
				DP2[i + 1][j + A] %= MOD;
			}
		}
	}

	int ans = 1;
	rep(i, 0, N)
	{
		ans = (ans * 3) % MOD;
	}
	rep(i, (sum + 1) / 2, sum + 1)
	{
		rep(j, 0, 3)
		{
			ans = (ans + MOD - DP[N][i]) % MOD;
		}
	}
	if (sum % 2 == 0)
	{
		rep(i, 0, 3)
		{
			ans = (ans + DP2[N][sum / 2]) % MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 424192
// #ifndef MY_LIBRARY
// #define MY_LIBRARY
// #include<iostream>
// using namespace std;
// #endif

//#pragma once
#include<iostream>


using namespace std;

template<typename T>
//ax + by = gcd(a,b)
T ext_gcd(T a,T b,T &x,T &y){
    if(b==0){x=1;y=0;return a;}    
    T d = ext_gcd(b, a%b,y,x);
    y-=a/b*x;
    return d;
}

int main(){
    int a,b;
    cin>>a>>b;
    int x,y;
    ext_gcd(a, b, x, y);
    printf("%d %d\n",x,y);
    return 0;
}

Measured memory_bytes: 1136
function Main(input) {
	let str = input.toString().split("")
	str.pop()
	let num = str.join(".").split("").map( x => ( x == "." ) ? "" : x )
	let l = str.length - 1
	let ans = 0
	for( let i = 0; i < (1<<l); ++i ){
	let tempnum = [...num]
	for( let j = 0; j < l; ++j ){
		if( (i>>j) & 1 ){
			tempnum[1+2*j] = "+"
		}	
	}
	ans += eval(tempnum.join(""))
	}
	console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

using namespace std;

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

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A, B;
  cin >> A >> B;
  int ret = 0, uku = 1;
  while(uku < B) {
    ++ret;
    uku += A - 1;
  }
  cout << ret << endl;
}




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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 998244353
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

int main()
{
    ll N;
    cin >> N;
    vec D(N);
    REP(i,0,N) cin >> D[i];
    
    vec A(N, 0);
    if(D[0] != 0) PR(0);
    else {
        ll m = 0;
        REP(i,0,N) {
            ++A[D[i]];
            m = MAX(m,D[i]);
        }
        if(A[0] > 1) PR(0);
        else {
            ll cnt = 1;
            REP(i,1,m+1) {
                cnt = (cnt * modpow(A[i-1], A[i], MOD)) % MOD;
            }
            PR(cnt);
        }
    }

    return 0;
}

/*



*/

Measured memory_bytes: 4832
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)



int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  /*文字列を種類ごと区切って配列にする*/
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<pair<char,ll>> p;
  vector<pair<char,ll>> pair=runlength(s,p);
  
  cout<<pair.size()<<endl;
  
  
  
  
}





Measured memory_bytes: 2676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int k = 0;
		if (N == 0) {
			System.out.println(0);
		} else if (N == 1) {
			System.out.println(1);

		} else if (N > 1 && N <= 3) {
			System.out.println(2);

		} else if (N > 3 && N <= 7) {
			System.out.println(4);

		} else if (N > 7 && N <= 15) {
			System.out.println(8);

		} else if (N > 15 && N <= 31) {
			System.out.println(16);

		} else if (N > 31 && N <= 63) {
			System.out.println(32);

		} else if (N > 63 && N <= 100) {
			System.out.println(64);

		}
	}

	// void solve(Scanner sc) {
	// int N = sc.nextInt();
	// int k = 0;
	//
	// for (double i = 1;; i++) {
	// k = (int) Math.pow(2, i);
	// N /= k;
	// if (N == 0) {
	// break;
	// }
	// }
	// System.out.println(k);
	// }
}


Measured memory_bytes: 21716
MAX_N = 100000
N = int(input())
ret = [1000000 for _ in range(MAX_N + 1)]
ret[0] = 0


def f(i, j):
    if j <= MAX_N:
        ret[j] = min(ret[j], ret[i] + 1)


for i in range(N + 1):
    f(i, i + 1)

    for k in range(1, 7):
        f(i, i + 6 ** k)

    for k in range(1, 6):
        f(i, i + 9 ** k)


print(ret[N])

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
ll L, R, dp[66][2][2];

ll solve(int x, int left, int right, bool flag) {
    if (x < 0) return 1;
    if (!flag && dp[x][left][right] != -1) return dp[x][left][right];
    int l = 0, r = 1;
    if (left) l = (L >> x & 1);
    if (right) r = (R >> x & 1);
    ll ret = 0;
    rep(i, l, 1) {
        rep(j, i, r) {
            if (j == 1 && flag) {  // 遇到最高位了
                if (i == 1)
                    ret += solve(x - 1, left && i == l, right && j == r, 0);
            } else
                ret += solve(x - 1, left && i == l, right && j == r, flag && j == 0);
        }
    }
    ret %= mod;
    if (!flag) dp[x][left][right] = ret;
    return ret;
}

int main() {
    cin >> L >> R;
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solve(60, 1, 1, 1));
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];

    map<lint, lint> mp;
    for (int i = 0; i < N; i++) {
        mp[A[i]]++;
    }

    lint total = 0;
    for (auto p : mp) {
        lint x, y;
        tie(x, y) = p;
        dd(x, y);
        total += y * (y - 1) / 2;
    }
    d(total);
    for (int k = 0; k < N; k++) {
        lint x   = A[k];
        lint s   = mp[x];
        lint ans = total;
        ans -= (s * (s - 1) / 2);
        s--;
        ans += (s * (s - 1) / 2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 11008
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //入力を受け取る
          var ABCXY = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          int A = ABCXY[0];
          int B = ABCXY[1];
          int C = ABCXY[2];
          int X = ABCXY[3];
          int Y = ABCXY[4];
          
          //枚数が少ない方をXとする
          if(X > Y){
            var tmp1 = X;
            var tmp2 = A;
            X = Y;
            Y = tmp1;
            A = B;
            B = tmp2;
          }
          var Amount = 0L;
          
          //1枚ずつ買った方がABで複製するより得かどうか
          if(A > 2*C && B > 2*C){
            
            //全部Cで作った方が安いという時
            Amount += 2*C*Y;
          }else if(A > 2*C){
            
            //Aの分だけCで作った方がいいとき
            Amount += 2*C*X;
            //残りのBの分を単体で作る
            Amount += B*(Y-X);
          }else if(B > 2*C){
            
            //Bの分をCで複製する(全てCで作る)
            Amount += 2*C*Y;
          }else if(A+B > 2*C){
            
            //X枚だけCで作る
            Amount += 2*C*X;
            
            //Y-X枚のBは単体で作る
            Amount += B*(Y-X);
          }else{
            //全部単体で作る
            Amount += A*X+B*Y;
          }
          Console.WriteLine(Amount);
        }
  
}


Measured memory_bytes: 13396
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::string S;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> S;
    if (S[0] != S[1] || S[1] != S[2]) {
        out << "Yes" << endl;
    }
    else {
        out << "No" << endl;
    }

    return 0;
}
#endif


Measured memory_bytes: 256
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

char buf[20];
char ans[20] = "x+x+x+x=7";

int main(void) {
  scanf("%s", buf);
  REP(i, 4) {
    ans[2*i] = buf[i];
  }

  REP(pat, 1 << 3) {
    int res = buf[0] - '0';
    REP(i, 3) {
      if(pat & (1 << i)) {
        ans[2*i+1] = '+';
        res += buf[i+1] - '0';
      } else {
        ans[2*i+1] = '-';
        res -= buf[i+1] - '0';
      }
    }
    if(res == 7) {
      puts(ans);
      break;
    }
  }
  return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];

int main() {
	cin >>a;
  	if (a>=30) cout <<"Yes\n";
  else cout <<"No\n";
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long int knap[110][110000];
long long int cost[110];
long long int wt[110000];
long long int n,make;
long long int solve(long long int pos,long long int w )
{
    if(pos==n+1)
        return 0;
    if(knap[pos][w]!=-1)
        return knap[pos][w];
    long long int  ans=0;
     if(w+wt[pos]<=make)
    {
        //return knap[pos][w]=max(solve(pos+1,w),cost[pos]+solve(pos+1,wt[pos]+w));
        ans=max(solve(pos+1,w),cost[pos]+solve(pos+1,wt[pos]+w));
    }
   else
   {
      // return knap[pos][w]=solve(pos+1,w);
      ans=solve(pos+1,w);
   }
   knap[pos][w]=ans;
   return ans;
}
int main()
{
      long long int j,p,q,r,s,t,i;
      memset(knap,-1,sizeof knap);
      cin>>n>>make;
      for(i=1;i<=n;i++)
      {
          cin>>wt[i]>>cost[i];
      }
      cout<<solve(1,0);
      return 0;
}

Measured memory_bytes: 94848
#include<stdio.h>

int main(void){
	int N, i, c[4] = {0}, cnt = 0;
	char S[100][1];

	do{
		scanf("%d", &N);
	}while(N < 1 || N > 100);

	for(i = 0; i < N; i++){
		do{
			scanf("%s", S[i]);
			if(S[i][0] == 'P')	c[0]++;
			else if(S[i][0] == 'W')	c[1]++;
			else if(S[i][0] == 'G')	c[2]++;
			else if(S[i][0] == 'Y')	c[3]++;
		}while(S[i][0] !='P' && S[i][0] !='W' && S[i][0] !='G' && S[i][0] != 'Y');
	}

	for(i = 0; i < 4; i++){
		if(c[i] == 0)	cnt++;
	}

	if(cnt == 0)	printf("Four\n");
	else	printf("Three\n");

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int ans = 0;
        for(int i=1; i<=N; i++) {
            if(i%2 == 1) {
                int num=0;
                for(int j=1; j<=N; j++) {
                    if(i%j == 0) num++;
                }
                if(num==8) ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
using System.IO;

namespace paiza
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetLong();
            var ans = new long();

            if (N == 1)
            {
                ans = 0;
                Console.WriteLine(ans);

                return;
            }

            var para = PrimeFactors(N);
            while (para.Count() > 0)
            {
                var p = para.First();
                var count = para.Count(value => value == p);
                for (int i = 1; i <= count; i++)
                {
                    ans++;
                    count -= i;
                }
                while (para.Count()>0 && para.First() == p)
                {

                    para.Remove(p);
                }

            }

            Console.WriteLine(ans);

            return;
        }

        public static List<long> PrimeFactors(long n)
        {
            long i = 2;
            var tmp = n;
            var list = new List<long>();

            while (i * i <= n)
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    list.Add(i);
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) list.Add(tmp);
            return list;
        }

    }
}

public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() => int.Parse(getArg());
    public static long GetLong() => long.Parse(getArg());
    public static double GetDouble() => double.Parse(getArg());
    public static string GetString() => getArg();
    public static char GetChar() => getArg()[0];
    public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
    public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
    public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
    public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vi h(n);
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    vi dp(n+k, 2e9);
    dp[n-1] = 0;
    for (int i=n-2; i>=0; i--) {
        for (int j=i+1; j<=min(i+k, n-1); j++) {
            dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
        }
    }
    cout << dp[0] << '\n';
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int a=sc.nextInt();
		sc.close();

		if(x<a) {
			System.out.println(0);
		}
		else {
			System.out.println(10);
		}
	}

}


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

bool equal(int n, int *a, int *b) {
  rep(i, n) {
    if (a[i] != b[i]) return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int p[n], q[n];
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  int a[n];
  rep(i, n) a[i] = i+1;
  int x, y;
  int k = 0;
  if (equal(n, a, p)) x = k;
  if (equal(n, a, q)) y = k;
  while (next_permutation(a, a+n)) {
    ++k;
    if (equal(n, a, p)) x = k;
    if (equal(n, a, q)) y = k;
  }
  cout << abs(x-y) << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int N, M;
    cin >> N >> M;
    cout << N * (N -1)/2 +  M * (M-1) / 2<< endl;
}


Measured memory_bytes: 3632
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,x,s;
bitset<2002001>f;
int main() 
{
	scanf("%d",&n),f[0]=1;
	for(int i=0;i<n;i++) 
	{
		scanf("%d",&x);
		f|=f<<x,s+=x;
	}
	for(int i=(s+1)/2;i<=s;i++)
		if (f[i]) 
		{
			printf("%d\n", i);
			return 0;
		}
}


Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int t, x; cin>>t>>x;
    cout << fixed << setprecision(10) << 1.*t/x << endl;
}

Measured memory_bytes: 256
fn main() {
    let (a, b, h, m) = input();
    println!("{:?}", solve(a, b, h, m));
}

fn input() -> (f64, f64, f64, f64) {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.pop();
    let mut iter = buf.split_whitespace();
    let a: f64 = iter.next().unwrap().parse().unwrap();
    let b: f64 = iter.next().unwrap().parse().unwrap();
    let h: f64 = iter.next().unwrap().parse().unwrap();
    let m: f64 = iter.next().unwrap().parse().unwrap();
    (a, b, h, m)
}

fn solve(a: f64, b: f64, h: f64, m: f64) -> f64 {
    let m_angle = m * 6.0;
    let h_angle = h * 30.0 + m / 2.0;
    let mut theta = (h_angle - m_angle);
    if theta > 180.0 {
        theta = 360.0 - theta;
    }
    theta = theta * std::f64::consts::PI / 180.0;
    // println!("theta_h={:?} theta_m={:?} theta={:?} cos(theta)={:?}", h_angle, m_angle, theta, theta.cos());
    let c_pow = a * a + b * b - 2.0 * b * a * theta.cos();
    ((c_pow.sqrt() * 1000000000.0) as i64) as f64 / 1000000000.0
}

Measured memory_bytes: 2976
from collections import defaultdict
import math
from decimal import Decimal


def main():
    N = int(input())
    t, a = map(int, input().split())
    for _ in range(N - 1):
        T, A = map(Decimal, map(int, input().split()))
        p = max(math.ceil(t / T), math.ceil(a / A))
        t, a = T * p, A * p
    print(t + a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5588
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// }}}

bool endWith(const string &s, const string &t)
{
    int slen = s.length();
    int tlen = t.length();

    for (int i = 1; i <= tlen; ++i) {
        if (slen-i < 0) return false;
        if (s[slen-i] != t[tlen-i]) return false;
    }
    return true;
}
signed main()
{
    string s;
    cin >> s;

    while(!s.empty()) {
        if (endWith(s, "dream") || endWith(s, "erase")) {
            rep(i, 0, 5) s.pop_back();
        }
        else if (endWith(s, "dreamer")) {
            rep(i, 0, 7) s.pop_back();
        }
        else if (endWith(s, "eraser")) {
            rep(i, 0, 6) s.pop_back();
        }
        else {
            cout << ("NO") << endl;
            return 0;
        }
    }

    cout << ("YES") << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;

string alpha="abcdefghijklmnopqrstuwvxyz";

int N;

int pow(int a,int b){
    if(b==0) return 1;
    else if(b%2==0) return pow(a,b/2)*pow(a,b/2);
    else return a*pow(a,b/2)*pow(a,b/2);
}

int a[50];
int dp[100002];


int main(){
    cin>>N;
    a[0]=1;
    rep(i,6){
        a[i]=pow(6,i);
    }
    rep(i,5){
        a[6+i]=pow(9,i);
    }
    dp[0]=0;
    dp[1]=1;
    rep(i,N-1){
        dp[i+1]=inf;
        Rep(j,12){
            if((i+1)>=a[j]){
                dp[i+1]=min(dp[i+1],dp[i+1-a[j]]+1);
            }

        }
    }
    cout<<dp[N]<<endl;


    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int sum=0;
  for (int i = 0; i < K; i++) {
  sum += vec.at(i);
  }
  cout << sum << endl;
}


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

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

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

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


using namespace std;

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

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

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

signed main() {
    Fast();

    int a, b, x;
    cin >> a >> b >> x;

    cout << (x >= a && x <= a + b ? "YES" : "NO") << endl;

    return 0;
}



Measured memory_bytes: 256