akhauriyash/Code-Regression huggingface dataset:
//p156

#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define MAX 500000 //5*1e5
#define INF 2000000000 //2*1e9 //sentinel

int L[MAX],R[MAX];
int cnt; // number of comparisons

void merge(int A[],int n,int left,int mid,int right){

  int n1=mid-left;
  int n2=right-mid;

  rep(i,n1) L[i]=A[left+i];
  rep(i,n2) R[i]=A[mid+i];
  L[n1]=R[n2]=INF;

  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }  
  }

}

//[left,right)
void mergesort(int A[],int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n;
  cnt=0;
  cin>>n;
  rep(i,n)cin>>A[i];

  mergesort(A,n,0,n);

  rep(i,n){
    if(i)cout<<" ";
    cout<<A[i];
  }
  cout<<endl;

  cout<<cnt<<endl;
}

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

int main(){
  int n;cin>>n;
  vector<int>h(n);
  rep(i,n)
    cin>>h.at(i);
  int ans=1,hi=h.at(0);
  rep(i,n-1)
  {
    if(h.at(i+1)>=hi)
    {
      hi=h.at(i+1);
      ans++;
    }
  }
  cout<<ans;
}
    
    
    

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


main(){
	bool first = true;
	for(int a,b;cin>>a>>b,0<a&&0<b;){

		if(!first){
			puts("");
		}

		first = false;

		int cnt=0;
		for(int year=a; year<=b; ++year){
			if( year%400==0 || (year%100!=0&&year%4==0) ){
				cout<<year<<endl;
				cnt++;
			}
		}
		if(cnt==0){
			puts("NA");
		}
	}
}


Measured memory_bytes: 3072
n=int(input())
for i in range(n):
    a=list(map(int,input().split()))
    b,c=0,0
    yes = True
    for j in range(10):
        if a[j]>b:b=a[j]
        elif a[j]>c:c=a[j]
        else:yes=False
    print("YES" if yes else "NO")


Measured memory_bytes: 5592
S = input()
Q = int(input())

head = ''
back = ''
direction = 1

for i in range(Q):
    q = list(map(str, input().split())) 
    if q[0] == "1":
        direction *= (-1)
        #S = S[::-1]
    else:
        if q[1] == "1":
            if direction == 1:
                head = head + q[2]
            else:
                back = back + q[2]
        else:
            if direction == 1:
                back = back + q[2]
            else:
                head = head + q[2]

if direction == 1:
    print(head[::-1]+S+back)
else:
    print(back[::-1]+S[::-1]+head)

Measured memory_bytes: 4340
# https://atcoder.jp/contests/abc086/tasks/arc089_a
n = int(input())

pre_x, pre_y = 0, 0
pre = 0
trip = []
for _ in range(n):
    t, x, y = map(int, input().split())
    trip.append((t, x, y))
for t, x, y in trip:
    d = abs(x - pre_x) + abs(y - pre_y)
    if d <= (t - pre) and d % 2 == (t - pre) % 2:
        pre, pre_x, pre_y = t, x, y
        continue
    else:
        print('No')
        break
else:
    print('Yes')

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second


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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin>>n>>q;
    VV to(n);
    int a,b;

    rep(i,n-1){
        cin>>a>>b;
        a--,b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    Vec ci(n,0);
    int p,x;
    while(q--){
        cin>>p>>x;
        p--;
        ci[p] += x;
    }
    Vec ans(n,0);
    queue<Pi> que;
    Vec parents(n,-1);
    ans[0]=ci[0];
    que.push(mp(0,ci[0]));
    while (!que.empty()){
        Pi &pr = que.front();
        int &now = pr.fi;
        int &cnt = pr.se;
        que.pop();
        Each(v,to[now]){
            if(v==parents[now])continue;
            que.push(mp(v,cnt+ci[v]));
            ans[v]=cnt+ci[v];
            parents[v]=now;
        }
    }
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return  0;
}


Measured memory_bytes: 21104
<?php
fscanf(STDIN, '%d', $n);
$a = explode(' ', trim(fgets(STDIN)));

$evenNum = 0;
$approvedNum = 0;

foreach ($a as $value) {
    if ($value % 2 === 0) {
        $evenNum++;

        if ($value % 3 === 0 || $value % 5 === 0) {
            $approvedNum++;
        }
    }
}
if($evenNum == $approvedNum){
    echo "APPROVED";
} else {
    echo "DENIED";
}

Measured memory_bytes: 4728
def find(u)
	if $f[u] == u
		return u
	end
	$f[u] = find($f[u])
	return $f[u]
end

def unite(a, b)
	a = find(a)
	b = find(b)
	if (a != b)
		$f[a] = b
	end
end

def same(a, b)
	a = find(a)
	b = find(b)
	if a == b
		return 1
	else
		return 0
	end
end

n, m = gets.split
n = n.to_i
m = m.to_i
$f = Array.new
(0..n).each do |i|
	$f.push(i)
end
(1..m).each do
	k, a, b, = gets.split
	k = k.to_i
	a = a.to_i
	b = b.to_i
	if (k == 0)
		unite(a, b)
	else
		p same(a, b)
	end
end

Measured memory_bytes: 10040
#include <stdio.h>
#define N 45

int f[N];

void Fib(int n){
    int i;
    f[0]=1;
    f[1]=1;

    for(i=2;i<=n;i++) f[i]=f[i-2]+f[i-1];
}

int main(){
int n;

scanf("%d",&n);
Fib(n);
printf("%d\n",f[n]);

return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    int L[2*n];
    REP(i,2*n)cin>>L[i];
    sort(L,L+(2*n));
    REP(i,n){
        ans=ans+min(L[(i*2)],L[(i*2)+1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define MAX_COLUMN_SIZE 100

int main() {
  int row_size, column_size;
  int column_sum[MAX_COLUMN_SIZE] = {};

  scanf("%d %d%*c", &row_size, &column_size);

  for(int i = 0; i < row_size; i++) {
    int row_sum = 0;

    for(int j = 0; j < column_size; j++) {
      int sell;
      scanf("%d", &sell);
      printf("%d ", sell);

      row_sum += sell;
      column_sum[j] += sell;

      if(j == column_size - 1) {
        printf("%d", row_sum);
        printf("\n");
      }
    }
  }

  int row_sum = 0;
  for(int i = 0; i < column_size; i++) {

    printf("%d ", column_sum[i]);

    row_sum += column_sum[i];

    if(i == column_size - 1) {
      printf("%d", row_sum);
      printf("\n");
    }
  }
}



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

int main() {
  int n,m,e,j;
  while(cin>>n, n) {
    for(int i=0; i<n; ++i) {
      cin>>m>>e>>j;
      if(m == 100 || e == 100 || j == 100) cout<<'A'<<endl;
      else if((m+e)/2 >= 90) cout<<'A'<<endl;
      else if((m+e+j)/3 >= 80) cout<<'A'<<endl;
      else if((m+e+j)/3 >= 70) cout<<'B'<<endl;
      else if((m+e+j)/3 >= 50 && (m >= 80 || e >= 80)) cout<<'B'<<endl;
      else cout<<'C'<<endl;
    }
  }
}

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

using namespace std;

/*

    top down.

*/


const int MAXN = 100 + 5 , MAXW = 1e5 + 5;


int n , W;
long long w[MAXN] , v[MAXN];
long long mem[MAXN][MAXW];

long long dp(int i , int totalWeight){

    if(i == n) return 0;

    if(mem[i][totalWeight] != -1) return mem[i][totalWeight];

    long long x = dp(i + 1 , totalWeight);
    long long y = 0;

    if(totalWeight + w[i] <= W){
            y = v[i] + dp(i + 1 , totalWeight + w[i]);
    }

    mem[i][totalWeight] = max(x , y);
    return mem[i][totalWeight];

}

main(){

    scanf("%d %d" , &n , &W);

    for(int i = 0 ; i < n ; i ++){
            scanf("%lld %lld" , &w[i] , &v[i]);
    }

    memset(mem , -1 , sizeof mem);

    printf("%lld\n" , dp(0 , 0));

    return 0;
}

Measured memory_bytes: 82304
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn];
int main(){
	ll sum=1,flag=1;
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			flag=2;
		}
	}
	if(flag==2){
		cout<<0;
		return 0;
	}
	for(int i=0;i<n;i++){
		ll d=1000000000000000000/sum;
		if(a[i]>d){
			flag=0;
			break;
		}
		sum*=a[i];
	}
	if(flag){
		cout<<sum;
	}
	else
		cout<<"-1";
	return 0;	
}

Measured memory_bytes: 4404
h, w = map(int, input().split())
s = [input() for _ in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      check = []
      if i > 0:
        check.append(s[i-1][j])
      if i < h-1:
        check.append(s[i+1][j])
      if j > 0:
        check.append(s[i][j-1])
      if j < w-1:
        check.append(s[i][j+1])
        
      if not "#" in check:
        print("No")
        break
  else:
    continue
  break
else:
  print("Yes")

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

using namespace std;

int main()
{
  	int N;
  	cin >> N;
  	vector<int> A(N);
  	for(int i = 0; i < N; i++){
      	cin >> A.at(i);
    }
  	int ans = 0;
  	bool x = true;
 	for(; x; ){
  		for(int i = 0;i < N; i++){
      		if(A.at(i) % 2 != 0){
        	  x = false;	
        	  break;
       		}else{
              A.at(i) /= 2;
            }
  	    }
      	if(x){
     	 ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100050;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int n,a[N];
int check(ll s){
  for (int i=1; i<=n; ++i) s-=s%a[i];
  if (s==2) return 1;
  if (s<2) return 0;
  return 2;
}
int main(){
  cin>>n;
  for (int i=1; i<=n; ++i) a[i]=gi();
  ll l=2,r=1ll<<60,mid,ans=0;
  int t;
  while(l<=r){
    mid=(l+r)>>1,t=check(mid);
    if (t==0) l=mid+1;
    else if (t==1) ans=mid,r=mid-1;
    else r=mid-1;
  }
  if (ans==0) return puts("-1"),0;
  cout<<ans<<" ";
  l=1,r=1ll<<60;
  while(l<=r){
    mid=(l+r)>>1,t=check(mid);
    if (t==0) l=mid+1;
    else if (t==1) ans=mid,l=mid+1;
    else r=mid-1;
  }
  cout<<ans;
  return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n,k,ans=0,ans2=0;
    cin >> n >> k;
    if (k%2){
        for(ll i=1;i<=n;i++){
            if(i%k== 0)ans++;
        }
    }else{
        for (ll i=1;i<=n;i++){
            if (i%k==0)ans++;
            if (i%k==k/2)ans2++;
        }
    }
    cout << ans*ans*ans+ans2*ans2*ans2 << endl;
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NM = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            var graph = new List<int>[N].Select(x => new List<int>()).ToArray();
            for (var i = 0; i < M; i++)
            {
                var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                graph[a].Add(b);
                graph[b].Add(a);
            }
            var queue = new Queue<int>();
            queue.Enqueue(0);
            var depths = Enumerable.Repeat(N + 1, N).ToArray();
            depths[0] = 0;
            while (queue.Any())
            {
                var current = queue.Dequeue();
                foreach (var next in graph[current])
                {
                    if (depths[next] != N + 1) continue;
                    depths[next] = depths[current] + 1;
                    queue.Enqueue(next);
                }
            }
            Console.WriteLine(depths[N - 1] <= 2 ? "POSSIBLE" : "IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 64880
#include <bits/stdc++.h>
#define INF 1e9 + 7
using namespace std;

const int maxn = 2e5 + 10;
const double pi = acos(-1);
struct point {
    int x, y;
    point () {}
    point (int x, int y) : x(x), y(y) {}
    bool operator < (const point &p) const { return x < p.x; }
};

int n, xs, ys, xt, yt;
bool flag;
vector <int> f;

double calc(int s, int p, int q) {
    return 100.0 * s - (20.0 - 5.0 * pi) * p + (10.0 * pi - 20.0) * q;
}

int main() {
  //  freopen("input.in", "r", stdin);
 //   freopen("output.out", "w", stdout);

    scanf("%d%d%d%d", &xs, &ys, &xt, &yt);
    if (xs > xt) swap(xs, xt), swap(ys, yt);
    if (ys > yt) flag = 1, ys = INF - ys, yt = INF - yt;
    scanf("%d", &n);
    vector <point> a;
    for (int i = 1; i <= n; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        if (flag) y = INF - y;
        if (xs <= x && x <= xt && ys <= y && y <= yt)
            a.push_back(point(x, y));
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < (int) a.size(); ++i) {
        vector <int> :: iterator it = lower_bound(f.begin(), f.end(), a[i].y);
        if (it == f.end())
            f.push_back(a[i].y);
        else
            *it = a[i].y;
    }
    int half = (int) f.size() == min(xt - xs, yt - ys) + 1;
    printf("%.15f\n", calc(xt - xs + yt - ys, (int) f.size() - half, half));

    return 0;
}


Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC145D_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var XY = ReadInt();
            int X = XY[0];
            int Y = XY[1];

            bool canGo = true;
            if ((2 * X - Y) % 3 != 0 || (2 * X - Y) < 0) canGo = false;
            if ((2 * Y - X) % 3 != 0 || (2 * Y - X) < 0) canGo = false;

            if (canGo)
            {
                int mod = 1000000007;
                int a = (2 * X - Y) / 3;
                int b = (2 * Y - X) / 3;

                var ans = nCk(a + b, a, mod);
                Console.WriteLine(ans);
            }
            else Console.WriteLine(0);

            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
        /// <summary>
        /// a^n (mod p)
        /// nが非常に大きい時に有効
        /// </summary>
        /// <param name="a"></param>
        /// <param name="n"></param>
        /// <param name="mod"></param>
        /// <returns></returns>
        public static long ModPow(long a, long n, long p)
        {
            if (n == 0) return 1;
            if (n == 1) return a % p;
            if (n % 2 == 1) return (a * ModPow(a, n - 1, p)) % p;

            long t = ModPow(a, n / 2, p);
            return (t * t) % p;
        }

        /// <summary>
        /// 組み合わせ個数
        /// </summary>
        /// <param name="n"></param>
        /// <param name="k"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static long nCk(long n, long k, long p)
        {
            long ans = 1;
            k = Math.Min(k, n - k);
            for (long i = n; i > n - k; i--)
            {
                ans = (ans * i) % p;
            }

            for (long i = 1; i <= k; i++)
            {
                ans = (ans * ModPow(i, p - 2, p)) % p;
            }

            return ans;
        }

    }
}


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

int main(){
  int n;
  cin >> n;
  double x[n+1], a[n+1];
  for(int i = 1; i <= n; i++){
    cin >> x[i];
    a[i] = x[i];
  }
  sort(a+1, a+n+1);
  int mid1 = a[n/2], mid2 = a[(n/2)+1];
  double idx = (mid2 + mid1) / 2;
  for(int i = 1; i <= n; i++){
    if(x[i] > idx) cout << mid1 << endl;
    else cout << mid2 << endl;
  }
  return 0;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination(int, int);
};
int Combination::calculate(int n, int k) {
	return (memo[n].fact * (memo[k].fact_inv * memo[n - k].fact_inv) % m_module) % m_module;
}
Combination::Combination(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

void A_Strings(void) {

	string S, T;
	cin >> S >> T;
	cout << T << S << flush;
	return;
}

void B_Greedy_Takahashi(void) {

	long long A, B, K;
	cin >> A >> B >> K;

	if (K < A) {
		A -= K;
	}
	else if (K < A + B) {
		B -= (K - A);
		A = 0;
	}
	else {
		A = 0;
		B = 0;
	}
	cout << A << " " << B << flush;
	return;
}

void C_Next_Prime(void) {
	
	int X;
	cin >> X;

	for (int sample = X;; sample++) {
		for (int loop = 2; loop <= (int)pow(sample, 0.5); loop++) {
			if (sample % loop == 0) goto nextSample;
		}
		cout << sample << flush;
		return;
	nextSample:
		continue;
	}
}

int main(void) {

	//A_Strings();
	//B_Greedy_Takahashi();
	C_Next_Prime();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		
		System.out.println(color(N,K));
	}
	
	public static int color(int N, int K){
		int color = K;
		for (int i = 1; i < N; i++) {
			color *= (K-1);
		}
		return color;
	}
}

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

long a;
long b;
long c;
long d;
int main()
{
  
long long data[5];
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;

    data[0] = a * c;
    data[1]  = a * d;
    data[2]  = b * c;
    data[3]  = b * d;
    long long res = data[0];

    for (int i = 0; i < 4; i++) 
    {
      if (data[i] > res) {
        res = data[i]; 
      }
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 3616
import math

n, m = map(int, input().split())

if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 1:
    n_facto = math.factorial(n) % (10**9 + 7)
    m_facto = math.factorial(m) % (10**9 + 7)
    ans = (n_facto * m_facto) % (10**9 + 7)
else:
    n_facto = math.factorial(n) % (10**9 + 7)
    m_facto = math.factorial(m) % (10**9 + 7)
    ans = (n_facto * m_facto * 2) % (10**9 + 7)

print(ans)

Measured memory_bytes: 4088
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, K, ans=-INF;
	ll a[100005], sum[100005]={};

	cin >> N >> K;
	rep(i,N) cin >> a[i];
	rep(i,N) sum[i+1] = sum[i] + max(0ll, a[i]);

	ll s = 0;
	rep(i,N){
		if( i < K-1 ) s += a[i];
		else{
			s += a[i];
			ll l = sum[i-K+1];
			ll r = sum[N] - sum[i+1];
			//cout << "i=" << i << " : " << l << " " << s << " " << r << endl;
			chmax( ans, max(0ll,s) + l + r );
			s -= a[i-K+1];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

ll di(ll v) {
	int a = 0;
	while(v) {
		a++;
		v/=10;
	}
	return a;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		ll ans = INF;
		for(ll i=1;i*i<=N;i++) {
			if(N%i==0) {
				ll A = i, B = N/i;
				ll v = di(max(A, B));
				minUpdate(ans, v);
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 21;
int n;
int dp[21][(1 << 21)];
int a[N][N];
const int mod = 1e9 + 7;

int add(int a, int b)
{
  return (a + b) % mod;
}

int solve(int idx, int mask)
{
  if(idx == n)
    return 1;
  int &ans = dp[idx][mask];
  if(~ans)
    return ans;
  ans = 0;
  for(int i = 0; i < n; i++)
  {
    if(!(mask & (1 << i)) && a[idx][i])
      ans = add(ans, solve(idx + 1, mask | (1 << i)));
  }
  return ans;
}

int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      cin >> a[i][j];
  memset(dp, -1, sizeof dp);
  cout << solve(0, 0);
  return 0;
}


Measured memory_bytes: 172288
#pragma GCC optimize("O1")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	//cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	//cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007

using namespace std;

int dp_table(int wt[],int val[],int capacity,int tot_item) {
	/*
	
	1<=W<=10^9
	
	so we can't make dp table for weight due to it's large range
	instead we check for value we can reach within our capacity
	
	so dp table look like dp[tot_items][sum of value of all items]
	
	because maximum it can goes upto 10^5 and within our limit so we can make dp table
	
	*/
	
	int tot_val=0;
	for(int i=0;i<tot_item;i++) {
		tot_val += val[i];
	}
	
	ll dp[tot_item+1][tot_val+1];
	
	for(int i=0;i<=tot_item;i++) {
		dp[i][0] = 0;
	}
	
	for(int i=0;i<=tot_val;i++) {
		if(i == 0) {
			continue;
		}
		dp[0][i] = INT_MAX;
	}
	
	
	for(int i=1;i<=tot_item;i++) {
		for(int j=1;j<=tot_val;j++) {
			if(j<val[i-1]) {
				dp[i][j] = dp[i-1][j];
			}
			else {
				dp[i][j] = min(dp[i-1][j],wt[i-1]+dp[i-1][j-val[i-1]]);
			}
		}
	}
	
	
	for(int i=tot_val;i>=0;i--) {
		if(dp[tot_item][i] <= capacity) {
			return i;
		}
	}
	
}

void input() {
	int tot_item,capacity;
	cin>>tot_item>>capacity;
	
	int wt[tot_item],val[tot_item];
	for(int i=0;i<tot_item;i++) {
		cin>>wt[i]>>val[i];
	}
	
	int ans = dp_table(wt,val,capacity,tot_item);
	
	cout<<ans;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	input();
	
	return 0;
}


Measured memory_bytes: 82436
s = str(input())

if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)

Measured memory_bytes: 2940
#!/usr/bin/env python3

t_hp, t_ap, a_hp, a_ap = map(int, input().split())
while True:
    if a_hp <= t_ap:
        print('Yes')
        break
    if t_hp <= a_ap:
        print('No')
        break

    a_hp -= t_ap
    t_hp -= a_ap

Measured memory_bytes: 9164
input = raw_input().split(" ")
input = map(int, input)

w = input[0]
h = input[1]
x = input[2]
y = input[3]
r = input[4]

if w < (x + r) or (x - r) < 0 or (y + r) > h or (y - r) < 0:
  print "No"
else:
  print "Yes"

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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '
#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll n,k,ans=1;
vector<ll>adj[MAXN];
void dfs(ll v,ll g,ll num){
    ans = ans*num %MOD;
    //if(num==0)return cout<<0<<endl,0;
    num=k-1;
    if(g!=-1)num--;
    for(auto u: adj[v]){
        if(u==g)continue;
        dfs(u,v,num);
        num--;
    }
}
int main()
{
    fast_io;
    cin>>n>>k;
    for(ll i=1;i<n;i++){
        ll uu,vv;
        cin>>uu>>vv;
        adj[uu].push_back(vv);
        adj[vv].push_back(uu);
    }
    dfs(1,-1,k);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 30336
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;cin>>a>>b>>c;
  ll num = c-a-b;
  if(num <= 0){
    cout<<"No"<<endl;
    return 0;
  }
  if(num*num > 4*a*b){
    cout<<"Yes"<<endl;
  }else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
/* Code by : Suraj (@suraj1611) */

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

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout<<endl;
#define endl "\n"
#define F first
#define S second
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll a[1001][1001];
ll dp[1001][1001];
ll n,m;

ll solve(ll i,ll j)
{
	if(a[i][j])
		return dp[i][j]=0;
	else
	{
		//if((i==n-1 and j==m-2) or (i==n-2 and j==m-1))
		if(i==n-1 and j==m-1) 
			return dp[i][j]=1;
		else
		{
			if(dp[i][j]!=-1)
				return dp[i][j];
			else
			{
				ll right = (i+1)<n? solve(i+1,j):0;
				ll down = (j+1)<m? solve(i,j+1):0;
				return dp[i][j]=(right%md + down%md)%md;
			}
		}
	}
}


int main()
{
	IOS
	


	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	rep(i,n)
	{
		string s;
		cin>>s;
		rep(j,m)
		{
			char c=s[j];
			if(c=='.')
				a[i][j]=0;
			else
				a[i][j]=1;
		}
	}
	cout<<solve(0,0)<<endl;




    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

void go(int len, int c, const string &str) {
	if (sz(str) == len) {
		cout << str << endl;
		return;
	}

	for (int i = 0; i < c; ++i)
		go(len, max(i + 2, c), str + char('a' + i));
}
int main() {
	fastio;
	int N;
	cin >> N;

	go(N, 2, "a");

	return 0;
}

Measured memory_bytes: 1536
import heapq

N,M=map(int,input().split())
A=list(map(lambda x:-int(x),input().split()))

heapq.heapify(A)

# print(A) #DB

for i in range(M):
    x=heapq.heappop(A)
    heapq.heappush(A,(x+1)//2)
    # print(A) #DB

ans=-sum(A)

print(ans)

Measured memory_bytes: 72216
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    edges <- VU.replicateM (n-1) $ do
        [a,b] <- getIntList
        return (a-1, b-1)
    let tree :: V.Vector [(Int,Int)]
        tree = V.create $ do
            t <- VM.replicate n []
            flip VU.imapM_ edges $ \i (a,b) -> do
                VM.modify t ((i,b) :) a
                VM.modify t ((i,a) :) b
            return t
    let colors :: VU.Vector Int
        colors = VU.create $ do
            color <- VUM.new (n-1)
            let dfs pv pc v = do
                    forM_ (zip (filter (/= pv) (tree V.! v)) (filter (/= pc) [1..])) $ \((i,a),c) -> do
                        VUM.write color i c
                        dfs (i,v) c a
            dfs (-1,-1) 0 0
            return color
    print $ VU.maximum colors
    VU.forM_ colors print

Measured memory_bytes: 28004
#include <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <vector>
#define rep(i,n) for(int i=0; i< int(n); i++)
using namespace std;


int main(){
	int n;
	cin >> n;
	int t = n;
	int sum = 0;
	while(t>0){
		sum += t%10;
		t /= 10;
	}
	if(n%sum==0) cout << "Yes" << endl;
	else cout << "No" << endl;


} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

const int MOD = 1e9+7;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll sum = 0;
  rep(i, n)
    sum = (sum+a[i])%MOD;
  ll ans = 0;
  rep(i, n-1) {
    sum = (sum-a[i]+MOD)%MOD;
    ans = (ans+a[i]*sum)%MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4756
N, M = map(int, input().split(" "))
keylist = [1, N]

for i in range(M):
    l, r = map(int, input().split(" "))
    if keylist[0] < l:
        keylist[0] = l
    if keylist[1] > r:
        keylist[1] = r

ans = keylist[1] - keylist[0] + 1

if ans < 1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

void swap(int *a,int *b);

int main(void)
{
    int x=0,y=0,z=0;

    scanf("%d %d %d",&x,&y,&z);
    swap(&x,&y);
    swap(&x,&z);

    printf("%d %d %d",x,y,z);
    return 0;
}

void swap(int *a,int *b){
    int temp=0;
    temp=*a;
    *a=*b;
    *b=temp;
}


Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	vector<LL> a(n), b(n);
	inc(i, n) { cin >> a[i] >> b[i]; }
	sort(ALL(a));
	sort(ALL(b));
	if(n % 2 == 1) { OUT(b[n / 2] - a[n / 2] + 1); }
	if(n % 2 == 0) {
		LL A = a[n / 2] + a[n / 2 - 1];
		LL B = b[n / 2] + b[n / 2 - 1];
		OUT(B - A + 1);
	}
}


Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <cmath>

using namespace std;

const long mod = 2019;

int main() {
	long n;
	cin >> n;
	vector<long> a(n);
	vector<long> x(n);

	x[0] = 0;

	for(long i=0; i<n; i++) {
		cin >> a[i];
		//a[i]*=2;
		if (i%2==0){
			x[0] += a[i];
		} else {
			x[0] -= a[i];
		}
	}

	cout << x[0] << " ";
	for(long i=1; i<n; i++) {
		x[i] = a[i-1]*2 - x[i-1];
		cout << x[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2944
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] h=new int[n];
		h[0]=1;
		long ans=1;
		for(int i=0;i<n;i++){
			if(((s[i]^n)&1)==1&&h[s[i]]!=2){h[s[i]]++;}
			else{ans=0;break;}
		}
		if(ans==1){
			for(int i=0;i<n/2;i++){ans=(ans+ans)%1000000007;}
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 18912
/*#include <bits/stdc++.h>
using namespace std;
int n;
vector<int>v[100009];
int leaves[100009];
int dp[100009][3];
void dfs(int node,int p){
	if(v[node].size()==1) leaves[node]=1;
	if(node!=p){
		dp[node][0]=dp[p][0]+dp[p][1];
		dp[node][1]=dp[p][0];
	}
	for(int i=0;i<v[node].size();i++){
		int u=v[node][i];
		if(u==p) continue;
		dfs(u,node);
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dp[0][0]=1;
	dp[0][1]=1;
	dfs(0,0);
	for(int i=0;i<n;i++){
		if(leaves[i]==0) continue;
		cout<<i+1<<" "<<dp[i][0]<<" "<<dp[i][1]<<endl;
	}
}*/
#include<bits/stdc++.h>
using namespace std;
long long n,arr[100009],dp[100009], k;
long long bt(int id)
{
    long long &ret=dp[id];
    if(ret!=1000000009)return ret;
    if(id+1 < n){
        ret = 10000000009;
        for(int i=1;i<=k;i++)
        {
            if(id+i < n) ret = min(ret,bt(id+i)+abs(arr[id]-arr[id+i]));
        }
		return ret;
    }
    else return 0;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<100009;i++)
    {
        dp[i]=1000000009;
    }
    cout<<bt(0)<<endl;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;

  if (
    S == "KIHBR" or
    S == "AKIHBR" or
    S == "KIHABR" or
    S == "AKIHABR" or
    S == "KIHBAR" or
    S == "AKIHBAR" or
    S == "KIHABAR" or
    S == "AKIHABAR" or
    S == "KIHBRA" or
    S == "AKIHBRA" or
    S == "KIHABRA" or
    S == "AKIHABRA" or
    S == "KIHBARA" or
    S == "AKIHBARA" or
    S == "KIHABARA" or
    S == "AKIHABARA"
  ) cout << "YES" << endl;
  else cout << "NO" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;


int main() {
	
	int n;
	cin >> n;
	ll y;
	cin >> y;
	int ans[3] = {-1, -1, -1};
	
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (10000 * i + 5000 * j + 1000 * (n - i - j) == y && n-i-j>=0) {
				ans[0] = i; ans[1] = j; ans[2] = n - i - j;
			}
		}
	}

	cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;

	return 0;
}

Measured memory_bytes: 256
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
void solve(){
	int a, b;
	cin >> a >> b;
	if(a > b){
		for(int i = 0; i < a; i++)
			cout << b;
	}else if(a < b){
		for(int i = 0; i < b; i++)
			cout << a;
	}else{
		for(int i = 0; i < a; i++){
			cout << a ;
		}
	}
	
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int h, n; cin >> h >> n;
    vector<int> a(n);
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) h-=a[i];
    if(h<=0) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li h, w, n;
PI pos[200200];
set<PI> obj;

int main() {
    cin >> h >> w >> n;
    rin{
        cin >> pos[i].F >> pos[i].S;
        obj.insert(pos[i]);
    }
    sort(pos, pos + n);

    li low = 1;
    li high = 1;

    li now_obj = 0;
    while (now_obj < n && pos[now_obj].F == 1) {now_obj++;}
    //dump2(pos, n);

    repp(i, 1, h) {
        //p3(i, low, high);
        while (now_obj < n && pos[now_obj].F <= i + 1) {
            if (pos[now_obj].F == i + 1 && low <= pos[now_obj].S && pos[now_obj].S <= high) {
                cout << i << endl;
                return 0;
            }
            now_obj++;
        }
        if (high < w && obj.find({i + 1, high + 1}) == obj.end()) {
            high++;
        }
    }
    cout << h << endl;

    return 0;
}

Measured memory_bytes: 15872