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

using namespace std;
using ll = long long;

int main() {
    int N, A, B;
    string S;
    int i = 0, e = 0, o = 0;
    cin >> N >> A >> B >> S;
    for (size_t j = 0; j < N; j++)
    {
        //cout << S.at(j);
        if (S.at(j) == 'a')
        {
            if(A + B > i + e)
            {
                i++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
            
        }
        else if (S.at(j) == 'b')
        {
            if(B > e && A + B > i + e)
            {
                e++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
            
        }
        else
        {
            o++;
            cout << "No" << endl;
        }
        
        
    }
    

    return 0;
}

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

int main()
{
    int K,A,B;
    string ans = "NG";
    cin >> K >> A >> B;
    for(int i = A;i <= B; i++){
        if(i % K == 0){
            ans = "OK";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define forr(i, b, e)     for(ll i = b; i < e; i++)
#define forg(i, b, e, m)  for(ll i = b; i < e; i+=m)
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e18);
#define tam 320000
#define tamlog 61
#define ptr nodo*

typedef pair<ii,ll> iii;
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);    
    ll n;
    cin>>n;
    ll turno=(n/11)*2;
    n-=(turno/2)*11;
    if (n>0){
    if (n<=6)turno++;
    else turno+=2;
    }
    cout<<turno<<endl;

}
// PLUS ULTRA!

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    string s;
    int k;
    cin>>s>>k;
    set<string> ans;
    

    rep(i,s.size()){
        for(int j=1;j<=k;j++){
            string t=s.substr(i,j);
            ans.insert(t);
        }
    }

    vector<string> res;
    for(auto e : ans) res.push_back(e);
    sort(all(res));
    cout<<res[k-1]<<endl;

}

Measured memory_bytes: 5124
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
#define F first
#define S second
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
struct XY
{
	int x;
	int y;
};

/*
(char)'1' - (int)48 = (int)1;
　1111181
*/
////////////////////////////////////////////////////
int M = 1046527;
char T[1046527][15];
int ci(char a)
{
	switch (a)
	{
	case 'A':return 1; break;
	case 'C':return 2; break;
	case 'T':return 3; break;
	case 'G':return 4; break;
	}
}

long long cn(char a[15])
{
	long long s = 0; int p = 1;
	for (int i = 0; i < strlen(a); i++)
	{
		s += p * 5 * ci(a[i]); p *= 5;
	}
	return s;
}

bool search(char a[15])
{
	long long n = cn(a);
	long long ha;
	int i = 0;
	while (1)
	{
		ha = (n%M + i*(1 + n % (M - 1))) % M;
		if (T[ha][0] == '-')return false;
		else if (strcmp(T[ha] ,a)==0)return true;
		i++;
	}

}

void insert(char a[15])
{
	long long n = cn(a);
	long long ha;
	int i = 0;
	while (1)
	{
		ha = (n%M + i*(1 + n % (M - 1))) % M;
		if (strcmp(T[ha], a) == 0)return;
		else if (T[ha][0] == '-')
		{
			strcpy(T[ha], a);
			return;
		}
		i++;
	}
}

int main()
{
	int n;
	cin >> n;
	rep(i, M)T[i][0] = '-';
	rep(i, n)
	{
		char mis[7],a[15];
		scanf("%s %s", mis, a);
		if (mis[0] == 'i')
		{
			insert(a);
		}
		else
		{
			if (search(a))cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 16524
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, t, a;
    cin >> n >> t >> a;
    vi h(n);
    rep(i, n) cin >> h[i];
    auto f = [&](int i) {
        return t - (double)h[i]*0.006;
    };
    int j = 0;
    REP(i, 1, n) {
        if(abs(a-f(i)) < abs(a-f(j))) j = i;
    }
    cout << j+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  int m=0;
  int c=0;
  for(int i=0; i<N; i++){
    int h;
    cin >> h;
    if(h>=m) c++;
    m = max(m, h);
  }
  cout << c << endl;
  return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
constexpr double EPS = 1e-10;
using number = long long;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 1;
    rep(i,n-1){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost		          ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);

using namespace std;
///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif

////////////////////////

template<typename T>T set_bit(T N,T pos){return N=N | (1<<pos);}
template<typename T>T reset_bit(T N,T pos){return N= N & ~(1<<pos);}
template<typename T> bool check_bit(T N,T pos){return (bool)(N & (1<<pos));}
template<typename T>void bin_print(T N){bitset<25>bit(N);cerr<<bit.to_string()<<"\n";}
template<typename T> void max_self(T &a, T b){
	a=max(a,b);
}
template <typename T > void min_self(T &a, T b){
	a=min(a,b);
}
template <typename T > void add_self(T &a, T b){
	a+=b;
}
////////////////////////

template<typename T> void ara_read(T &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
template<typename T> void ara_print(T &v){
	for(ll x : v)
		printf("%lld ",x);
	puts("");
}
////////////////////////
const int INF = 1e9 + 99;
typedef pair<int,int> Pair;
typedef vector<int> vec;;


int main()
{
	int n;
	scanf("%d",&n);
	vector <int > v;
	ara_read(v,n);
	int ans = 0;
	
	for(int i =1 ; i < n-1 ; i++){
		if(v[i]>v[i-1] && v[i] < v[i+1])
			ans++;
		else if(v[i] < v[i-1] && v[i] > v[i+1])
			ans++;
	}
	
	
	printf("%d\n",ans);
	
    return 0;
}


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

using namespace std;
#define         MAX         1000000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)



int main() {

    int n,k,sum;
    cin>>k>>n;
    vector<int>v(n);

    for(int i=0;i<n;i++){
        cin>>v[i];
    }

    vector<int>dis;

    for(int i=0;i<v.size()-1;i++){
        dis.push_back(v[i+1]-v[i]);
    }
    int tmp = k-v[v.size()-1];
    if(v[0]>0){
        tmp += v[0];
    }
    dis.push_back(tmp);
    int mx = 0;
    sum = 0;
    for(int i=0;i<dis.size();i++){
        mx = max(mx,dis[i]);
        sum += dis[i];
    }

    cout<<sum-mx<<endl;
    return 0;
}


Measured memory_bytes: 2168
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	S = input()
	S = S[:-1]

	tmp = len(S)
	tmp = tmp // 2

	ans = 0
	for i in range(tmp):
		#print("{} {}".format(S[i], S[-1 * (i+1)]))
		if S[i] == S[-1 * (i+1)]:
			pass
		else:
			ans += 1

	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i=a;i<=b;i++)

void solve()
{
    ll a, b;
    cin >> a >> b;

    FOR(i, 0, 1000000){
        if(floor(double(i)*0.08)==a && floor(double(i)*0.1)==b){
            cout << i;
            return;
        }
    }

    cout << -1;

    return;
}

int main() 
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    fastio

    ll t = 1;
    //cin >> t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<stdio.h>


void rev(char *a)
{
        if(*a=='0')
                *a='1';
        else
                *a='0';
}
int main( )
{
        char a,b='5';
        int c=0;
        while(a=getchar( ),a!='\n')
        {
                if(a==b)
                {
                        rev(&a);
                        c++;
                }
                b=a;
        }
        printf("\n%d",c);

        return 0;
}


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

using namespace std;

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

    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3580
def main():
    N = int(input())
    if N % 2 == 1:
        print(0)
        return
    # N = 2k
    N //= 2
    d = 5
    res = 0
    while True:
        if N < d:
            break
        res += N // d
        d *= 5
    print(res)
main()

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

using namespace std;

#define PB push_back
#define MEM(n, val) memset(n, val, sizeof(n))
#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define ROF(i, j, k) for(int i = j; i >= k; i--)
#define LL long long
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define INF 1999999999
#define MP make_pair
#define LN (node * 2)
#define RN ((node * 2) + 1)
#define MX 1010
#define MOD 10000

int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};

//map<PII, int> mp;
//int mp[3000][3000];
int ara[3000][3000];

int main()  {
    std::ios_base::sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    bool chk = 1;
    int n;
    cin >> n;
    int ct = 0, cx = 0, cy = 0;
    FOR(i, 1, n)   {
        int t, x, y;
        cin >> t >> x >> y;

        int dist = t - ct;
        int dis = abs(x - cx) + abs(y - cy);

        if((dist % 2) == (dis % 2) && dist >= dis)    {
            ct = t;
            cx = x;
            cy = y;
            continue;
        }

        //cout << i << " : " << dis << " " << dist << "\n";
        chk = 0;
    }
    if(chk)    {
        cout << "Yes";
    }
    else    {
        cout << "No";
    }
    return 0;
}
/**
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int H, W;
string A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W;
    rep(y, 0, H) cin >> A[y];

    rep(x, 0, W + 2) printf("#");
    printf("\n");
    rep(y, 0, H) {
        string s = "#" + A[y] + "#";
        printf("%s\n", s.c_str());
    }
    rep(x, 0, W + 2) printf("#");
    printf("\n");
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ll fact[N+1]={0};
    fact[0]=1;
    FORI(i,1,N+1)
    {
        fact[i]=fact[i-1]*i;
    }
    READAR(A,N);
    READAR(B,N);
    ll a=0,b=0;
    ordered_set Z;
    FORI(i,1,N+1)
    {
        Z.insert(i);
    }
    FORI(i,0,N)
    {
        a+=Z.order_of_key(A[i])*fact[N-i-1];
        Z.erase(Z.find(A[i]));
    }
    FORI(i,1,N+1)
    {
        Z.insert(i);
    }
    FORI(i,0,N)
    {
        b+=Z.order_of_key(B[i])*fact[N-i-1];
        Z.erase(Z.find(B[i]));
    }
    cout<<abs(a-b)<<endl;

//-----------------------------------------------------------------------------------------------------------//


   
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

const int MAXN = 100000+10;
int a[MAXN];
int N;

double ABS(double N) {
	return N>=0?N:-N;
}

int main() {
	scanf("%d",&N);
	for(int i = 1; i <= N; i++) scanf("%d",&a[i]);
	sort(a+1,a+N+1);
	double res1,res2;
	int ans;
	for(int i = 1; i <= N; i++) {
		if(a[i] <= a[N]/2 & a[i+1] >= a[N]/2){
			res1=  ABS(a[N]/2.0 - a[i]);
			res2 = ABS(a[i+1] - a[N]/2.0);
//			cout << res1 << " " <<res2 << " "<< i << endl;
			if(res1 <= res2) {
				cout << a[N] <<' '<<a[i]<<endl;
			} 
			else cout << a[N] <<' ' <<a[i+1];
			return 0;
		} 
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
  if(n%1000==0)
    cout<<0;
  else
    cout<<1000-n%1000;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

using VD = vector<double>;
using VVD = vector<VD>;
using VVVD = vector<VVD>;

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

	vector<double> p(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	VVD dp(n+1, VD(n+1, 0)); // i枚目までで、表がj枚となる確率
	dp[0][0] = 1;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (dp[i][j] == 0) {
				continue;
			}

			dp[i+1][j+1] += dp[i][j] * p[i];
			dp[i+1][j]   += dp[i][j] * (1.0 - p[i]);
		}
	}

	double ans = 0;
	for (int i = n/2 + 1; i <= n; i++) {
		ans += dp[n][i];
	}
	printf("%.12f\n", ans);
	return 0;
}


Measured memory_bytes: 70656
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
diff_dist = B - A
diff_v = V - W
flag = False
if diff_v == 0:
    if diff_dist == 0:
        flag = True
elif diff_dist == 0:
    flag = True
else:
    if diff_v > 0:
        t = abs(diff_dist) / diff_v
        if t <= T:
            flag = True
if flag:
    print('YES')
else:
    print('NO')

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
int U, V;

vector<int> E[MAX_N];
int D[MAX_N];
int rD[MAX_N];
vector<int> DD[MAX_N];

int ans = 0;

bool reaf[MAX_N];
void calcD(int pos, int pre, int depth) {
  D[pos] = depth;
  bool flag = true;
  for(int next : E[pos]) {
    if(next == pre) continue;
    calcD(next, pos, depth+1);
    flag = false;
  }
  if(flag) {
    reaf[pos] = true;
  }
}

bool used[MAX_N];

void solve(int pos, int pre, int depth)
{
  used[pos] = true;
  for(int next : E[pos]) {
    if(next == pre) continue;
    if(D[next] > depth+1) {
      solve(next, pos, depth+1);
    }
  }
}

signed main()
{
  cin >> N >> U >> V;
  REP(n,N) {
    int a,b; cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }

  if(U == V) {
    cout << 0 << endl;
    return 0;
  }

  calcD(V, -1, 0);

  solve(U, -1, 0);

  int ans = 0;
  FOR(n,1,N+1) {
    if(used[n] && reaf[n]) {
      ans = max(ans, D[n]-1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13824
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long N,K,i,j,k,MOD,n,m;


int main()
{
cin>> N>>K;
MOD=1000000007;

n=(N+1)*(N+2)/2-K*(K-1)/2;
n%=MOD;
n*=N+1;
n%=MOD;

m=(N+1)*(N+2)*(2*N+3)/6-(K-1)*K*(2*K-1)/6;
m%=MOD;

n=n-m+N-K+2;
while(n<0)
{
n+=MOD;
}

n%=MOD;


cout <<n;



}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    a66(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a66(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val sortedPriceList = args[0].split(" ").map { it.toInt() }.sorted()
    println(sortedPriceList.take(2).sum())
}

Measured memory_bytes: 38180
n = (int, input())
MX = 10**18
a = list(map(int, input().split()))
for x in a:
  if x == 0:
    print(0)
    exit(0)
ans = 1
for x in a:
  ans *= x
  if ans > MX:
    print(-1)
    exit(0)
print(ans)

Measured memory_bytes: 21696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int count = 0;
    
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c; k++){
                if (500 * i + 100 * j + 50 * k == x){
                    count++;
                }
            }
        }
    }

    cout << count << endl;
}

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

int main(){
	int d, n, max = 0;
	long long sum = 0;
	cin >> d;
	for(int i = 0; i < d; ++i){
		cin >> n;
		sum += n;
		max = std::max(max, n);
	}
	sum -= max / 2;
	cout << sum << endl;
}

Measured memory_bytes: 256
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int a, b;
    readf("%s %s", &a, &b);
    readln;
    
    int k = (a + b) / 2;
    if (abs(a - k) != abs(b - k)) {
        writeln("IMPOSSIBLE");
        return;
    }
    
    k.writeln;
}

Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [0] * N
for i in range(N):
  T[i] = int(input())
T = sorted(T)
ans = 0
waiting = []
for t in T:
  if len(waiting) == C:
    ans += 1
    waiting = []
  if len(waiting) > 0 and t > waiting[0] + K:
    ans += 1
    waiting = []
  waiting.append(t)
else:
  ans += 1
print(ans)

Measured memory_bytes: 8240
#include <bits/stdc++.h> 
using namespace std;
const int N = 2e5 + 4;
long long tree[4*N];
long long h[N];
long long b[N];
long long dp[N];
 
void update(int node,int st,int en,int id,long long val)
{
    if(st>en || st>id || en<id) return ;
    if(st==en && st==id){
        tree[node]=max(tree[node],val);
        return ;
    }
    int mid=(st+en)/2;
    if(st<=id && id<=mid){
        update(2*node,st,mid,id,val);
    }
    else{
        update(2*node+1,mid+1,en,id,val);
    }	
    tree[node]=max(tree[2*node],tree[2*node+1]);
}
long long query(int node,int st,int en,int l,int r)
{
    if(st>r || en<l)
        return 0;
    if(l<=st && en<=r)
        return tree[node];
 
    int mid=(st+en)/2;
    return max(query(2*node,st,mid,l,r),query(2*node+1,mid+1,en,l,r));
}
int main(){
    int n;
    cin >> n;
    int i;
    for(i=1;i<=n;i++){
        cin>>h[i];
    }
    for(i=1;i<=n;i++){
        cin >> b[i];
    }
    dp[0]=0;
    for(i=1;i<=n;i++){
        long long tmp=query(1,1,n,1,h[i]-1);
        dp[h[i]]=tmp+b[i];
        update(1,1,n,h[i],dp[h[i]]);
    }
    long long ans=0;
    for(i=0;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
 
    cout<<ans;	
	return 0;
}  


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

int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> l(Q), r(Q);
    vector<int> acstart;
    for(size_t i = 0; i < Q; i++)
    {
        cin >> l[i] >> r[i];
    }
    int ret = 0;
    string::size_type pos = 0;
    while((pos = S.find("AC", pos)) != string::npos){
        ret++;
        acstart.push_back(pos);
        pos += 2;
    }

    for(size_t i = 0; i < Q; i++)
    {
        auto start = lower_bound(acstart.begin(), acstart.end(), l[i]-1);
        auto end = upper_bound(acstart.begin(), acstart.end(), r[i]-2);
        cout << end-start << endl;
    }
    return 0;
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n){
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    
    int res = 1 << 30;
    rep(i, n-k+1){
        res = min(h.at(k-1+i)-h.at(i), res);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
from numba import njit, i8


@njit((i8, i8, i8, i8), cache=True)
def floor_sum(n, m, a, b):
    ans = n*(b//m)
    b %= m
    while True:
        ans += (n-1)*n*(a//m)//2
        a %= m
        if a*n+b < m:
            return ans
        y_max = (a*n + b)//m
        b -= y_max*m  # now we have x_max = -(b//a)
        ans += (n + b//a)*y_max
        b %= a
        m, a, n = a, m, y_max


def main():
    t = int(sys.stdin.buffer.readline())
    ans = [0]*t
    for i, x in enumerate(sys.stdin.buffer.readlines()):
        n, m, a, b = map(int, x.split())
        ans[i] = floor_sum(n, m, a, b)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 112916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        int N = int.Parse(Console.ReadLine());

        //すべての数字のリスト
        var ansList = new List<int>();


        for (int i = 0; i < N; i++) {
            int s = int.Parse(Console.ReadLine());
            ansList.Add(s);
        }

        //ソートする
        ansList.Sort();

        for (int i = 0; i < N - 1; i++) {
            if (ansList[i] == ansList[i + 1]) {
                ansList[i] = 0;
                ansList[i + 1] = 0;
            }
        }

        ansList.RemoveAll(num => num == 0);

        //出力
        Console.WriteLine(ansList.Count);


    }
}

Measured memory_bytes: 16096
module Main (main) where

import Control.Applicative

solve :: Int -> Int -> Int -> Int
solve a b c = length $ factors a b c []

factors :: Int -> Int -> Int -> [Int] -> [Int]
factors a b c xs
  | a > b          = xs
  | c `mod` b == 0 = factors a (b - 1) c (b:xs)
  | otherwise      = factors a (b - 1) c xs

main :: IO ()
main = do
  [a, b, c] <- map read . words <$> getLine
  putStrLn $ show $ solve a b c

Measured memory_bytes: 4116
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,x;
	cin >> a >>b >>x;
	double f=a*a*b;
	double s;
	if(x<f/2) {
		s = atan(a*b*b/2/x) ;
		s= s*180.0/3.1415926;
		printf("%.10f\n",s) ;
	}else if(x>f/2){
		s = atan(2*(f-x)/(a*a*a)) ;
		s= s*180.0/3.1415926;
		//s=90-s;
		printf("%.10f\n",s) ;
	}else {
		cout <<"45.0000000000";
	}
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

const long long mod = 1000000007;

bool G[15][15];
int N;
int M;

void input(){
	scanf("%d%d", &N, &M);
	for(int i = 0; i < M; ++i){
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;
		G[x][y] = true;
	}
}

long long dp[1 << 15];

inline long long f(int n){
	return (1 << n) - 1;
}

inline int count(int v, int S){
	int res = 0;
	for(int i = 0; i < N; ++i){
		if((S >> i) & 1){
			if(G[v][i]) res++;
		}
	}
	return res;
}

bool check(int S){
	int x = (S & 1) ^ ((S & 2) >> 1);
	return x == 0;
}

long long solve(){
	dp[0] = 1;
	int mask = (1 << N) - 1;
	for(int S = 1; S < (1 << N); ++S){
		if(!check(S)) continue;
		for(int S2 = (S - 1) & S; ; S2 = (S2 - 1) & S){
			if(!check(S2)) continue;
			long long coe = 1;
			for(int v = 0; v < N; ++v){
				if((S >> v) & 1) continue;
				int cnt = count(v, S - S2);
				coe *= f(cnt);
				coe %= mod;
			}
			for(int v = 0; v < N; ++v){
				int x = S - S2;
				if((x >> v) & 1){
					int cnt = count(v, mask - S);
					coe *= (f(cnt) + 1);
					coe %= mod;
				}
			}
			dp[S] += dp[S2] * coe;
			dp[S] %= mod;
			if(S2 == 0) break;
		}
	}
	long long all = 1;
	for(int i = 0; i < M; ++i){
		all *= 2;
		all %= mod;
	}
	long long ans = all - dp[mask];
	ans %= mod;
	ans += mod;
	ans %= mod;
	return ans;
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
 
int main() {
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i<MAX; i++) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }
    
    // 2017likeかどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; i++) {
        if (i%2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }
    
    // 累積和
    vector<int> s(MAX, 0);
    for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];
    
    int Q;
    cin >> Q;
    for (int i = 0; i<Q; i++) {
        int l, r;
        cin >> l >> r;
        r++;
        
        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1792
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e7;

vector < int > adj[N];
int used[N], dp[N];

void dfs( int v ) {
    used[v] = 1;
    for ( auto u: adj[v] ) {
        if ( !used[u] ) {
            dfs( u );
        }
        dp[v] = max( dp[v], dp[u] + 1 );
    }
}

int32_t main() {
    speed;
    int n, m;
    cin >> n >> m;
    for ( int i = 0; i < m; i++ ) {
        int v, u;
        cin >> v >> u;
        adj[v].push_back(u);
    }
    for ( int i = 1; i <= n; i++ ) {
        if ( !used[i] ) {
            dfs( i );
        }
    }
    int mx = 0;
    for ( int i = 1; i <= n; ++i ) {
        mx = max( mx, dp[i] );
    }
    cout << mx;
}


Measured memory_bytes: 13344
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int dif(vector<string> s,vector<string> t){
	int n = s.size();
	int res = 0;
	rep(i, n)
	{
		rep(j,n){
			if(s[i][j] != t[i][j])
				res++;
		}
	}
	return res;
}

vector<string> r(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[j][n - i - 1] = s[i][j];
		}
	}
	return temp;
}
vector<string> l(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[n-j-1][i] = s[i][j];
		}
	}
	return temp;
}

int main(){
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 A,B,C;
	cin >> A>>B>>C;

	SINT32 ma;
	ma = max(A,max(B,C));
	SINT32 ans = ma-A+ma-B+ma-C;
	
	
	if ((ans % 2) == 0) {
		ans = ans /2;
	} else {
		ans = (ans / 2) + 2;
	}
	cout << ans << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
n,a,b=map(int, input().split())
 
def comb(n, r,MOD):
    p, q = 1, 1
    for i in range(r):
        p = p * (n-i) % MOD
        q = q * (i+1) % MOD
    return p * pow(q, MOD-2, MOD) % MOD

mod=10**9+7
    
A=comb(n,a,mod)
B=comb(n,b,mod)  
C=pow(2,n,mod)

if n==2:
    print(0)
else:
    print((C-1-A-B)%mod)

Measured memory_bytes: 38672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26812
N = int(input())
L = sorted(list(map(int, input().split())))[::-1]


def is_ok(i, x):
    return L[i] > x


def bisect(ng, ok, x):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, x):
            ok = mid
        else:
            ng = mid
    return ok


ans = 0
for i in range(N):
    for j in range(i + 1, N):
        k = bisect(N, j, L[i] - L[j])
        ans += k - j
print(ans)


Measured memory_bytes: 74548
K, N = [int(x) for x in input().split()]
list = [0]*N
list = [int(x) for x in input().split()]
list.append(K+list[0])

a = 0
for i in range(N):
    if a < (list[i+1] - list[i]):
        a = list[i+1] - list[i]
        b = i

print(K-a)

Measured memory_bytes: 78924
def counting_sort(array, maxval):
    m = maxval+100
    count = [0] * (m)
    for a in array:
        count[a] += 1
    i = 0
    for a in range(m):
        for c in range(count[a]):
            array[i] = a
            i += 1
    return array


N = int(input())
l = list(map(int, input().split()))
a = 0
li = counting_sort(l, N)
for a in range(N-1):
    print(li[a], end=" ")
print(li[N-1])



Measured memory_bytes: 224376
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n = int(input())
    a_s = [0] * n
    b_s = [0] * n
    for i in range(n):
        a, b = list(map(int, input().split()))
        a_s[i] = a
        b_s[i] = b
    a_s.sort()
    b_s.sort()
    #print('a_s') # debug
    #print(a_s) # debug
    #print('b_s') # debug
    #print(b_s) # debug
    if n % 2 == 0:
        mb2 = (b_s[n // 2 - 1] + b_s[n // 2])
        ma2 = (a_s[n // 2 - 1] + a_s[n // 2])
        #print('ma2, mb2') # debug
        #print(ma2, mb2) # debug
        ans = mb2 - ma2 + 1
    else:
        ans = b_s[n // 2] - a_s[n // 2] + 1
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 78644
#include <iostream>

using namespace std;

int main(){
  int L, R, d;
  cin >> L >> R >> d;
  
  int i;
  int count = 0;
  for(i=L; i<=R; i++){
    if(i%d == 0) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            //Problem Number A
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            if (A >= 13)
            {
                Console.WriteLine(B);
            }
            else if (A >= 6 && A <= 12)
            {
                Console.WriteLine(B / 2);
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

ll lcm(int a, int b) { return 1ll * a / gcd(a, b) * b; }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  bool ng = false;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int val = a[i];
    int tmp = 0;
    while (val % 2 == 0) {
      tmp++;
      val /= 2;
    }
    if (i != 0 && cnt != tmp) {
      ng = true;
    }
    cnt = tmp;
  }
  if (ng) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    a[i] /= 2;
  }
  ll l = 1;
  for (int i = 0; i < n; ++i) {
    l = lcm(l, a[i]);
  }
  ll ans = m / l;
  cout << ans / 2 + (ans % 2) << endl;
  return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
N = int(input())
v = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    v[a].append([b,i])

ans = [None] * (N-1)

def decide_colord(cur,color):
    cnt = 1
    for (to,j)in v[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        decide_colord(to,cnt)
        cnt += 1
decide_colord(0,0)
print(max(ans))
[print(a) for a in ans]

Measured memory_bytes: 70944
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	map<string, int> mp;
	string s;
	for(int i=0; i<n;i++)
	{
		cin>>s;
		mp[s]++;
	}
	int maxPos = 0;
	for(auto m : mp)
	{
		maxPos = max(m.second, maxPos);
	}
	set<string> st;
	for(auto m : mp)
	{
		if(m.second==maxPos)
		{
			st.insert(m.first);
		}
	}
	for(auto s : st)
	{
		cout<<s<<"\n";
	}
	return 0;
}

Measured memory_bytes: 34560
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int n;
    cin>>n;
    int ans=0;
    for (int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            
            int r=n;
            if(i!=1){
            while(r>=i&&r%i==0)r/=i;
            if(r==1||(r-1)%i==0)ans++;}
            if(i!=n/i&&n/i!=1)
            {
                int x=n/i;r=n;
                while(r>=x&&r%x==0)r/=x;
               if(r==1||(r-1)%x==0)ans++;
            }
            
        }
    }int n1=n;
    n--;
    for (int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            if(i!=1&&n1%i!=0)ans++;if(n/i!=i&&n/i!=1&&(n1%(n/i))!=0)ans++;
            
        }
    }

    cout<<ans<<endl;

}


return 0;
}





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

int main()
{
	while (1){

		char s[5];
		int i = 0, n, sum = 0;

		while (1){
			s[i] = getchar();
			if (s[i] == '\n')
				break;
			n = atoi(s);
			sum += n;
		}
		if (sum == 0)
			break;
		printf("%d\n", sum);
	}

	return(0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int ans[200010],v[200010];
int main(){
    int n,x;
    cin>>n>>x;
    if(x==1||x==n*2-1) return 0*puts("No");
    puts("Yes");
    int m=2*n-1;
    int a=(x-n+m)%m;
    for(int i=1;i<=2*n-1;i++){
        cout<<a%m+1<<" ";
        a++;
    }
    return 0;
}


Measured memory_bytes: 1536