akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using i64 = long long;

long long *fact, *inv;

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

void init_factorial(int n, long long mod) {
    fact = new long long[n + 1];
    inv = new long long[n + 1];
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int main() {
    int b, w;
    constexpr i64 mod = 1000000007;
    std::cin >> b >> w;
    int n = b + w;
    init_factorial(n, mod);
    i64 ret = 1, inv2 = inverse(2ll, mod), c = 0, d = 0, p2 = 1;
    for (int i = 0; i < n; i++) {
        if (i >= b) {
            c = (c + p2 * fact[i - 1] % mod * inv[i - b] % mod * inv[b - 1] % mod) % mod;
        }
        if (i >= w) {
            d = (d + p2 * fact[i - 1] % mod * inv[i - w] % mod * inv[w - 1] % mod) % mod;
        }
        p2 = p2 * inv2 % mod;
        std::cout << (ret + mod - c + d) % mod * inv2 % mod << '\n';
    }

    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Cloudy"){
        cout<<"Rainy"<<endl;
    }
    else{
        cout<<"Sunny"<<endl;
    }
    return 0;

}

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

using namespace std;

int main()
  {
    string s;
    cin>>s;
    int n;
    n=s.length();
   if(s[n-1]=='s'){
       s=s+"es";
   }
   else{
       s=s+"s";
       
   }
    
    cout<<s;
}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b;cin>>a>>b;
  print((b%a==0)?(a+b):(b-a));
  return 0;
}


Measured memory_bytes: 256
n = int(input())
words_list = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        words_list[i].append((x - 1, y))

ans = 0
for i in range(2 ** n):
    peoples = []
    flag = True
    for j in range(n):
        if (i >> j & 1):
            peoples.append(1)
        else:
            peoples.append(0)
    for k in range(n):
        if peoples[k] == 1:
            words = words_list[k]
            for word in words:
                if peoples[word[0]] != word[1]:
                    flag = False
                    break
    if flag:
        ans = max(ans, sum(peoples))

print(ans)

Measured memory_bytes: 3064
/*
░░░░██████████████████
░░▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ManavJ07▒▀██████▄
░███▀▒▒▒▒BITS▒▒▒▒▒▒▀█████
░▐██▒▒▒.........▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int main()
{
    fastio();
    double N;
    cin>>N;
    double s=N/1.08;
    ll j=s;
    ll k=j+1;
    double s1=j*1.08;
    double s2=k*1.08;
    if((ll)s1==N)
        cout<<j;
    else if((ll)s2==N)
        cout<<k;
    else
        cout<<":(";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
const int P = 4000;
int N, K;
pair<i64, i64> dp[110][P];

void add(pair<i64, i64> &a, i64 ct, i64 pf)
{
	a = make_pair((a.first + ct) % MOD, (a.second + pf) % MOD);
}

int main()
{
	scanf("%d%d", &N, &K);

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j < P; ++j) {
			dp[i][j] = make_pair(0LL, 0LL);
		}
	}
	dp[N][0] = make_pair(1LL, 0LL);
	for (int i = N; i >= 1; --i) {
		for (int j = 0; j < P; ++j) {
			if (dp[i][j] == make_pair(0LL, 0LL)) continue;

			for (int k = 0; k <= K; ++k) {
				if (k > i) {
					add(dp[i - 1][j], dp[i][j].first, dp[i][j].second);
				} else {
					int chg = k + j;
					int j2 = j + chg / i;
					add(dp[i - 1][j2], dp[i][j].first, dp[i][j].second + dp[i][j].first * chg);
				}
			}
		}
	}
	i64 ret = 0;
	for (int i = 0; i < P; ++i) {
		ADD(ret, dp[0][i].first * i);
	}
	i64 base = K * (K + 1) / 2;
	for (int i = 0; i < N - 1; ++i) base = base * (K + 1) % MOD;
	base = base * N % MOD;

	printf("%lld\n", (base + MOD - ret) % MOD);

	return 0;
}


Measured memory_bytes: 7168
import Data.List

n :: [Int] -> [Int]
n [a,b,c,d,e,f] = [b,f,c,d,a,e]

w :: [Int] -> [Int]
w [a,b,c,d,e,f] = [c,b,f,a,e,d]

turn :: [Int] -> [[Int]]
turn [a,b,c,d,e,f]
  = [a,b,c,d,e,f] : [a,c,e,b,d,f] : [a,e,d,c,b,f] : [a,d,b,e,c,f] : []

solve :: String -> [Int] -> [[Int]]
solve [] _ = []
solve (x:xs) list
  | 'f' == x = turn list ++ solve xs list
  | 'n' == x = (turn . n) list ++ solve xs (n list)
  | 'w' == x = (turn . w) list ++ solve xs (w list)

main = do
  n <- fmap (*24) readLn
  m <- fmap (map (solve "fnnwnn". map read . words) . lines) getContents
  if a m == b m then putStrLn "Yes" else putStrLn "No"
  where a = sum . map (length . nub)
        b = length . nub . concat

Measured memory_bytes: 4556
while true
    equation = gets.split()
    if equation[1] == "?"
        break
    else
        if equation[1] == "+"
            puts equation[0].to_i + equation[2].to_i
        elsif equation[1] == "-"
            puts equation[0].to_i - equation[2].to_i
        elsif equation[1] == "*"
            puts equation[0].to_i * equation[2].to_i
        elsif equation[1] == "/"
            puts (equation[0].to_i / equation[2].to_i).floor
        end
    end
end


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

    int main(){
        int b;
        cin >> b;
        cin.ignore();

        string a;
        cin >> a;
        if(a.length()<=b)
            cout << a;
        else{

            cout << a.substr(0,b) << "...";
        }
        return 0;
    }









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

int main() {
  long N;
  cin >> N;
  vector<long> A(N);
  for (long i = 0; i < N; i++) cin >> A.at(i);
  long mx = A.at(0), ans = 0;
  for (long i = 1; i < N; i++) {
    if (A.at(i) < mx) {
      ans += mx - A.at(i);
    }
    mx = max(mx, A.at(i));
  }
  cout << ans << "\n";
}

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

/* define const */
const long Div = 1000000007;
/* finish defineing const */

int n;

int main()
{
    cin >> n;
    long ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans = (ans * i) % Div;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import heapq as h
 
# a,b = map(int,input().split())
n = int(input())
# l = list(map(lambda x:-int(x),input().split()))
can = 'No'
for i in range(1,10):
  if ((n%i) == 0):
    right = n/i
    if (1<=right) and (right<=9):
      can = 'Yes'
print(can)

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    string s;
    cin >> n >> k >> s;
    int sc=0;
    for(int i = 0; i < n-1; i++) {
        if(s[i]==s[i+1]) sc++;
    }
    int ans=min(sc+2*k,n-1);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int n[5],k=0,i,j;
	for(i=0;i<3;i++){
		scanf("%d",&n[i]);
		if(k>n[i] || k==0)k=n[i];
	}
	scanf("%d %d",&n[3],&n[4]);
	if(n[3]>n[4])n[3]=n[4];
	printf("%d\n",n[3]+k-50);
	return 0;
}


Measured memory_bytes: 2080
#include<stdio.h>
#include<math.h>
int main(void){
  	char tryal[6];
  	for(int i=0;i<6;i++){
  	scanf("%c",&tryal[i]);
    }
  if((tryal[2]==tryal[3])&&(tryal[4]==tryal[5])){
  	printf("Yes");
  }
  	else{
    	printf("No");
    }
  
}


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

int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    long a = 0, b = abs(arr[1]-arr[0]),c=b;
    for(int i=2;i<n;i++){
        c = min(a+abs(arr[i] - arr[i-2]),b+abs(arr[i] - arr[i-1]));
        a=b;
        b=c;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 4004
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(ll int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
vector<ll int>V;
int gcd(int a, int b)
{
	if (a % b == 0) {
		return b;
	}
	return gcd(b, a % b);
}
int main(void)
{
	char S;
	scanf("%c", &S);
	if (S == 'A') {
		printf("T");
		return 0;
	}
	else if (S == 'C') {
		printf("G");
		return 0;
	}
	else if (S == 'T') {
		printf("A");
		return 0;
	}
	printf("C");
	return 0;
}


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

for h in range(1,3501):
    if 4*h != N:
        n_min = max(N*h //(4*h - N), 1)
    else:
        n_min = 1
#    print(n_min)
    for n in range(n_min,3501):
        nume = N*h*n
        enum = 4*h*n - N*n - N*h

        if enum > 0 and nume%enum == 0:
            w = nume//enum
            print(h,n,w)
            exit()


Measured memory_bytes: 3060
#include <iostream>

int main(void)
{
    int A, B, C;
    std::cin >> A >> B >> C;

    bool flag = false;
    for (int n = 0; n < B; ++n) {
        if ( ((n+B) * A) % B == C ) {
            flag = true;
            break;
        }
    }

    std::cout << (flag ? "YES" : "NO") << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

template<typename T>
struct BIT {
  int n;
  int mod;
  std::vector<T> d;

  BIT(int n=500001, int mod=0) : n(n), mod(mod), d(n+1) {}

  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
      if (mod) {
          d[i] %= mod;
      }
    }
  }

  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
      if (mod) {
          x %= mod;
      }
    }
    return x;
  }
};

BIT<int> bit[26]; //! bit for a to z


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

    int N;
    string S;
    cin >> N >> S;
    rep(i, N) {
        int a = (S[i] - 'a');
        bit[a].add(i+1);
    }

    int Q;
    cin >> Q;
    rep(i, Q) {
        int t;
        cin >> t;
        if (t == 1) {
            int j;
            string c;
            cin >> j >> c;
            if (S[j-1] != c[0]) {
                int from = S[j-1]-'a';
                int to = c[0]-'a';
                bit[from].add(j, -1);
                bit[to].add(j);
                S[j-1] = c[0];
            }
        } else if (t == 2) {
            int l, r;
            cin >> l >> r;
            int cnt = 0;
            rep(a, 26) {
                int occ = bit[a].sum(r) - bit[a].sum(l-1);
                if (0 < occ) {
                    ++cnt;
                }
            }
            cout << cnt << '\n';
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 52116
//#include "pch.h"
#include <iostream>
#include <string>

using namespace std;



int main() {


	int a, b;
	char op;

	cin >> a;
	getchar();
	cin >> op;
	getchar();
	cin >> b;

	if (op == '+')a += b;
	else a -= b;

	cout << a << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

H.reverse()
m = [0]
c = 0
for i in range(1,N):
    if (H[i] >= H[i-1]):
        c += 1
    else:
        c = 0

    m.append(c)

print(max(m))



Measured memory_bytes: 15020
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;
Node *find(Node *u, int k) {
	while (u != NIL&&k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}
void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL)root = z;
	else {
		if (z->key < y->key)y->left = z;
		else y->right = z;
	}
	return;
}
void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
	return;
}
void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}
int main() {
	int n, i, x;
	string com;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			cin >> x;
			Node *t = find(root, x);
			if (t != NIL)puts("yes");
			else puts("no");
		}
		else if (com == "insert") {
			cin >> x;
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 22036
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e7+7;
ll A[N];
vector<ll> v;
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

int main()
{
    sieve();
   ll a,b,cnt=0;
   cin>>a>>b;
   ll d=__gcd(max(a,b),min(a,b));
   for(ll i=0;v[i]<=sqrt(d);i++)
   {
       if(d%v[i]==0)
       {
           while(d%v[i]==0)
             {
                 d/=v[i];
             }
           cnt++;
       }
   }
   if(d!=1)
   {
       cnt++;
   }
   cout<<cnt+1<<endl;
return 0;
}


//bool is_prime(ll n){
//    if(n==1) return 1;
//for(ll i=2;i*i<=n;i++)
//    if(n%i==0) return 0;
//    return 1;
//}
//
//int main(){
//   ios::sync_with_stdio(0);
//        cin.tie(0);
//        cout.tie(0);
////        map<ll,ll> ma;
//        vector<ll>v1;
//ll a,b;
//cin>>a>>b;
//ll mx=max(a,b);
//for(ll i=1;i*i<=mx;i++){
//    if(a%i==0&&b%i==0)
//        v1.push_back(i);
//}
//ll cnt=0;
//for(ll i=0;i<v1.size();i++){
//if(is_prime(v1[i]))
//    cnt++;
////cout<<v1[i]<<" ";
//}
//
//cout<<cnt;
//
//}









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

int main(){
    int N,res=0,u=0;
    cin >> N;

    vector<int> A1(N),A2(N);
    for (int i=0;i<N;i++){
        cin >> A1[i];
    }
    for (int i=0;i<N;i++){
        cin >> A2[i];
    }

    for (int i=0;i<N;i++){
        u += A1[i];
        res = max(res,u) + A2[i];
    }
    
    cout << res << endl;
    }

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
x2x1 = x2 - x1
y2y1 = y2 - y1    
v = x2x1 + y2y1 * 1j
turn90 = 0 + 1j
for _ in range(2):
    v = v * turn90
    x2 += int(v.real)
    y2 += int(v.imag)
    print(x2, y2, end=' ')

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

int main(){
	int N;
	scanf("%d", &N);
	char s[N];
	int a = 0, b = 0;
	for(int i=0; i<N; i++){
		cin >> s[i];
		if(s[i] == '(') a++;
		else if(a) a--;
		else b++;
	};
	for(int i=0; i<N+a+b; i++){
		if(i<b){ cout << "(";}
		else if(i>N+b-1){ cout << ")";}
		else{ cout << s[i-b];}
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
sp = []
n.times do
  sp.push gets.chomp.split
end
h = Hash.new([])
sp.each_index do |i|
  s = sp[i].first
  p = sp[i].last.to_i
  h[s] += [[p, i + 1]]
end
sh = h.sort
sh.each do |e|
  pi = e.last
  pi.sort_by(&:first).reverse_each do |p|
    puts p.last
  end
end


Measured memory_bytes: 1788
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, K = in_nn()
    D = in_nl()

    num = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(D)

    for n in range(N, N * 10 * 1):
        if set(map(int, str(n))) <= num:
            break

    print(n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

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

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int x[N], y[N], t[N];
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	int now = 0;
	for (int i = 1; i <= n; i++) {
		int need = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if (now + need > t[i]) cout << "No", ioi
		now += need;
		if ((t[i] - now) % 2) cout << "No", ioi
		now = t[i];
	}
	cout << "Yes";
	ioi
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long T[2];
  cin >> T[0] >> T[1];
  long long A[2], B[2];
  cin >> A[0] >> A[1];
  cin >> B[0] >> B[1];
  B[0] -= A[0];
  B[1] -= A[1];
  long long C[2] = {abs(T[0] * B[0]), abs(T[1] * B[1])};
  if (B[0] / abs(B[0]) == B[1] / abs(B[1])) {
    cout << 0 << endl;
  } else if (C[0] == C[1]) {
    cout << "infinity" << endl;
  } else if (C[0] > C[1]) {
    cout << 0 << endl;
  } else {
    long long dif = C[1] - C[0];
    if (C[0] % dif == 0) {
      cout << C[0] / dif * 2 << endl;
    } else {
      cout << C[0] / dif * 2 + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(int argc, char* argv[])
{
    int a, b, c, n, m, k, i;
    scanf("%d %d %d", &a, &b, &c);
    k = a * 7 + b;//1週間連続ログインしたときの取得コイン数
    n = c / k;//週数
    m = c % k;//週数に満たないあまり,0<=m<k
    for(i = 1; 0 < m; i++){
        m -= a;
        if(i % 7 == 0){
            m -= b;
        }
    }
    printf("%d\n",n*7+i-1);
    return 0;
}


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

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n;
        cin>>n;
        vi a(n);
        inputarr(a,n);
        sort(all(a));
        int k=n/2;

        cout<<a[k]-a[k-1];         
     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

int n;
int key[100];
string s;
string eki;

int toIndex(char c) {
	if (c >= 'a') return c - 'a';
	return c - 'A' + 26;
}

int main() {
	int i;
	
	for (i = 0; i < 26; i++) eki += 'a' + i;
	for (i = 0; i < 26; i++) eki += 'A' + i;
	
	while (cin >> n) {
		if (!n) break;
		for (i = 0; i < n; i++) cin >> key[i];
		cin >> s;
		
		for (i = 0; i < s.length(); i++) {
			int k = key[i % n];
			cout << eki[(toIndex(s[i]) - k + 52) % 52];
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<ll> v(N+1);
    for (int i = 1; i <= N; ++i) {
        for (int j = i; j <= N; j += i) {
            v[j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += i * (v[i]);
    }
    cout << ans << endl;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  
  int S = A + B;
  int T = A - B;
  int U = A * B;
  
  if (S >= T && S >= U) {
    cout << S << endl;
  } else if (T >= S && T >= U) {
    cout << T << endl;
  } else if (U >= S && U >= T) {
    cout << U << endl;
  }
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,x,count;
	int i,j,k;
	for(;;){
		count = 0;
		scanf("%d %d",&n,&x);
		if(!n&&!x) break;
		for(i=1;i<=n;i++)for(j=i+1;j<=n;j++)for(k=j+1;k<=n;k++) if((i+j+k) == x) count++;
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> L(N); rep(i,N) cin>>L[i];
  sort(L.rbegin(),L.rend());
  ll l=L[0];
  ll sum=0; for(int i=1;i<N;i++) sum+=L[i];
  
  cout<<(l<sum?"Yes":"No")<<'\n';
         
  return 0;
}


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

class Board
{
public:
	Board()
	{
		memset( m_board, 0, sizeof(m_board) );
	}
	~Board()
	{
	}

	void input()
	{
		for( int i = 1; i < 11; ++i ){
			int bits = 0;
			for( int j = 0; j < 10; ++j ){
				bits <<= 1;
				int n;
				cin >> n;
				bits |= n;
			}
			m_board[ i ] = bits;
		}
	}
	void output()
	{
		for( int i = 0; i < 10; ++i ){
			int bit = 1 << 9;
			bool first = true;
			for( int j = 0; j < 10; ++j ){
				if( first ){
					first = false;
				}else{
					cout << " ";
				}
				cout << ( m_correct[ i ] & bit ? 1 : 0 );
				bit >>= 1;
			}
			cout << endl;
		}
	}
	bool light( int bits )
	{
		memset( m_correct, 0, sizeof(m_correct) );
		int board[ 12 ];
		memcpy( board, m_board, sizeof(m_board) );

		int mask = ( 1 << 10 ) - 1;
		for( int i = 1; i < 11; ++i ){
			m_correct[ i - 1 ] = bits;

			board[ i - 1 ] ^= bits; board[ i - 1 ] &= mask;
			board[ i + 1 ] ^= bits; board[ i + 1 ] &= mask;

			board[ i ] ^= bits;
			board[ i ] ^= ( bits << 1 );
			board[ i ] ^= ( bits >> 1 );
			board[ i ] &= mask;
			if( i > 1 && board[ i - 1 ] != 0 ){
				return false;
			}
			bits = board[ i ];
		}

		return board[ 10 ] == 0;
	}

private:
	int m_board[ 12 ];
	int m_correct[ 10 ];
};

int main()
{
	int n;

	while( cin >> n ){
		for( int i = 0; i < n; ++i ){
			Board board;
			board.input();

			for( int j = 0; j < ( 1 << 10 ); ++j ){
				if( board.light( j ) ){
					board.output();
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int h,w,x[4]={0,-1,0,1},y[4]={-1,0,1,0};
char s[50][50];
bool ok;
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>s[i][j];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.')continue;
            ok=false;
            for(int k=0;k<4;k++){
                int ni=i+x[k],nj=j+y[k];
                if(ni<0||h<=ni||nj<0||w<=nj) continue;
                if(s[ni][nj]=='#') ok=true;
            }
            if(!ok){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

    int N;
    ll H;

    cin >> N >> H;

    vector<ll> b(N);
    ll a_max, tmp_a;
    a_max = 0;
    for(int i = 0; i < N; i++){
        cin >> tmp_a >> b[i];
        chmax(a_max, tmp_a);
    }

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

    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(b[i] > a_max && H > 0){
            H -= b[i];
            ans++;
        }else{
            break;
        }
    }
    
    if(H>0){
        ans += (H+a_max-1)/a_max;
    }
    
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc169/abc169_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  unsigned long long A;
  string B;
  cin >> A >> B;

  unsigned long long C = (B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0');

  unsigned long long ans = A * C;
  ans /= 100;

  cout << ans << endl;

}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {

    int n,k;
    cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    Sort(v);
    int ans=INF;
    rep(i,n){
        if(i+k-1==n)break;
        chmin(ans,v[i+k-1]-v[i]);
    }
    fin(ans);
    
}


Measured memory_bytes: 640
N,K = map(int, input().split())
Alist = list(map(int, input().split()))

Alist_str = [str(n) for n in Alist]

M=N
while True:
    Mlist_str = list(str(M))
    double = set(Alist_str) & set(Mlist_str)
    if len(double) == 0:
        print(M)
        break
    else:
        M = M +1

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"container/list"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}
func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100000), 100000)
}

func main() {
	s := scanString()
	ls := list.New()
	for _, r := range s {
		ls.PushBack(string(r))
	}
	rv := false
	q := scanInt()
	for i := 0; i < q; i++ {
		t := scanInt()
		switch t {
		case 1:
			rv = !rv
		case 2:
			f, c := scanInt(), scanString()
			if rv {
				f = 3 - f
			}
			if f == 1 {
				ls.PushFront(c)
			} else {
				ls.PushBack(c)
			}
		}
	}

	var wr = bufio.NewWriter(os.Stdout)
	if rv {
		for e := ls.Back(); e != nil; e = e.Prev() {
			wr.WriteString(e.Value.(string))
		}
	} else {

		for e := ls.Front(); e != nil; e = e.Next() {
			wr.WriteString(e.Value.(string))
		}
	}
	wr.WriteString("\n")
	wr.Flush()
}


Measured memory_bytes: 21760
import collections
h, w = map(int, input().split())
s = [[""]*(w+2)]
starts = []
for i in range(h):
    _s = list(input())
    _s.insert(0, "")
    _s.append("")
    s.append(_s)
    for j, __s in enumerate(_s):
        if __s == ".":
            starts.append([i+1, j])
s.append([""]*(w+2))

dx = [0, -1, 0, 1]
dy = [1, 0, -1, 0]

ans = 0
for _start in starts:
    dist = [[-1]*(w+2) for _ in range(h+2)]
    dist[_start[0]][_start[1]] = 0
    q = collections.deque([_start])

    # BFS
    while 0 < len(q):
        c = q.pop()
        for _dx, _dy in zip(dx, dy):
            x = c[0] + _dx
            y = c[1] + _dy
            if s[x][y] == "." and dist[x][y] == -1:
                dist[x][y] = dist[c[0]][c[1]] + 1
                q.appendleft([x, y])

    for _d in dist:
        ans = max(ans, max(_d))

print(ans)


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  size_t k = 0;
  for (size_t i = 1; i < n; ++i)
    if (std::abs(a[k]) < std::abs(a[i]))
      k = i;

  if (a[k] == 0) return puts("0"), 0;

  std::vector<std::pair<size_t, size_t>> res;
  for (size_t i = 0; i < n; ++i) {
    if (i != k) res.emplace_back(k, i);
  }

  if (a[k] > 0) {
    for (size_t i = 1; i < n; ++i)
      res.emplace_back(i-1, i);
  } else {
    for (size_t i = n-1; i--;)
      res.emplace_back(i+1, i);
  }

  printf("%zu\n", res.size());
  for (auto const& p: res)
    printf("%zu %zu\n", p.first+1, p.second+1);

  {
    for (auto const& p: res)
      a[p.second] += a[p.first];

    assert(std::is_sorted(a.begin(), a.end()));
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,X,L,a=0;
    scanf("%d %d",&N,&X);
    for(int i=0;i<N;i++){
        scanf("%d",&L);
        a+=L;
        if(a>X){
            printf("%d\n",i+1);
            break;
        }
        if(i==N-1) printf("%d",N+1);
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()
wr = s.count('W')
er = n-wr
wl = 0
el = 0
ans = 10**10
for i in range(n):
    if s[i] == 'W':
        wr -= 1
        ans = min(ans,er+wl)
        wl += 1
    else:
        er -= 1
        ans = min(ans,er+wl)
        el += 1
print(ans)
    


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> C(10, vector<int>(10));
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) cin >> C.at(i).at(j);
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++) C.at(j).at(k) = min(C.at(j).at(k), C.at(j).at(i) + C.at(i).at(k));
  int ans = 0;
  int A;
  while (cin >> A) ans += (A != -1) ? C.at(A).at(1) : 0;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_n = 17, inf = 1e15, mod = 1e9 + 7, max_mask = (1LL << 17) + 10;
ll n, a[max_n][max_n];
ll DP[max_mask], gscore[max_mask];

void calc_scores(ll mask)
{
    ll score = 0;
    for (ll i = 0; i < 17; ++i)
    {
        for (ll j = i + 1; j < 17; ++j)
            if( ((mask >> i) & 1) & ((mask >> j) & 1))
                score += a[i][j];
    }
    gscore[mask] = score;
}

ll max_score(ll mask)
{
    if (mask == 0)
        return 0;
    ll &ans = DP[mask];
    if (ans != -inf)
        return ans;
    ans = 0;
    for (ll submask = mask; submask > 0; submask = (submask - 1) & mask)
        ans = max(ans, gscore[submask] + max_score((submask ^ mask) & mask));
    return ans;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
    ll res = -inf;
    ll done = (1LL << n) - 1;
    for (ll i = 1; i <= done; ++i)
        calc_scores(i);
    fill(DP, DP + max_mask, -inf);
    res = max_score(done);
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 5184
n = int(input())
cards = {} #空の辞書
for i in range(n):
    card = input()
    cards[card] = 1
    
#print(cards)
    
for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c +' ' + str(n)
        if not key in cards:
            print(key)


Measured memory_bytes: 5596
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: Vec<i64> = (0..6).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let (x, y, a, b) = (a[0], a[1], a[4] - a[2], a[5] - a[3]);
    if a * x + b * y == 0 {
        println!("infinity");
        return;
    }
    let p = a * x;
    let q = a * x + b * y;
    if p.signum() == q.signum() {
        println!("0");
        return;
    }
    let p = p.abs();
    let q = q.abs();
    let mut ans = 0;
    ans += (p + q) / q * 2;
    if (p + q) % q == 0 {
        ans -= 1;
    }
    ans -= 1;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#138_D
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

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

edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x
    
def dfs(frm, cur):
    for to in edges[cur]:
        if to != frm:
            cnt[to] += cnt[cur]
            dfs(cur, to)
dfs(-1, 0)          
print(*cnt)


Measured memory_bytes: 230920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int N; cin>>N;
  ll A[N],B[N]; rep(i,N) cin>>A[i]>>B[i];
  sort(A,A+N);
  sort(B,B+N);
  if(N%2){
    cout<<B[N/2]-A[N/2]+1<<endl;
  }else{
    cout<<(B[N/2-1]+B[N/2])-(A[N/2-1]+A[N/2])+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 6752
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int a=sc.nextInt(); if(a==1) a+=13;
			int b=sc.nextInt(); if(b==1) b+=13;
			if(a>b) System.out.println("Alice");
			else if(a<b) System.out.println("Bob");
			else System.out.println("Draw");
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    int n;
    cin>>n;
    int k;
    cin>>k;
    ll bit=0;
    rep(i,k){
        int t;
        cin>>t;
        bit|=(1LL<<t);
    }
    rep(i,bit+1){
        if((i&bit)==i){
            cout<<i<<":";
            rep(j, 29) {
                if(i&(1LL<<j)){
                    cout<<" "<<j;
                }
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
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)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int a, b; cin >> a >> b;
    
    if(a <= b) {
        cout << a << endl;
    } else {
        cout << a-1 << endl;
    } 
    
    return 0;
}



Measured memory_bytes: 256
//AT2205 3分割ゲーム / Trichotomy
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
ll ans;
int n;
ll jishu(int k,ll num)
{
	if(k==n)return num;
	else return jishu(k+1,num*2+1);
}
ll oushu(int k,ll num)
{
	if(k==n)return num;
	else return oushu(k+1,2*num+2);
}
int main()
{
	cin>>n;
	ans=max(jishu(0,1),oushu(0,2));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

void solve(){
	int h,w,k;
	cin>>h>>w>>k;
	char c[h][w];
	rep(i,h){
		rep(j,w){
			cin>>c[i][j];
		}
	}
	int ans=0;
	rep(mask1,1<<h){
		rep(mask2,1<<w){
			int cnt=0;
			rep(i,h){
				rep(j,w){
					if(mask1&(1<<i) || mask2&(1<<j))continue;
					cnt+=c[i][j]=='#';
				}
			}
			ans+=cnt==k;
		}
	}
	cout<<ans;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {        
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    if (k > *max_element(v.begin(), v.end())) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int g = v[0];
    int flag = 0;
    for (int i = 1; i < n; i++) {
        g = gcd(g, v[i]);
        if (v[i] == k) flag = 1;
    }
    if (abs(v[0] - k) % g == 0) flag = 1;
    if (flag) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 3152
package main

import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanLines)

  sc.Scan()
  s := sc.Text()

  yymm := false
  mmyy := false

  a, _ := strconv.Atoi(s[:2])
  if a > 0 && a < 13 {
    mmyy = true
  }
  a, _ = strconv.Atoi(s[2:])
  if a > 0 && a < 13 {
    yymm = true
  }

  if yymm && mmyy {
    fmt.Println("AMBIGUOUS")
  } else if yymm {
    fmt.Println("YYMM")
  } else if mmyy {
    fmt.Println("MMYY")
  } else {
    fmt.Println("NA")
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=2e5+20;
const ll mod=1e9+7;
ll f[N],n,m,A,B;
ll powmod(ll x,ll n)
{
    ll s=1;
    while(n){
        if(n&1)
            s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
ll C(ll n,ll m)
{
    ll a=f[n];
    ll b=(f[m]*f[n-m])%mod;
    return (a*powmod(b,mod-2))%mod;
}
int main()
{
    f[0]=1;
    for(ll i=1;i<N;i++)
        f[i]=(f[i-1]*i)%mod;
    while(cin>>n>>m>>A>>B){
        ll res=0;
        for(ll i=B+1;i<=m;i++){
            ll tmp=(C(i-1+n-A-1,n-A-1)*C(m-i+A-1,m-i))%mod;
            res=(res+tmp)%mod;
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
import math

a,b,h,w = map(int, input().split())
if w == 0:
    c = abs(h*30-360)
else:
    c = min(abs(h*30-w*5.5), abs(w*5.5-h*30))

cosc = math.cos(math.radians(c))

print(math.sqrt(a**2 + b**2 - 2*a*b*cosc))

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	long long A[100010] = {};
	int mx = 0; 
	vector<int> place, value; 
	place.push_back(0); value.push_back(0); 
	for(int i = 1; i <= N; i++){
		cin >> A[i];
		if(A[i] > mx){
			mx = A[i]; place.push_back(i); 
			value.push_back(A[i]); 
		}
	}
	long long Full[100010] = {}; 
	long long full[100010] = {}; 
	long long ans[100010] = {}; 
	for(int i = 1; i <= N; i++){
		int a = lower_bound(value.begin(), value.end(), A[i]) - value.begin(); 
		ans[place[a]] += A[i] - value[a-1]; 
		Full[a-1] ++; 
	}
	for(int i = N + 2; i >= 0; i--){
		full[i] = full[i+1] + Full[i]; 
	}
	for(int i = 1; i < place.size(); i++){
		ans[place[i]] += (value[i] - value[i-1]) * full[i]; 
	}
	for(int i = 1; i <= N; i++) cout << ans[i] << "\n"; 
}

Measured memory_bytes: 5236