akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define EPS (1e-10)    //誤差
typedef complex<double> P;

//内積
double dot(P a, P b){
    return (a.real() * b.real() + a.imag() * b.imag());
}

P projection(P a, P b, P c){
    return a + dot(b-a, c-a) / norm(b-a) * (b-a);
}

int main(){

    P p1, p2;
    cin >> p1.real() >> p1.imag() >> p2.real() >> p2.imag();
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        int x, y; cin >> x >> y;
        P ans = projection(p1, p2, P(x, y));
        printf("%.10f %.10f\n", ans.real(), ans.imag());
    }
}


Measured memory_bytes: 3328
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import bisect
import sys
input = sys.stdin.readline

Q=one_int()

import math
lim = int(math.pow(10, 5))
is_prime = [True for _ in range(lim+1)]
is_prime[0], is_prime[1] = False, False
for i in range(2, int(math.sqrt(lim))+1):
    if is_prime[i]:
        for j in range(i*2, lim+1, i):
            is_prime[j] = False
 

# sosu_dict = {s:0 for s in sosuu_list}

like_list = [0 for i in range(10**5 + 1)]
count=0
for i in range(10**5):
    if (is_prime[(i+1)//2]) and (is_prime[i]):
        count+=1
    like_list[i] = count

for i in range(Q):
    l,r = many_int()
    print(like_list[r]-like_list[l-1])

Measured memory_bytes: 53472
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A == 1 && B > 1){
            System.out.println("Alice");
            return;
        }
        if(B == 1 && A > 1){
            System.out.println("Bob");
            return;
        }
        if(A < B){
            System.out.println("Bob");
            return;
        }
        if(A > B){
            System.out.println("Alice");
            return;
        }
        if(A == B){
            System.out.println("Draw");
            return;
        }
    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		long[] a = new long[n];
		long[] l = new long[n + 1];
		long[] r = new long[n + 1];

		int i;

		for(i = 0; i < n; i++)
			a[i] = scan.nextLong();

		for(i = 1; i <= n; i++) {
			l[i] = gcd(l[i - 1], a[i - 1]);
			r[n - i] = gcd(r[n - i + 1], a[n - i]);
		}

		long[] m = new long[n];

		for(i = 0; i < n; i++) {
			m[i] = gcd(l[i], r[i + 1]);
		}

		long max = Long.MIN_VALUE;

		for(i = 0; i < n; i++)
			max = Math.max(max, m[i]);

		System.out.println(max);

	}
	public static long gcd(long a, long b) {
		if(b == 0)
			return a;

		return gcd(b, a % b);
	}
}


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

int main() {
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                int temp = i*500 + j*100 + k*50;
                if(temp==x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int p[M];
    string S[M];
    for (int i = 0; i < M; i++)
    {
        cin >> p[i] >> S[i];
    }
    bool is_ac[N + 1];
    for (int i = 0; i < N + 1; i++)
    {
        is_ac[i] = false;
    }

    int pena[N + 1] = {0};
    for (int i = 0; i < M; i++)
    {
        if (is_ac[p[i]])
        {
            continue;
        }
        if (S[i] == "AC")
        {
            is_ac[p[i]] = true;
        }
        if (S[i] == "WA")
        {
            pena[p[i]]++;
        }
    }
    int cnt_ac = 0;
    int cnt_pena = 0;
    for (int i = 0; i < N + 1; i++)
    {
        if (is_ac[i])
        {
            cnt_ac++;
            cnt_pena += pena[i];
        }
    }
    cout << cnt_ac << " " << cnt_pena << endl;
}

Measured memory_bytes: 6528
/*
 * main.c
 *
 *  Created on: 2019/07/07
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef unsigned long long int uint64_t;
typedef long long int int64my_t;

//qsort(a, 3, sizeof(int), sort_inc);
int sort_inc(const void *a, const void *b)
{
    return (*(int*)a - *(int*)b);
}
int sort_dec(const void* a, const void* b)
{
    return (*(int*)b - *(int*)a);
}

int A[200001] = {0};
int sortA[200001] = {0};

int main()
{
	int N = 0, i = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		sortA[i] = A[i];
	}
	qsort(sortA, N, sizeof(int), sort_dec);

	for (i = 0; i < N; i++) {
		// maxでないなら
		if(A[i] != sortA[0]) {
			printf("%d\n", sortA[0]);
		} else {
			printf("%d\n", sortA[1]);
		}
	}
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>
int main()
{
  int dice[6];
  int i,j;
  char ins[101];
  for(i=0;i<6;i++)scanf("%d",&dice[i]);
  scanf("%s",ins);
  for(i=0;i<strlen(ins);i++)
  {
    if(ins[i]=='N')
    {
      int temp=dice[0];
      dice[0]=dice[1];
      dice[1]=dice[5];
      dice[5]=dice[4];
      dice[4]=temp;
    }
    if(ins[i]=='E')
    {
      int temp=dice[0];
      dice[0]=dice[3];
      dice[3]=dice[5];
      dice[5]=dice[2];
      dice[2]=temp;
    }
    if(ins[i]=='S')
    {
      int temp=dice[0];
      dice[0]=dice[4];
      dice[4]=dice[5];
      dice[5]=dice[1];
      dice[1]=temp;
    }
    if(ins[i]=='W')
    {
      int temp=dice[0];
      dice[0]=dice[2];
      dice[2]=dice[5];
      dice[5]=dice[3];
      dice[3]=temp;
    }
  }
  printf("%d\n",dice[0]);
  return 0;
}


Measured memory_bytes: 2088
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
ll n,m;
vi a[N];
ll dp1[N],dp2[N];

void dfs(ll node,ll pr)
{
	dp1[node]=1;
	for(auto i:a[node])
	{
		if(i!=pr)
		{
			dfs(i,node);
			dp1[node]=(dp1[node]*(dp1[i]+1))%m;
		}
	}
	return;
}
void dfs1(ll node,ll pr,ll pre)
{
	// cout<<node<<" "<<pre<<endl;
	vi v1,v2;
	v1.pb(1);
	for(auto i:a[node])
	{
		if(i==pr)
		{
			v1.pb(1);
			v2.pb(1);
		}
		else
		{
			v1.pb(dp1[i]+1);
			v2.pb(dp1[i]+1);
		}
		// dfs1(i,node,(ans*modInverse(dp1[node]+1,m))%m);
	}
	v2.pb(1);
	ll temp_n=sz(a[node]);
	rep(i,1,temp_n+1)
	v1[i]=(v1[i]*v1[i-1])%m;
	repr(i,0,temp_n)
	v2[i]=(v2[i]*v2[i+1])%m;
	ll num;
	rep(i,0,temp_n)
	{
		if(a[node][i]==pr)
			continue;
		num=(v1[i]*v2[i+1])%m;
		dfs1(a[node][i],node,(num*(pre+1))%m);
	}
	dp2[node]=(v1[temp_n]*(pre+1))%m;
	return;
}

void solve()
{
	cin>>n>>m;
	ll x,y;
	rep(i,1,n)
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	dfs(1,-1);
	// rep(i,1,n+1)
	// cout<<dp1[i]<<' ';
	// cout<<endl;
	dfs1(1,-1,0);
	rep(i,1,n+1)
	{
		cout<<dp2[i]<<"\n";
	}
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 26624
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;  using i64 = int64_t;  using str = string;
using u32 = uint32_t; using u64 = uint64_t; using usize = size_t;
using f64 = double_t; template <typename T> using vec = vector<T>;
#define times(n, i) for (i64 i = 0; i < (n); ++i)
#define range(n, m, i) for (i64 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i64 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i64 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n;
i32 a[100000];
i32 p[100000];

i32 main()
{
    cin >> n;
    vec<pair<i32, i32>> v(n);
    times(n, i) {
        cin >> a[i];
        v[i] = make_pair(a[i], i);
    }
    sortall(v);

    times(n, i) {
        p[v[i].second] = i;
    }

    i32 ans = 0;
    times(n, i) {
        if (abs(p[i] - i) % 2 == 1) {
            ans++;
        }
    }

    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
h, n = map(int, input().split())
ab = []
ma = 0
for i in range(n):
    a, b = map(int, input().split())
    ma = max(ma, a)
    ab.append([a, b])

INF = 10 ** 9
dp = [[INF for i in range(h + ma + 1)] for j in range(n+1)]

for i, (a, b) in enumerate(ab):
    dp[i + 1][0] = 0
    for j in range(h + ma + 1):
        if j >= a:
            dp[i + 1][j] = min(dp[i + 1][j - a] + b, dp[i][j])
        else:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])

print(min(dp[n][h:]))


Measured memory_bytes: 133640
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int x, t;
	cin >> x >> t;
	cout << max(0, x - t) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.stream.IntStream;


public class Main {

	class Container {
		String cityName;
		int score;
		int i;

		Container(String cityName, int score, int i) {
			this.cityName = cityName;
			this.score = score;
			this.i = i;
		}
	}

	// invoked from main
	private void solve() throws Exception {
		int N = in.i(), M = in.i();
		int[] pow2 = new int[N+1];
		pow2[0] = 1;
		for (int i = 1; i <= N; i++)
			pow2[i] = 2*pow2[i-1];

		// 電球M個のon条件をbitで表す
		int[] s = new int[M];
		for (int i = 0; i < M; i++) {
			s[i] = 0;
			int k_i = in.i();
			for (int j = 0; j < k_i; j++)
				s[i] += pow2[in.i()-1];
		}

		int[] p = new int[M];
		for (int i = 0; i < M; i++)
			p[i] = in.i();

		int count = 0;
		label: for (int i = 0; i < pow2[N]; i++) {
			for (int j = 0; j < M ; j++)
				if (Integer.bitCount(i & s[j]) % 2 != p[j])
					continue label;
			count++;
		}

		out.println(count);
	}


	public static void main(String[] args) throws Exception {
		instance.solve();
	}

	static PrintStream out = System.out;
	static FastReader in = new FastReader();
	static Main instance = new Main();
}

class FastReader {
	final private int BUF_SIZE = 1 << 16;
	private DataInputStream din = new DataInputStream(System.in);
	private byte[] buffer = new byte[BUF_SIZE];
	private int bufferPointer, bytesRead;

	String s() throws IOException {
		return s(64);
	}

	// make for line
	String s(int capacity) throws IOException {
		byte[] buf = new byte[capacity];
		int cnt = 0, c;
		while ((c = c()) != -1) {
			if (Character.isSpaceChar(c)) break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	int i() throws IOException {
		int ret = 0;
		byte c = c();
		while (c <= ' ') c = c();
		boolean neg = (c == '-');
		if (neg) c = c();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = c()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	long l() throws IOException {
		long ret = 0;
		byte c = c();
		while (c <= ' ') c = c();
		boolean neg = (c == '-');
		if (neg) c = c();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = c()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	double d() throws IOException {
		double ret = 0, div = 1;
		byte c = c();
		while (c <= ' ') c = c();
		boolean neg = (c == '-');
		if (neg) c = c();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = c()) >= '0' && c <= '9');
		if (c == '.')
			while ((c = c()) >= '0' && c <= '9')
				ret += (c - '0') / (div *= 10);
		return neg ? -ret : ret;
	}

	private void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUF_SIZE);
		if (bytesRead == -1) buffer[0] = -1;
	}

	byte c() throws IOException {
		if (bufferPointer == bytesRead) fillBuffer();
		return buffer[bufferPointer++];
	}
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
const bool ready = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();
 
const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)
 
#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }
 
using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;
 
/** stolen from tourist, Problem D, https://codeforces.com/contest/1208/standings/page/1 */
template <typename T>
struct fenwick {
    vector<T> fenw;
    int n;
 
    fenwick(int _n) : n(_n) {
        fenw.resize(n);
    }
 
    /* update add */
    void update(int x, T v) {
        while (x < n) {
            fenw[x] += v;
            x |= (x + 1);
        }
    }
 
    /* get sum of range (0,x), including x */
    T query(int x) {
        T v{};
        while (x >= 0) {
            v += fenw[x];
            x = (x & (x + 1)) - 1;
        }
        return v;
    }
};
 
struct Query {
    int l, r, idx;
 
    bool operator<(Query other) const {
        return r<other.r;
    }
};
 
/*
 */
void solve() {
    cini(n);
    cini(q);
 
    cinai(aa, n);
 
    vector<Query> quer(q);
    for(int i=0; i<q; i++) {
        cin>>quer[i].l>>quer[i].r;
        quer[i].l--;
        quer[i].r--;
        quer[i].idx=i;
    }
 
    sort(all(quer));
 
    fenwick<int> fen(n);
 
    map<int,int> pos;  /* pos[a]= previous position of a */
    int r=0;
    int cnt=0;
    vi ans(q);
    for(int i=0; i<q; i++) {
        while(r<=quer[i].r) {
            auto it=pos.find(aa[r]);
            if(it!=pos.end()) {
                fen.update(it->second, -1);
                it->second=r;
            } else {
                cnt++;
            }
            pos[aa[r]]=r;
            fen.update(r,1);
            r++;
        }
 
        ans[quer[i].idx]=cnt-fen.query(quer[i].l-1);
    }
 
 
    for(int i=0; i<q; i++)
        cout<<ans[i]<<endl;
}
 
signed main() {
    solve();
}


Measured memory_bytes: 58528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		double[] in = new double[N];
		double sum = 0;
		
		for (int i = 0; i < N; i++) {
			in[i] = Double.parseDouble(sc.next());
			sum += 1 / in[i];
		}
		
		System.out.println(1 / sum);
	}
}


Measured memory_bytes: 21716
#include<stdio.h>
int main(){
  char s[110],a[2];
  long long int k;
  int i=0;
  scanf("%s%lld",s,&k);
  for(i=0;i<k-1;i++){
    if(s[i]!='1'){
      printf("%c\n",s[i]);
      return 0;
    }
  }
  printf("%c\n",s[i]);
  return 0;
}

Measured memory_bytes: 128
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
L=[]
for i in range(n):
    L.append(l[i][1])
dp=[[0]*(t) for i in range(n+1)]
for i in range(1,n+1):
    for j in range(t):
        if j-l[i-1][0]>=0:
            dp[i][j]=max(dp[i-1][j-l[i-1][0]]+l[i-1][1],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
ans=[]
for i in range(n):
    ans.append(dp[i][-1]+max(L[i:]))
print(max(ans))

Measured memory_bytes: 117080
N = int(input())
A_list = list(map(int, input().split()))
n_minus = 0
for a in A_list:
    if a < 0:
        n_minus += 1
if int(n_minus)%2 == 0:
    print(sum([abs(a) for a in A_list]))
else:
    tmp = sorted([abs(a) for a in A_list])
    print(int(sum(tmp[1:]) - tmp[0]))
    

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a - 2 * b, 0) << endl;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())

A = []
for _ in range(Q):
    A.append(int(input()))
    
    
P = [0]*N
    
for i in range(Q):
    P[A[i]-1] += 1

for j in range(N):
    if P[j]-(Q-K)>0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8676
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
左から順に一致していないことを確定していく.
一致しているものに出会ったら、すぐ右のものと交換して損をしない.
最後の要素が一致していたらすぐ左のと交換.
*/
int main() {
  int n;in(n);
  vector<int> A(n);
  loop(i,0,n) in(A[i]),A[i]--;
  int k=0;
  loop(i,0,n) {
    if (i==n-1 and i==A[i]) {
      swap(A[i], A[i-1]);
      k++;
      break;
    }
    
    if (i==A[i]) {
      swap(A[i], A[i+1]);
      k++;
    }
  }
  print(k);
  return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b; cin >> a >> b;
    if (b >= a) out(a);
    else out(a - 1);
}


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


int main(){
    int n; cin >> n;
    vector<int> x(n),y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    int ans = n;
    rep(i,n){
        rep(j,n){
            if(i == j)continue;
            else{
                int p = x[i] - x[j];
                int q = y[i] - y[j];
                int cnt = 0;
                rep(ii,n){
                    rep(jj,n){
                        if(x[ii] - x[jj] == p && y[ii] - y[jj] == q){
                            cnt++;
                        }
                    }
                }
                ans = min(ans, n-cnt);
            }
        }
    }
    if(n==1)ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int n = sc.nextInt();
        String s = sc.next();

        final int M = 26;
        int[][] r = new int[M][n];
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                for (int j = 0; j < M; j++) {
                    r[j][i] = r[j][i - 1];
                }
            }

            int k = s.charAt(i) - 'A';
            ++r[k][i];
        }

        long ans = 0;
        for (int i = 0; i < n; i++) {
            char ci = s.charAt(i);
            for (int j = i + 1; j < n; j++) {
                char cj = s.charAt(j);

                if (ci == cj) {
                    continue;
                }

                char ck;
                if (ci == 'R') {
                    ck = cj == 'G' ? 'B' : 'G';
                } else if (ci == 'G'){
                    ck = cj == 'R' ? 'B' : 'R';
                } else {
                    ck = cj == 'G' ? 'R' : 'G';
                }

                int t = r[ck - 'A'][n - 1] - r[ck - 'A'][j];
                int rk = j + (j - i);
                if (rk < n && s.charAt(rk) == ck) {
                    --t;
                }
                ans += t;
            }
        }
        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 34016
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

ll a, b, c, d;
map<ll, ll> memo;

ll solve(ll n) {
  if (n == 0) return 0;
  if (n == 1) return d;
  if (memo.count(n)) return memo[n];

  ll l2 = (n/2) * 2;
  ll r2 = ((n+1)/2) * 2;
  ll l3 = (n/3) * 3;
  ll r3 = ((n+2)/3) * 3;
  ll l5 = (n/5) * 5;
  ll r5 = ((n+4)/5) * 5;

  ll res = 1e18;
  if (n < res/d) res = n * d;

  res = min(res, llabs(l2-n)*d + a + solve(l2/2));
  res = min(res, llabs(r2-n)*d + a + solve(r2/2));

  res = min(res, llabs(l3-n)*d + b + solve(l3/3));
  res = min(res, llabs(r3-n)*d + b + solve(r3/3));

  res = min(res, llabs(l5-n)*d + c + solve(l5/5));
  res = min(res, llabs(r5-n)*d + c + solve(r5/5));

  memo[n] = res;

  return res;
}

int main() {
  int t; cin >> t;
  for(int i = 0; i < t; i++) {
    memo.clear();
    ll n; cin >> n;
    cin >> a >> b >> c >> d;
    cout << solve(n) << endl;
  }
  return 0;
}


Measured memory_bytes: 4436
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s, t;
    cin >> s >> t;
    vector<ll> v(s.size()+1, 0), v2(t.size()+1, 0);
    ll sum = 0;
    for (int i = 0; i < s.size(); ++i) {
        sum += (s[i] == 'A' ? 1 : 2);
        v[i+1] = sum;
    }
    sum = 0;
    for (int i = 0; i < t.size(); ++i) {
        sum += (t[i] == 'A' ? 1 : 2);
        v2[i+1] = sum;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int a, b, c, d;
        scanf("%d %d %d %d", &a, &b ,&c, &d);
        ll x = v[b]-v[a-1], y = v2[d]-v2[c-1];
        x = x%3, y = y%3;
        puts(x == y ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N;
  cin >> N;
  if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9){
    cout << "hon" << endl;
  }
  else if(N % 10 == 3){
    cout << "bon" << endl;
  }
  else{
    cout << "pon" << endl;
  }
}

Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;
int n,cnt;
char s[100+10];
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
		cnt=s[i]=='R'?cnt+1:cnt;
	if(cnt>n-cnt)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  if(c <= b/a){
  	cout << c << endl;
  }else{
  	cout << b/a << endl;
  }


}


Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::{min, max};

#[fastout]
fn main() {
    input! {
    h: usize,
    w: usize,
    a: [Chars; h]
    }
    let mut nw = vec![false; w];
    let mut nh = vec![false; h];
    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                nh[i] = true;
                nw[j] = true;
            }
        }
    }
    for i in 0..h {
        for j in 0..w {
            if nh[i] && nw[j] {
                print!("{}", a[i][j]);
            }
        }
        if nh[i] {
            println!(" ");
        }
    }
}


Measured memory_bytes: 2136
# Here your code !
n=gets.chomp.split("")


i=0
answer=0
(n.length-1).times{
    if n[i]=="A"  && n[i+1]=="C"
      answer+=1
    end
    
    i=i+1
    
    
    
}

if answer==0 
    puts "No"
else puts "Yes"
end

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

using namespace std;


int p[10][10], s[10][10];
vector< vector< int > > st;
map< tuple< vector< vector< int > >, int, int >, int > dp;
int W, H;

int dfs(int x, int y)
{
  auto ps = tie(st, x, y);
  if(dp.count(ps)) return (dp[ps]);
  if(y == H) return (0);
  if(x == W) return (dfs(0, y + 1));
  if(p[y][x] == 0) return (dfs(x + 1, y));
  int ret = 1 << 30;
  if(st[y][x] == 0) ret = min(ret, dfs(x + 1, y));
  vector< pair< int, int > > beet;
  for(int i = 0; i < s[y][x]; i++) {
    for(int j = 0; j < s[y][x]; j++) {
      if(st[y + i][x + j] == 1) {
        beet.emplace_back(y + i, x + j);
        st[y + i][x + j] = 0;
      }
    }
  }
  if(beet.size()) {
    ret = min(ret, dfs(x + 1, y) + 1);
    for(auto &p : beet) st[p.first][p.second] = 1;
  }
  return (dp[ps] = ret);
}

int main()
{
  while(cin >> W >> H, W) {
    dp.clear();
    st.resize(H);
    for(int i = 0; i < H; i++) {
      st[i].resize(W);
      for(int j = 0; j < W; j++) {
        cin >> p[i][j];
        st[i][j] = p[i][j];
      }
    }
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        for(int k = min(H - i, W - j); k >= 1; k--) {
          bool flag = true;
          for(int l = 0; l < k; l++) {
            for(int m = 0; m < k; m++) flag &= p[i + l][j + m];
          }
          if(flag) {
            s[i][j] = k;
            break;
          }
        }
      }
    }
    cout << dfs(0, 0) << endl;
  }
}

Measured memory_bytes: 10340
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;


void solve(int *preorder, int *inorder, int *root_pos, int left, int right, int total_num);
int get_left_child(int *inorder, int root_id, int num);

vector<int> result;

int main(){
	int n;
	scanf("%d", &n);
	int* preorder = (int*)malloc((n+1) * sizeof(int));
	int* inorder  = (int*)malloc((n+1) * sizeof(int));
	for(int i = 0; i < n; ++i){
		scanf("%d", &preorder[i]);
	}
	for(int i = 0; i < n; ++i){
		scanf("%d", &inorder[i]);
	}
	int* root  = (int*)calloc(1, sizeof(int));
	solve(preorder, inorder, root, 0, n, n);
	for(int i = 0; i < n; ++i){
		if(i) putchar(' ');
		printf("%d", result[i]);
	}

	putchar('\n');
	return 0;
}
void solve(int *preorder, int *inorder, int *root_pos, int left, int right, int total_num){
	if(left >= right) return;
	int root_id = preorder[*root_pos];
	int mid = get_left_child(inorder, root_id, total_num);
	(*root_pos)++;
	solve(preorder, inorder, root_pos, left, mid,  total_num);
	solve(preorder, inorder, root_pos, mid+1, right, total_num);
	result.push_back(root_id);
}

int get_left_child(int *inorder, int root_id, int num){
	int left_num = -1;
	for(int i = 0; i < num; ++i){
		if(inorder[i] == root_id){
			left_num = i;
			break;
		}
	}
	return left_num;
}

Measured memory_bytes: 1060
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N;
  cin >> N;
  vector<int32_t> subs(N,0); 
  for (int i = 1; i < N; i++) {
    int32_t a;
    cin >> a;
    subs[a-1]++;
  }

  for (auto sub : subs) {
    cout << sub << endl;
  }
  return 0;
}


Measured memory_bytes: 3992
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        int t = scan.nextInt();
        if (X < t) {
            System.out.println(0);
        } else {
            System.out.println(X-t);
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
int lcm(int x,int y){
  return x/__gcd(x,y)*y;
}
signed main(){
  int n;
  cin>>n;
  int t[n];
  for(int i=0;i<n;i++) cin>>t[i];
  int ans=1;
  for(int i=0;i<n;i++) ans=lcm(ans,t[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()
new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N >= M):
    print(0)

else:
  if(N  >= 2):
      for i in range(N-1):
        new_dif_list.pop(0)

  print(sum(new_dif_list))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long int> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
const ll N = 1e9+7;



ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int diff(string a,string b){
    int dc=0;
    fore(i,a.length()){
        if(a[i]!=b[i])dc++;
    }
    return dc;
}
int main()
 {  fast();
     ll t,n,k,x,y;
    t=1;
    while(t--){
        cin>>n>>k>>x>>y;
      if(n-k>0)cout<<(n-k)*y+k*x<<endl;
      else cout<<n*x<<endl;
    }
	}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long total = 0;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] targets = new String[]{"dream", "dreamer", "erase", "eraser"};
		StringBuilder sb = new StringBuilder(sc.next());
		while (sb.length() > 0) {
		    boolean flag = false;
		    for (String s : targets) {
		        if (sb.length() >= s.length() && sb.lastIndexOf(s) == sb.length() - s.length()) {
		            flag = true;
		            sb.setLength(sb.length() - s.length());
		            break;
		        }
		    }
		    if (!flag) {
		        System.out.println("NO");
		        return;
		    }
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 28816
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n;
	cin>>n;
	ll arr[n];
	REP(i,0,n){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	reverse(arr,arr+n);
	ll ct = n-2;
	ll sum = arr[0];
	ll i = 1;
	while(ct > 0){
		if(ct > 1){
			ct -= 2;
			sum += 2*arr[i];
			i++;
		}
		else {
			ct -= 1;
			sum += arr[i];
			i++;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5196
import java.util.Scanner;

class Main{

  public static void main(String[] args){

        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
  	int b = scan.nextInt();
  	
  	if(a < b){
  		System.out.println("a < b");
  	}else if(a > b){
  		System.out.println("a > b");
  	}else{
  		System.out.println("a == b");
    }
  }
}

Measured memory_bytes: 26036
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
      ll GCD(ll a,ll b){
         if(a%b == 0)return b;
          return GCD(b,a%b);
      }
      ll lcm(ll a,ll b){
        ll gcd = GCD(a,b);
        return a*b/gcd;
      }
    
    

    int main(){
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      ll sum = b-a+1;
      ll e,f,g;
      a--;
      e = b/c-a/c;
      f = b/d-a/d;
      g = b/lcm(c,d)-a/lcm(c,d);
      ll ans = sum - (e+f-g);
      cout<<ans<<endl;
    }
      


Measured memory_bytes: 256
import java.util.*;
public class Main {
	private static Scanner sc;

	public static void main(String[] args){
		sc = new Scanner(System.in);
		// get a integer
		String a = sc.next();
		
		StringBuilder b = new StringBuilder();
		b.append(a);
		b = b.reverse();
		
		if(a.length() == 2) {
			System.out.println(a);
		} else if (b.length() == 3){
			System.out.println(b);
		}
	}
}

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

int main() {
  int n,k; cin >>n >>k;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int a0, a3;
  for(int i = k; i<n; i++){
    a0=a[i-k]; a3=a[i]; 
    if(a0<a3) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4000
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[100002];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll s[100002];
    s[n] = 0;
    for(int i = n - 1; i >= 0; i--){
        s[i] = s[i + 1] + a[i];
    }
    ll now = 131072;
    ll mid = now / 2;
    while(mid){
        ll k = 0;
        for(int i = 0; i < n; i++){
            k += (a + n) - lower_bound(a, a + n, now - a[i]);
        }
        if(k >= m) now += mid;
        else now -= mid;
        mid /= 2;
    }
    ll k = 0;
    for(int i = 0; i < n; i++){
        k += (a + n) - lower_bound(a, a + n, now - a[i]);
    }
    if(k >= m) now++;
    ll ans = 0;
    k = 0;
    for(int i = 0; i < n; i++){
        int l = lower_bound(a, a + n, now - a[i]) - a;
        k += n - l;
        ans += s[l] + a[i] * (n - l);
    }
    ll r = now - 1;
    ll l = 0;
    for(int i = 0; i < n; i++){
        int t = lower_bound(a, a + n, r - a[i]) - a - 1;
        if(t >= 0) l = max(l, a[i] + a[t]);
    }
    cout << ans + r * (m - k) << endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

const string YES = "Yes";
const string NO = "No";

#define MAX_V 1000000

#define MAX_V 1000000
struct edge{
    lli to;
    lli cost;
};
bool operator< (const edge &l, const edge &r){
    return l.cost < r.cost;
}
bool operator> (const edge &l, const edge &r){
    return l.cost > r.cost;
}
vector<edge> G[MAX_V];
vector<lli> dijkstra(lli s,lli num){
    priority_queue<edge,vector<edge>,greater<edge>> que;
    vector<lli> d(num+2,INF);
    //fill(d,d+n+2,INF);
    d[s]=0;
    que.push({s,0});

    while(!que.empty())
    {
        edge p = que.top();
        que.pop();
        lli v = p.to;
        if(d[v] < p.cost)continue;

        for(lli i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to] > d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                que.push({e.to,d[e.to]});
            }
        }
    }
    return d;
};

int main(){
    // cout << fixed << setprecision(5);

    lli V,E,R;
    cin>>V>>E>>R;

    REP(i,0,E){
        lli s,t,d;
        cin>>s>>t>>d;
        G[s].push_back({t,d});
    }

    auto d = dijkstra(R,V);

    REP(i,0,V){
        if(d[i] != INF)cout<<d[i]<<endl;
        else cout<<"INF"<<endl;
    }

    return 0;
}



Measured memory_bytes: 40596
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print(a*b)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 14652
size=int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(size)]
for i in range(1,size):
    if i == 1:
        dp[i] = dp[0]+abs(h[0]-h[1])
    else:
        a = dp[i-2]+abs(h[i-2]-h[i])
        b = dp[i-1]+abs(h[i-1]-h[i])
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
print(dp[-1])

Measured memory_bytes: 13908
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long int

int main(){
  ll x;
  scanf("%lld",&x);

  ll m=100;
  ll count=0;
  while(x>m){
    m+=m/100;
    count++;}
  printf("%lld\n",count);
  
  return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i<k;i++)
int N;
int A[10];
bool DFS(int Aindex,int x,int y){
  if(Aindex ==10)return true;
  if(x>A[Aindex] && y>A[Aindex])return false;
  bool m=false;
  if(x<A[Aindex])m=max(m,DFS(Aindex+1,A[Aindex],y));
  if(y<A[Aindex])m=max(m,DFS(Aindex+1,x,A[Aindex]));
  return m;
}
int main(){
  cin >> N;
  string ans[2]={"NO","YES"};
  rep(i,0,N){
    rep(i,0,10){
      cin >>A[i];
    }
    cout << ans[DFS(0,0,0)]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{

    static void Main(string[] args)
    {
        new Program().Solve();
    }

    public void Solve()
    {
        var sc = new Scanner();
        long S = sc.NextLong();

        long X2, Y2, X3, Y3;

        //X1 = 0 Y1 = 0, |X2*Y3 - X3*Y2| = S

        long ok = 0;
        long ng = int.MaxValue - 1;

        while (ng - ok > 1)
        {
            long med = (ok + ng) / 2;
            if (med * med < S)
            {
                ok = med;
            }
            else
            {
                ng = med;
            }
        }

        X2 = ng;
        Y3 = ng;

        long dif = X2 * Y3 - S;

        X3 = 1;
        Y2 = dif;
        Console.WriteLine($"0 0 {X2} {Y2} {X3} {Y3}");
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


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

// List of Top 3 Hills(0001)
int main()
{
	vector<int> dat(10);
	for (int i = 0; i < 10; ++i)
		cin >> dat[i];

	sort(dat.begin(), dat.end(), greater<int>());
	
	for (int i = 0; i < 3; ++i)
		cout << dat[i] << endl;

	return 0;
}

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

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

int Rn = 0,Bn = 0;
    for(int i = 0;i < N ;i++){
        if(s[i] == 'R'){

Rn++;
        }else{
            Bn++;
        }
    }
    if(Rn > Bn ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll k,x,i,a,b;
    cin>>k>>x;
    a=x-k+1;
    b=x+k-1;
    if(a<(-1000000))
    a=-1000000;
    if(b>1000000)
    b=1000000;
    for(i=a;i<=b;i++){
        cout<<i<<" ";
    }
}

Measured memory_bytes: 256