akhauriyash/Code-Regression huggingface dataset:
/*
 *  * main.cpp
 *   *
 *    */

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

int A[300000];
int MOD = 1000000007;
long long BIT[100];

long long compute(int n, int a) {
    long long res = 1;
    int r =  a > n - a ? n - a : a;

    for (int i = 0; i < r; ++i) res = (res * (n - i)) % MOD;

    for (int i = 1; i <= r; ++i) {
        if (res < i) res += MOD;
        res /= i;
        res %= MOD;
    }

    return res;
}
#define ll long long
 
ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll nCr(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

int main() {

    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);


    long long res = 1;
    BIT[0] = 2;
    for (int i = 1; i < 32; ++i) BIT[i] = (BIT[i - 1] * BIT[i - 1]) % MOD;

    for (int i = 0; i < 31; ++i) {
        if ((n & (1 << i)) != 0) res = (res * BIT[i]) % MOD;
    }

    res--;
    if (n >= a)
    res = (res + 2 * MOD - nCr(n, a, MOD)) % MOD;

    if (n >= b)
    res = (res + 2 * MOD - nCr(n, b, MOD)) % MOD;


    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using i64 = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
  mod = (i64)mod;
  i64 res = 1, p = a % mod;
  while (n) {
    if (n & 1) res = res * p % mod;
    p = p * p % mod;
    n >>= 1;
  }
  return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
  cout << sizeof...(rest) << endl;
  std::cout << first;
  if (sizeof...(rest)) std::cout << " ";
  print(rest...);
}
template <typename... A>
void print(const A&... rest) {
  print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
  std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
  std::cout << std::endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  int cnt[26] = {};
  rep(i, h) {
    string a;
    cin >> a;
    for (auto& ai : a) {
      cnt[ai - 'a']++;
    }
  }
  if (!(h & 1) && !(w & 1)) {
    rep(i, 26) {
      if (cnt[i] % 4 == 0) {
        continue;
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else if ((h & 1) && (w & 1)) {
    int cnt_odd = 0;
    int cnt_mod_2 = 0;
    rep(i, 26) {
      if (cnt[i] & 1) {
        cnt_odd++;
        cnt[i]--;
      }
      if (cnt[i] % 4 == 2) {
        cnt_mod_2++;
        cnt[i] -= 2;
      }
    }
    if (cnt_odd != 1 || !(cnt_mod_2 <= (h / 2) + (w / 2))) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, 26) {
      if (cnt[i] % 4 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;

  } else {
    int cnt_mod_2 = 0;
    rep(i, 26) {
      if (cnt[i] % 4 == 2) {
        cnt_mod_2++;
        cnt[i] -= 2;
      }
    }
    if (!(cnt_mod_2 <= ((w & 1) ? h / 2 : w / 2))) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, 26) {
      if (cnt[i] % 4 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
long long dfs(long long now,long long num){
	if(now==1){
		return num;
	}else{
		return dfs(now/2,num*2)+num;
	}
}
int main(){
	long long h;
	cin>>h;
	cout<<dfs(h,1)<<endl;
	return 0;
}


Measured memory_bytes: 256
def c_switches(N, M, Switches, P):
    import numpy as np

    def rank_matrix(matrix, is_extended=False):
        num_row = matrix.shape[0]
        num_col = matrix.shape[1]
        rank = 0

        for col in range(num_col):
            # if is_extended and col == num_col - 1:
            #     break

            pivot = -1
            ma = 0
            for row in range(rank, num_row):
                if matrix[row][col] > ma:
                    ma = matrix[row][col]
                    pivot = row
            if pivot == -1:
                continue

            tmp = matrix[pivot, :].copy()
            matrix[pivot, :] = matrix[rank, :]
            matrix[rank, :] = tmp

            for row in range(num_row):
                if row != rank and matrix[row][col] == 1:
                    for col2 in range(num_col):
                        matrix[row][col2] = (matrix[row][col2] + matrix[rank][col2]) % 2
            rank += 1
        return rank

    a = np.zeros((M, N), dtype='uint8')
    for t, (_, *switches) in enumerate(Switches):
        for s in switches:
            a[t][s - 1] = 1
    p = np.reshape(P, (-1, 1))
    ap = np.concatenate((a, p), axis=1)
    rank_a, rank_ap = rank_matrix(a), rank_matrix(ap)
    return 2**(N - rank_a) if rank_a == rank_ap else 0

N, M = [int(i) for i in input().split()]
Switches = [[int(i) for i in input().split()] for j in range(M)]
P = [int(i) for i in input().split()]
print(c_switches(N, M, Switches, P))

Measured memory_bytes: 15628
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

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

void inorder(Node *u)
{
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(Node *u)
{
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main()
{
	int n,i,x;
	string com;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> com;
		if(com == "insert")
		{
			scanf("%d", &x);
			insert(x);
		}
		else if(com == "print")
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}





Measured memory_bytes: 26724
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int d,t,s;
  cin>>d>>t>>s;
  if(s*t<d){
    cout<<"No"<<'\n';
  }
  else{
    cout<<"Yes"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		long ans = 1;
		for(int i=1;i<=n;i++){
			ans*=i;
			ans%=1000000007;
		}
		
		System.out.println(ans);
	}
}


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

int main(){
    int n, q;
    long k;
    cin >> n >> k >> q;
    int score[n];
    int alist[q];

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

    for(int i = 0; i < n; i++){
        score[i] = 0;
    }
    for(int i = 0; i < q; i++){
        score[alist[i]-1]++;
    }
    
    for(int i = 0; i < n; i++){
        if((long)(score[i]) > q - (long)k){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void){
  int i,j,k,n,b,f,r,v;
  static int pe[4][3][10];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    pe[b-1][f-1][r-1]+=v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++)
        printf(" %d",pe[i][j][k]);
      printf("\n");
    }
    if(i<3) printf("####################\n");
  }
return 0;
}

Measured memory_bytes: 612
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(N):
  for _ in range(A[i]):
    ans.append(i+1)
cnt = 0
for i in range(0,H*W,W):
  if cnt % 2 != 0:
    print(*ans[i:i+W][::-1],end="\n")
  else:
    print(*ans[i:i+W],end="\n")
  cnt += 1

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	vi a;
	int mxid=0; ll mx=-1;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x; a.pb(x);
	}
	sort(a.rbegin(),a.rend());
	ll ans = a[0];
	for(int i=1;i<n-1;i++)
	{
		ans+=a[(i+1)/2];
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 5320
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    char str1[15],str2[15],str3[15];
    cin>>str1>>str2>>str3;
    int a,b;
    a=strlen(str1);
    b=strlen(str2);
    if(str1[a-1]==str2[0]&&str2[b-1]==str3[0]) cout<<"YES";
    else cout<<"NO";
    return 0;
    
}

Measured memory_bytes: 256
N, A = [int(_) for _ in input().split()]

MAX_I = 5000
memo = [[0] * MAX_I for _ in range(N + 2)]


def cnv(v):
    return v - A + (MAX_I // 2)


X = [int(_) for _ in input().split()]
for i in range(N):
    offset = X[i] - A
    # print('x', offset)

    mm = memo[i]
    for j in range(MAX_I):
        if mm[j] > 0:
            memo[i + 1][j + offset] += mm[j]
        memo[i + 1][j] += mm[j]

    memo[i + 1][cnv(X[i])] += 1

print(memo[N][MAX_I//2])


Measured memory_bytes: 5620
#import sys
#input = sys.stdin.readline

n=int(input())
s=input()
if n%2:
    print("No")
    exit()

s1=s[0:n//2]
#s2=s[n//2:]
#if s1==s2:
if s==(s1+s1):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
N=int(input())
T,A=map(int,input().split())
hlist=list(map(int,input().split()))

min_index,min_diff = -1,10**10
for i,h in enumerate(hlist):
  diff=abs(A-(T-h*0.006))
  if diff<min_diff:
    min_index,min_diff = i+1,diff
    
print(min_index)

Measured memory_bytes: 3060
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

char arr[2][3];
int flag = 0;

int main()
{
	for(int i = 0; i < 2; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> arr[i][j];
		}
	}
	if(arr[0][0] == arr[1][2] && arr[0][2] == arr[1][0] && arr[0][1]== arr[1][1])
	{
		flag = 1;
	}
	if(flag)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main(){
	int N,W;
	vector<vector<long int>>Table;
	vector<int>Weights;
	vector<int>Values;
	int i,j;
	cin>>N>>W;
	Table.reserve(N+1);
	Weights.reserve(N+1);
	Values.reserve(N+1);
	Table[0].reserve(W+1);
	//int temp;
	for(j=0;j<=W;j++){
		Table[0][j]=0;
	}
	for(i=1;i<=N;i++){
		Table[i].reserve(W+1);
		cin>>Weights[i]>>Values[i];
		for(j=0;j<=W;j++){
			if(j-Weights[i]<0){
				Table[i][j]=Table[i-1][j];
			}
			else{
				Table[i][j]=max(Table[i-1][j],Table[i-1][j-Weights[i]]+Values[i]);
			}
		}
	}
	cout<<Table[N][W];
	return 0;
}


Measured memory_bytes: 79488
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int cnt = 0;
	while (A > 0 && C > 0) {
		if (cnt % 2)A -= D;
		else C -= B;

	
		cnt++;
	}
	if (cnt % 2)cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}



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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }

int main(){

	ll N ; 
	cin >> N; 
	cout << (N*(N-1))/2 << endl; 
}


Measured memory_bytes: 384
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n = int(input())
A = get_nums_l()

# スキップできる回数
p = 1 if n%2==0 else 2
# log(p)

# dp[i][j][k] i==1なら次取れる スキップ回数をj回残してk個目まで見たときの最大和
dp = [ [ [0]*(n+1) for _ in range(p+1) ] for _ in range(2) ]

dp[0][0][0] = -999999999999999999
dp[0][1][0] = -999999999999999999
dp[1][0][0] = -999999999999999999
if p == 2:
    dp[0][2][0] = -999999999999999999
    dp[1][1][0] = -999999999999999999

# log(dp)

for k in range(n):
    dp[0][0][k+1] = dp[1][0][k] + A[k]
    dp[0][1][k+1] = dp[1][1][k] + A[k]
    dp[1][0][k+1] = max(dp[1][1][k], dp[0][0][k])
    dp[1][1][k+1] = dp[0][1][k]

    if p == 2:
        dp[0][2][k+1] = dp[1][2][k] + A[k]
        dp[1][2][k+1] = dp[0][2][k]
        #dp[1][0][k+1] = max(dp[1][0][k+1], dp[1][1][k])
        dp[1][1][k+1] = max(dp[1][1][k+1], dp[1][2][k])

# for a in dp:
#     for b in a:
#         log(b)


ans = [dp[0][0][n], dp[0][1][n], dp[1][0][n], dp[1][1][n]]
if p == 2:
    # ans.append(dp[0][2][n])
    ans.append(dp[1][2][n])
print(max(ans))



Measured memory_bytes: 111264
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        w: usize,
        mut weval: [(usize, usize); n],
    }

    weval.insert(0, (0, 0));
    let mut dp = vec![vec![1_000_000_001; 1_000_001]; n+1];

    dp[0][0] = 0;

    for i in 1..=n {
        for j in 0..1_000_000 {
            if weval[i].1 <= j {
                dp[i][j] = dp[i-1][j].min(dp[i-1][j-weval[i].1] + weval[i].0);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    let mut ans = n;
    let mut count = 0;
    for i in dp[n].iter() {
        if i <= &w {
            ans = count;
        }
        count += 1;
    }

    println!("{}", ans);
}


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

string S;
char X[100005];

int main()
{
    cin >> S;
    int moves = 0, k = 0;

    for(int i=0; i<S.size(); i++)
    {
        while(k>=2 && S[i]!=X[k-2])
            k--, moves++;

        X[k++] = S[i];
    }

    if(moves%2)
        cout << "First\n";
    else
        cout << "Second\n";

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll t(n);
  vll x(n);
  vll y(n);
  rep(i,n) cin>>t[i]>>x[i]>>y[i];
  if(abs(x[0])+abs(y[0])<=t[0]&&(abs(x[0])+abs(y[0]))%2==t[0]%2){
    if(n==1) COUT("Yes");
    for(int i=1;i<n;i++){
      if(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])<=t[i]-t[i-1]&&(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2==(t[i]-t[i-1])%2){
        if(i==n-1){
          COUT("Yes");
        }
        continue;
      }
      else{
        COUT("No");
        break;
      }
    }
    
  }
  else{
    COUT("No");
  }
}


Measured memory_bytes: 2560
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  double p[200005]={},cnt=0,ans=0;
  cin >> n >> k;
  for(int i=1; i<=n; i++) {
    cin >> p[i];
    p[i]=p[i]*(1+p[i])/2/p[i];
  }
  for(int i=1; i<=n; i++) {
    p[i]+=p[i-1];
  }
  for(int i=1; i<=n-k+1; i++) {
    ans=max(ans,p[i+k-1]-p[i-1]);
  }
  cout << fixed << setprecision(10) << ans << endl;
}

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

int main()
{
     int n,b[101],ans=0,a[101];
     cin>>n;
     for(int i=1;i<n;i++){cin>>b[i];a[i]=b[i];}
     b[0]=a[0]=b[1];

     for(int i=n-1;i>1;i--)
     {
          if(b[i]<b[i-1])
          {a[i-1]=b[i];}
     }
     for(int i=0;i<n;i++)
     {
          //cout<<a[i]<<" ";
         ans+=a[i];
     }
     //cout<<"\n";
     cout<<ans<<"\n";
}



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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N, 0);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int AA;
      cin >> AA;
      A.at(AA-1)++;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3616
//Kaori Miyazono, did I reach you ?
//"I can't die because... I'm the one who will protect you." -Asuna Yuuki

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

const int N = 100100;

int n;
long long int c;
long long int x[N], v[N];
long long int best[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> c;
	for(int i = 0; i < n; i++) cin >> x[i] >> v[i];
	long long int cur = 0;
	for(int i = n - 1; i >= 0; i--) {
		cur += v[i];
		best[i] = cur - (c - x[i]);
		if (i + 1 < n) best[i] = max(best[i], best[i + 1]);
	}
	long long int ans = 0;
	cur = 0;
	for(int i = 0; i < n; i++) {
		cur += v[i];
		ans = max(ans, cur - x[i] + max(0ll, best[i + 1] - x[i]));
	}
	memset(best, 0, sizeof best);
	cur = 0;
	for(int i = 0; i < n; i++) {
		cur += v[i];
		best[i] = cur - x[i];
		if (i > 0) best[i] = max(best[i], best[i - 1]);
	}
	cur = 0;
	for(int i = n - 1; i >= 0; i--) {
		cur += v[i];
		ans = max(ans, cur - (c - x[i]) + max(0ll, best[i - 1] - (c - x[i])));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

struct Node {int p, y, z;};
struct Node T[10000];

int n;

void preParse(int u) {
    if (u == -1) {
        return;
    }
    
    printf(" %d", u);
    
    preParse(T[u].y);
    preParse(T[u].z);
}

void inParse(int u) {
    if (u == -1) {
        return;
    }
    
    inParse(T[u].y);
    
    printf(" %d", u);
    
    inParse(T[u].z);
}

void postParse(int u) {
    if (u == -1) {
        return;
    }
    
    postParse(T[u].y);
    postParse(T[u].z);
    
    printf(" %d", u);
}

int main() {
    int i, x, y, z, root;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        T[i].p = -1;
    }
    
    for (i = 0; i < n; i++) {
        scanf("%d %d %d", &x, &y, &z);
        
        T[x].y = y;
        T[x].z = z;
        
        if (y != -1) {
            T[y].p = x;
        }
        if (z != -1) {
            T[z].p = x;
        }
    }
    
    for (i = 0; i < n; i++) {
        if (T[i].p == -1) {
            root = i;
        }
    }
    
    printf("Preorder\n");
    preParse(root);
    putchar('\n');
    printf("Inorder\n");
    inParse(root);
    putchar('\n');
    printf("Postorder\n");
    postParse(root);
    putchar('\n');
    
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
    #define ll  long long int
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define vi vector<int>
    #define br cout <<"\n";
    #define all(x)  (x).begin(),(x).end()
    #define tr(c,i) for(auto i : c)
    #define pii pair< int,int >
    #define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
    #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
    #define er(x) cout << x << " "
    #define err(x,y) cout << x << " "<<y
    const int M = 200005;
    using namespace std;
    clock_t time_p=clock();
    void dem()
    {
        time_p=clock()-time_p;
        cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
    }
    using namespace std ;
    const int N =  100 ;
    const int dx[] = { 1, -1 , 0 , 0  };
    const int dy [] = { 0 ,0 , 1 , -1  };
    const int MOD = 1000 * 1000 * 1000 + 9 ;
ll gcd (  ll a , ll b ) // a > b
{
return     b ==  0   ?  a  : gcd ( b , a % b   ) ;
}
int main (){
   ll  a , b ;
   cin >> a >> b ;
    ll   g = gcd ( a, b ) ;
ll res = 1 ; 
 if ( g % 2 ==  0 ){ res ++ ; 
  while ( g % 2 == 0 ){
    g/=2 ; 
}
}
  for (  ll i = 3 ; i * i <= g ; i+= 2 ){
	if ( g % i == 0 ) {
    res ++ ; 
      while (  g % i == 0 ){
        g /=i ;
    }
    }
}

if ( g > 1 )res ++ ;
cout <<  res ;

    return 0 ;
    }


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

string S;
int N;

int main()
{
    cin >> S;
    N = S.size();
    int ans = N;

    for(int i = 0; i < N - 1; i++)
    {
        if(S[i] != S[i + 1])ans = min(ans,max(i + 1,N - i - 1));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;cin>>A>>B>>K;
  for(int i=A;i<=min(B,A+K-1);i++)cout<<i<<endl;
  for(int i=max(B-K+1,min(B,A+K-1)+1);i<=B;i++)cout<<i<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long K,A,B,ans;
	scanf("%lld%lld%lld",&K,&A,&B);
	if(B-A<=2 || K<=A)ans=K+1;
	else{
		K-=A-1;
		ans=A;
		ans+=(B-A)*(K/2)+(K%2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
s = input()
len = len(s)
ns = list(map(int,s))
total_sum = 0
for bit in range(1 << (len-1)):
  ##print(bit)
  sum_ = 0
  num = ns[0]
  for i in range(1, len):
    if (bit & 1) > 0:
     
      sum_ += num
      num = ns[i]
    else:
      num = (num * 10 + ns[i])
    bit = bit >> 1
  total_sum += sum_ + num
print(total_sum)

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

int main() {
    ll K; cin >> K;
    const ll N = 50;
    vector<ll> v(N);
    for (int i = 0; i < N; i++) v[i] = i;
    ll c = K/N;
    for (int i = 0; i < N; i++) v[i] += c;
    c = K%N;
    for (int i = 0; i < N; i++) v[i] -= c;
    for (int i = 0; i < c; i++) v[i] += N+1;

    cout << N << endl;
    for (int i = 0; i < N; i++)
    {
        if(i!=N-1) cout << v[i] << " ";
        else cout << v[i] << endl;
    }
}

Measured memory_bytes: 256
fn solve(xs: Vec<u32>, acc: usize) -> usize {
    if xs.iter().all(|x| x % 2 == 0) {
        solve(xs.iter().map(|x| x / 2).collect(), acc + 1)
    } else {
        acc
    }
}

fn main() {
    let _ = read_none();
    let xs = read_vec();

    println!("{}", solve(xs, 0));
}

fn read_none() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|c| c.parse().ok().unwrap())
        .collect()
}


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

int main() {
  ll N, K; cin>>N>>K;
  map<ll, ll> D;
  ll count=0;
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    if(D.count(a)) D[a]++;
    else{
      D[a]=1;
      count++;
    }
  } //else
  priority_queue<ll, vector<ll>, greater<ll>> pq;
  for(auto p:D){
    ll v=p.second;
    pq.push(v);
  }
  ll ans=0;
  while(count>K){
    ans+=pq.top();
    pq.pop();
    count--;
  }
  cout<<ans<<endl;
}


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

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

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

  vector<ll> A(N, 0);
  for(ll i = 0; i < N; i++){
    cin >> A[i];
  }

  ll ans = 0;
  for(int i = 0; i < N; i++){
    ans += A[i] - 1;
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
<?php
list($N, $M) = explode(" ", trim(fgets(STDIN)));  // スペース区切りで2つ入力
$A = explode(" ", trim(fgets(STDIN)));
if ($N - array_sum($A) >= 0) {
    echo $N - array_sum($A);
} elseif ($N - array_sum($A) < 0) {
    echo '-1';
}

Measured memory_bytes: 16824
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define MAX ((ll)(2e10+100))
#define MX ((ll)(2e6+100))
#define ARRS ((ll)(2e6+500))
#define EP ((double)(1e-9))

ll n,m,M;
ll a[310000];
ll wl,wr;
ll d1[ARRS];
ll d2[ARRS];
vector<ll> pref[ARRS];
vector<ll> suf[ARRS];
vector<ll> cld[ARRS];
vector<ll> v[ARRS];
ll mod;


void go1(ll x,ll p){
	d1[x]=1;
	for(auto y:v[x]){
		if(y==p)continue;
		go1(y, x);
		d1[x]=d1[x]*(d1[y]+1)%mod;
		pref[x].pb(d1[y]+1);
		suf[x].pb(d1[y]+1);
		cld[x].pb(y);
	}
	//cout<<x<<" "<<d1[x]<<endl;
	reverse(suf[x].begin(), suf[x].end());
	for(int i=1; i<suf[x].size(); i++){
		suf[x][i]=suf[x][i-1]*suf[x][i];
		pref[x][i]=pref[x][i-1]*pref[x][i];
		suf[x][i]%=mod;
		pref[x][i]%=mod;
	}
	reverse(suf[x].begin(), suf[x].end());
}


void go2(ll x,ll p){
	//d2[x]=...
	for(int i=0; i<cld[x].size(); i++){
		ll y=cld[x][i];
		d2[y]=d2[x];
		if(i)
			d2[y]=d2[y]*pref[x][i-1]%mod;
		if(i!=cld[x].size()-1)
			d2[y]=d2[y]*suf[x][i+1]%mod;
		d2[y]++;
		go2(y, x);
	}
}

int main(){
	ll n,k,p;
	cin>>n>>mod;
	for(int i=0; i<n-1; i++){
		cin>>k>>p;
		v[k].pb(p);
		v[p].pb(k);
	}
	go1(1,-1);
	d2[1]=1;
	go2(1,-1);
	for(int i=1; i<=n; i++){
		//cout<<d1[i]<<" "<<d2[i]<<endl;
		cout<<d1[i]*d2[i]%mod<<endl;
	}
}


Measured memory_bytes: 209920
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(i=0; i<n; i++)
#define ford(i,n) for(i=n-1; i>=0; i--)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define fi first
#define se second

#define fast_cin() ios::sync_with_stdio(false); cin.tie(nullptr)

using namespace std;

int a[101];
void sieve(int arr[]){
  int i,j;
  for(i=1; i<10; i++){
    for(j=1; j<10; j++){
      arr[i*j]=1;
    }
  }
}
int main(int argc, char const *argv[]){
    fast_cin();
	sieve(a);
  	int n;
  	cin>>n;
  	if(a[n]==1) cout<<"Yes\n";
  	else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i = 1; i<=10000;i++){
        int a = sc.nextInt();
        if(a == 0){
            break;
        }
        System.out.println("Case "+ i +": " + a);
        }
        
    }
}


Measured memory_bytes: 43144
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
bool arr[100000],arr2[100000];
int p[100000];
string s[100000];
signed main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
        cin>>p[i]>>s[i],p[i]--;
    int ac=0,pena=0;
    for(int i=0;i<m;i++)
        if(s[i]=="AC")
            arr[p[i]]=1;
    for(int i=0;i<n;i++)
        if(arr[i])
            ac++;
    for(int i=0;i<m;i++)
        if(s[i]=="WA"&&!arr2[p[i]]&&arr[p[i]])
            pena++;
        else if(s[i]=="AC")
            arr2[p[i]]=1;
    cout<<ac<<' '<<pena<<endl;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
void solve() {
    int k;
    cin >> k;
    cout << a[k - 1] << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, M = sc.nextInt()
    val from1, toN = mutable.HashSet[Int]()
    rep(M) { _ =>
      val a, b = sc.nextInt()
      if (a == 1) from1 += b
      if (b == N) toN += a
    }
    val ok = from1.intersect(toN).nonEmpty
    val ans = if (ok) "POSSIBLE" else "IMPOSSIBLE"

    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;

	int n; cin >> n;
	double p[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> p[i];

	double dp[n + 1][n + 1];

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

			else if (j == 0)
				dp[i][j] = dp[i - 1][j] * (1 - p[i]);

			else if (j > i)
				dp[i][j] = 0.0;

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

	double ans = 0.0;
	for (int i = n / 2 + 1; i <= n; i++)
		ans += dp[n][i];

	cout << ps(ans, 9) << endl;

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    ll a, b;
    if(N%2==0){
        a = A[N/2] + A[N/2-1];
        b = B[N/2] + B[N/2-1];
    }else{
        a = A[N/2];
        b = B[N/2];
    }
    cout << b-a+1 << endl;
    return 0;
}

Measured memory_bytes: 6312
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	
	ll data[N][2];
	F0R(i, N) {
		F0R(j, 2) cin >> data[i][j];
	}
	
	ll ans = 0;
	
	F0R(xP, 2) {
		F0R(yP, 2) {
			ll xC = xP; if (xC == 0) xC = -1;
			ll yC = yP; if (yP == 0) yC = -1;
			
			vpl oldPoints;
			oldPoints.pb({0, 0});
			
			F0R(i, N) {
				vpl newPoints;
				F0R(j, sz(oldPoints)) {
					newPoints.pb(oldPoints[j]);
					newPoints.pb(mp(oldPoints[j].f+data[i][0]*xC, oldPoints[j].s+data[i][1]*yC));
				}
				sort(all(newPoints));
				reverse(all(newPoints));
				oldPoints.clear();
				
				F0R(x, sz(newPoints)) {
					int k = sz(oldPoints)-1;
					if (sz(oldPoints) == 0 || oldPoints[k].f < newPoints[x].f || oldPoints[k].s < newPoints[x].s) {
						oldPoints.pb(newPoints[x]);
					}
				}
				
				/*for (auto it = newPoints.begin(); it != newPoints.end(); it++) {
					pl cur = *it;
					if (it == newPoints.begin()) continue;
					it--;
					pl lst = *(it);
					it++;
					
					if (lst.f >= cur.f && lst.s >= cur.s) newPoints.erase(cur);
					it = newPoints.upper_bound(cur);
					it--;
				}
				
				oldPoints.clear();
				for (auto it = newPoints.begin(); it != newPoints.end(); it++) oldPoints.pb(*it);*/
			}
			
			F0R(i, sz(oldPoints)) {
				//cout << oldPoints[i].f << " " << oldPoints[i].s << endl;
				ans = max(ans, oldPoints[i].f*oldPoints[i].f+oldPoints[i].s*oldPoints[i].s);
			}
		}
	}
	
	
	cout << setprecision(30) << sqrtl((ld) ans) << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 10000
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 10
int n;
vector<pair<int, int> > vp;

void input() {
  cin >> n;
  rep(i, 0, n) {
    int x, y;
    cin >> x >> y;
    vp.push_back(make_pair(x, y));
  }
}

long double calDis(pair<int, int> from, pair<int, int> to) {
  return sqrt(pow(from.first - to.first, 2) + pow(from.second - to.second, 2));
}

int kaijo() {
  int rsl = 1;
  rep(i, 1, n + 1) rsl *= i;
  return rsl;
}

void solve() {
  long double rsl = 0;
  int arr[n];
  rep(i, 0, n) arr[i] = i;

  do {
    rep(i, 0, n - 1) {
      rsl += calDis(vp[arr[i]], vp[arr[i + 1]]);
    }
  } while (next_permutation(arr, arr + n));
  cout << fixed << setprecision(10) << rsl / kaijo() << endl;
}

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


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

ll n;

map<pair<ll, ll>, ll> m;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<pair<ll, ll>> a(n);
    for (auto& i : a) cin >> i.first >> i.second;
    sort(a.begin(), a.end());

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ll y = a[j].second - a[i].second;
            ll x = a[j].first - a[i].first;
            m[{x, y}]++;
        }
    }
    
    ll ans = 0;
    for (auto& i : m) {
        ans = max(ans, i.second);
    }
    cout << n - ans;    
}   


Measured memory_bytes: 384
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
  print(0)
else:
  if H % 3 == 1:
    x = (H-1)//3
    S2 = (H-x)*((W+1)//2)
  else:
    x = (H+1)//3
    S2 = (H-x)*(W//2)
  S1 = x*W
  if W % 3 == 1:
    x = (W-1)//3
    S4 = (W-x)*((H+1)//2)
  else:
    x = (W+1)//3
    S4 = (W-x)*(H//2)
  S3 = x*H
  print(min(H, W, abs(S1-S2), abs(S3-S4)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, L;
  cin >> N >> L;

  ll sum = 0;
  ll m = INF;
  rep(i, N + 1) {
    if (i == 0) {
      continue;
    }
    ll a = L + i - 1;
    sum += a;

    if (abs(a) < abs(m)) {
      m = a;
    }
  }
  debug(m);
  COUT(sum - m);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d %d",&a,&b);
	if ("%d %d", a < b)
		printf("a < b\n");
	else if ("%d %d", a > b)
		printf("a > b\n");
	else if ("%d %d", a == b)
		printf("a == b\n");

	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, r;
  cin >> n >> r;

  if (n < 10) {
    cout << (r + 100 * (10 - n)) << endl;
  } else {
    cout << r << endl;
  }

  return 0;
}


Measured memory_bytes: 256