akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
a = n.times.map{gets.split}
a.map! {|a| {suit: a[0], value: a[1].to_i} }

b = Marshal.load(Marshal.dump(a))

SENTINEL = 2000000000
$cnt = 0

def merge(a, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  l = []
  r = []

  (0...n1).each do |i|
    l[i] = a[left + i]
  end
  (0...n2).each do |i|
    r[i] = a[mid + i]
  end

  l[n1] = r[n2] = {value: SENTINEL}
  i = j = 0

  (left...right).each do |k|
    if l[i][:value] <= r[j][:value]
      a[k] = l[i]
      i += 1
    else
      a[k] = r[j]
      j += 1
    end
  end
end

def merge_sort(a, left, right)
  if left+1 < right
    mid = (left + right) / 2
    merge_sort(a, left, mid)
    merge_sort(a, mid, right)
    merge(a, left, mid, right)
  end
end

def partition(a, p, r)
  x = a[r]
  i = p - 1

  (p...r).each do |j|
    if a[j][:value] <= x[:value]
      i += 1
      tmp = a[i]
      a[i] = a[j]
      a[j] = tmp
    end
  end

  tmp = a[i + 1]
  a[i + 1] = a[r]
  a[r] = tmp
  return i + 1
end

def quick_sort(a, p, r)
  if p < r
    q = partition(a, p, r)
    quick_sort(a, p, q - 1)
    quick_sort(a, q + 1, r)
  end
end

merge_sort(a, 0, n)
quick_sort(b, 0, n - 1)

puts a == b ? 'Stable' : 'Not stable'
puts b.map {|b| "#{b[:suit]} #{b[:value]}" }


Measured memory_bytes: 96996
import bisect
from collections import defaultdict
from typing import Dict, List


def prime_factorization(n: int) -> Dict[int, int]:
    factorized = defaultdict(int)
    if n == 1:
        return factorized

    if n in {2, 3}:
        factorized[n] += 1
        return factorized

    i: int = 2
    while i * i <= n:
        if n % i == 0:
            factorized[i] += 1
            n = n // i
        else:
            i += 1
    if n != 1:
        factorized[n] += 1
    return factorized


def main():
    n: int = int(input())
    factorized: Dict[int, int] = prime_factorization(n)
    # print(factorized)
    # largest k that satisfies 0.5 * k * (k * 1) <= count
    # 1 + 2 + ... + k
    # 1 + 2 + ... + k + alpha -> 1 + 2 + ... + (k + alpha)
    # count -> k
    # 1 -> 1
    # 2 -> 1
    # 3 -> 2
    ans: int = 0
    thresholds: List[int] = [k * (k + 1) // 2 for k in range(1, 14 * 10 ** 5)]
    for v in factorized.values():
        thresh: int = bisect.bisect_right(thresholds, v)
        ans += thresh
        # print(thresh)
    print(ans)


if __name__ == "__main__":
    main()
    

Measured memory_bytes: 65640
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
using namespace std;

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


int main() {
	int N, M;
	int ans = 1;
	cin >> N >> M;


	rep(i, sqrt(M)) {

		if (M % (i + 1) == 0 && (i + 1) >= N) {
			ans = M / (i + 1);
			break;
		}
		else if (M % (i + 1) == 0 && M / (i + 1) >= N) {
			ans = i + 1;
		}


	}



	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
function f(A,N)
	id=1
	for i=1:60
		t=id
		x=1<<(60-i)
		while t<=N&&(A[t]&x)==0
			t+=1
		end
		if t>N
			continue
		end
		if t>id
			A[id],A[t]=A[t],A[id]
		end
		for j=1:N
			if j==id||(A[j]&x)==0
				continue
			end
			A[j]$=A[id]
		end
		id+=1
	end
	A
end
function main()
	N=parse(Int,readline())
	X=0
	A=map(x->parse(Int,x),split(readline()))
	for a=A
		X$=a
	end
	Y=(2^60-1)$X
	B=zeros(Int,N,60)
	for i=1:N
		A[i]&=Y
	end
	ans=0
	for a=f(A,N)
		ans$=a
	end
	println(ans+(X$ans))
end
main()


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

int a,b,ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b;
    if(a>b){
        ans+=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
    if(a>b){
        ans+=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
// abc171_e
#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 <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  int x = 0;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    x = x ^ a[i];
  }

  for (auto y : a) {
    int ans = y ^ x;
    cout<<ans<<" ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long

int main(void){
    int N;
    int ans=0;
    cin>>N;
    vector<string> letter(N);
    vector<char> head(N);
    vector<char> back(N);
    for(int i=0;i<N;i++) {
        cin>>letter.at(i);
        for(int j=0;j<letter.at(i).size()-1;j++) {
            if(letter.at(i).at(j)=='A' && letter.at(i).at(j+1)=='B') ans++;
        }
        head.at(i)=letter.at(i).at(0);
        back.at(i)=letter.at(i).at(letter.at(i).size()-1);
    }


    int BA=0,BnA=0,notBA=0;
    for(int i=0;i<N;i++) {
        if(head.at(i)=='B' && back.at(i)=='A') BA++;
        else if(head.at(i)=='B') BnA++;
        else if(back.at(i)=='A') notBA++;
    }
    int chou=min(BnA,notBA);
    ans+=(BA+chou);
    if(max(BnA,notBA)==0 && BA==0) ans++;
    if(max(BnA,notBA)==0) ans--;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<string.h>

using namespace std;

int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    if(a+b >= x && a <= x)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define pi acos(-1)
#define pb push_back
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;

int water[3010],sugar[3010];

int main()
{
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    double A,B,C,D,E,F;
    scanf("%lf%lf%lf%lf%lf%lf",&A,&B,&C,&D,&E,&F);
    for(int i=0; i<=300; i++)
        for(int j=0; j<=300; j++) {
            if(100*i*A+100*j*B>F) continue;
            water[(int)(100*i*A+100*j*B)]=1;
//            printf("%d\n",100*i*A+100*j*B);
        }

    for(int i=0; i<=3000; i++)
        for(int j=0; j<=3000; j++) {
            if(i*C+j*D>F) continue;
            sugar[(int)(i*C+j*D)]=1;
//            printf("%d\n",i*C+j*D);
        }
    double ans=-1;
    int sum1=0,sum2=0;
    for(int i=0; i<=3000; i++) {
        if(water[i]) {
            for(int j=0; j<=3000; j++) {
                if(i+j>F) break;
                if(!sugar[j]) continue;
                if(j>((double)((double)i/100.0)*E)) break;
                double sum=((double)(j))/((double)(i+j));
//                printf("%d %d \n",i,j);
                if(sum>ans) {
                    ans=sum;
                    sum1=i;
                    sum2=j;
                }
            }
        }
    }
    printf("%d %d\n",sum1+sum2,sum2);
    return 0;
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll powmod(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        ll t = powmod(x, n / 2, mod);
        return t * t % mod;
    }
    return x * powmod(x, n - 1, mod) % mod;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    COMinit();
    ll ans = 0;
    for (ll i = 0; i <= min(n, k); i++) {
        ans += COM(n, i) * COM(n - 1, i);
        ans %= mod;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,cnt=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        if(i%2==0){
            if(a[i]%2) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    vector<int> a(4),b(2);
    FORE(x,a) cin>>x;
    FORE(x,b) cin>>x;
    sort(ALL(a));
    sort(ALL(b));
    cout<<a[1]+a[2]+a[3]+b[1]<<endl;
    return 0;
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  ll K;
  int N;
  cin >> K >> N;
  ll sum = 0;
  ll a;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i, N) {
    cin >> A[i];
    if (i >= 1)
      B[i-1] = A[i]-A[i-1];
  }
  rep(i, N-1) {
    sum += B[i];
  }
  B[N-1] = K-sum;
  sort(all(B));
  K -= B[N-1];
  cout << K << endl;
}


Measured memory_bytes: 3456
import math

n = input()
b = int(n) - 1

num = []
maxnum = 0

nnc = int(0)

for j in range(int(n)):
	inpn = int(input())
	if inpn < 2 or inpn % 2 == 0:
		if inpn != 2:
			continue
		else:
			nnc += 1
			continue
	num.append(inpn)
	if maxnum < inpn:
		maxnum = inpn



rx = math.sqrt(maxnum)
rx += 2

#nature number counter

for i in range(3, int(rx),2):
	for j in reversed(num):
		if math.sqrt(j) < i:
			nnc += 1
			num.remove(j)
		elif j%i == 0:
			num.remove(j)

nnc += len(num)

print(nnc)



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> ma(n);
    for (int i = 0;i < n;i++){
        cin >> a.at(i);
        ma.at(i) = a.at(i);
    }
    sort(ma.begin(),ma.end());
    for (int i = 0;i < n;i++){
        if (a.at(i) == ma.at(n-1)){
            cout << ma.at(n-2) << endl;
        }
        else {
            cout << ma.at(n-1) << endl;
        }
    }
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
        for(int j = 0; j < m; j++)cin >> a[i][j];
    }

    int min_cost = 12345678;

    for(int bit=1; bit < (1 << n); bit++)
    {
        int cost =0;
        vector<int> skill(m); 
        bool judge = true;

        //i 番目のbitが立っているかチェック
        for(int i = 0; i < n; i++){
            if((bit>>i)&1){
                //料金アップ
                cost += c[i];

                //スキルアップ
                for(int j=0; j<m; j++)
                {
                    skill[j] += a[i][j];
                }
            }
        }

        //スキルがX未満のものが一つでもあるならjudgeをfalseに
        for(int k=0; k<m; k++)
        {
            if(skill[k] < x)
            {
                judge = false;
            }
        }

        //最小費用を更新
        if(judge == true)
        {
            min_cost = min(min_cost, cost);
        }

    }

    
    if(min_cost != 12345678)
    {
        cout << min_cost;
    }
    else
    {
        cout << (-1);
    }
    
    return 0;

}


Measured memory_bytes: 3596
a, b, c, d = map(int, raw_input().split())
table = dict()
for i in range(101):
    table[i] = 0
for i in range(a, b + 1):
    table[i] += 1
for i in range(c, d + 1):
    table[i] += 1
result = 0
for i in table:
    if table[i] == 2:
        result += 1
print(result - 1 if result > 0 else '0')


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d,n;

  cin >> d >> n;
  int a = 1;
    if(n==100)n++;
  int i;
  for(i=0;i<d;i++)
    a *= 100;
  cout << a * n << endl;
}

Measured memory_bytes: 256
#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;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	ll n, i;
	cin >> n;
	vll a(n), dp(n + 2);
	for(i = 0; i < n; i++)
		cin >> a[i];
	for(i = 1; i < dp.size(); i++)
		dp[i] = LLONG_MAX;
	for(i = 0; i < n; i++)
	{
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

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

bool p(string s){
  string t(s.rbegin(), s.rend());
  return s == t;
}

int main(){
  string s;
  cin >> s;
  if(p(s) && p(s.substr(0,(s.size() - 1) / 2)) && p(s.substr((s.size()+1)/2))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
#include <stdio.h>
int main(void){
    double xp1, yp1, xp2, yp2, xp0, yp0, x, y, xp2p1, yp2p1, zp2p1;
    int n, i;
    scanf("%lf %lf %lf %lf", &xp1, &yp1, &xp2, &yp2);
    scanf("%d", &n);
    
    xp2p1=xp2-xp1;
    yp2p1=yp2-yp1;
    
    for(i=1; i<=n; i++){
        scanf("%lf %lf", &xp0, &yp0);
        
        if(xp2p1 == 0){
            x=xp1;
            y=yp0;
        }
        else if(yp2p1 == 0){
            x=xp0;
            y=yp1;
        }
        else{
            zp2p1=yp2p1/xp2p1;
            x=(-yp1+zp2p1*xp1+yp0+xp0/zp2p1)/(zp2p1+1/zp2p1);
            y=-x/zp2p1+yp0+xp0/zp2p1;
        }
    
        printf("%.10lf %.10lf\n", x, y);
    }
    return 0;
    
}



Measured memory_bytes: 2104
#include <stdio.h>
int main(void){
    // Your code here!
    int i,j,n,m;
    char ch;
    scanf("%d\n",&n);
    int cards[4][13]={0};
    for(i=0; i<n; i++){
        scanf("%c %d\n",&ch,&m);
        if(ch=='S'){
            cards[0][m-1]=m;
        }else if(ch=='H'){
            cards[1][m-1]=m;
        }else if(ch=='C'){
            cards[2][m-1]=m;
        }else{
            cards[3][m-1]=m;
        }
    }
    for(i=0; i<4; i++){
        for(j=0; j<13; j++){
            if(cards[i][j]==0){
                if(i==0){
                    printf("S %d\n",j+1);
                }else if(i==1){
                    printf("H %d\n",j+1);
                }else if(i==2){
                    printf("C %d\n",j+1);
                }else if(i==3){
                    printf("D %d\n",j+1);
                }
            }    
        }
    }
        return 0;
}



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> 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<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h) * (W-w) << endl;

    return 0;
}


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

using namespace std;

int main() {
    long A, B;
    cin >> A >> B;

    long a = (long)ceil((double)(A-1) / 2.0) % 2;
    if ((A-1) % 2 == 0) a ^= (A-1);
    long b = (long)ceil((double)B / 2.0) % 2;
    if (B % 2 == 0) b ^= B;
    long ans = a ^ b;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
vll B;
vll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;
ll A_min=base10_9+100;
ll ind_min = 0;
ll B_min=base10_9+100;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    rep(ni,N){
        cin >> ltmp;
        A.push_back(ltmp);
    }

    ll ans0=0;

    rep(ni,N){
        if(ni%2==0) ans0+=A[ni];
        else ans0-=A[ni];
    }

    cout << ans0 << " ";

    ll bef = ans0;
    for( ll ni = 0 ; ni <N-1 ; ni++ ){
        ll ans = (A[ni] - bef/2)*2;
        cout << ans << " ";
        bef = ans;
    }



    

}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 3010;

int dp[maxn][maxn];

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &el : a) cin >> el;
    for (int len = 0; len < n; len++) {
        for (int l = 0; l + len < n; l++) {
            int r = l + len;
            if (len == 0) {
                if ((n - len - 1) % 2 == 0) {
                    dp[l][l] = a[l];
                } else {
                    dp[l][l] = -a[l];
                }
            } else {
                if ((n - len - 1) % 2 == 0) {
                    dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r]);
                } else {
                    dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r]);
                }
            }
        }
    }
    cout << dp[0][n - 1] << "\n";


    return 0;
}

Measured memory_bytes: 70144
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7; 
int n;
int dp[2005];
int dfs(int x) {
	if(dp[x] != -1)return dp[x];
	int Ans = 0;
	for(int i = 3; i <= x; i++) {
		Ans += dfs(x - i);
		Ans %= mod;
	}
	dp[x] = Ans;
	return Ans;
}
signed main() {
	memset(dp, -1, sizeof(dp));
	dp[0] = dp[3] = 1;
	dp[2] = dp[1] = 0; 
	cin >> n;
	cout << dfs(n) << endl;
	return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int N, H[100010];
void solve()
{
    int t = 0;
    int ans = 0;
    FOR(i, 0, N - 1)
    {
        if (H[i + 1] <= H[i]) {
            t++;
            ans = max(ans, t);
        } else {
            t = 0;
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
    {
        cin >> H[i];
    }
    solve();
    return 0;
}


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

int main(){
    ll n, m;
    string s;
    cin >> n >> m >> s;
    ll now = n;
    vector<ll> ans;
    bool flag = true;
    while(flag){
        for(ll i = min(now, m); i >= 0; i--){
            if(i == 0){
                cout << -1 << endl;
                return 0;
            }
            if(s[now-i] != '1'){
                now -= i;
                ans.push_back(i);
                if(now == 0){
                    flag = false;
                }
                break;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    rep(i, 0, ans.size()) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

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

const int INF = 1001001001;
int main() {
    int n, m, l;
    cin >> n >> m >> l;
vector<vector<int>> dist(n, vector<int>(n, INF));
   	
  rep(i,n) dist[i][i] = 0;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        dist[a][b] = dist[b][a] = c;    
       
    }
 
rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j], dist[i][k] + dist[k][j]);
vector<vector<int>> dist2(n, vector<int>(n, INF));
rep(i, n)rep(j, n) {
  if (dist[i][j] <= l) dist2[i][j] = 1;
}
rep(k, n)rep(i, n)rep(j, n) chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);
int q;
cin >> q;
rep(qi, q) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    int ans = dist2[s][t] - 1;
    if(dist2[s][t] == INF) ans = -1;
    cout << ans << endl;
}

}

Measured memory_bytes: 1280
(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

(* O(|s|) *)
let get_left_info s =
  let n = String.length s in
  let left = Array.make (n + 1) 0 in
  for i = 1 to n - 1 do
    if s.[i - 1] = 'A' && s.[i] = 'C' then
      left.(i + 1) <- left.(i) + 1
    else
      left.(i + 1) <- left.(i)
  done;
  left

(* O(max {n, q}) *)
let solve n q s lrs =
  let left = get_left_info s in
  List.iter
    (fun (l, r) ->
      let l = l - 1 in
      let count = left.(r) - left.(l + 1) in (* l + 1 = l + |"AC"| - 1 *)
      string_of_int count |> print_endline)
    lrs

let _ = Scanf.scanf " %d %d %s" (fun n q s ->
  fold_int
    (fun acc _ -> Scanf.scanf " %d %d" (fun l r ->
      (l, r) :: acc))
    []
    q |> List.rev |> solve n q s)

Measured memory_bytes: 12816
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
dp = [0] * N
dp[0] = sum(a)
res = float("inf")
for i in range(N - 1):
  dp[i + 1] = dp[i] - a[i]
for i in range(1, N):
  res = min(abs(2 * dp[i] - dp[0]), res)
print(res)

Measured memory_bytes: 71844
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use std::cmp::max;
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    let d=read::<i32>();
    println!("{}",max(a*b,c*d))
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(W-r>=x && H-r>=y && x-r>=0 && y-r>=0){
printf("Yes\n");
}
if(W-r<x || H-r<y || x-r<0 || y-r<0){
printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
const int limit_n = 8;
int mat[limit_n][limit_n];
int n,m;
int cnt=0;

void dfs(int node_id, vector<bool>& used){
  if(used[node_id]) return;
  auto used_cp = used;
  used_cp[node_id] = true;
  int cnt_used =0;
  for(int i=0; i<n;++i)if(used_cp[i]) ++cnt_used;
  if(cnt_used==n){
    ++cnt;
    return;
  }
  for(int j =0;j<n;++j){
    if(mat[node_id][j]==1) dfs(j,used_cp);
  }
}

int main() {
  cin >> n >> m;
  vector<bool> used(n, false);
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      mat[i][j] = 0;
    }
  }
  for(int j=0;j<m;++j){
    int a,b;cin >> a >> b;
    mat[a-1][b-1] = 1;
    mat[b-1][a-1] = 1;
  }
  dfs(0, used);
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut cumsum_ = vec![];
    cumsum_.push(0);
    for i in 0..n {
        let acc = cumsum_[i] + a[i];
        cumsum_.push(acc);
    }
    cumsum_.sort();

    let mut ans = 0u64;
    let mut cnt = 1u64;
    let mut acc = cumsum_[0];
    for i in 1..n + 1 {
        if acc == cumsum_[i] {
            cnt += 1;
        } else {
            ans += (cnt * (cnt - 1)) / 2;
            cnt = 1;
            acc = cumsum_[i];
        }
    }
    ans += (cnt * (cnt - 1)) / 2;

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <cstdlib>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main(){
    
    
    int a,b;
    cin >> a >> b;
    string A,B;
    
    A = to_string(a);
    B = to_string(b);
    
    string str = A+B;
    long long num = atoi(str.c_str());
    
    long long suu = num;
    
    suu = sqrt(suu);
    
    suu*=suu;
    
    if(num==suu) cout << "Yes";
    else cout << "No";
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#define SF scanf
#define PF printf
using namespace std;
int s[11]={1,8,64,512,4096,32768,262144,2097152};
map<int,int> vis;
queue<int>q;
int push_down(int a[]){
    int res=0;
    for(int i=1;i<=8;i++)
        res+=s[i-1]*a[i];
    return res;
}
void push_up(int a[],int num){
    for(int i=7;i>=0;i--){
        a[i+1]=num/s[i];
        num=num%s[i];
    }
}
void prepare(){
    q.push(16434824);
    vis[16434824]=1;
    while(!q.empty()){
        int a[10]={0};
        int nex=q.front();
        q.pop();
        push_up(a,nex);
        for(int i=1;i<=8;i++)
            if(a[i]==0){
                if(i!=5&&i!=1){
                    swap(a[i],a[i-1]);
                    int newx=push_down(a);
                    if(vis[newx]==0){
                        vis[newx]=vis[nex]+1;
                        q.push(newx);
                    }
                    swap(a[i],a[i-1]);
                }
                if(i!=4&&i!=8){
                    swap(a[i],a[i+1]);
                    int newx=push_down(a);
                    if(vis[newx]==0){
                        vis[newx]=vis[nex]+1;
                        q.push(newx);
                    }
                    swap(a[i],a[i+1]);
                }
                if(i>4){
                    swap(a[i],a[i-4]);
                    int newx=push_down(a);
                    if(vis[newx]==0){
                        vis[newx]=vis[nex]+1;
                        q.push(newx);
                    }
                    swap(a[i],a[i-4]);
                }
                if(i<5){
                    swap(a[i],a[i+4]);
                    int newx=push_down(a);
                    if(vis[newx]==0){
                        vis[newx]=vis[nex]+1;
                        q.push(newx);
                    }
                    swap(a[i],a[i+4]);
                }
            }
    }
}
int main(){
    prepare();
    int a[11];
    while(SF("%d",&a[1])!=EOF){
        int x=0;
        for(int i=2;i<=8;i++)
            SF("%d",&a[i]);
        for(int i=1;i<=8;i++)
            x+=a[i]*s[i-1];
        PF("%d\n",vis[x]-1);
    }
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, x;
    cin >> n >> x;
    vector<ll> a(n); 
    rep(i, 0, n) cin >> a[i];

    ll sum(0);

    if (x < a[0])
        sum += a[0] - x, a[0] = x;

    rep(i, 1, n)
    {
        ll test = a[i-1] + a[i];  
        if (test > x) 
        {
            sum += test - x; 
            a[i] -= (test -x);
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n,m,a[100001],b[100001];
	long ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>a[i];
	sort(a,a+m);
	for(int i=1;i<m;i++)b[i-1]=a[i-1]-a[i];
	sort(b,b+m-1);
	for(int i=n;i<m;i++)ans-=b[i-1];
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
ll nikou(ll x, ll y){
  ll cnt=1;
  for(int i=0;i<y;i++){
    ll p=i+1;
  cnt*=x-p+1;
    cnt/=p;}
  return cnt;}
  

int main(){
string s;
  cin>>s;
  ll n=s.size();
  
  ll ans=0;
  
  ll mz[26];
  rep(i, 26){
    mz[i]=0;}
  
  rep(i, n){
    mz[s[i]-'a']++;
  }
  
  rep(i, 26){
    if(mz[i]>=2){
      ans+=nikou(mz[i], 2);}
  }
  
  ans=nikou(n,2)+1-ans;
  
  cout<<ans<<endl;

}

Measured memory_bytes: 640
n = int(input())
ablist = []

for i in range(n):
    t = list(map(int, input().split()))
    ablist.append(t)

ablist = sorted(ablist, key=lambda x: x[1])

t = 0
flag = True
for i in ablist:
    t += i[0]
    if t > i[1]:
        flag = False

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 55252
from fractions import Fraction as F
n, m = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)
T = S * F(1, 4 * m)

cnt = 0
for a in A:
    if a >= T:
        cnt += 1

print("Yes" if cnt >= m else "No")

Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

int dfs(vector<vector<int>> &adjList, vector<bool> &visited, int i, int l)
{
    visited[i] = true;
    for(auto it: adjList[i])
    {
        if(!visited[it])
        {
            //cout << "Called at " << it << " in " << i << endl;
            visited[it] = true;
            l = dfs(adjList, visited, it, l+1);
        }
    }
    return l;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    vector<vector<int>> adjList(n+1);
    for(int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;

        adjList[u].push_back(v);
        adjList[v].push_back(u);
    }

    vector<bool> visited(n+1);

    int maxi = - 1;

    for(int i = 1; i <= n; i++)
    {
        if(!visited[i])
        {
            maxi = max(maxi, dfs(adjList, visited, i, 0));
        }
    }

    cout << maxi + 1 << endl;
}



Measured memory_bytes: 23348
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a >= 10 || b >= 10){
            System.out.println(-1);
            return;
        }else{
            System.out.println(a*b);
        }
    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



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

m=(n-1)*(n-2)//2 - k
if m < 0:
  print(-1)
  exit()

print(n-1+m)
for i in range(n-1):
  print(1,i+2)

if m>0:
  for i in range(2,n):
    for j in range(i+1,n+1):
      print(i, j)
      m -= 1
      if m==0:
         exit()


Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	final int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		final int MAX = 1000 * 1000 + 1;
		boolean isPrime[] = new boolean[MAX];
		Arrays.fill(isPrime, true);
		int[] primes = new int[MAX];
		int idx = 0;
		for (int i = 2; i < MAX; i++) {
			if (isPrime[i]) {
				primes[idx++] = i;
				for (int j = i + i; j < MAX; j += i) {
					isPrime[j] = false;
				}
			}
		}
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if ((a | b) == 0)
				break;
			int i = 0;
			int sum = 0;
			int last = 0;
			int a_key = 0;
			while (true) {
				if (primes[i] > a || primes[i] == 0) {
					a_key = last - sum;
					break;
				}
				if (a % primes[i] == 0) {
					sum += last;
					last = primes[i];
				}
				i++;
			}
			sum = 0;
			last = 0;
			i = 0;
			int b_key = 0;
			while (true) {
				if (primes[i] > b || primes[i] == 0) {
					b_key = last - sum;
					break;
				}
				if (b % primes[i] == 0) {
					sum += last;
					last = primes[i];
				}
				i++;
			}
			System.out.println(a_key > b_key ? "a" : "b");
		}
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}
}

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

int main(){
    int n;
    cin >> n;
    int a[n+5];
    int max1 = 0;
    int max2 = 0;
    for (int i = 0; i < n; ++i){
        cin >> a[i];
        if (a[i]>=max1){
            max2 = max1;
            max1 = a[i];
        }else if (max1>=a[i]&&a[i]>=max2){
            max2 = a[i];
        }
    }
    for (int i = 0; i < n; ++i){
        if (a[i]==max1){
            cout << max2 << endl;
        }else{
            cout << max1 << endl;
        }
    }
}

Measured memory_bytes: 2432
#include<stdio.h>
 
int main(){
	int a, b, n;
	while(scanf("%d %d", &a, &b) != EOF){
		if(a <= b){
			n = a;
			a = b;
			b = n;
		}
		if(a % b == 0) n = b;
		while(a % b != 0){
			if(a % b == 0){
				n = b;
				break;
			}
			a = a % b;
			n = a;
			a = b;
			b = n;
		}
		printf("%d\n", n);
	}
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int dp[100000];
vi g[100000];

int dfs(int v){
    if(dp[v]!=-1)return dp[v];
    int ret=0;
    for(int u:g[v]){
        ret=max(ret,dfs(u)+1);
    }
    return dp[v]=ret;
}

void run(){
    int n,m;
    cin>>n>>m;
    fill(dp,dp+n,-1);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        g[x].pb(y);
    }
    int ans=0;
    rep(i,n)ans=max(ans,dfs(i));
    cout<<ans<<endl;
}

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

/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// ここからコピペ /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

///////////////////
// RangeSumQuery //
///////////////////

class RangeSumQuery {
private:
	std::vector<long long> container_;
	long long getHelper(const int index) const
	{
		if (index < 0) return 0;
		if ((int)(container_.size()) <= index) return container_.back();
		long long sum{};
		for (int add_place{index}; add_place > 0; add_place -= add_place & -add_place)
			sum += container_[add_place];
		return sum;
	}

public:
	RangeSumQuery(const int array_size)
		: container_(array_size + 1) {}
	// indexは0-indexed
	void update(const int index, const int added)
	{
		for (int update_place{index + 1}; update_place < (int)(container_.size()); update_place += update_place & -update_place)
			container_[update_place] += added;
	}
	// left,rightは0-indexed、[left, right)の半開区間
	long long get(const int left, const int right) const
	{
		return -getHelper(left) + getHelper(right);
	}
};

/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// ここまでコピペ /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
int main()
{
	int n, q;
	scanf("%d%d", &n, &q);
	RangeSumQuery rsq(n);
	for (int i{}; i < q; i++)
	{
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
		if (!com) rsq.update(x - 1, y);
		else printf("%lld\n", rsq.get(x - 1, y));
	}

	return 0;
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


long long int p[100005];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		p[x] = -1;
	}
	p[0] = 1;
	for (int i = 0; i <= n - 1; i++) {
		if (p[i] == -1)continue;
		if (p[i + 1] != -1) { p[i + 1] += p[i];
		p[i + 1] %= 1000000007;
		}
		if (p[i + 2] != -1) { p[i + 2] += p[i];
		p[i + 2] %= 1000000007;
		}
	}
	
	cout << p[n] << endl;

	return 0;



}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
 
 
int main(){
  char s[100];
  scanf("%s",s);
  int i,j;
  int n;
  int x=0;
  
  for(n=0;s[n]!='\0';++n);
 
  for(i=0,j=n-1;i<n/2,n/2<=j;i++,j--){
     if(s[i]!=s[j]){
       ++x;}
  }
   
  printf("%d",x);
  return 0;
  
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005][5];
int dp[100005][5];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i][1]>>a[i][2]>>a[i][3];
	for(int i=1;i<=n;i++){
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+a[i][2];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+a[i][3];
	}
	cout<<max(max(dp[n][1],dp[n][2]),dp[n][3])<<endl;
	return 0;
} 

Measured memory_bytes: 4096
N = int(input())
H = list(map(int, input().split()))

ans = 0
hei = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        hei += 1
    else:
        ans = max(ans, hei)
        hei = 0
ans = max(ans, hei)
print(ans)

Measured memory_bytes: 20416