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

using namespace std;

typedef long long   ll;
typedef pair< ll, ll >    pii;
vector< pii > vw;

const ll mod = ll(1e9 + 7LL);
const int N = int(1e5), K = 110;
ll dp[N][K];
ll pref[N];
ll id[N];

ll binary_search(ll v1, ll n, ll i){
    ll lo = i, hi = n;
    ll r = i;

    while(lo <= hi){
        ll mid = (lo + hi) >> 1LL;

        if((n / mid) != v1){
            hi = mid - 1LL;
        }else{
            r = mid;
            lo = mid + 1LL;
        }
    }

    return r;
}

ll sum(int i, int k){
    if(i < 0){
        return 0LL;
    }

    return dp[i][k];
}

int binary_search1(int idx, ll n){
    int lo = 0, hi = int(vw.size() - 1);
    int r = 0;
    ll tt = vw[idx].first;

    while(lo <= hi){
        int mid = (lo + hi) >> 1;
        ll val = id[mid];
        if(val > tt){
            hi = mid - 1;
        }else{
            r = mid;
            lo = mid + 1;
        }

        
     //   printf("val = %lld %lld %d\n", val, tt, r);
    }
   // printf("returning %d\n", r);

    return r;
}

int main(){
    int k;
    ll n;

    scanf("%lld %d", &n, &k);

    ll i = 1;

    while(i <= n){
        ll idx = binary_search(n / i, n, i);

        id[vw.size()] = i;
        vw.push_back({n / i, idx - i + 1LL});

        i = idx + 1LL;
    }

    for(int i = 0 ; i < vw.size() ; i++){
        pref[i] = vw[i].second;

        if(i){
            pref[i] += pref[i - 1];
            pref[i] %= mod;
        }
    }

  //  printf("%lu\n", vw.size());

    for(int i = 0 ; i < vw.size() ; i++){
        dp[i][1] = (sum(i - 1, 1) + vw[i].second) % mod;
    }

    for(int t = 2 ; t <= k ; t++){
        for(int i = 0 ; i < vw.size() ; i++){
            int idx = binary_search1(i, n);
         //   printf("recebi %d\n", idx);
         //   printf("%d %lld %d %lld\n", i, vw[i].first, idx, vw[idx].first);

            dp[i][t] = (vw[i].second * dp[idx][t - 1] + sum(i - 1, t)) % mod;
        }
    }

    printf("%lld\n", dp[int(vw.size()) - 1][k]);

    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    for (int i = 0; i < M; i++) cin >> X[i];
    
    sort(X.begin(), X.end());

    vector<int> sub(M - 1);
    for (int i = 0; i + 1 < M; i++) sub[i] = X[i + 1] - X[i];

    sort(sub.begin(), sub.end(), greater<int>());

    long long ans = 0;
    for (int i = N - 1; i < M - 1; i++) ans += sub[i];

    cout << ans << endl;
}

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

using namespace std;

typedef long long llint;
typedef pair<llint, llint> P;

llint v[101010];

int main() {
  llint n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    llint a, b;
    cin >> a >> b;
    v[a] += b;
  }
  for (int i = 0; i < 101010; i++) {
    if (k <= v[i]) {
      cout << i << endl;
      break;
    }
    k -= v[i];
  }

  return 0;
}

Measured memory_bytes: 1024
def parse i
  ret = []
  while i > 1
    if i % 2 == 1
      i -= 1
      i /= 2
      ret << 1
    else
      i -= 1
      ret << 0
    end
  end
  ret << 0
  return ret.reverse
end
def make arr
  s10 = []
  s11 = []
  s2 = []
  arr.each_with_index do |a, i|
    _i = i + 1
    s2 << _i
    if a == 1
      s11 << _i
    else
      s10 << _i
    end
  end
  _a = s10.reverse + s11 + s2
  puts _a.length
  puts _a*' '
end
make parse gets.to_i


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int a[4][3][10] = {0};

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }
    rep(i,4){
        rep(j,3){
            rep(k,10){
                cout << ' ' << a[i][j][k];
            }
            cout << endl;
        }
        if(i!=3) cout << "####################" << endl;
    }
}


Measured memory_bytes: 3068
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2*N-1], dneg[2*N-1], X[N][N];

void initialize(void);
void putQueen(int);
void printBoard(void);

int main()
{
  int i, j, k, r, c;

  initialize();
  
   for(i = 0; i < N; i++)
    {
      for(j = 0; j < N; j++)
	{
	  X[i][j] = -1;
	}
    }

  scanf("%d",&k);

  for(i = 0; i < k; i++)
    {
      scanf("%d %d",&r,&c);
      X[r][c] = 1;
    }

  putQueen(0);
  
  return 0;
}

void initialize(void)
{
  int i;
  
  for(i = 0; i < N; i++)
    {
      row[i] = FREE;
      col[i] = FREE;
    }
  for(i = 0; i < 2*N-1; i++)
    {
      dpos[i] = FREE;
      dneg[i] = FREE;
    }
}

void putQueen(int i)
{
  int j;
  
  if( i == N )
    {
      printBoard();
      return;
    }

  for(j = 0; j < N; j++)
    {
      if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE)continue;

      row[i] = j;
      col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
      putQueen(i+1);
      col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }
}

void printBoard(void)
{
  int i, j;
  for(i = 0; i < N; i++)
    {
      for(j = 0; j < N; j++)
	{
	  if(X[i][j] == 1)
	    {
	      if(row[i] != j)return;
	    }
	}
    }

  for(i = 0; i < N; i++)
    {
      for(j = 0; j < N; j++)
	{
	  if(row[i] == j)printf("Q");
	  else printf(".");
	}
      printf("\n");
    }
}



Measured memory_bytes: 2112
#include<iostream>
#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int;  
using namespace std;

int main(){
  int n;
  cpp_int k;
  long long int arr[2000001] = {0};
  cin>>n>>k;
  for(int i=1;i<=n;i++){
	cin>>arr[i];
  }
  long long int arr2[2000001] = {0};
  arr2[1] = 0;
  long long int x = arr[1];
  long long int steps = 1;
  
  while(arr2[x]==0 && steps<k){
    arr2[x] = steps;
    steps++;
    x = arr[int(x)];
    
  }
  if(steps<k){
    cpp_int cycle = steps - arr2[x];
    k = k- steps;
    k = k% cycle;

    while(k--){
      x = arr[x];
    }
    cout<<x<<endl;
  }
  else {
    cout<<x<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 34908
import java.util.*;

public class Main {
    public static int n;
    public static ArrayList<Integer>[] map;
    public static ArrayList<Integer> way;
    public static boolean[] check;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        map = new ArrayList[n];
        way = new ArrayList<Integer>();
        check = new boolean[n];
        for(int i=0; i<n; i++){
            map[i] = new ArrayList<Integer>();
        }
        for(int i=0; i<n-1; i++){
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            map[a].add(b);
            map[b].add(a);
        }
        sc.close();

        bfs(n-1);
        way.add(n-1);


        int[] num = new int[n];
        Arrays.fill(check, false);
        for(int i=0; i<way.size(); i++){
            check[way.get(i)] = true;
        }
        for(int i=0; i<way.size(); i++){
            num[way.get(i)] = count(way.get(i));
        }
        int black = 0;
        for(int i=0; i<way.size()/2 + way.size()%2; i++){
            black += num[way.get(i)];
        }
        
        if(black <= n - black){
            System.out.println("Snuke");
        }else{
            System.out.println("Fennec");
        }
    }

    public static boolean bfs(int pos){
        if(pos == 0) return true;
        check[pos] = true;
        boolean ans = false;
        for(int i=0; i<map[pos].size(); i++){
            int next = map[pos].get(i);
            if(!check[next]){
                if(bfs(next)){
                    ans = true;
                    way.add(next);
                    break;
                }
            }
        }
        return ans;
    }

    public static int count(int pos){
        int ans = 1;
        check[pos] = true;
        for(int i=0; i<map[pos].size(); i++){
            int next = map[pos].get(i);
            if(!check[next]){
                ans += count(next);
            }
        }
        return ans;
    }
}

Measured memory_bytes: 112916
N = int(input())
A = list(map(int,input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

gcd_a = A[0]

for i in A:
    gcd_a = gcd(gcd_a,i)

print(gcd_a)

Measured memory_bytes: 15020
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;

int main(){
  int n,i,j;
  while(cin >> n) {
    if(n==1){
      cout << 0 <<endl;
      continue;
    }
    int k = 0, a[n];
    a[0] = 2;
  
    for (i = 3; i <= n; i = i + 2) {
      for (j = 0; j <= k; j++) {
        if(i % a[j] == 0 ) break;
        if(i <= a[j] * a[j]) {
          k++;
          a[k] =i;
          break;
        }
        
      }
      if(j == k + 1) {
        k++;
        a[k] = i;
      }
    }
    cout << k+1 << endl;
  }
  
  return 0;
}

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


int mem[100];
int main()
{
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	{
		char c = s[i];
		if(c >= '0' && c <= '9')
			mem[c - '0']++;
		if(c >= 'a' && c <= 'z')
			mem[c - 'a' + 20]++;
	}
	int ans = 0;
	bool updated = true;
	while(updated)
	{
		updated = false;
		for(int i = 0; i < 100; i++)
		{
			int ii = i;
			while(mem[i] > 0)
			{
				updated = true;
				mem[i++]--;
			}
			ans += min(3, i - ii);
		}
	}
	cout << ans << endl;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int mn = 1000, mx = -1;
	for (int i = 0; i < 3; i++) {
		int a; cin >> a;
		mx = max(mx, a); mn = min(mn, a);
	}
	cout << mx - mn << '\n';
	return 0;
}

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

int main(){
  int m,f,r;
  cin >> m >> f >> r;
  while(m!=-1||f!=-1||r!=-1){
    if(m==-1||f==-1) cout << "F" << endl;
    else if(m+f>=80) cout << "A" << endl;
    else if(m+f>=65) cout << "B" << endl;
    else if(m+f>=50) cout << "C" << endl;
    else if(m+f>=30)
      if(r>=50) cout << "C" << endl;
      else cout << "D" << endl;
    else cout << "F" << endl;

    cin >> m >> f >> r;
  }
  return 0;
}



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

const int INF = 1e9+7;

int dfs(int i, int n, int m, int x, vector<vec> a, vec c, bool f, vec s, int t) {
  if (i == n) {
    bool f1 = true;
    rep(j,m) {
      if (s[j] < x) {
        f1 = false;
        break;
      }
    }
    if (f1) {
      return t;
    }
    return INF;
  }

  if (f) {
    rep(j,m) {
      s[j] += a[i][j];
    }
    t += c[i];
  }
  return min(dfs(i+1,n,m,x,a,c,true,s,t), dfs(i+1,n,m,x,a,c,false,s,t));
}

int main() {
  int n, m, x; cin >> n >> m >> x;
  vec c(n);
  vector<vec> a(n, vec(m));
  rep(i,n) {
    cin >> c[i];
    rep(j,m) {
      cin >> a[i][j];
    }
  }

  vec s(m, 0); // スキルの合計
  int t = 0; // 値段の合計

  int ans = min(dfs(0,n,m,x,a,c,true,s,t), dfs(0,n,m,x,a,c,false,s,t));
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 3664
n = int(input())
ts = list(map(int, input().split()))
xs = list(map(int, input().split()))

ts = [0] + ts + [ts[-1]]
xs = [xs[0]] + xs + [0]

if n == 1:
    if xs[1] == ts[1]:
        print(1)
    else:
        print(0)
else:
    m = 10**9 + 7
    a = 1
    for i in range(1, n+1):
        if ts[i-1]==ts[i] and xs[i]==xs[i+1]:
            a = a*min(ts[i], xs[i]) % m
        else:
            if ts[i-1]<ts[i] and xs[i]>xs[i+1]:
                if ts[i]!=xs[i]:
                    a = 0
            elif ts[i-1]<ts[i]:
                if xs[i]<ts[i]:
                    a = 0
            else:
                if ts[i]<xs[i]:
                    a = 0
    print(a)

Measured memory_bytes: 19052
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int main() {
	int c1,c2,c3,my, count=0;
	map<int, bool> card;
	while(cin>>c1>>c2>>c3){
		for(int i=1; i<=10; i++) card[i] = false;
		card[c1] = true;
		card[c2] = true;
		card[c3] = true;
		my = c1 + c2;
		for(int i=1; i<=10; i++){
			if(card[i] == false){
				if(my+i <= 20){
					count++;
				}
			}
		}
		if(count>=4){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    int n{},a,c;
    while((c=getchar_unlocked()-'0')>=0) n*=10,n+=c;
    unordered_set<int> mp;
    fr(i,n){
        a=0;
        while((c=getchar_unlocked()-'0')>=0) a*=10,a+=c;
        if(mp.count(a)){
            putchar_unlocked('N');
            putchar_unlocked('O');
            putchar_unlocked('\n');
            return 0;
        }
        mp.insert(a);
    }
    putchar_unlocked('Y');
    putchar_unlocked('E');
    putchar_unlocked('S');
    putchar_unlocked('\n');
}

Measured memory_bytes: 8520
//cao 看不到wa的那组数据  鬼知道被什么卡了。
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> >
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const ll INF = 1e18 + 0;
const ll mod = 1e9 + 7;
//const int mod = 998244353;

ll mul(ll a, ll b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    ll n,k;
    cin>>n>>k;
    ll K=k;
    vector<ll>pos,neg,zero;
    for(ll i=0;i<n;i++){
        ll d;
        cin>>d;
        if(d>0)pos.push_back(d);
        else if(d<0)neg.push_back(abs(d));
        else zero.push_back(d);
    }
    sort(pos.begin(),pos.end(),greater<ll>());sort(neg.begin(),neg.end(),greater<ll>());
    ll ans=1;
    ll pcur=0,ncur=0;
    if(k%2){
        if(pos.size()){
            ans=mul(ans,pos[pcur]);
            pcur++;
            k--;
        }
    }
    while(k && (pcur+1<(ll)pos.size() || ncur+1<(ll)neg.size())){
        ll val1=-INF,val2=-INF;
        if(pcur+1<(ll)pos.size()){
            val1=pos[pcur] * pos[pcur+1];
        }
        if(ncur+1<(ll)neg.size()){
            val2=neg[ncur] * neg[ncur+1];
        }
        if(val1>val2){
            ans=mul(ans,val1);
            pcur+=2;
        }
        else{
            ans=mul(ans,val2);
            ncur+=2;
        }
        k-=2;
    }
    if(k){
        if(!zero.empty()){
            ans=0;
            cout<<ans<<endl;
            return;
        }
        ans=1;
        vector<pair<ll,ll>>v;
        for(auto i:pos)v.push_back({i,1});
        for(auto i:neg)v.push_back({i,-1});
        for(auto i:zero)v.push_back({i,1});
        sort(v.begin(),v.end());
        for(ll i=0;i<K;i++){
            ans=mul(ans,v[i].first * v[i].second);
        }
    }
    cout<<ans<<endl;
    return;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}

Measured memory_bytes: 8928
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(6);
    double pi=3.141592653589793238462643;
    double r;cin>>r;
    cout<<2*r*pi<<endl;
    return 0;
}


Measured memory_bytes: 3788
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
if a== b :
    print("Yes")
else:
    print("No")


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

typedef pair<int, int> P;

bool custom(P a, P b) {
  return (a.second < b.second);
}
int main() {
  int n;
  cin >> n;

  vector<P> jobs(n);
  for(int i=0;i<n;i++) cin >> jobs[i].first >> jobs[i].second;

  sort(jobs.begin(), jobs.end(), custom);

  int time = 0;

  bool yes = true;

  for(int i=0;i<n;i++) {
    time += jobs[i].first;
    if(time > jobs[i].second) {
      yes = false;
      break;
    }
  }

  if(yes) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<algorithm>
using namespace std;
char str1[10];
char str2[10];

int main(){
	int a,b,c,d,e;
	while(scanf("%d%d%d%s%s%d%d",&a,&b,&c,str1,str2,&d,&e),a){
		int f,g;
		if(str1[0]=='A')f=-1;
		if(str1[0]=='M')f=1;
		if(str1[0]=='T'&&str1[1]=='u')f=2;
		if(str1[0]=='W')f=3;
		if(str1[0]=='T'&&str1[1]=='h')f=4;
		if(str1[0]=='F')f=5;
		if(str1[0]=='S'&&str1[1]=='a')f=6;
		if(str1[0]=='S'&&str1[1]=='u')f=0;
		if(str2[0]=='A')g=-1;
		if(str2[0]=='D')g=0;
		if(str2[0]=='N')g=1;
		int mod=7*1440;
		double p=1.0;
		double miss=1.0;
		for(int i=0;i<b;i++)miss*=(double)(d-1)/d;
		int t=0;
		for(int i=0;i<7*1440;i++){
			double val=1;
			int q=0;
			int now=i;
			int NOW=i+a;
			int SS=(now+NOW)/2;
			for(int j=0;j<e;j++){
				if((f==-1||(now%mod)/1440==f)&&(g==-1||(360<=(now%mod)%1440&&(now%mod)%1440<1080&&g==0)||((360>(now%mod)%1440||(now%mod)%1440>=1080)&&g==1))
				&&(f==-1||(NOW%mod)/1440==f)&&(g==-1||(360<=(NOW%mod)%1440&&(NOW%mod)%1440<1080&&g==0)||((360>(NOW%mod)%1440||(NOW%mod)%1440>=1080)&&g==1))
				&&(f==-1||(SS%mod)/1440==f)&&(g==-1||(360<=(SS%mod)%1440&&(SS%mod)%1440<1080&&g==0)||((360>(SS%mod)%1440||(SS%mod)%1440>=1080)&&g==1))){val*=miss;q++;}
				now+=c;
				NOW+=c;
				SS+=c;
			}
			p=min(p,val);
			//if(q==97)printf("%d\n",i);
			t=max(t,q);
		}
		//printf("%d\n",t);
		printf("%.9f\n",1.0-p);
	}
}

Measured memory_bytes: 1068
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int k;
    int a[40] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cin >> k;

    cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <string>
#include <cstring>
#include <algorithm>
typedef long long ll;
using namespace std;

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

    string num;
    cin >> num;
    bool flag=false;
    for (char c : num) {
        if (c=='7') flag=true;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";

}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  ll res=0;
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    if(A[i]+i<N)ans[A[i]+i]++;
    if(i-A[i]>=0)res+=ans[i-A[i]];
  }
  cout<<res<<endl;
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

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

  string s;
  cin >> s;

  if(p == 2 || p == 5) {
    ll res = 0;
    for(int i = n - 1; i >= 0; i--) {
      int t = s[i] - '0';
      if(t % p == 0) {
        res += i + 1;
      }
    }
    cout << res << endl;
    return 0;
  }

  vector<int> v(n+1, 0);
  int d = 1;
  for(int i = n - 1; i >= 0; i--) {
    int t = s[i] - '0';
    int m = (t * d) % p;
    v[i] = (v[i + 1] + m) % p;
    d = (10 * d) % p;
  }

  vector<int> cnt(p, 0);
  ll res = 0;
  for(int i = n; i >= 0; i--) {
    res += cnt[v[i]];
    cnt[v[i]] += 1;
  }
  cout << res << endl;
  return 0;
}


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

int bingo[8][3]={
    {1,2,3},{4,5,6},{7,8,9},
    {1,4,7},{2,5,8},{3,6,9},
    {1,5,9},{3,5,7}
};
int main() {
  int a[9] = {0};
  for(int i = 0;i < 3;i++){
      cin >> a[3*i] >> a[3*i+1] >> a[3*i+2];
  }
  int n, chk;
  int b;
  int bng[9] = {0};
  cin >> n;
  for(int i=0; i<n; i++){
      cin >> b;
      for(int j = 0; j < 9; j++){
          if(b==a[j]) bng[j]=1;
      }
  }
  for(int i = 0; i < 8; i++){
      chk = 0;
      for(int j = 0; j < 3; j++){
          if(bng[bingo[i][j]-1]==1){
              chk += 1;
          }
      }
      if(chk == 3){
        cout << "Yes" << endl;
        return 0;
      }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
in_1 = input().split()
n = int(in_1[0])
k = int(in_1[1])

trees_height = []
for i in range(n):
    trees_height.append(int(input()))

trees_height.sort()


def sub_minmax(list):
    return max(list)-min(list)

subs = []

for i in range(n+1-k):
    subs.append(trees_height[i+k-1]-trees_height[i])


print(min(subs))



Measured memory_bytes: 11288
let () =
    let main () =
        let r, d, x2000 = Scanf.sscanf (read_line ()) "%d %d %d" (fun r d x2000 -> r, d, x2000) in
        let rec loop i x =
            if i > 0 then (
                let x = r * x - d in
                Printf.printf "%d\n" x;
                loop (i - 1) x
            )
        in
        loop 10 x2000

    in
    main ()

Measured memory_bytes: 384
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

    fastread();

    ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;



    string str;


    cin>>str;



    n=str.size();

    ll ara[n+2]= {};




    for(i=0; i<n; i++ )
    {




        if(str[i]=='R')cnt++;


        else
        {



            ara[i-1]+=(cnt+1)/2;

            ara[i]+=cnt/2;

            cnt=0;


        }



    }


    cnt=0;
    for(i=n-1; i>=0; i-- )
    {




        if(str[i]=='L')cnt++;


        else
        {


            ara[i+1]+=(cnt+1)/2;

            ara[i]+=cnt/2;

            cnt=0;


        }



    }

    for(i=0; i<n; i++)
        cout<<ara[i]<<" ";

    cout<<endl;




}



Measured memory_bytes: 4564
#include<stdio.h>

int tax (int,int);

int main (void)
{
	int s[1000];
	int x[1000],y[1000];

	int i,j,p,q;

	for(i=0;;i++){
		scanf("%d %d %d",&x[i],&y[i],&s[i]);
		if(x[i]==0&&y[i]==0&&s[i]==0) break;
	}

	for(j=0;j<i;j++){
		int max=0;
		for(p=1;p<=s[j];p++){
			for(q=1;q<=s[j]-p;q++){
				if(tax(x[j],p)+tax(x[j],q)==s[j]){
					if(tax(y[j],p)+tax(y[j],q)>max) max=tax(y[j],p)+tax(y[j],q);
				}
			}
		}

		printf("%d\n", max);
	}

	return 0;
}

int tax (int taxrate, int cost)/*?¨?????????????*/
{
	int price;/*?¨?????????????*/
	
	price=cost*(100+taxrate)/100;
	return price;
}

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


int main(){
    int H,W,cnt;
    cin >> H >> W;
    vector<string> a(H);
    for(int i=0;i<H;++i) cin >> a[i];

    vector<bool> row(H,false);
    vector<bool> col(W,false);

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(a[i][j]=='#'){
                row[i]=true;
                col[j]=true;
            }
        }
    }

    for(int i=0;i<H;++i){
        if(row[i]){
            for(int j=0;j<W;++j){
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}



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

#include <bits/stdc++.h>
using namespace std;
const int maxn = 300, MAXN = 300;
struct edge
{
	int u,v;
	ll cap,flow;
};
vector<edge>e;

vector<int>graph[maxn];

int dist[maxn];
int ptr[maxn];


void add_edge(int u , int v, ll cap)
{
	edge e1 = {u,v,cap,0LL};
	edge e2 = {v,u,0LL,0LL};

	graph[u].push_back(e.size());
	e.push_back(e1);
	
	graph[v].push_back(e.size());
	e.push_back(e2);
}


bool bfs(int s, int t)
{
	memset(dist,-1, sizeof(dist));
	queue<int>q;
	q.push(s);
	dist[s] = 0;
	while(q.size() && dist[t] == -1)
	{
		int u = q.front();
		q.pop();

		for(int i = 0; i < graph[u].size(); i++)
		{
			int id = graph[u][i];
			int v = e[id].v;

			if(dist[v] == -1 && e[id].cap > e[id].flow)
			{
				q.push(v);
				dist[v] = dist[u] + 1;
			}
		}
	}

	return dist[t] != -1;
}

ll dfs(int u , ll flow, int t)
{
	if(!flow)
		return 0;
	if(u == t)
		return flow;
	for(; ptr[u] < graph[u].size(); ptr[u]++)
	{
		int id = graph[u][ptr[u]];
		int v = e[id].v;

		if(dist[v] != dist[u] + 1)
			continue;
		
		ll pushed = dfs(v, min(flow, e[id].cap - e[id].flow), t);
		
		if(pushed)
		{
			e[id].flow += pushed;
			e[id^1].flow -= pushed;
			return pushed;
		}

	}
	return 0;
}


ll dinic(int s, int t)
{
	ll ans = 0;
	while(bfs(s,t))
	{
		memset(ptr,0,sizeof(ptr));
		while(ll pushed = dfs(s, (1LL << 55), t) )
			ans += pushed;
	}
	return ans;
}


ll v[MAXN + 5];
int main(){
	ios::sync_with_stdio(0);
	//cin.tie(0); cout.tie();
	int N;
	cin >> N;
	ll sum = 0;
	for(int i = 2; i <= N+1; i++) {
		cin >> v[i];
		if(v[i] > 0) sum += v[i];
	}


	for(int i = 2; i <= N+1; i++){
		if(v[i] > 0) add_edge(i, N+2, v[i]);
		else add_edge(1, i, -v[i]);
	}

	for(int i = 1; i <= N; i++)
		for(int j = i+i; j <= N; j+=i)
			add_edge(i+1, j+1, (1LL << 50));

	ll ans = dinic(1, N+2);

	cout << sum - ans << "\n";
	return 0;
}

Measured memory_bytes: 384
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n=int(input())
s=[input() for i in range(n)]

ans=0
for i in range(n):
    flag=0
    for j in range(n):
        for k in range(n):
            # print(s[(i+j)%n][k],s[(i+k)%n][j])
            if s[(i+j)%n][k]!=s[(i+k)%n][j]:
                flag=1
    # print(flag)
    if flag==0:
        ans+=n
    # print()
print(ans)

Measured memory_bytes: 69220
num,food_num = map(int,input().split())

food_dict = {}

for i in range(num):
    l = list(map(int,input().split()))
    for j in range(1,l[0]+1):
            food_dict.setdefault(l[j],0)
            food_dict[l[j]] += 1

ans = 0

for name, likes in food_dict.items():
    if likes == num:
        ans += 1

print(ans)


Measured memory_bytes: 9184
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let a:u64 = read();
    let b = read::<String>();
    let mut b100: Vec<u64> = Vec::new();

    for c in b.chars(){
        if c == '.'{
            continue;
        }
        b100.push(c.to_digit(10).unwrap() as u64);
    }

    let b = b100[0]*100 + b100[1]*10 + b100[2];
    let mul = a * b / 100;

    println!("{}",mul);

}


Measured memory_bytes: 2156
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>

using namespace std;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  int ans = 0;
  while(true){
    int m = 0;
    bool check = false;
    for(int i = 0; i < n; i++){
      m = max(m, h[i]);
      if(h[i] > 0){
        check = true;
        h[i]--;
      }else if(check){
        if(h[i] == 0){
          ans++;
          check = false;
        }
      }

    }

    if(check){
      ans++;
    }
    if(m == 0){
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    int N;
    cin>>N;
    vector<int> b(N);
    rep(i,N) cin>>b[i];

    vector<int> ans(N);
    rep(i,N){
        int idx=-1;
        rep(j,N-i){
            if(b[j]==j+1){
                idx=j;
            }
        }
        if(idx==-1){
            cout<<-1<<endl;
            return 0;
        }else{
            ans[N-i-1]=idx+1;
            b.erase(b.begin()+idx);
        }
    }

    rep(i,N){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3580
def dfs(A, B):
    if len(A) > len(str(n)):
        return
    for i in sft:
        A.append(i)
        if int("".join(A)) <= n and ("3" in A) and ("5" in A) and ("7" in A):
            B.append("".join(A))
        dfs(A,B)
        A.pop()

if __name__ == "__main__":
    n = int(input())
    num_list = []
    ans_list=[]
    sft = ["3", "5", "7"]
    dfs(num_list,ans_list)
    print(len(ans_list))


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

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

    int a,b;
    cin>>a>>b;
    while(a!=0 or b!=0){
        if(a>b){
            swap(a,b);
        }
        cout<<a<<" "<<b<<endl;
        cin>>a>>b;
    }
    return 0;
}


Measured memory_bytes: 3224
s1 = input()
s2 = input()

dp = [[1010] * (len(s2) + 1) for _ in range(len(s1) + 1)]
for i in range(len(s1) + 1):
    dp[i][0] = i
for j in range(len(s2) + 1):
    dp[0][j] = j

for i in range(len(s1)):
    for j in range(len(s2)):
        cost = 0 if s1[i] == s2[j] else 1
        dp[i + 1][j + 1] = min(dp[i + 1][j] + 1, dp[i][j + 1] + 1, dp[i][j] + cost)

print(dp[len(s1)][len(s2)])



Measured memory_bytes: 43076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll ans=0,n;
    cin>>n;
    vector<ll> sum(n+1,0);
    for(int i=0;i < n;i++)
    {
        ll x;
        cin>>x;
        sum.at(i+1)=x+sum.at(i);
    }

    map<ll,ll> ma;
    vector<ll> apd(0);
    for(int i=0;i < n+1;i++)
    {
        if(!ma.count(sum.at(i))){
            ma.emplace(sum.at(i),1);
            apd.pb(sum.at(i));
        }else{
            ma.at(sum.at(i))++;
        }
    }

    for(auto i:apd)
    {
        ans+=(ma.at(i))*(ma.at(i)-1)/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 15856
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;

int main(void) {
    int N;
    LLs A;
    std::cin >> N;
    LL res = 0;

    for(int i=0;i<N;i++){
        int a;
        std::cin >> a;
        A.push_back(a);
        res^=a;
    }

    for(int i=0;i<N;i++){
        res^=A[i];
        std::cout << res << std::endl;
        res^=A[i];
    }

    return 0;
}

Measured memory_bytes: 5360
#include<stdio.h>
#define NODATA -1

int fibonacci(int  );
int F[100];

int main(){

  int inputdata,i,outputdata;

  scanf("%d",&inputdata);

  for(i =0; i < 100; i++){

    F[i] = NODATA;

  }

  outputdata = fibonacci(inputdata);

  printf("%d\n",outputdata);

  return 0;

}

int fibonacci(int n){

  if ( n == 0 || n == 1){

    return F[n] = 1;

  }

  if(F[n] != NODATA){

    return F[n];

  }

  return F[n] = fibonacci(n -2) + fibonacci(n -1);


}

Measured memory_bytes: 596
import math
n,d = map(int,input().split())
x = [list(map(int,input().split()))for i in range(n)]
count =0
for i in range(n):
    for k in range(i+1,n):
        judge = 0
        for j in range(d):
            judge += abs(x[i][j] - x[k][j])**2
        if math.sqrt(judge).is_integer() == True:
            count+=1
print(count)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var O = ReadString().GetEnumerator();
            var E = ReadString().GetEnumerator();
            for (;;)
            {
                if (!O.MoveNext()) break;
                Console.Write(O.Current);
                if (!E.MoveNext()) break;
                Console.Write(E.Current);
            }

            Console.WriteLine();
        }

        //最小公倍数
        static int LCM(int num1, int num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        static long LCM(long num1, long num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        //最大公約数
        static int GCD(int num1, int num2)
        {
            int a = Math.Max(num1, num2);
            int b = Math.Min(num1, num2);
            int mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static long GCD(long num1, long num2)
        {
            long a = Math.Max(num1, num2);
            long b = Math.Min(num1, num2);
            long mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }

    class PriorityQueue<T>
    {
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a[4];
    for(int i=0; i<4; i++)
    cin>>a[i];
    sort (a,a+4);
    if(a[0]==a[1]&&a[2]==a[3])
    cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}



Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front

typedef long long ll;

using namespace std;

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

int main(){
    string S;
    cin>>S;
    ll K;
    cin>>K;

    rep(i,0,K){
        if(S[i]-'0' >= 2){
            cout<<S[i]<<endl;
            return 0;
        }
        if(i == K-1){
            cout<<S[i]<<endl;
            return 0;
        }
    }
    return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)



typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////


ll SOLVE(){
    ll n;cin>>n;
    ll a[n],b[n];
    rep(i,0,n-1)cin>>a[i]>>b[i];
    sort(a,a+n);sort(b,b+n);
    if(n%2==0){
        
        ll t=n/2-1;
        cout<<(b[t]+b[t+1])-(a[t]+a[t+1])+1;
        
    }else{
        ll t=n/2;
        cout<<b[t]-a[t]+1;
    }
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}



Measured memory_bytes: 6936
#include <bits/stdc++.h>
using namespace std;
int cnt[15];
int main() {
	int n;
	scanf("%d", &n);
	cnt[0] = 1;
	for (int i = 0; i < n; ++ i) {
		int x;
		scanf("%d", &x);
		cnt[x] ++;
	}
	vector<int> a, c;
	for (int i = 0; i <= 12; ++ i) {
		if (cnt[i] >= 3) return 0 * puts("0");
		if (cnt[i] == 2) {
			c.push_back(i);
			c.push_back(24 - i);
		}
		else if (cnt[i]) {
			a.push_back(i);
		}
	}
	int ans = 0;
	for (int mask = 0; mask < (1 << (int) a.size()); ++ mask) {
		vector<int> b = c;
		for (int i = 0; i < (int) a.size(); ++ i) {
			b.push_back((mask >> i & 1) ? a[i] : 24 - a[i]);
		}
		int s = 100;
		for (int i = 0; i < (int) b.size(); ++ i) {
			for (int j = i + 1; j < (int) b.size(); ++ j) {
				int t = abs(b[i] - b[j]);
				s = min(s, min(t, 24 - t));
			}
		}
		ans = max(ans, s);
	}
	printf("%d\n", ans);
}


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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main()
{   
    ll n,X; cin >> n >> X;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    ll res = abs(x[0] - X);
    rep1(i,n)res = __gcd(res,abs(x[i-1] - x[i]));
    cout << res << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{   int A, B, sum, sub, mul;
    scanf("%d %d", &A, &B);
    sum = (A+B);
    sub = (A-B);
    mul = (A*B);
    if(sum>=sub && sum>=mul) printf("%d", sum);
    else if(sub>=sum && sub>=mul) printf("%d", sub);
    else printf("%d", mul);
        return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

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

int main(void){
    int h, w, n;
    cin >> h >> w >> n;
    VI a(n), b(n), cnta(h), cntb(w);
    VVI a2bs(h);
    REP(i,n){
        a[i] = in() - 1;
        b[i] = in() - 1;
        cnta[a[i]]++;
        cntb[b[i]]++;
        a2bs[a[i]].push_back(b[i]);
    }
    int maa = *max_element(ALL(cnta));
    int mab = *max_element(ALL(cntb));
    int ans = maa + mab - 1;
    int mab_cnt = 0;
    REP(j,w) if (cntb[j] == mab) mab_cnt++;
    REP(i,h){
        if (cnta[i] != maa) continue;
        int c = 0;
        for (int j : a2bs[i]){
            if (cntb[j] == mab) c++;
        }
        if (c < mab_cnt) ans = maa + mab;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24436
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec A(N, 0);
  ll sum = 0;
  rep(i, N){
    cin >> A[i];
    sum += (i%2==0)? A[i]:-A[i];
  }
  ll a = sum/2;
  cout << a*2 << " ";
  rep(i, N-1){
    a = A[i] - a;
    cout << a*2 << " ";
  }
  
  return 0;
}


Measured memory_bytes: 2048
/*
w2sc
2019/12/19
17:09:09
*/
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
double sqr(double x){return x*x;}
struct point{
    double x,y;
    point(){}
    point(double xx,double yy){x=xx,y=yy;}
}A,B,P;
typedef point vec;
vec operator +(vec x,vec y){return vec(x.x+y.x,x.y+y.y);}
vec operator -(vec x,vec y){return vec(x.x-y.x,x.y-y.y);}
vec operator *(double x,vec y){return vec(x*y.x,x*y.y);}
struct line{
    point A,B;
    line(){}
    line(point AA,point BB){A=AA,B=BB;}
    double len()
    {
        return sqrt(sqr(A.x-B.x)+sqr(A.y-B.y));
    }
}a,b;
double operator *(vec p1,vec p2)
{return p1.x*p2.x+p1.y*p2.y;}
int q;
int main()
{
    double x,y;
    scanf("%lf%lf",&x,&y);
    A=point(x,y);
    scanf("%lf%lf",&x,&y);
    B=point(x,y);
    a=line(A,B);
    scanf("%d",&q);
    while(q--)
    {
        scanf("%lf%lf",&x,&y);
        P=point(x,y);
        b=line(A,P);
        point ans=A+((a.B-a.A)*(b.B-b.A))/a.len()/a.len()*(a.B-a.A);
        printf("%.15f %.15f\n",ans.x,ans.y);
    }
    return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

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

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

typedef long long ll;

using namespace std;




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int h,w;
  cin>>h>>w;
  int edge[10][10];
  rep(i,10)rep(j,10)cin>>edge[i][j];
  vector<int> dist(10,1000);
  dist[1]=0;
  rep(i,10)rep(j,10)rep(k,10)
  {
    if(dist[k]==1000)continue;
    chmin(dist[j],dist[k]+edge[j][k]);
  }
  int res=0;
  rep(i,h)rep(j,w){int a;cin>>a;if(a>=0)res+=dist[a];}
  cout<<res<<endl;
    return 0;

}


Measured memory_bytes: 256