akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

vector<pair<ll, ll> > a;

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    ll n,k; cin >> n >>k;
    for (int i = 0; i <n; i++) {
        ll l,r; cin >> l >>r;
        a.pb(make_pair(l, r));
    }
    sort(a.begin(), a.end());
    ll now = 0;
    for (int i = 0; i < n; i++) {
        now += a[i].se;
        if (now >= k) {
            cout << a[i].fi <<endl;return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2420
N = int(input())
L = list(list(map(int,input().split())) for i in range(N))
dp = [[0,0,0] for i in range(N+1)]

for i in range(N) :
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + L[i][0]
    dp[i+1][1] = max(dp[i][2], dp[i][0]) + L[i][1]
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + L[i][2]

ans = max(dp[N][0], dp[N][1], dp[N][2])

print(ans)


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


#define INF 2000000000

using ll=long long;

int main(){

  int N,W;
  cin >> N >> W;

  vector<vector<ll>> dp(N+1,vector<ll>(W+1,-INF));
  vector<pair<int,int>> obj(N);
  for(int i=0;i<N;i++){
    cin >> obj[i].first >> obj[i].second;
  }

  for(int i=0;i<=W;i++) dp[0][i]=0;

  for(int i=0;i<N;i++){
    for(int w=0;w<=W;w++){
      if(w>=obj[i].first){
        dp[i+1][w]=max(dp[i][w],dp[i][w-obj[i].first]+obj[i].second);
      }else{
        dp[i+1][w]=dp[i][w];
      }
    }
  }

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

Measured memory_bytes: 80256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	int n,x;
	cin >> n >> x;
	lld arr[n];
	lld arr2[n];
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
		arr2[i]=arr[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if(arr[i]+arr[i+1]>x)
		{
			arr[i+1]-=(arr[i]+arr[i+1]-x);
			if(arr[i+1]<0)
			{
				arr[i]+=arr[i+1];
				arr[i+1]=0;
			}
		}
	}
	lld sum=0;
	for(int i=0;i<n;i++)
	{
		// cout << arr[i] << " ";
		sum+=(arr2[i]-arr[i]);
	}
	cout << sum;
}

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

int main(){
  int N,D;
  cin >> N >> D;
  int c=0;
  for (int i= 0; i<N; i++){
  	int x,y;
  	cin >> x >> y ;
  	if (std::pow((std::pow(x,2)+std::pow(y,2)),0.5)<=D){
      c++;
    }
  }
  cout << c<<endl;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 100005;

/*
	X = A3 ^ A4 ... ^ AN
	S = A1 + A2
	encontrar a,b : a <= A1 | a+b = S | a^b = X | a : max

	a + b = (a ^ b) + 2*(a & b)
	-> a & b = ((a + b) - (a ^ b))/2
	->a & b = (S - X)/2 = D

	garantindo que D&X == 0
	se o iésimo bit de X esta ligado, acenda o iésimo
	bit de a, ou de b
*/

ll v[N];

void solve(){
	int n;
	cin >> n;
	ll X = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		if(i >= 2)X ^= v[i];
	}
	ll S = (v[0] + v[1]);
	ll D = (S - X)>>1, a = D, b = D;
	if(X > S or a > v[0]){
		cout << -1 << endl;
		return ;
	}
	for(int i = 60; i >= 0; i--){
		ll temp = (1LL<<i);
		if(temp&X){
			if(a + temp <= v[0]){
				a += temp;
			}else{
				b += temp;
			}
		}
	}
	if(min(a,b) > 0 and (a^b) == X and (a+b) == S){
		cout << v[0] - a << endl;
	} else {
		cout << -1 << endl;
	}
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 310;
int n, m;
int a[N][N];
int bal[N];
int use[N];

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n >> m;
	forn(i, n)
		forn(j, m) {
			cin >> a[i][j];
			a[i][j]--;
		}
	forn(i, n)
		bal[a[i][0]]++;
	int ans = n;
	forn(i, m) {
		int maxi = -1, maxx = 0;
		forn(j, m) {
			if (!use[j] && umx(maxx, bal[j])) {
				maxi = j;
			}
		}
		debug(mp(maxx, maxi));
		umn(ans, maxx);
		use[maxi] = 1;
		memset(bal, 0, sizeof(bal));
		forn(j, n) {
			forn(k, m) {
				if (!use[a[j][k]]) {
					bal[a[j][k]]++;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

bool solve(int n, int A[], int m, int i) {
	if (m == 0) return true;
	if (i >= n) return false;
	return solve(n, A, m, i + 1) || solve(n, A, m - A[i], i + 1);
}

bool solve(int n, int A[], int m) {
	return solve(n, A, m, 0);
}

int main() {
	int n,q,A[2000],m;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m;
		if (solve(n, A, m)) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		int[] ans = new int[n];
		
		for(int i = 0;i < n;i++)
		{
			for(int j = 0;j < m;j++)
			{
				A[i][j] = scan.nextInt();
			}
		}
		
		for(int i = 0;i < m;i++)
		{
			b[i] = scan.nextInt();
		}
		
		for(int i = 0;i < n;i++)
		{
			for(int j = 0;j < m;j++)
			{
				ans[i] += A[i][j] * b[j];
			}
		}
		
		for(int i = 0;i< n;i++)
		{
			System.out.println(ans[i]);
		}
	}
}

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

int main(){
    int N,X;
    cin >> N >> X;
    int m[N];
    int gram = 0;

    for(int i=0;i<N;i++){
        cin >> m[i];
        gram += m[i];
    } 
    sort(m,m+N);

    cout << N + (X-gram)/m[0] << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
using namespace std;
int n,m;
bool from1[222222],ton[222222];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		if(x==1)from1[y] = true;
		if(y==n)ton[x] = true;
	}
	for(int i=1; i<=n; i++)
		if(from1[i] && ton[i]){
			puts("POSSIBLE");
			return 0;
		}
	puts("IMPOSSIBLE");
	return 0;
}


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

using namespace std;

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

#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

const int MAXN = 3005;
const int MOD = 1000000007;

int power(int x, int n) {
    if (n == 0) return 1;
    if (n&1) return (1LL*x*power(x, n-1))%MOD;
    int p = power(x, n/2);
    return (1LL*p*p)%MOD;
}

int n, q, a[MAXN], dp[MAXN][MAXN];
int inv2;

int mul(int a, int b) {return (1LL*a*b)%MOD;}

int main () {
    scanf("%d%d", &n, &q);
    fto(i, 1, n) scanf("%d", &a[i]);

    fto(i, 1, n)
        fto(j, 1, n)
            if (a[i] > a[j]) dp[i][j] = 1;

    inv2 = power(2, MOD-2);

    fto(iq, 1, q) {
        int x, y;
        scanf("%d%d", &x, &y);

        int oldYX = dp[y][x], oldXY = dp[x][y];

        vector<int> oldIX(n+1); //dp[i][x]
        fto(i, 1, n) oldIX[i] = dp[i][x];
        vector<int> oldIY(n+1); //dp[i][x]
        fto(i, 1, n) oldIY[i] = dp[i][y];

        vector<int> oldXI(n+1); //dp[y][i]
        fto(i, 1, n) oldXI[i] = dp[x][i];
        vector<int> oldYI(n+1); //dp[y][i]
        fto(i, 1, n) oldYI[i] = dp[y][i];

        dp[y][x] = dp[x][y] = mul(oldXY + oldYX, inv2);

        fto(i, 1, n) {
            if (i != x)
                dp[i][y] = mul(dp[i][y] + oldIX[i], inv2);
            if (i != y)
                dp[i][x] = mul(dp[i][x] + oldIY[i], inv2);
        }

        fto(i, 1, n) {
            if (i != x)
                dp[y][i] = mul(dp[y][i] + oldXI[i], inv2);
            if (i != y)
                dp[x][i] = mul(dp[x][i] + oldYI[i], inv2);
        }
    }

    int ans = 0;
    fto(i, 1, n)
        fto(j, i+1, n)
            ans = (ans + dp[i][j])%MOD;

    fto(i, 1, q)
        ans = (ans * 2)%MOD;

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 35584
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
*/
#include <bits/stdc++.h>

#define iosb ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define BIT(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define F first
#define S second
#define pb push_back

using namespace std ;

typedef unsigned long long UL ;
typedef long long L ;
typedef string T ;
typedef int I ;

const I MaxN =      1e5+1 ;
const I MOD =       1e9+7 ;
const I inf =       2e9+7 ;
const L INF = 2e18+7 ;

int32_t main()
{
    //freopen(".in" , "r" , stdin) ;
    //freopen(".out" , "w" , stdout) ;
    string s ;
    cin >> s ;
    if(s[0] == 'B' && s[1] == 'B' && s[2] == 'B')
        cout << "No" ;
    else if (s[0] == 'A' && s[1] == 'A' && s[2] == 'A')
        cout << "No" ;
    else
    {
        cout << "Yes" ;
    }
    
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    string str = to_string(N);
    cout << count(str.begin(), str.end(), '2') << endl;
}

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


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    for (int i = 0; i < N; i++)
    {
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

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

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

int main(){
    ll n, x; cin>>n>>x;
    vector<ll> cntP(60, 0), l(60, 0);
    cntP[0]=1, l[0]=1;
    for(int i=1; i<=n; i++){
        cntP[i]=cntP[i-1]*2+1;
        l[i]=l[i-1]*2+3;
    }

    ll lb=1, ub=l[n];
    ll ans=0;
    while(n--){ // [lb, ub]
        ll mid=(lb+ub)/2;
        //cout << lb << " " << ub << endl;
        //cout << n << " " << mid << endl;

        if(mid==x){
            ans+=cntP[n]+1;
            break;
        }
        else if(lb==x){
            break;
        }
        else if(ub==x){
            ans+=cntP[n+1];
            break;
        }
        else if(mid<x){
            lb=mid+1;
            ub--;
            ans+=cntP[n]+1;
            if(n==0) ans++;
        }
        else{
            ub=mid-1;
            lb++;
            if(n==0) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    VL a(n), b(m);
    REP(i,n) a[i] = in();
    REP(i,m) b[i] = in();
    sort(ALL(a));
    sort(ALL(b));
    VL s(n + 1);
    REP(i,n) s[i + 1] = s[i] + a[i];

    ll ans = 0;
    map<ll, ll> mp;
    for (ll x : b){
        if (mp.count(x)){
            ans += mp[x];
            continue;
        }
        int c = a[n - 1] / x;
        ll cnt = 0;
        REP(i,c + 1){
            int l = lower_bound(ALL(a), i * x) - a.begin();
            int r = lower_bound(ALL(a), (i + 1) * x) - a.begin();
            cnt += s[r] - s[l] - i * x * (r - l);
        }
        mp[x] = cnt;
        ans += cnt;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 19684
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
 
 
void solve(){
	string a = "Christmas", b = " Eve";
	cout << a;
	int d;
	cin >> d;
	for(int i = 24; i >= d; --i) cout << b;
}
 
 
 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
const main = (inputs) => {
  var N = inputs[0].split(" ")[0]-0;
  var a = inputs[0].split(" ")[1]-0;
  var b = inputs[0].split(" ")[2]-0;
  console.log(Math.min(N*a,b));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


Measured memory_bytes: 22076
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976
#define MAX_N 100010

int main(){
	lint n,m,x;cin>>n>>m>>x;
	lint s=0,t=0;
	LIV a(m);
	rep(i,m){
		cin>>a[i];
		if(a[i]<x)++s;
		else ++t;
	}cout<<min(s,t)<<endl;

}

//sub-EOF


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
const double pi = acos(-1.);
const int N = 105;
int n, x[N], y[N];
double p[N + N];
signed main()
{
    cin >> n;
    for (int i = 0; i < n; i++)cin >> x[i] >> y[i];
    for (int i = 0; i < n; i++)
    {
        int tot = 0;
        for (int j = 0; j < n; j++)
            if (i != j)p[tot++] = atan2(y[j] - y[i], x[j] - x[i]);
        sort(p, p + tot);
        for (int j = 0; j < tot; j++)p[j + tot] = p[j] + 2 * pi;
        double ans = 0;
        for (int j = 0; j < tot; j++)ans = max(ans, pi - p[j + tot - 1] + p[j]);
        printf("%.8f\n", ans / 2 / pi);
    }
    return 0;
}


Measured memory_bytes: 4152
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
MOD = 998244353

N = int(input())
A = [int(input()) for _ in range(N)]
S = sum(A)

# 赤青の和がS/2以下となるものを求めて3倍

dp = np.zeros(S//2+1, dtype=np.int64)
dp[0] = 1
for a in A:
    prev = dp
    dp = prev.copy()
    dp[a:] += prev[:-a] * 2
    dp %= MOD

answer = pow(3,N,MOD) - dp.sum() * 3
if S % 2 == 0:
    dp = np.zeros(S//2+1, dtype=np.int64)
    dp[0] = 1
    for a in A:
        dp[a:] += dp.copy()[:-a]
        dp %= MOD
    answer += dp[S//2] * 3
answer %= MOD
print(answer)

Measured memory_bytes: 13504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const ll inf = 1LL<<60;

const int MAX = 1000005;

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;
    }
 
}
long long 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;
}

vector< pair<int, int> > prime_factorization(ll n){
    vector< pair<int, int> > res;

    for(ll i=2; i*i<=n; ++i){
        if(n%i == 0){
            int cnt = 0;
            while(n%i == 0){
                ++cnt;
                n /= i;
            }
            res.push_back(make_pair(i, cnt));
        }
    }
    if(n!=1) res.push_back(make_pair(n, 1));

    return res;
}


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

    ll n, m; cin >> n >> m;

    vector< pair<int, int> > div = prime_factorization(m);

    COMinit();

    ll ans = 1;
    for(auto p:div){
        ans *= COM(p.second+n-1, n-1);
        chmod(ans);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n, m; cin >> n >> m;
    priority_queue<int, vector<int>, greater<int> > que; 
    for(int i=0; i<n; ++i){int a; cin >> a; que.push(a);}
    vector<pair<int, int>> p(m); 
    for(int i=0; i<m; ++i){
        int b, c; cin >> b >> c;
        p[i] = make_pair(c, b);
    }
    sort(p.begin(), p.end()); 
    for(int i=0; i<m; ++i){
        int c = p[m-i-1].first, b = p[m-i-1].second;//cout << que.size() << endl;
        if(que.top()>=c){break;}
        for(int i=0; i<b; ++i){
            if(que.top()<c){ //cout << que.top() << endl;
                que.pop(); que.push(c); 
            }else{break;}
        }
    }
    ll res = 0; //cout << que.size() << endl;
    while(!que.empty()){
        res += que.top(); //cout << "top:" << que.top() << endl; 
      	que.pop(); //cout << "size:" << que.size() << endl; cout << "atop:" << que.top() << endl;
    }
    cout << res << endl; 
    return 0;
}

Measured memory_bytes: 4564
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a = 0, b, c, e;
	string s;
	cin >> s;
	char test[30];
	for (int h = 0; h < s.size(); h++) {
		test[h] = s[h];
	}
	for (int j = 0; j < s.size(); j++) {
		for (int i = 0; i < j; i++) {
			if (test[i] == s[j] && a == 0) {
				cout << "no" << endl;
				a++;
			}
		}
	}
	if (a == 0) {
		cout << "yes" << endl;
	}
	cin >> e;
}

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


int main() {
    int a, b, c;
    cin >> a >> b;
    c = a + b;
    if (a % 3 == 0 or b % 3 == 0 or c % 3 == 0) puts("Possible");
    else puts("Impossible");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include <string>
#include <utility>
#include<array>
#include<set>
#define EPS (1e-7)
using namespace std;




int main() {

	int A, B, C, X, Y, cost;
	int mincost = 6000000000;
	cin >> A >> B >> C >> X >> Y;

	for (auto i = 0; i <= max(X,Y); i++)
	{
		
		mincost = min(mincost, 2 * C*i + A * max((X - i), 0) + B * max((Y - i), 0));
	}

	cout << mincost << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

class NBase {
    public:
        NBase(Int base, Int digits);
        void EnumAllNum();
        void EnumAllNum(vector<string>& v);
    private:
        Int m_base;
        Int m_digits; // 3から9まで
};
NBase::NBase(Int base, Int digits) : m_base(base), m_digits(digits) {
}
void NBase::EnumAllNum() {
    for (Int d = 1; d <= m_digits; ++d) {
        Int count = pow(m_base, d);
        for (Int c = 0; c < count; ++c) {
            string number = "";
            Int now = c;
            for (Int k = 0; k < d; ++k) {
                if (now == 0) {
                    number += '0';
                } else {
                    number += char((now % m_base) + '0');
                    now /= m_base;
                }
            }
            cout << number << endl;
        }
    }
    return;
}
void NBase::EnumAllNum(vector<string>& v) {
    for (Int d = 1; d <= m_digits; ++d) {
        Int count = pow(m_base, d);
        for (Int c = 0; c < count; ++c) {
            string number = "";
            Int now = c;
            for (Int k = 0; k < d; ++k) {
                if (now == 0) {
                    number += '0';
                } else {
                    number += char((now % m_base) + '0');
                    now /= m_base;
                }
            }
            v.push_back(number);
        }
    }
    return;
}

int main(void) {
    string s;
    cin >> s;
    NBase base(3, s.length());

    vector<string> v;
    base.EnumAllNum(v);

    Int answer = 0;
    Int n = stol(s);
    for (Int i = 0; i < (Int)v.size(); ++i) {
        for (Int k = 0; k < v[i].length(); ++k) {
            if (v[i][k] == '0') {
                v[i][k] = '3';
            }
            else if (v[i][k] == '1') {
                v[i][k] = '5';
            }
            else if (v[i][k] == '2') {
                v[i][k] = '7';
            }
        }
        bool a = (v[i].find('3') != string::npos && v[i].find('5') != string::npos && v[i].find('7') != string::npos);
        bool b = (n >= stoi(v[i]));
        if (a && b) {
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 4652
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nx = readInts()
    let (_, x) = (nx[0], nx[1])
    let aryX = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let aryXd = aryX.map {abs($0 - x)}
    
    print(gcd(aryXd))
}

main()


Measured memory_bytes: 18844
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

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)*}};}
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, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize
    }

    let mut n = n;

    let mut ans = 0;

    ans += (n / 500) * 1000;
    n = n % 500;
    ans += (n / 5) * 5;

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    double n=s.size(),ans=0;
    for(int i=0;i<(n-1)/2;i++)
        if(s[i]!=s[n-i-1])
            ans=1;
    for(int i=0;i<(n-3)/4;i++)
        if(s[i]!=s[(n-3)/2-i])
            ans=1;
    for(int i=0;i<(n-3)/4;i++)
        if(s[i+(n+1)/2]!=s[n-i-1])
            ans=1;
    if(ans==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > t(N + 1);
  vec< double > v(N);
  t[0] = 0;
  REP(i, N) {
    int p;
    cin >> p;
    t[i + 1] = t[i] + p;
  }
  REP(i, N) { cin >> v[i]; }
  vec< double > tLis(2 * t[N] + 1, INF);

  REP(i, (int)tLis.size()) {
    double val = i * .5;
    // int index = lower_bound(ALL(t), val) - t.begin();
    chmin(tLis[i], val);
    REP(j, N) {
      if (val < t[j]) {
        chmin(tLis[i], v[j] + t[j] - val);
      } else if (val > t[j + 1]) {
        chmin(tLis[i], v[j] + val - t[j + 1]);
      } else {
        chmin(tLis[i], v[j]);
      }
    }
    chmin(tLis[i], t[N] - val);
  }
  // PRINTALL(tLis);
  double sum = 0;
  REP(i, (int)tLis.size() - 1) { sum += (tLis[i] + tLis[i + 1]) * .25; }
  print(sum);
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int x,n;
    cin>>x>>n;
    set<int> p;
    while(n--)
    {
        int pi;
        cin>>pi;
        p.insert(pi);
    }
    for(int l=x,r=x;;l--,r++)
        if(!p.count(l))
            cout<<l,exit(0);
        else if(!p.count(r))
            cout<<r,exit(0);
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
queue<int>q[3];
int main(){
for(int i=0;i<=2;i++){
string s;
cin>>s;
for(int j=0;j<s.size();j++)
q[i].push(s[j]-'a');
}
int n=0;
while(!q[n].empty()){
int x=q[n].front();
q[n].pop();
n=x;}
char ans='A';
ans+=n;
cout<<ans;
system("pause");
return 0;
}

Measured memory_bytes: 504
s = int(input())
a = list(map(str, input().split()))
n = {}
for i in a:
  n.setdefault(i, 0)
for i in a:
  n[i] += 1
x = 0
for i in n.values():
  if x <= i:
    x = i
if x == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 38836
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define BUG cout << "acdsfas" << endl
 
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 1e5 + 15;
int n, m, d[N];
vector <int> g[N], gr[N], topsort;
bool used[N];

void dfs(int v) {
    used[v] = true;
    for(int to : gr[v])
        if(!used[to])
            dfs(to);
    topsort.pb(v);
}

main() {
    scanf("%d %d", &n, &m);
    while(m--) {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].pb(v);
        gr[v].pb(u);
    }
    for(int i = 1; i <= n; ++i)
        if(!used[i] && g[i].empty())
            dfs(i);
    for(int v : topsort)
        for(int to : g[v])
            d[to] = max(d[to], d[v] + 1);
    printf("%d\n", *max_element(d + 1, d + 1 + n));
    return 0;
}

Measured memory_bytes: 16892
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
//#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll K = 0;
	ll Y = 0;
	ll X = 0;
	ll x[100000] = {};
	//ll c[10000] = {};
	//ll d[10000] = {};
	//ll *x, *c, *d;
	string S;
	ll count = 0;
	ll sum = 0;
	ll i = 0;
	cin >> S;
	
	rep(i, 0, 3) {
		if (S[i] == 'o')count++;
	}
	

	cout << 700+100*count << endl;
	return 0;

}



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

int main() {
    //
    int r, g, b;
    int num;

    cin >> r >> g >> b >> num;

    bool chk = false;
    for (int i = 0; i < num; i++) {
        if (r < g && g < b) {
            chk = true;
            break;
        }

        if (g >= b)
            b *= 2;
        else if (r >= g)
            g *= 2;
    }

    if (r < g && g < b) chk = true; 

    if (chk)
        cout << "Yes";
    else
        cout << "No";
    //
}


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

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

    string S;
    cin >> S;
    int toBlackWhite = 0; // 010101...
    int toWhiteBlack = 0; // 101010...

    rep(i, S.size()) {
        if (i % 2 == 0) {
            if (S[i] == '0')
                ++toWhiteBlack;
            else
                ++toBlackWhite;
        }
        if (i % 2 == 1) {
            if (S[i] == '0')
                ++toBlackWhite;
            else
                ++toWhiteBlack;
        }
    }

    cout << min(toBlackWhite, toWhiteBlack) << "\n";
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 105;

//map<pair<pair<int, int>, set<int>>, int> dp;
int dp[N][N][N];
int a[N];
int n;

/*
int go(int p, set<int> b, int prev) {
  if(p == 0) {
    return 1;
  }
  if(dp.find(make_pair(make_pair(p, prev), b)) != dp.end()) {
    return dp[make_pair(make_pair(p, prev), b)];
  }
  int &res = dp[make_pair(make_pair(p, prev), b)];
  res = 0;
  b.insert(a[p]);
  b.insert(a[2 * n - p]);
  fore(y, b) {
    set<int> c;
    for(set<int>::iterator it = b.begin(); it != b.end(); it++) {
        int x = *it;
        if((prev < x && x < y) || (y < x && x < prev)) {
          continue;
        } else {
          c.insert(x);
        }
      }
    res += go(p - 1, c, y);
    if(res >= mod) {
      res -= mod;
    }
  }
  return res;
}
*/

int go(int p, int b, int prev) {
  if(p == 0) {
    return 1;
  }
  int &res = dp[p][b][prev];
  if(res == -1) {
    res = 0;
    if(p != n) {
      if(a[p] != a[p + 1]) {
        b++;
        prev++;
      }
      if(a[2 * n - p] != a[2 * n - p - 1]) {
        b++;
      }
    }
    rep(y, 1, b) {
      int newb = b, newprev = prev;
      if(y > prev) {
        newb -= (y - prev - 1);
        newprev = prev + 1;
      }
      if(prev > y) {
        newb -= (prev - y - 1);
        newprev = y;
      }
      res += go(p - 1, newb, newprev);
      if(res >= mod) {
        res -= mod;
      }
    }
  }
  return res;
}

int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  rep(i, 1, 2 * n - 1) {
    cin >> a[i];
  }
  sort(a + 1, a + 2 * n);
  /*
  set<int> cands;
  cout << go(n, cands, a[n]) << endl;
  */
  memset(dp, -1, sizeof(dp));
  cout << go(n, 1, 1) << endl;
  return 0;
}

Measured memory_bytes: 4736
n,k=map(int,input().split())
s=list(input())
idx=[]
idx.append(0)
for i in range(1,n):
  if s[i]!=s[i-1]:
    idx.append(i)
arr=idx+[n]*(2*k+1)
ans=-10**18
z=0
for m in idx:
    if s[m]=='0':
      ans=max(ans,arr[z+2*k]-arr[z])
    else:
      ans=max(ans,arr[z+2*k+1]-arr[z])
    z+=1
print(ans)

Measured memory_bytes: 9340
N = int(input())

inputlist = [sorted(input()) for _ in range(N)]

inputlist.sort()

ans = 0
continued = 1

last = []
for l in inputlist:
    if last == l:
        continued += 1
    else:
        ans += continued * (continued - 1) // 2
        continued = 1
    last = l

ans += continued * (continued - 1) // 2
continued = 0

print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n),b;
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=0;i<n;i++){
        b.push_back(v[i]-(i+1));
    }
    sort(b.begin(),b.end());
    int e=b[b.size()/2];
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(v[i]-(e+i+1));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;
//0->決定
//1->xのみ決定
//2->yのみ決定
//3->x,yの範囲のみ決定
struct query {
	ll type;
	pll p1, p2;
};

ll H, W;
vector<ll> A, B;
vector<vector<pll>> DP;
vector<query> DP2;

int main() {
	cin >> H >> W;
	A.resize(H + 1);
	for (ll y = 1; y <= H; y++)cin >> A[y];
	sort(A.begin(), A.end(), [](ll a, ll b) {return a < b; });
	B.resize(W + 1);
	for (ll x = 1; x <= W; x++)cin >> B[x];
	sort(B.begin(), B.end(), [](ll a, ll b) {return a < b; });
	for (ll x = W; x > 1; x--) {
		if (B[x] == B[x - 1]) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (ll y = H; y > 1; y--) {
		if (A[y] == A[y - 1]) {
			cout << 0 << endl;
			return 0;
		}
	}
	DP.resize(W * H + 1, vector<pll>(2, pll(0, 0)));
	DP2.resize(W * H + 1);
	ll xuse = W, yuse = H;
	for (ll p = W * H; p >= 1; p--) {
		if (A[yuse] == p && B[xuse] == p) {
			DP[p][0] = pll(xuse, yuse);
			DP[p][1] = pll(xuse, yuse);
			xuse--;
			yuse--;
			DP2[p] = { 0,pll(xuse,yuse),pll(-1,-1) };
		}
		else if (A[yuse] == p) {
			DP[p][0] = pll(xuse + 1, yuse);
			DP[p][1] = pll(W, yuse);
			DP2[p] = { 2,pll(xuse + 1, yuse),pll(W, yuse) };
			yuse--;
		}
		else if (B[xuse] == p) {
			DP[p][0] = pll(xuse, yuse + 1);
			DP[p][1] = pll(xuse, H);
			DP2[p] = { 1,pll(xuse, yuse + 1) ,pll(xuse, H) };
			xuse--;
		}
		else {
			DP[p][0] = pll(xuse+1, yuse+1);
			DP[p][1] = pll(W, H);
			DP2[p] = { 3,pll(xuse + 1, yuse + 1) ,pll(W, H) };
		}
	}
	ll ans = 1;
	for (ll p = W * H; p >= 1; p--) {
		if (DP[p][0] == DP[p][1])continue;
		else if (DP[p][0].second == DP[p][1].second) {
			ans = (ans * (DP[p][1].first - DP[p][0].first + 1)) % MOD;
		}
		else if (DP[p][0].first == DP[p][1].first) {
			ans = (ans * (DP[p][1].second - DP[p][0].second + 1)) % MOD;
		}
	}
	for (ll p = W * H; p >= 1; p--) {
		if (DP[p][0].first == DP[p][1].first ||
			DP[p][0].second == DP[p][1].second)continue;
		ans = (ans * ((W - DP[p][0].first+1) * (H - DP[p][0].second+1)-(W*H-p))) % MOD;
	}
	ans = 1;
	for (ll p = W * H; p >= 1; p--) {
		if (DP2[p].type == 0)continue;
		else if (DP2[p].type == 1) {
			ll left = DP2[p].p2.second - DP2[p].p1.second + 1;
			ans = (ans * left) % MOD;
		}
		else if (DP2[p].type == 2) {
			ll left = DP2[p].p2.first - DP2[p].p1.first + 1;
			ans = (ans * left) % MOD;
		}
		else {
			ll left = (W - DP[p][0].first + 1) * (H - DP[p][0].second + 1) - (W * H - p);
			ans = (ans * left) % MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 109696
a, b, c, x, y = gets.split.map(&:to_i)
min_half = [x, y].min
max_half = [x, y].max
puts [
  a*x + b*y,
  a*([x-min_half, 0].max) + b*([y-min_half, 0].max) + c*2*min_half,
  a*([x-max_half, 0].max) + b*([y-max_half, 0].max) + c*2*max_half,
].min


Measured memory_bytes: 1916
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define ma 200005

namespace IO
{
	const unsigned int bufsize=1<<16,outsize=1<<24;
	static char ch[bufsize],*S=ch,*T=ch;
	inline char getc()
	{return ((S==T)&&(T=(S=ch)+fread(ch,1,bufsize,stdin),S==T)?0:*S++);}
	static char Out[outsize],*nowp=Out;
	inline void flush(){fwrite(Out,1,nowp-Out,stdout);nowp=Out;}
	template<typename T>
		void read(T &x)
		{
			char c=getc();x=0;
			for(;!isdigit(c);c=getc());
			for(;isdigit(c);x=(x<<1)+(x<<3)+(c^'0'),c=getc());
		}
	template<typename T>
		void write(T x,char c='\n')
		{
			if(!x)*nowp++='0';
			static unsigned int stk[50],tp=0;
			for(;x;x/=10)stk[++tp]=x%10;
			for(;tp;*nowp++=stk[tp--]^'0');*nowp++=c;
		}
}

int n,a[ma],c;
ll row[ma];
int stk[ma][2];

int main() {
    using namespace IO;
    read(n);

    rep(i,n){
        read(a[i]);
    }

    int c = 0;

    ll ans = 0;

    rep(i,n){
        if(i==0){
            row[i] = a[i];
            stk[c][0] = a[i];
            stk[c][1] = 1;
            c++; 
        } else {
            row[i] = row[i-1] + a[i];
            int c_ = 1;
            while(0 < c && a[i] < stk[c-1][0]){
                row[i] -= (stk[c-1][0] - a[i]) * stk[c-1][1];
                c_ += stk[c-1][1];
                c--;
            }
            stk[c][0] = a[i];
            stk[c][1] = c_;
            c++;
        }
        ans += row[i];
    }
    
    return write(ans),flush(),0;
    return 0;
}
 
 


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

int main() {
  int N, l, r;
  cin >> N;
  
  int result = 0;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    result += r - l + 1;
  }
  
  cout << result << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N,i;
    cin >> N;
    int min = N;
    for(i=1;i<=1e6;i++){
        if(((N%i)==0)&&(min>(i+(N/i)-2))){
                min = (i+(N/i)-2);
        }
    }
    cout << min << endl;
}


Measured memory_bytes: 256