akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num; ++i)
		{
			std::getline(sstr, buf, delim);
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

	struct Process
	{
		std::string name;
		int time;
	};
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;

	std::array<int, 2> ar = GetValue<2>(stream);
	int process_num = ar[0];
	int quantum = ar[1];

	std::queue<Process> q;

	for (int i = 0; i < process_num; ++i)
	{
		std::vector<std::string> temp = GetValueString(stream, 2, ' ');

		q.push({ temp[0], std::stoi(temp[1]) });
	}

	int total_time = 0;

	while (!q.empty())
	{
		Process process = q.front();
		process.time -= quantum;
		total_time += quantum;
		total_time += std::min(0, process.time);

		q.pop();
		if (0 < process.time)
		{
			q.push(process);
		}
		else
		{
			std::cout << process.name << ' ' << total_time << std::endl;
		}
	}
}



Measured memory_bytes: 6316
A, B, K = map(int, input().split())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

def divisors(n):
    div = []
    A = 1
    while A*A <= n:
        if n%A == 0:
            if A*A == n:
                div += [A]
            else:
                B = n//A
                div += [A, B]
        A += 1
    div.sort()
    return div

g = gcd(A, B)
v = divisors(g)
v.reverse()
print(v[K-1])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int l = s.length();
  
  int ans = 0;
  for(int i=0;i<l/2;i++){
    if(s[i] != s[l - i - 1]) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

int main()
{
	std::uint32_t n;
	std::cin >> n;
	for (std::uint32_t i = 0; i < n; ++i) {
		bool is_collect_rank = true;
		std::uint16_t b = 0, c = 0;
		for (std::uint16_t j = 0; j < 10; ++j) {
			std::uint16_t num;
			std::cin >> num;
			if (b > num && c > num) {
				is_collect_rank = false;
			}
			else if (b < num && c > num) {
				b = num;
			}
			else if (b > num && c < num) {
				c = num;
			}
			else {
				(b > c ? b : c) = num;
			}
		}
		std::cout << (is_collect_rank ? "YES" : "NO") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1148
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
int c[N], sum[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
  }
  n = unique(c, c + n) - c;
  sum[c[n - 1]] = 1;
  for (int i = n - 1; i > 0; --i) {
    sum[c[i - 1]] += sum[c[i]];
    sum[c[i - 1]] %= MOD;
  }
  printf("%d\n", sum[c[0]]);
  return 0;
}


Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
long long int max(long long int a,long long int b)
{
        if(a>b)
                return(a);
        return(b);
}
int main()
{
  
         long long int n,k,i,j;
                cin>>n;
        long long int p[n];
        for(i=0;i<n;i++)
        {
                cin>>p[i];
        }
        long long int a[n];
               a[0]=1000;
        long long int s[n];
        s[0]=0;
          for(i=1;i<n;i++)
          {
                  a[i]=max(a[i-1],a[i-1]+(a[i-1]/p[i-1])*(p[i]-p[i-1]));
                  //cout<<a[i]<<endl;
          }     
        cout<<a[n-1];
   return 0;    
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string S; cin >> S;
  cout<<count(all(S),'2')<<endl;


    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
from math import factorial
n=int(input())
XY=[list(map(int,input().split())) for _ in range(n)]

ans=0
for A in permutations(XY,n):
    cnt=0
    for j in range(n-1):
        cnt +=((A[j][0]-A[j+1][0])**2+(A[j][1]-A[j+1][1])**2)**0.5
    ans +=cnt
print(ans/factorial(n))

Measured memory_bytes: 41196
#include<iostream>

#include <bits/stdc++.h>
using namespace std;

int main()
{
  int N,K,X,J=0;
  cin>>N>>K;
  vector<int> v;
  for(int i=0;i<N;i++)
  {
    cin>>X;
    v.push_back(X);
  }
   sort(v.begin(),v.end());

for(int i=0;i<K;i++)
{
  J+=v[i];
}
cout<<J<<endl;

return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]);
    for (int j = 1; j <= i; j++) {
      dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
      dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
    }
  }
  double ans = 0;
  for (int i = (N + 1) / 2; i <= N; i++) {
    ans += dp[N][i];
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 70784
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int N = 1e6+10;
string s;
vector<int> v[N];
int n,m;
int a[N],x[10], y[10];

int kaijo(int a) {
  if(a == 0) return 1;
  return a * kaijo(a-1);
}

int main () {
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i,n) {
    cin >> x[i] >> y[i];
  }
  double result = 0;
  rep(i,n-1) {
    for(int j= i+1; j < n; j++) {
      result += sqrt((pow(x[i] - x[j],2) + pow(y[i] - y[j],2)));
    }
  }
  double g = (double)(n-1) / ((double)(n-1)*n/2.0) ;
  pd(g * result);
  br();
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
#define PI 3.14159265 
using namespace std;

int main()
{
	long long int a, b, c, d, pro1, pro2, pro3, pro4, pro5, pro6, pro7;

	cin >> a >> b >> c >> d;

	pro1 = a*c;
	pro2 = a*d;
	pro3 = b*c;
	pro4 = b*d;

	pro5 = max(pro1, pro2);
	pro6 = max(pro3, pro4);
	pro7 = max(pro5, pro6);

	cout << pro7;

  	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
//SUPER FACIL, SI TENGO EL STRING AAABBCCCC VEO LAS VECES QUE SE REPITEN Y SACO UN NUMERO  DESPUES MULTIPLICO POR T, SI ES QUE ES 
// DE LA FORMA AAABBAAAA AHORA AL REPETIRSE QUEDARAN LAS A DEL INICIO Y DEL FINAL JUNTAS, ASI QUE AHI HAY QUE HACER OTRO TRUCAZO
using namespace std;

int main(){
	string S; long long int K;
	cin>>S; cin>>K;
	
	int N = S.length();
	
	int DER = 0;
	int IZQ = 0;
	int SWITCH = 0;		
	char P = S.at(0);
	for(int i = 0; i < N; i++){
		char A = S.at(i);
		if(A == P) IZQ = IZQ + 1;
		else if(A != P){
			SWITCH = 1; 
			break;
		}
	}
	if(SWITCH == 1){
		for(int i = N-1; i >= 0; i--){
			char A = S.at(i);
			if(A == P) DER = DER + 1;
			else if(A != P) break;
		}
	}
	
	if(S.at(0) == S.at(N-1) and SWITCH == 0){ //SOLO UNA LETRA
		long long int sol = (N * K) / 2;
		cout<<sol;
	}
	
	else if(S.at(0) == S.at(N-1) and SWITCH == 1){ //CASO PROBLEMATICO
		
		
		//cout<<"izq: "<<IZQ<<endl;
		//cout<<"der: "<<DER<<endl;
		
		int contadorK = 0;
		int contadorC = 1;
		
		for(int i = 0; i < N-1; i++){
			char L = S.at(i);
			char R = S.at(i+1);
			
			if(L == R){
				contadorC = contadorC + 1;
				if(i == N-2){
					int Kambios = contadorC / 2;
					contadorK = contadorK + Kambios;
					contadorC = 1;
				}
			}
			
			else{
				int Kambios = contadorC / 2;
				contadorK = contadorK + Kambios;
				contadorC = 1;
			}	
		}
		
		if(DER % 2 == 0 or IZQ % 2 == 0){ //TODO BIEN
			long long int sol = contadorK * K;
			cout<<sol;
		}
		else{ //TODO MAL
			long long int sol = contadorK * K +  (K - 1);
			cout<<sol;
		}
	}
	
	else{ //CASO FACIL
		int contadorK = 0;
		int contadorC = 1;
		
		for(int i = 0; i < N-1; i++){
			char L = S.at(i);
			char R = S.at(i+1);
			
			if(L == R){
				contadorC = contadorC + 1;
				if(i == N-2){
					int Kambios = contadorC / 2;
					contadorK = contadorK + Kambios;
					contadorC = 1;
				}
			}
			
			else{
				int Kambios = contadorC / 2;
				contadorK = contadorK + Kambios;
				contadorC = 1;
			}	
		}
		long long int sol = contadorK * K;
		cout<<sol;
	}
	
	return 0;
}

Measured memory_bytes: 256
using System;
   class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String a = Console.ReadLine();
                if (a == null) break;
                int N = int.Parse(a);
                int count = 0;
                for (int i=0;i<10;i++)
                {
                    for (int j = 0;j <10; j++)
                    {
                        for (int k = 0; k <10; k++)
                        {
                            int sum = i + j + k;
                            if (N - sum < 10 && N - sum >= 0) count++;
                        }
                    }
                }
                Console.WriteLine(count);
            }
        }
    }


Measured memory_bytes: 15872
#include <iostream>


int main() {
	int a, b;
	std::string op;
	while (std::cin >> a >> op >> b && op != "?") {
		int sol;
		op == "+" ? sol = a + b :
			op == "-" ? sol = a - b :
			op == "*" ? sol = a * b :
			sol = a / b;
		std::cout << sol << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3164
def plan_one(time, price_base):
    price = time * price_base
    return price

if __name__ == "__main__":
    input_list = input().split(" ")
    N, A, B = int(input_list[0]), int(input_list[1]), int(input_list[2])
    price = min(plan_one(N, A), B)
    print(price)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
ll n;
inline ll S(ll l,ll r){return (l+r)*(r-l+1)/2;}
int main(){
	scanf("%lld",&n);
	int lim=sqrt(n+0.2);
	ll ans=0;
	for(ll now=lim+1,d,nxt;now<=n;now=nxt+1){
		d=n/now;
		nxt=n/d;
		ll x=n-d,l=x/nxt,r=x/now;
		for(ll i=max(1ll,l);i<=r;++i){
			if(x%i==0)if(x/i>=now&&x/i<=nxt)ans+=x/i;
		}
		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        long a = stdIn.nextLong();
        long b = stdIn.nextLong();
        long c = stdIn.nextLong();
        long d = stdIn.nextLong();

        long max = Long.MIN_VALUE;
        if(max < a * c)
            max = a * c;
        if(max < a * d)
            max = a * d;
        if(max < b * c)
            max = b * c;
        if(max < b * d)
            max = b * d;
        
        System.out.println(max);
    }
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> fmax(n), bmax(n);
    rep(i, n) {
        chmax(fmax[i], a[i]);
        if (i-1 >= 0) chmax(fmax[i], fmax[i-1]);
    }
    rrep(i, n) {
        chmax(bmax[i], a[i]);
        if (i+1 < n) chmax(bmax[i], bmax[i+1]);
    }

    rep(i, n) {
        if (i == 0) cout << bmax[1] << '\n';
        else if (i == n-1) cout << fmax[n-2] << '\n';
        else cout << max(fmax[i-1], bmax[i+1]) << '\n';
    }
}


Measured memory_bytes: 5576
#include <stdio.h>

int main(){
  int K;
  int A,B;
  scanf("%d¥n",&K);
  scanf("%d %d",&A,&B);
  
  int i;
  
  for(i = A;i <= B;i++){
    if(i % K ==0){
      printf("OK");
      break;
    }else if(i == B){
      printf("NG");
      break;
    }
  }
  
  return 0;
}



Measured memory_bytes: 1736
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc;


  static final int MID = 20;

  void run() {
    for (; ; ) {
      int r = ni();
      int n = ni();

      if ( (r | n) == 0 ) {
        break;
      }

      boolean[][] field = new boolean[ 32 ][ 64 ];
      for ( int i = 0; i < n; ++i ) {
        int xl = ni();
        int xr = ni();
        int h = ni();

        for ( int k = 1; k <= h; ++k ) {
          for ( int j = xl; j < xr; ++j ) {
            field[ k ][ j + MID ] = true;
          }
        }
      }
      int[] hs = new int[ 32 ];
      for ( int i = 1; i <= 20; ++i ) {
        for ( int w = 1; field[ i ][ MID + w - 1 ] && field[ i ][ MID - w ]; ++w ) {
          hs[ i ] = w;
        }
      }

      // p1
//      debug(hs);
      int h = 0;
      for ( int i = 1; i <= 20; ++i ) {
        if ( hs[ i ] < r ) {
          break;
        }
        ++h;
      }
      // p2
      double dh = 0;
      double right = r;
      while ( right - dh > 1e-6 ) {
        double mid = (dh + right) / 2;
        boolean flag = true;

//        debug(dh, mid, right);
        for ( int i = 0; i <= mid; ++i ) {
          double theta = Math.acos((r - (mid - i)) / r);
          double w = r * Math.sin(theta);
//          debug("\t", w, hs[h + i + 1]);
          flag &= hs[ h + i + 1 ] >= w;
        }

        if ( flag ) {
          dh = mid;
        } else {
          right = mid;
        }
      }

//      debug(h, dh);

      System.out.printf("%.4f\n", h + dh);
//      System.out.println(h + dh);
    }
  }

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 31116
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 5005;

vector<int> G[MAX_N];
int mult[MAX_N];

inline int add(int x,int y)
{
    return (x+y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

// 最上位の連結成分内の頂点数, 条件を満たさないものの偶奇
vvi dfs(int u, int p)
{
    vvi dp(2, vi(2, 0));
    dp[1][0] = 1;
    each(v,G[u]){
        if(v != p){
            auto res = dfs(v, u);
            vvi ndp(len(dp)+len(res)-1, vi(2, 0));
            srep(j,1,len(dp)){
                srep(k,1,len(res)){
                    // つなげる
                    rep(l,2){
                        rep(m,2){
                            ndp[j+k][l^m] = add(ndp[j+k][l^m], mul(dp[j][l], res[k][m]));
                        }
                    }
                    if(k % 2) continue;
                    // つなげない
                    rep(l,2){
                        rep(m,2){
                            ndp[j][!(l^m)] = add(ndp[j][!(l^m)], mul(dp[j][l], mul(res[k][m], mult[k])));
                        }
                    }
                }
            }
            swap(dp, ndp);
        }
    }
    return dp;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        G[u-1].pb(v-1), G[v-1].pb(u-1);
    }
    mult[2] = 1;
    for(int i = 3; i < n; i += 2){
        mult[i+1] = mul(mult[i-1], i);
    }
    auto res = dfs(0,-1);
    int ans = 0;
    srep(i,1,n+1){
        if(i % 2 == 0) ans = add(ans, mul(mult[i], sub(res[i][0], res[i][1])));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1988
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#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[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

#define MAX_N (ll)2E7///変更！！！！！！！
vector<int>prime;
bool is_prime[MAX_N+1];
void precal(){
    rep(i,0,MAX_N)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,MAX_N){
        if(is_prime[i]){
            prime.pb(i);
            for(int j=2*i;j<=MAX_N;j+=i)is_prime[j]=false;
        }
    }
}
vector<i_i> fact(ll n){//ただし2<=n<=MAX_N^2
    vector<i_i>v;
    for(int p:prime){
        if(p*p>n)break;
        int c=0;
        while(n%p==0){
            n/=p;
            c++;
        }
        if(c)v.pb(i_i(p,c));//pという素因数がc個入っている
    }
    if(n!=1){
        int vsize=v.size();
        if(vsize>=1&&v[vsize-1].first==n)v[vsize-1].second++;
        else v.pb(i_i(n,1));
    }
    return v;
}
/////////////////////////////////////////////////////

int main(){
    ll n;cin>>n;
    precal();
    ll a[200];memset(a,0,sizeof(a));
    rep(i,2,n){
        vector<i_i>v=fact(i);
        for(auto x:v){
            a[x.first]+=x.second;
        }
    }
   /* rep(i,0,100){
        cout<<i<<" "<<a[i]<<endl;
    }cout<<endl;*/
    ll ans=0;
    rep(i,2,100){
        if(a[i]>=74)ans++;
    }
    int b[2][2]={{24,14},{2,4}};
    rep(i,2,100){
        rep(j,0,1){
            if(a[i]>=b[0][j]){
                rep(k,2,100){
                    if(k==i)continue;
                    if(a[k]>=b[1][j])ans++;
                }
            }
        }
    }
    rep(i,2,100){
        if(a[i]>=4){
            rep(j,i+1,100){
                if(a[j]>=4){
                    rep(k,2,100){
                        if(i==k||j==k)continue;
                        if(a[k]>=2)ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 30060
import heapq
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
for i in range(len(A)):
    A[i] = A[i]*(-1)
heapq.heapify(A)
for i in range(M):
    maxa = heapq.heappop(A)
    maxa = -1 * maxa
    maxa = maxa//2
    maxa = -1 * maxa
    heapq.heappush(A,maxa)
print(-sum(A))

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

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

    vector <vector<int>> G(n + 1);
    vector <pair<int, int>> ans;

    if(n % 2 == 0){
        for(int now = 1; now <= n; now ++){
            for(int to = 1; to < n + 1; to ++){
                if(to + now == n + 1 || to == now) continue;
                if(find(G.at(now).begin(), G.at(now).end(), to) != G.at(now).end()) continue;
                ans.push_back(make_pair(now, to));
                G.at(now).push_back(to);
                G.at(to).push_back(now);
            }
        }
    }
    else{
        for(int i = 1; i < n; i ++){
            G.at(n).push_back(i);
            G.at(i).push_back(n);
            ans.push_back(make_pair(i, n));
        }
        n -= 1;
        for(int now = 1; now <= n; now ++){
            for(int to = 1; to < n + 1; to ++){
                if(to + now == n + 1 || to == now) continue;
                if(find(G.at(now).begin(), G.at(now).end(), to) != G.at(now).end()) continue;
                ans.push_back(make_pair(now, to));
                G.at(now).push_back(to);
                G.at(to).push_back(now);
            }
        }
    }

    cout << ans.size() << endl;
    for(auto P: ans){
        cout << P.first << " " << P.second << endl;
    }
}

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

int main(){
	char a;
	cin >> a;
	if(a - 'a' < 0){
		cout << 'A' << endl;
	}else{
		cout << 'a' << endl;
	}
    return 0;
}



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

using namespace std;

const int N = (1 << 18);
int n, a[N];

vector<int> sub[N], ans(N);

signed main(){
	cin >> n;
	for(int i = 0; i < (1 << n); ++i) cin >> a[i], sub[i].push_back(a[i]);
	for(int j = 0; j < n; ++j){	
		for(int i = 0; i < (1 << n); ++i){
			if(!(i & (1 << j))){
				for(auto v : sub[i]) sub[i | (1 << j)].push_back(v);
				sort(sub[i | (1 << j)].rbegin(), sub[i | (1 << j)].rend());
				while(sub[i | (1 << j)].size() > 2) sub[i | (1 << j)].pop_back();
			}
		}
	}
	for(int i = 1; i < (1 << n); ++i){
		ans[i] = max({ans[i], ans[i - 1], sub[i][0] + sub[i][1]});
	}
	for(int i = 1; i < (1 << n); ++i) cout << ans[i] << '\n';
	
}

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

int main(){
    unsigned long long int x,count,yen;
    count = 0;
    yen = 100;
    cin >> x;
    while(yen < x){
        yen *= 1.01;
        count++;
    }
    cout << count << endl;
    return 0;
}


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

int main(){
  int a;
  cin >> a;
  if(a==0)cout << "NA"<<endl;
  else if(a/100>=13&&a%100==0)cout << "NA"<<endl;
  else if(a/100==0&&a%100>=13)cout << "NA"<<endl;
  else if(a/100>=13&&a%100>=13)cout << "NA"<<endl;
  else if(a/100<=12&&a%100==0)cout << "MMYY"<<endl;
  else if(a/100==0&&a%100<=12)cout << "YYMM"<<endl;
  else if(a/100>=13)cout << "YYMM"<<endl;
  else if(a%100>=13)cout << "MMYY"<<endl;
  else cout << "AMBIGUOUS"<<endl;
}

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

using namespace std;

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

  int sum = 0;
  vector<int> s(N);
  for (int i = 0; i < N; ++i) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s.begin(), s.end());

  if (sum % 10 != 0) {
    cout << sum << endl;
    return 0;
  }
  for (int i = 0; i < N; ++i) {
    if ((sum - s[i]) % 10 != 0) {
      cout << sum - s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> v(n); rep(i,n) cin >> v[i];
    sort(all(v));
    bool f = true;
    for(int i=1;i<n;i++){
        if(v[i]==v[i-1]){f = false; break;}
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << 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  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

LL GCD(LL a,LL b){ //ユークリッドの互助法で最大公約数
    if (a%b == 0){
        return b;
    }
    else {
        return GCD(b,a%b);
    }
}

int main(){
    int N;
    LL X; cin >> N >> X ;
    LL y;
    LL temp;
    rep(i,N){
        cin >> y ;
        if(i == 0)temp = abs(y-X);
        LL yab = abs(y-X);
        temp = GCD(temp,yab);           
    }
    cout << temp << endl;
}

Measured memory_bytes: 256
def main():
    A,B = map(int, input().split())
    for i in range(50000):
        a = int(i * 0.08)
        b = int(i * 0.1)
        if a==A and b == B:
            print(i)
            return

    print(-1)






if __name__ == '__main__':
    main()

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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcode abc 176
//A

int main(){
    string s;
    cin>>s;
    long long a= 0;

    for (int i = 0; i < s.length(); ++i)
    {
        a+=s[i]-'0';
    }

    if(a%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 3744
#include <stdio.h>

int main(void){
	int data[3];
	int sum;
	
	while(1){
		scanf("%d %d %d", &data[0], &data[1], &data[2]);
		if(data[0] == -1 && data[1] == -1 && data[2] == -1){
			return 0;
		}
		sum = data[0] + data[1];
		
		if(data[0] == -1 || data[1] == -1){
			printf("F\n");
		}
		else if(sum >= 80){
			printf("A\n");
		}
		else if(65 <= sum && sum < 80){
			printf("B\n");
		}
		else if(50 <= sum && sum < 65){
			printf("C\n");
		}
		else if(30 <= sum && sum < 65){
			if(data[2] >= 50){
				printf("C\n");
			}
			else{
				printf("D\n");
			}
		}
		else{
			printf("F\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, K, a;
  pair<int,int> p[SIZE];

  scanf("%d%d", &N, &K);
  K++;

  ll ok = true;
  ll sum = 0;

  for(int i=0;i<N;i++){
    scanf("%d", &a);
    p[i] = {a, i};

    sum += a;
    ok &= a >= (K+1) / 2;
  }

  ok &= sum >= K * N - (K - 1);

  sort(p, p+N);

  if (ok){
    set<pair<int,int> > ss;
    vector<int> vec;
    for(int i=0; i<N; i++) {
      int q = max(0, K - p[i].first);
      ss.insert({-q, p[i].second});
    }

    int prev = -1;
    for(int i=0;ss.size();i++){
      auto it = ss.begin();
      if(prev == it->second) it++;
      auto p = *it;
      ss.erase(it);
      vec.push_back(p.second);
      prev = p.second;
      p.first++;
      if (-p.first > 0) ss.insert(p);
      debug(prev);
    }

    vector<int> ans;

    for(int i=0;i<K;i++) {
      int r = -1;
      int next = -1;

      if (i <= vec.size() && i > 0) {
        r = vec[i-1];
      }

      if (i < vec.size()) {
        next = vec[i];
      }

      for(int j=0; j<N; j++){
        if (r != j && next != j)
          ans.push_back(j);
      }
      if (next != -1)
        ans.push_back(next);

      debug(ans.size());
    }

    printf("%d\n", (int)ans.size());

    for(int i=0;i<ans.size();i++){
      printf("%d%c", ans[i] + 1, " \n"[i+1 == ans.size()]);
    }

  } else {
    puts("-1");
  }

  return 0;
}

/*
0 0 0 0 1
2 1 1 1
  2 2 2 3
4 3 3 3
  4 4 4 5
6 5 5 5
  6 6 6 7
8 7 7 7

N / 2 + 1
(N+1) / 2
N


0 0 0 0 1
1 1 1 2
3 2 2   2
  3 4 3 3
4 5   4 4
5   5 5 6
* * * *

  1 1 1
2 2 2 2 3
  3 3 3
4 4 4 4 5
  5 5 5
6

0 1
2
  3
4
  5
*
 */


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

#define lint long long
#define all(it) it.begin(), it.end()
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"
lint INF = 2e18;
lint MOD = 1e9 + 7;

lint i, j, k, t;

pair<lint, lint> div(lint n) {
    pair<int, int> ret = {0, 0};
    while(true) {
        if(n % 2 == 0) {
            ret.first += 1;
            n /= 2;
        } else if(n % 5 == 0) {
            ret.second += 1;
            n /= 5;
        } else {
            break;
        }
    }
    return ret;
}

int main() {

    lint N;
    cin >> N;

    map<pair<lint, lint>, lint> count25;

    FOR(i, N) {
        string s;
        cin >> s;

        string g;
        if(count(s.begin(), s.end(), '.') != 0) {
            while(s.back() != '.') {
                g.push_back(s.back());
                s.pop_back();
            }
            s.pop_back();
            reverse(g.begin(), g.end());
        }
        while((int)g.length() < 9)
            g.push_back('0');

        lint x = stoi(s) * 1000000000LL + stoi(g);
        count25[div(x)] += 1;
    }

    vector<pair<lint, lint>> keys;
    for(const auto &it : count25) {
        keys.emplace_back(it.first);
    }

    lint ans = 0;
    for(auto &k1 : keys) {
        for(auto &k2 : keys) {
            if(k1.first + k2.first >= 18 && k1.second + k2.second >= 18) {
                if(k1.first == k2.first && k1.second == k2.second) {
                    ans += count25[k1] * (count25[k1] - 1);
                } else {
                    ans += count25[k1] * count25[k2];
                }
            }
        }
    }
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 3632
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  REP(i,h)cin>>s[i];
  REP(i,h){
    REP(q,w){
      if(s[i][q]=='.'){
        int sum=0;
        if(q!=w-1)if(s[i][q+1]=='#')sum++;
        if(q!=0)if(s[i][q-1]=='#')sum++;
        if(i!=h-1)if(s[i+1][q]=='#')sum++;
        if(i!=0)if(s[i-1][q]=='#')sum++;
        if(i!=h-1)if(q!=w-1)if(s[i+1][q+1]=='#')sum++;
        if(i!=0)if(q!=0)if(s[i-1][q-1]=='#')sum++;
        if(i!=h-1)if(q!=0)if(s[i+1][q-1]=='#')sum++;
        if(i!=0)if(q!=w-1)if(s[i-1][q+1]=='#')sum++;
        s[i].replace(q,1,to_string(sum));
      }
    }
  }
  REP(i,h){
    cout<<s[i]<<endl;
  }

}


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

const int N = 200 * 1000 + 20;
int n, a[N], b[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	cout << (n % 2 == 1? b[n / 2] - a[n / 2]: (b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1])) + 1 << "\n";
}


Measured memory_bytes: 5204
#include <iostream>
#include <istream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
//#include <unordered_map>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std;

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

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

#define fopen freopen("substrcmp.in", "r", stdin); freopen("substrcmp.out","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define IOSFAST ios::sync_with_stdio(false); cin.tie(0)

const ll MOD = 1000LL * 1000 * 1000 + 7;
const int INF = 1e9;
const ll base = 1e18;
const int MAX = 1000;
const double EPS = 1e-9;
const double PI = acos(-1.);

int main()
{
	int n,m;
	string s;
	cin >> s;
	if (s.size()>=4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
	{
		cout << "Yes";
		return 0;
	}
	cout << "No";



	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))



sho=1
dai=max(a)
for jfdlas in range(100):
    now=(sho+dai)//2
    gokei=0
    for i in range(n):
        gokei+=(a[i]-1)//now
        #print(gokei)
        if(gokei>k):
            sho=now
            continue
    if(gokei<=k):
        dai=now
    else:
        sho=now
    #print(now,gokei,sho,dai)


print(dai)
#gokei=0
#for i in range(n):
#    gokei+=(a[i]-1)//
#if(gokei>k):
#    print(sho)
#else:
#    print(dai)

Measured memory_bytes: 93892
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll hell=pow(10,9)+7;
ll func(ll n){
	return n*(n+1)/2;
}
void solve(){
	ll n,k;
	cin>>n>>k;
	ll res=0;
	for(ll i=k;i<=n+1;i++){
		ll val=n*i-func(i-1)-func(i-1)+1;
		res+=val%hell;
		res%=hell;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> q;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    q.push(A);
  }

  for (int i = 0; i < M; i++) {
    int a = q.top(); q.pop();
    q.push(a/2);
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main()
{
  long long D,T,S; cin>>D>>T>>S;
  cerr<<D<<", "<<S*T<<endl;
  if (D<=T*S){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
using static System.Math;
using System;

public class Hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var a = int.Parse(line[0]);
		var b = int.Parse(line[1]);
		var c = int.Parse(line[2]);
		Console.WriteLine(Max(0, c - a + b));
	}
}

Measured memory_bytes: 13140
#include <stdio.h>

void gcd(int x, int z) {
  int w = 1;
  while (w) {
    w = x % z;
    if (w != 0) {
      x = z;
      z = w;
    }
  }
  printf("%d\n", z);
}

int main() {
  int x, y, z;

  scanf("%d %d", &x, &y);
  if (x > y) {
    z = x % y;
    gcd(y, z);
  } else if (x < y) {
    z = y % x;
    gcd(x, z);
  } else {
    printf("%d\n", x);
  }
  return 0;
}



Measured memory_bytes: 2080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = scanner.nextLong();
        long b = scanner.nextLong();

        long result1 = n / (a + b) * a;
        long result2 = Math.min(n % (a + b), a);
        System.out.println(result1 + result2);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct edge{
    int to, cap, rev;
    edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev){}
};

struct Dinic{
    int size;
    vector< vector<edge> > edg;
    vector< int > dst, mem;

    void init(int n){
        size = n;
        edg.assign(size, vector<edge>());
    }

    void add_edge(int from, int to, int cap){
        edg[from].push_back(edge(to, cap, edg[to].size()));
        edg[to].push_back(edge(from, 0, edg[from].size() - 1));
    }

    void cal_dist(int s){
        dst.assign(size, -1);
        queue<int> q;
        dst[s] = 0;
        q.push(s);
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for(int i=0;i<edg[v].size();i++){
                edge &e = edg[v][i];
                if(e.cap > 0 && dst[e.to] < 0){
                    dst[e.to] = dst[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    int flow(int v, int t, int f){
        if(v == t) return f;
        for(int &i = mem[v]; i < edg[v].size(); i++){
            edge &e = edg[v][i];
            if(e.cap > 0 && dst[v] < dst[e.to]){
                int d = flow(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    edg[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t){
        int res = 0;
        for(;;){
            cal_dist(s);
            if(dst[t] < 0) return res;
            mem.assign(size, 0);
            int f = 0;
            do{
                res += f;
                f = flow(s, t, 1e9);
            }while(f > 0);
        }
    }
};

int main(void){
    int h, w, source, sink;
    string brd[100];
    Dinic f;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> brd[i];
    }
    f.init(h*w*2);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int id = i*w+j;
            if(brd[i][j] == '.') continue;
            if(brd[i][j] == 'S') source = id;
            if(brd[i][j] == 'T') sink = id;
            f.add_edge(id+h*w, id, 1);
            for(int k=0;k<h;k++){
                if(k != i && brd[k][j] != '.'){
                    f.add_edge(id, k*w+j+h*w, h+w);
                }
            }
            for(int k=0;k<w;k++){
                if(k != j && brd[i][k] != '.'){
                    f.add_edge(id, i*w+k+h*w, h+w);
                }
            }
        }
    }
    int ans = f.max_flow(source, sink+h*w);
    if(ans >= h+w) ans = -1;
    cout << ans << endl;
}


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

int main() {
  long int A, B, N;
  scanf("%ld", &N);

  int sum = 0; 
  switch (N){
    case 100000:
    case 10000:
    case 1000:
    case 100:
    case 10:
      sum = 10;
    break;
    default:
      while (N != 0) { 
        sum += N % 10; 
        N = N/10; 
      } 
  }

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


Measured memory_bytes: 128