akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

int dp[100005][3];

int main() {
  int n;
  cin >> n;
  vvi a(n, vi(3));
  rep(i, n) rep(j, 3) cin >> a[i][j];
  rep(j, 3) dp[0][j] = a[0][j];
  rrep(i, n-1) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;
        chmax(dp[i][j], dp[i-1][k] + a[i][j]);
      }
    }
  }
  int ans = 0;
  rep(j, 3) chmax(ans, dp[n-1][j]);
  cout << ans << endl;
}

Measured memory_bytes: 9888
#include<bits/stdc++.h>
using namespace std;
#define D(x)		cout << #x " = " << (x) << endl
#define MAX 		150
typedef long long int LL; 

const LL inf = 1e16; 

int hap[MAX+5]; 
int enr[MAX+5]; 
int csum[MAX+5]; 
int n;
LL dp[MAX+5][MAX+5]; 

LL F(int i, int h){
	if(h <= 0) return -inf;
	
	if(i == n + 1){
		if(h <= 0) return -inf; 
		return inf;
	}
	
	if(dp[i][h] != -1) return dp[i][h]; 
	
	///I eat it
	int opHap = (csum[i + 1] - (h - hap[i])) + 1;
	LL eg = F(i + 1, opHap); 
	LL p = -eg + 1 - enr[i]; 
		
	
	///I don't eat it
	eg = F(i + 1, h);
	LL q = max(1LL, eg + enr[i] + 1);
		
	return dp[i][h] = min(p, q);    
}

int main()
{
	//freopen("in.txt", "r", stdin);
	
	int i, A, B;
	memset(dp, -1, sizeof(dp));
	
	scanf("%d %d %d", &n, &A, &B);
	for(i = 1; i <= n; i++){
		scanf("%d %d", &enr[i], &hap[i]); 
	}
	for(i = n; i >= 1; i--){
		csum[i] = hap[i] + csum[i + 1];
	}
	
	
	for(i = csum[1]; i >= 0; i--)
		if(F(1, i) <= A - B){
			printf("%d %d\n", i, csum[1] - i);
			return 0; 
		}
	return 0;
}



Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=1;i<=(n);i++)
#define rep3(i,i0,n) for(ll i=i0;i<(n);i++)
#define pb push_back
#define MOD 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}

bool comparex(tuple<ll,ll,ll> a, tuple<ll,ll,ll> b) {

    return get<1>(a) < get<1>(b);
        
}
bool comparey(tuple<ll,ll,ll> a, tuple<ll,ll,ll> b) {

    return get<2>(a) < get<2>(b);
        
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

#define mod 100000
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};




int main() {
    while(1){
    ll n;
    cin>>n;
    if(n == 0) break;
    vector<ll> str(25*3600);
    vector<ll> end(25*3600);

    rep(i,n){
        ll h,m,s;
        char c;
        cin >>h>>c>>m>>c>>s;
        str[h*3600+m*60+s]++;
        cin >>h>>c>>m>>c>>s;
        end[h*3600+m*60+s]++;
        //cout <<h<<" "<<m<<" "<<s<<endl;
    }
    ll now = 0;
    ll mx = 0;
    rep(i,25*3600){
        now = now + str[i]-end[i];
        chmax(mx,now);
    }
    cout<<mx<<endl;
    }

    return 0;
    

}



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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long long INF = 1000000000;
const ll MOD = 1000000007;

ll f[101010], rf[101010];

ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}

void init() {
    f[0] = 1;
    for(int i = 1; i < 101010; ++i) f[i] = (f[i - 1] * i) % MOD;
    rep(i, 101010) rf[i] = inv(f[i]);
}

ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}

int main() {
    ll n, k;
    cin >> n >> k;
    init();
    ll tmp1, tmp2;
    for(int i = 1; i < k + 1; ++i){
        if(n - k + 1 < i){
            cout << 0 << '\n';
            continue;
        }
        tmp1 = C(n - k + 1, i) % MOD;
        tmp2 = C(k - 1, i - 1) % MOD;
        cout << (tmp1 * tmp2) % MOD << '\n';
    }
}

Measured memory_bytes: 1792
/*
 * Created By : pash123
 * 2020-09-19-17.21
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

const int M=1e9+7;

int main()
{
    string s;
    cin>>s;
    string s1;
    if(s[(int)s.size()-1]=='s')
    {
        s1=s.substr(0,s.size());
        s1+="es";
    }
    else
    {
        s1=s.substr(0,s.size());
        s1+="s";
    }
    cout<<s1;
    return 0;
}


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

bool prime (int n)
{
  bool flag = true;
  for (int i = 2; i < n; i++) {
    if (n % i == 0)
      flag = false;
  }
  return flag;
}

int main()
{
  int n;
  cin >> n;
  int p[60];
  int pnum = 0;
  int inow = 2;
  while (pnum < n) {
    for (int i = inow; i < 55555; i++) {
      int pcan = 5 * i + 1;
      if (prime(pcan)) {
        p[pnum] = pcan;
        inow = i + 1;
        pnum++;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << p[i] <<" ";
  }
  return 0;
}


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

int main() {
  string N;
  cin >> N;
  char num = N.at(N.size()-1);
  
  if(num == '3'){
    cout << "bon";
  }
  else if(num == '0' || num == '1' || num == '6' || num == '8'){
    cout << "pon";
  }
  else{
    cout << "hon";
  }
}



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

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

int digit_sum(int a){
	int ans = 0;
	while(a > 0){
		ans += a % 10;
		a /= 10;
	}
	return ans;
}

int main(){
	int N, i, j, ans = 100000;
	scanf("%d", &N);
	for(i = 1; i <= N - 1; i++){
		j = N - i;
		ans = min(ans, digit_sum(i) + digit_sum(j));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>

using namespace std;

class Shiritori
{
private:
    int length;
    string before;
    set<string> words;

    bool check(string w) {
        return w[0] == before[before.size() - 1]; 
    }

    void accept(string w) {
        before = w;
        words.insert(w);
    }

    bool isObserved(string w) {
        bool observed = true;
        if (check(w) && words.count(w) <= 0) {
            accept(w);
        } else {
            observed = false;
        }
        return observed;
    }

public:
    Shiritori(int len, string first) {
        length = len;
        accept(first);
    }

    bool isCompleted() {
        bool completed = true;

        string w;
        for (int i = 1; i < length; i++) {
            cin >> w;
            if (!isObserved(w)) {
                completed = false;
                break;
            }
        }

        return completed;
    }
};


int main()
{
    int length;
    string first;
    
    cin >> length;   
    cin >> first;
    Shiritori srtr(length, first);
    
    if (srtr.isCompleted()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n],s=0,dp[n];
    for(int i = 0; i < n; i++) 
        cin>>a[i];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; i++) 
        dp[i] = min(dp[i-1] +abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<w*h/2<<" "<<(x==w/2 && y==h/2)<<endl;
}

Measured memory_bytes: 3700
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    for i in range(101):
        if int(map_list[i][2]) > 0:
            x = int(map_list[i][0])
            y = int(map_list[i][1])
            h = int(map_list[i][2])
            break
        else:
            continue

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for data in map_list:
                xx, yy, hh = map(int, data)
                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)



Measured memory_bytes: 3064
x, n = map(int,input().split())
L = list(map(int,input().split()))

if n == 0 or x not in L:
  print(x)
  exit()

for i in range(102):
  if (x-i) not in L:
    print(x-i)
    break
  elif (x+i) not in L:
    print(x+i)
    break

Measured memory_bytes: 9168
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  a=a==1?14:a;
  b=b==1?14:b;
  if(a==b)cout<<"Draw"<<endl;
  if(a<b)cout<<"Bob"<<endl;
  if(a>b)cout<<"Alice"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long LL;
int n,m;
LL jc[1000500];
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
int main() {
	n = rd(), m = rd();
	jc[0] = 1;
	for (int i=1;i<=max(n,m);i++) jc[i] = 1LL * jc[i-1] * i % mod;
	if (abs(n-m) > 1) return puts("0"), 0;
	LL ans = 0LL;
	if (n == m) {
		ans = 2LL * jc[n] % mod * jc[m] % mod;
	} else {
		ans = 1LL * jc[n] * jc[m] % mod;
	}
	cout << ans << endl;
	
	return 0;
}


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

struct Stone
{
	int color;
	int chain;

	Stone(int color = 0, int chain = 1):color(color),chain(chain){}


};

int n;

void solve()
{
	Stone st = Stone(0,1);
	vector<Stone> vec;

	cin >> st.color;
	vec.push_back(st);

	for(int i = 2; i <= n; i++){
		cin >> st.color;

		if(i % 2 == 1){
			if(vec.back().color == st.color){
				vec.back().chain++;
			}
			else {
				vec.push_back(st);
			}
		}
		else{
			if(vec.back().color == st.color){
				vec.back().chain++;
			}
			else {
				vec.back().color = st.color;
				vec.back().chain++;
			
				if(vec.size() > 1){
					int vsize = vec.size();

					vec[vsize-2].chain += vec[vsize-1].chain;
					vec.pop_back();
				}
			}
			
		}
	}

	int ans = 0;
	for(int i = 0; i < vec.size(); i++){
		if(vec[i].color == 0){
			ans += vec[i].chain;
		}
	}

//	cout << "************" << endl;
/*
	for(int i = 0; i < vec.size(); i++){
		for(int j = 0; j < vec[i].chain; j++)
			cout << vec[i].color << endl;
	}
*/

//	cout << "answer" << endl;
	cout << ans << endl;
		
	
}

int main(void)
{
	while(cin >> n, n)
		solve();
}

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }
  int x1=0,x2=0,x3=0,x4=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=="AC"){
      x1++;
    }else if(s.at(i)=="WA"){
      x2++;
    }else if(s.at(i)=="TLE"){
      x3++;
    }else{
      x4++;
    }
  }
  cout << "AC x " << x1 << endl;
  cout << "WA x " << x2 << endl;
  cout << "TLE x " << x3 << endl;
  cout << "RE x " << x4 << endl;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n;
        cin>>n;
        vi a(3*n);
        for(auto &x:a)cin>>x;
        sort(a.begin(),a.end());
        ll ans=0;
        ll u=3*n-2;
        for(int i=0;i<n;i++)ans+=a[u],u-=2;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int n;
int main(void){
    int i, j;
    string s;
    cin >> s;
    n = s.size();
    int ans = 0, r = s.size() - 2;
    for (i = n - 2; i; i -= 2) {
        bool ok = 1;
        for (j = 0; j < i / 2; j++) {
            if (s[j] != s[j + i / 2])ok = 0;
        }if (ok) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;


//UnionFind
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int n) : par(n, -1) { }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool merge(int x, int y) {//xの木とyの木を結合する
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {//sizeの取得
        return -par[root(x)];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<P>B(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        B[i]=make_pair(a,b);
    }
    ll ans = 0;
    rep(i,m){
        UnionFind u(n);
        rep(j,m){
            if(i==j)continue;
            u.merge(B[j].first,B[j].second);
        }
        if(u.size(0)!=n)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long long>A(N);
  vector<long long>B(N);
  for (int i = 0; i < N; i ++) cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  long long mi, ma;
  mi = A[N / 2];
  ma = B[N / 2];
  if (N % 2 == 0) {
    mi += A[N / 2 - 1];
    ma += B[N / 2 - 1];
  }
  cout << ma - mi + 1 << endl;
}

Measured memory_bytes: 6364
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long M = 1000000007;

	void solve() {
		int n = ni();
		out.println((n-2)*180);

	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 19412
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define sz size()
using namespace std;
typedef pair<int,int> pii;

struct Node{
  int id,left,right;
  Node(int a,int b,int c):id(a),left(b),right(c){}
};

vector<pii> sim;
vector<int> shape_id;
vector< set<int> > shapes;
map<pii,int> shape_hash;

int construct(const string &s, int &p, vector<Node> &tree){
  if(s[p] == 'x'){
    tree.pb( Node(tree.sz, -1, -1) );
  }else if(s[p] == '('){
    int lid = construct(s, ++p, tree), rid = construct(s, ++p, tree);
    tree.pb( Node(tree.sz, lid, rid) );
  }
  ++p;
  return tree.sz-1;
}

void cal_sim(int v, const vector<Node> &tree){
  shapes[v].clear();

  if(tree[v].left<0){
    shape_id[v] = 0;
    shapes[v].insert(0);

    sim[v] = pii(0,1);
  }else{
    int l = tree[v].left, r = tree[v].right;
    cal_sim(l,tree); cal_sim(r,tree);
    for(int x : shapes[l])shapes[v].insert(x);
    for(int x : shapes[r])shapes[v].insert(x);

    pii new_shape = pii(shape_id[l], shape_id[r]);
    if(new_shape.first > new_shape.second)swap(new_shape.first, new_shape.second);
    int new_id;
    if(shape_hash.find(new_shape)!=shape_hash.end())new_id = shape_hash[new_shape];
    else{
      new_id = shape_hash.sz + 1;
      shape_hash[new_shape] = new_id;
    }
    shape_id[v] = new_id;
    shapes[v].insert(new_id);

    int cnt = 0;
    for(int x : shapes[l]){
      if(shapes[r].find(x) != shapes[r].end())cnt++;
    }
    sim[v] = pii(cnt,shapes[v].sz-1);
  }
}

//-1: a<b, 0:a==b, 1: a>b
map<pii,int> memo;
int cmp_node(int a, int b, const vector<Node> &tree){
  //if(memo[pii(a,b)])return memo[pii(a,b)];
  int res = 0;

  int dif = sim[a].first*sim[b].second - sim[b].first*sim[a].second;
  if(dif!=0){
    if(dif<0)res = 1;
    else res = -1;
  }else if(tree[a].left<0 && tree[b].left<0){
    res = 0;
  }else{
    int al = tree[a].left, ar = tree[a].right;
    if(cmp_node(al,ar,tree)<0)swap(al,ar);
    int bl = tree[b].left, br = tree[b].right;
    if(cmp_node(bl,br,tree)<0)swap(bl,br);
    
    res = cmp_node(al,bl,tree);
    if(res == 0)res = cmp_node(ar,br,tree);
  }
  //return memo[pii(a,b)] = res;
  return res;
}

void transform(int v, vector<Node> &tree, bool is_lc){
  if(tree[v].left<0)return;
  if(is_lc && (cmp_node(tree[v].left, tree[v].right, tree) < 0)){
    swap(tree[v].left, tree[v].right);
  }
  if(!is_lc && (cmp_node(tree[v].left, tree[v].right, tree) > 0)){
    swap(tree[v].left, tree[v].right);
  }
  transform(tree[v].left, tree, true);
  transform(tree[v].right, tree, false);
}

string encode(int v, const vector<Node> &tree){
  if(tree[v].left<0)return "x";
  return "(" + encode(tree[v].left,tree) +  " " +  encode(tree[v].right,tree) + ")";
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  string s;
  while(getline(cin,s)){
    if(s == "0")break;
    vector<Node> tree;
    int p = 0;
    construct(s,p,tree);

    sim.resize(tree.sz);
    shape_id.resize(tree.sz); shapes.resize(tree.sz);
    shape_hash.clear();
    cal_sim(tree.sz-1,tree);

    memo.clear();
    transform(tree.sz-1,tree,true);

    cout << encode(tree.sz-1,tree) << endl;
  }
}

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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;


int main() {
    //SYNC
    string s, ans;
    int a, b;
    cin >> s;
    a = 10*(s[0] - 48) + s[1] - 48;
    b = 10*(s[2] - 48) + s[3] - 48;
    if (a > 12) {
        if (b > 12) {
            ans = "NA";
        }else if(b < 1) {
            cout << "NA";
        } else {
            ans = "YYMM";
        }
    }else if(a < 1) {
        if (b > 12) {
            ans = "NA";
        }else if(b < 1) {
            cout << "NA";
        } else {
            ans = "YYMM";
        }
    } else {
        if (b > 12) {
            ans = "MMYY";
        }else if(b < 1) {
            cout << "MMYY";
        } else {
            ans = "AMBIGUOUS";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Mod 1000000007
#define N 500005
using namespace std;
int n;long long a[N],A,B,dp[N],d[N];
void change(int k,int l,int r,int x,int y){
	if (l==r){d[k]+=y;d[k]%=Mod;return;}
	int mid=(l+r)>>1;if (x<=mid) change(k*2,l,mid,x,y);
	else if (x>mid) change(k*2+1,mid+1,r,x,y);
	d[k]=d[k*2]+d[k*2+1];d[k]%=Mod;
}
long long query(int k,int l,int r,int x,int y){
	if (x>y) return 0;
	if (x<=l&&y>=r) return d[k]%Mod;int mid=(l+r)>>1;
	if (y<=mid) return query(k*2,l,mid,x,y)%Mod;
	else if (x>mid) return query(k*2+1,mid+1,r,x,y)%Mod;
	else return (query(k*2,l,mid,x,mid)+query(k*2+1,mid+1,r,mid+1,y))%Mod;
}
int main(){
	scanf("%d%lld%lld",&n,&A,&B);if (A<B) swap(A,B);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	a[0]=-A;a[n+1]=a[n]+A;dp[0]=1;
	change(1,0,n,0,dp[0]);int l=0;int r=0;
	for (int i=1;i<=n+1;i++){
		while (a[i]-a[r+1]>=A) r++;
		if (i>=2&&a[i-1]-a[i-2]<B) l=i-2;
		if (a[i]>=a[i-1]+A) dp[i]=dp[i-1];
		dp[i]+=query(1,0,n,l,min(i-2,r));dp[i]%=Mod;
		if (i<=n&&a[i+1]-a[i-1]>=B) change(1,0,n,i,dp[i]);
	}
	printf("%lld\n",(dp[n+1]+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 10496
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << (a*b)/ 2 << endl;



    return 0;
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n){
      for(int i = 0; i < n; i++)par[i] = i;
    }
    int root(int x){
      if(par[x] == x)return x;
      return par[x] = root(par[x]);
    }
    void unite(int x,int y){
      int rx = root(x);
      int ry = root(y);
      if(rx == ry)return;
      par[rx] = ry;
    }
    bool same(int x,int y){
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
    }
};
int ans[1000][1000];
int solve(){
  int h,w;
  cin >> h >> w;
  vector<string>v(h);
  rep(i,h)cin >> v[i];
  int vx[] = {0,1,1,1,0,-1,-1,-1};
  int vy[] = {1,1,0,-1,-1,-1,0,1};
  rep(i,h)rep(j,w){
    int cnt = 0;
    if(v[i][j] == '#')cnt = -100;
    rep(k,8){
      int nowy = i,nowx = j;
      nowx += vx[k];
      nowy += vy[k];
      if(0 <= nowx && nowx <= w - 1){
        if(0 <= nowy && nowy <= h - 1){
          if(v[nowy][nowx] == '#')cnt++;
        }
        else continue;
      }
      else continue;
    }
    ans[i][j] = cnt;
  }
  rep(i,h){
    rep(j,w){
    if(ans[i][j] < 0)cout << "#";
    else cout << ans[i][j];
    }
    cout << endl;
  }
  return 0; 
}

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

Measured memory_bytes: 384
//by tzupengwang™
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<iostream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n;
vector<int> v[100005];
int p[100005];
int ch[100005];
int dp[100005];
int z1[100005];
bool nd[100005];

void dfs(int x) {

  z1[x] = 0;
  for (int y : v[x]) if (y != p[x]) {
    p[y] = x;
    ch[x] ++;

    dfs(y);
    dp[x] += dp[y];
    if (dp[y] == 0) z1[x] ++;
  }

  if (ch[x] == 0) {
    dp[x] = 0;
    nd[x] = true;
    z1[x] = 1;
  } else {
    if (z1[x] >= 1) {
      nd[x] = true;
      dp[x] += (z1[x] - 1);
    } else nd[x] = false;
  }
}

void init() {
  scanf("%d", &n);
  for (int i = 1; i < n; i ++) {
    int x, y;
    scanf("%d%d", &x, &y);

    v[x].push_back(y);
    v[y].push_back(x);
  }
}

void process() {
  p[0] = 0;
  dfs(0);

  int ans = dp[0];

  if (ch[0] == 1) {
    if (nd[v[0][0]]) ans ++;
  } else if (ch[0] == 2) {
    if (z1[0] == 1) {
      if (dp[v[0][0]] && nd[v[0][0]]) ans ++;
      else if (dp[v[0][1]] && nd[v[0][1]]) ans ++;
    }
  }
  printf("%d\n", ans);
}

int main() {
/*
#ifdef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
  int Cases;
  scanf( "%d" , &Cases ) ;
  for ( int cases = 1 ; cases <= Cases ; cases ++ ) {
*/
    init() ;
    process() ;
/*
  }
*/
  return 0 ;
}

Measured memory_bytes: 12032
import numpy as np

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

n, k = map(int, input().split())
a = list(map(int, input().split()))

arr = np.array(a)
wa = sum(arr)
divisors = make_divisors(wa)

ans = 1
for div in divisors:
    lst = [0] * n
    for i in range(n):
        lst[i] = a[i] % div
    lst.sort()
    lst = [i for i in lst if i != 0]
    if lst == []:
        ans = max(ans, div)
    arr = np.array(lst)
    arr_amari = np.cumsum(arr)
    arr_reversed = arr[::-1]
    arr_husoku = np.cumsum(div - arr_reversed)[::-1]
    for i in range(len(arr_amari)-1):
        if arr_amari[i] == arr_husoku[i+1] and arr_amari[i] <= k:
            ans = max(ans, div)

print(ans)

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}


int main() {
  int x, y;
  cin >> x >> y;

  if (x % y == 0) {
    p(-1);
  } else {
    p(x);
  }
}

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

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

  if( a < b ) cout<<"a < b"<<endl;
  if( a > b ) cout<<"a > b"<<endl;
  if( a == b ) cout<<"a == b"<<endl;

  return 0;
}



Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
#define maxn 120
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

const ll mod = 1e9 + 7;
int h[maxn],a[maxn],tag[maxn],r[maxn * maxn],tot,n;
ll f[maxn][2][2][2],rec[maxn * maxn][2][2][2];

inline void up(ll &x,ll y){ x = (x + y) % mod; }
inline ll power(ll x,ll y){
	ll res = 1;
	if ( y < 0 ) return 1;
	while ( y ){
		if ( y & 1 ) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int main(){
	
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&h[i]) , a[i] = h[i];
	a[n + 1] = 1;
	sort(a + 1,a + n + 2);
	repd(l,n + 1,1){
		if ( a[l] == a[l + 1] ) continue;
		int curh = a[l],last = 0,t = (a[l + 1] - a[l]) & 1; ll curp = power(2,a[l + 1] - a[l] - 1);
		memset(f,0,sizeof(f));
		for (register int i = 1 ; i <= n ; ){
			if ( h[i] >= curh && h[i - 1] >= curh ){
				int nxt;
				if ( tag[i] ){
					nxt = r[tag[i]];
					rep(x,0,1) rep(y,0,1) rep(cx,0,1) rep(cy,0,1){
						if ( y != cx ){
							up(f[nxt][x][cy][1],f[i - 1][x][y][1] * (rec[tag[i]][cx][cy][1] + rec[tag[i]][cy][cx][1]) % mod * curp);
							up(f[nxt][x][cy][0],f[i - 1][x][y][0] * (rec[tag[i]][cx][cy][1] + rec[tag[i]][cy][cx][1]) % mod * curp);
							up(f[nxt][x][cy][0],(f[i - 1][x][y][0] + f[i - 1][x][y][1]) * rec[tag[i]][cx ^ t][cy ^ t][0]);
						}
						else{
							up(f[nxt][x][cy][0],(f[i - 1][x][y][0] + f[i - 1][x][y][1]) * rec[tag[i]][cx ^ t][cy ^ t][0]);
							up(f[nxt][x][cy][0],(f[i - 1][x][y][0] + f[i - 1][x][y][1]) * (rec[tag[i]][cx][cy][1] + rec[tag[i]][cy][cx][1]) % mod * curp);	
						}
					}
				}
				else{
					nxt = i;
					rep(x,0,1) rep(y,0,1) rep(z,0,1) rep(c,0,1){
						up(f[nxt][x][c][z && (c != y)],f[i - 1][x][y][z]);
					}
				}
				i = nxt + 1;
			}
			else if ( h[i] < curh && h[i - 1] >= curh ){
				tag[last] = ++tot , r[tot] = i - 1;
				rep(x,0,1) rep(y,0,1) rep(z,0,1) rec[tot][x][y][z] = f[i - 1][x][y][z];
				i++;
			}
			else if ( h[i] >= curh && h[i - 1] < curh ){
				last = i;
				int nxt;
				if ( tag[i] ){
					nxt = r[tag[i]];
					rep(x,0,1) rep(y,0,1){
						f[nxt][x][y][0] = rec[tag[i]][x ^ t][y ^ t][0];
						f[nxt][x][y][1] = (rec[tag[i]][y][x][1] + rec[tag[i]][x][y][1]) * curp % mod;
					}
				}
				else{
					nxt = i;
					rep(c,0,1) f[i][c][c][1] = 1;
				}
				i = nxt + 1;
			}
			else i++;
		}
		if ( h[n] >= curh ){
			tag[last] = ++tot , r[tot] = n;
			rep(x,0,1) rep(y,0,1) rep(z,0,1) rec[tot][x][y][z] = f[n][x][y][z];
		}
	}
	ll ans = 0;
	rep(x,0,1) rep(y,0,1) rep(z,0,1) up(ans,f[n][x][y][z]);
	printf("%lld\n",ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

int main(){
    using namespace std;
    vector<int> s;
    vector<int> h;
    vector<int> c;
    vector<int> d;
    s.assign(13,0);
    h.assign(13,0);
    c.assign(13,0);
    d.assign(13,0);
    int a, n;
    char b;
    cin >> n;
    for(int i{0}; i<n; i++){
        cin >> b >> a;
        switch(b){
            case 'S' : s[a-1]=1;;break;
            case 'H' : h[a-1]=1;break;
            case 'C' : c[a-1]=1;break;
            case 'D' : d[a-1]=1;break;
        }
    }
    for(int j{0}; j<13; j++){if (s[j]==0){cout << "S " << j+1 << endl;}}
    for(int j{0}; j<13; j++){if (h[j]==0){cout << "H " << j+1 << endl;}}
    for(int j{0}; j<13; j++){if (c[j]==0){cout << "C " << j+1 << endl;}}
    for(int j{0}; j<13; j++){if (d[j]==0){cout << "D " << j+1 << endl;}}
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M, X;
    cin >> N >> M >> X;

    vector<ll> A(M);
    rep (i, M) {
        cin >> A[i];
    }

    vector<ll> count(N+1);
    rep (i, M) {
        count[A[i]]++;
    }

    ll left = 0;
    ll right = 0;
    rep (i, X) {
        if (count[i] == 1) {
            left++;
        }
    }
    for (ll i = X+1; i < N; i++) {
        if (count[i] == 1) {
            right++;
        }
    }

    cout << min(left, right) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int n, k;
	cin >> n >> k;

	vector<ll>h(n);

	REP(i, n) {
		cin >> h[i];
	}

	sort(h.begin(), h.end(), greater<ll>());

	//REP(i, n) cout << h[i] << endl;

	ll ans = 0;
	for (int i = k; i < n; i++) {
		ans += h[i];
	}

	cout << ans << endl;

	return 0;

}

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

inline void read(int&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();
}

const int N=300,p=1e9+7;
struct Edge{int v,w,nxt;}a[N];
int head[N],low[N],dfn[N],d[N];
int fac[N],inv[N],cut[N],vs[N];
int fa[N],dep[N],tog[N];
int n,m,k,_,dfc,ans=1,nn,mm;

bitset <N> bit[N],t[N];

inline int gcd(int x,int y){return y?gcd(y,x%y):x;}

inline void add(int*arr,int u,int v){a[++_].v=v,a[_].nxt=head[u],head[u]=_;}

struct node{
	int l,r;
	inline void in(){read(l),read(r);}
}e[N];

inline int f(int x){return d[x]?d[x]=f(d[x]):x;}

inline int qpow(int A,int B){
	int res(1);while(B){
		if(B&1)res=1ll*A*res%p;
		A=1ll*A*A%p,B>>=1;
	}return res;
}

inline int c(int kn,int km){return 1ll*fac[kn]*inv[km]%p*inv[kn-km]%p;}

inline void dfs(int x,int las){
	dep[x]=dep[fa[x]=las]+1;
	for(int i=head[x];i;i=a[i].nxt)
		if(a[i].v!=las)dfs(a[i].v,x);
}

inline int lca(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	while(dep[x]!=dep[y])x=fa[x];
	while(x!=y)x=fa[x],y=fa[y];
	return x;
}

inline int dis(int x,int y){return dep[x]+dep[y]-(dep[lca(x,y)]*2);}

int main(){
	read(n),read(m),read(k);
	
	fac[0]=inv[0]=1;
	for(rg int i=1;i<N;++i)fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=qpow(fac[N-1],p-2);
	for(rg int i=N-2;i;--i)inv[i]=1ll*inv[i+1]*(i+1)%p;
	
	int km=0;
	for(rg int i=1;i<=m;++i){
		e[i].in();
		if(f(e[i].l)!=f(e[i].r)){
			d[f(e[i].l)]=f(e[i].r);
			add(head,e[i].l,e[i].r);
			add(head,e[i].r,e[i].l);
		}else e[++km]=e[i];
	}m=km;
	
	for(rg int i=1;i<=n;++i)
		if(!dep[i])
			dep[i]=1,dfs(i,0);
	
	for(rg int i=1;i<=m;++i){
		int x=e[i].l,y=e[i].r;
		if(dep[x]<dep[y])swap(x,y);
		while(dep[x]!=dep[y]){
			bit[i].set(x);
			vs[x]=1,x=fa[x];
		}
		while(x!=y){
			bit[i].set(x);vs[x]=1,x=fa[x];
			bit[i].set(y);vs[y]=1,y=fa[y];
		}
	}
	
	memset(d,0,sizeof d);
	
	for(rg int i=1;i<=m;++i)
	for(rg int j=i+1;j<=m;++j)
		if((bit[i]&bit[j]).count()>0)
			if(f(i)!=f(j))
				d[f(i)]=f(j);
	
	for(rg int i=1;i<=n;++i)
		if(!vs[i]&&fa[i])
			ans=1ll*ans*k%p;
	
	for(rg int i=1;i<=m;++i)
		if(d[i]){
			t[f(i)]|=bit[i];
			++tog[f(i)];
		}
	for(rg int i=1;i<=m;++i)
		if(f(i)==i&&tog[i])
			t[i]|=bit[i],++tog[i];
	
	for(rg int i=1;i<=m;++i)
		if(!tog[i]&&!d[i]){
			int kn=dis(e[i].l,e[i].r)+1;
			int res=0;
			for(int j=1;j<=kn;++j)
				res=(res+qpow(k,gcd(j,kn)))%p;
			ans=1ll*ans*res%p*qpow(kn,p-2)%p;
		}
	
	for(rg int i=1;i<=m;++i){
		int g=t[i].count()+tog[i];
		if(!g)continue;
		ans=1ll*ans*c(k+g-1,k-1)%p;
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

vector<pair<int, int>> inp;


bool check(int added, int m)
{
	if ((m + added) < inp.size())
	{
		return false;
	}

	vector<int> all_rs;
	multiset<int> rs;
	for (auto x : inp)
	{
		rs.insert(x.second);
		while (((int)rs.size() - added) > x.first )
		{
			int vvv = *rs.begin();
			all_rs.push_back(vvv);
			rs.erase(rs.find(vvv));
		}
	}
	sort(all_rs.begin(), all_rs.end());


	int cnt = 0;
	for (int i = all_rs.size()-1;i>=0;i--)
	{
		int val = all_rs[i];
#if 0
		if (rs.find(val) != rs.end())
		{
			rs.erase(rs.find(val));
			continue;
		}
#endif
		if (val > m)
			return false;
		cnt++;
		if ((m - val + 1) < cnt)
			return false;
	}
	return true;
}


int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, m;
//	cin >> n >> m;
	scanf("%d %d ", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int a, b;
//		cin >> a >> b;
		scanf("%d %d ", &a, &b);
		inp.push_back({ a,b });
	}
	sort(inp.begin(), inp.end());



	int left = 0, right = (n  + 1);
	while (left < right)
	{
		int mm = (left + right) / 2;
		if (check(mm, m))
		{
			right = mm;
		}
		else
		{
			left = mm + 1;
		}
	}

	printf("%d", left);
//	cout << left;
	return 0;
}


Measured memory_bytes: 11248
import java.util.Scanner;

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

		int H = sc.nextInt();
		int W = sc.nextInt();

		System.out.println((H - sc.nextInt()) * (W - sc.nextInt()));

		sc.close();
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
using ll = long long;
 
int main() {
	
	uint N, M;
	cin >> N >> M;
	
	vector<pair<pair<uint, uint>, uint>> LRC(M);
	uint l, r, c;
	for(uint i=0; i<M; i++) {
		cin >> l >> r >> c;
		auto p = make_pair(l - 1, r - 1);
		LRC[i] = make_pair(p, c);
	}
	
	sort(LRC.begin(), LRC.end());
	
	vector<ll> d(N, -1);
	d[0] = 0;
	
	l = 0;
	r = 0;
	for(uint i=0; i<M; i++) {
		auto LR = LRC[i].first;
		l = LR.first;
		r = LR.second;
		c = LRC[i].second;
		
		if(d[l] == -1) {
			cout << -1;
			return 0;
		}
		
		ll dj = d[l] + c;
		for(uint j=r; j>l; j--) {
			if(d[j] == -1) {
				d[j] = dj;
			} else if (d[j] <= dj) {
				break;
			} else {
				d[j] = dj;
			}
		}
	}
	
	cout << d[N-1];
	
	return 0;
}

Measured memory_bytes: 2176