akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

const int MAX_N = 110;
const int MAX_W = 100010;
int N;
int W;
int w[MAX_N];
LL v[MAX_N];
LL dp[MAX_N][MAX_W];

LL Solve(int index, int weight)
{
    if (dp[index][weight] >= 0) return dp[index][weight];
    if (index >= N) return 0;
    LL res = Solve(index + 1, weight);
    if (w[index] <= W - weight)
    {
        updateMax(res, v[index] + Solve(index + 1, weight + w[index]));
    }
    return dp[index][weight] = res;
}

int main()
{
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];
    REP(i, MAX_N) REP(j, MAX_W) dp[i][j] = -1;
    cout << Solve(0, 0) << endl;
    return 0;
}

Measured memory_bytes: 86144
N = int(input())
A = []
for i in range(N):
    A.append(input())
k = 0
c = [ 0,0,0,0,0]
for i in A:
  if i[0] == 'M':
    c[0] += 1
  if i[0] == 'A':
    c[1] += 1
  if i[0] == 'R':
    c[2] += 1
  if i[0] == 'C':
    c[3] += 1
  if i[0] == 'H':
    c[4] += 1


if not c.count(0) >= 3:
  k += c[0] * c[1] * c[2] + c[0] * c[1] * c[3] + c[0] * c[1] * c[4] + c[0] * c[2] * c[3] + c[0] * c[2] * c[4] + c[0] * c[3] * c[4] + c[1] * c[2] * c[3] + c[1] * c[2] * c[4] + c[1] * c[3] * c[4] + c[2] * c[3] * c[4] 

print(k)

Measured memory_bytes: 9772
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();

    let mut dp: Vec<Vec<usize>> = vec![vec![0;13];s.len()+1];
    dp[0][0] = 1;
    for (i, ch) in s.bytes().enumerate(){
        let i = i+1;
        //if number
        if 48 <= ch && ch < 58{
            let n = (ch - 48) as usize;
            for j in 0..13{
                dp[i][(j*10+n)%13] += dp[i-1][j];
            }
        }else{
            for j in 0..13{
                for k in 0..10{
                    dp[i][(j*10+k)%13] += dp[i-1][j];
                }
            }
        }

        for j in 0..13{
            dp[i][j] %= 1000000007;
        }
    }

    println!("{}", dp[s.len()][5]);
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
//#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
/////////////////////////////////////////////////////////////////
vector<ll> arr;
ll n,k;
bool is_poss( ll x )
{
    ll cuts=0;
    rep(i,0,n)
    {
        if( arr[i] > x )
        {
            cuts+= arr[i]/x;
            if( arr[i]%x == 0 )
            cuts--;
        }
    }
    if( cuts<=k )
    return true;
    return false;
}
/////////////////////////////////////////////////////////////////

int main() {
	//code
	//int tc=1;
	//cin>>tc;
	//while(tc--)
	{
        cin>>n>>k;
        arr.assign(n,0); 
        rep(i,0,n)
        cin>>arr[i];
        ll low=1;
        ll high = 1e16;
        while( low <= high )
        {
            ll mid = ( low + high ) /2;
            if( is_poss(mid) )
            {
                high=mid; // we have to minimize
            }
            else 
            {
                low=mid;
            }
            if( high-low <=5 )
            {
                rep(i,low,high+1)
                {
                    if( is_poss(i) )
                    {
                        cout<<i<<'\n';
                        return 0;
                    }
                }
            }
        }   
	}
	return 0;
}


Measured memory_bytes: 4792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
            int n = s.nextInt();
            int k = s.nextInt();
            s.nextLine();
            int r = Arrays.stream(s.nextLine().split(" "))
                            .mapToInt(Integer::parseInt)
                            .sorted()
                            .limit(k)
                            .sum();
            System.out.println(r);
        }
    }
}


Measured memory_bytes: 37968
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n;
    cin >> n;
    ll a[n],b[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for (ll i=0;i<n;i++){
        if (a[i]>=b[n/2]){
            cout << b[n/2-1] << endl;
        }else{
            cout << b[n/2] << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 5376
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = sr()
answer = 0
for x, y, z in zip(S, S[1:], S[2:]):
    if x + y + z == 'ABC':
        answer += 1
print(answer)
# 36

Measured memory_bytes: 3060
S = input()
N = len(S)
ans = 0

for n in range(2 ** (N - 1)):
    B = bin(n)[2:]
    while len(B) < N - 1:
        B = "0" + B
    idx = 0
    for i, b in enumerate(B):
        if b == "1":
            ans += int(S[idx:i+1])
            idx = i+1
        if i == len(B) - 1:
            ans += int(S[idx:N])

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}





Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

const ll m = 1e9+7;

int main(){
  int N , M;
  cin >> N >> M;
  vector<int> oks(N+1, true);
  rep(i,M){
    int a;
    cin >> a;
    oks[a] = false;
  }

  vector<ll> dp(N+1);
  dp[0] = 1;
  for(int now = 0; now < N; ++now){
    for(int next = now+1; next <= min(N,now+2); next++){
      if(oks[next]){
	dp[next]+=dp[now];
	dp[next]%=m;
      }
    }
  }
  cout << dp[N] << endl;
}



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

 int main() {
   int n; cin >> n;
   int a[110];
   string res = "APPROVED";
     for (size_t i = 0; i < n; i++) {
            cin >> a[i];
       if (a[i] % 2 == 0) {
         if (a[i] % 3 != 0 && a[i] % 5 != 0) {
           res = "DENIED";
         }
       }
     }

   cout << res << "\n";
 }


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    int buf = 0;

    for (int j = 0; j < k; ++j)
    {
        buf += (1 + p[j]);
    }
    ans = buf;

    for (int i = 1; i <= n - k; ++i)
    {
        buf = buf - (p[i - 1] + 1) + (p[k + i - 1] + 1);

        if (buf > ans)
        {
            ans = buf;
        }
    }
    printf("%f\n", (double)ans / 2);

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
#include <iomanip>  
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;

}

Measured memory_bytes: 256
#123_D
import heapq
ans = []
heapq.heapify(ans)
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse= True)
b = sorted(list(map(int, input().split())), reverse= True)
c = sorted(list(map(int, input().split())), reverse= True)

for i in range(x):
    p = k // (i+1)
    for j in range(min(p + 1, y)):
        q = p // (j+1)
        for l in range(min(q + 1, z)):
            heapq.heappush(ans, -(a[i] + b[j] + c[l]))
            
for _ in range(k):
    print(-heapq.heappop(ans))

Measured memory_bytes: 8604
#include <stdio.h>

int main()
{
    int m, f, r;
    int cbn;
    
    while(1){
        scanf("%d %d %d", &m, &f, &r);
        cbn = m + f;
        
        if (m == -1 && f == -1 && r == -1) break;
        else if (m == -1 || f == -1){
            printf("F\n");
        }
        else if (80 <= cbn){
            printf("A\n");
        }
        else if (65 <= cbn && cbn < 80){
            printf("B\n");
        }
        else if (50 <= cbn && cbn < 65){
            printf("C\n");
        }
        else if (cbn >= 30 && r >= 50){
            printf("C\n");
        }
        else if (cbn >=30 && r < 50){
            printf("D\n");
        }
        else if (cbn < 30){
            printf("F\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 584
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;


int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	

    int n;cin>>n;
    int t[n];
    arrayin(t,n)
    int res=0;
    for(int i=0;i<n;i++){
    	res+=(t[i]);
    }

    int m;cin>>m;
    while(m--){
    	int p,x;cin>>p>>x;
    	int temp=res;
    	temp=temp-t[p-1]+x;
    	cout<<temp<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
 
  int n,i;
  int f0, f1, f2;
  int hai[44];
  int cnt = 0;
  f0 = 0;
  f1 = 1;
 
 
  scanf("%d",&i);
 
 
  while(f1<=1134903170) {
    
    hai[cnt] = f1;
    
    f2 = f1 + f0;
   
    f0 = f1;
    f1 = f2;
    cnt++;
  }

  printf("%d\n",hai[i]);
 
  return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    string A[N];
    int ans=0;
    int tb=0;
    int ba=0;
    int tbba=0;
    REP(i,N){
        cin>>A[i];
        if(A[i][0]=='B')tb++;
        if(A[i][A[i].size()-1]=='A')ba++;
        if((A[i][0]=='B')&&(A[i][A[i].size()-1]=='A'))tbba++;
        REP(j,A[i].size()-1){
            if(A[i][j]=='A'&&A[i][j+1]=='B')ans++;
        }
    }
    int d=0;
  	tb-=tbba;
  	ba-=tbba;
  	if(tbba==0){
      d=min(tb,ba);
    }
  	else{
      if(tb+ba==0) d=tbba-1;
      else d=tbba+min(tb,ba);
    }
    cout<<ans+d<<endl;
}

Measured memory_bytes: 768
import Data.List
-- |
-- >>> d2a 6 083268
-- [0,8,3,2,6,8]
d2a n d = reverse $ d2a' n d
  where
    d2a' 0 _ = []
    d2a' n d = (d `mod` 10):(d2a' (n-1) (d`div`10))
-- |
-- >>> a2d 6 [0,8,3,2,6,8]
-- 83268
a2d :: Int -> [Int] -> Int
a2d 0 _ = 0
a2d n (a:as)= a * 10^(n-1) + (a2d (n-1) as)

-- |
-- >>> f 6 83268
-- 862632
-- >>> f 6 862632
-- 642654
f :: Int -> Int -> Int
f n a = max-min
  where
    ary = sort $ d2a n a
    max = a2d n $ reverse $ ary
    min = a2d n $ ary

as n a = a:(as n (f n a))

ans' s (a:as) =
  case i of
    Just i' -> [(length s) - i', a, i']
    Nothing -> ans' (a:s) as
  where
    i = lookup a $ zip s [1..]

ans ([0,0]:_) = []
ans ([a,n]:r) = (ans' [] (as n a)):(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ putStrLn $ map unwords $ map (map show) o



Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	fast;
	ll n, m;
	cin >> n >> m;
	cout << (n * (n - 1) + m * (m - 1)) / 2 << "\n";

	return 0;
}


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

#define mb __builtin_clz
int n, s = 0;
vector<int> v;

int solve();

int main() {
  cin >> n;
  v.resize(n);
  for (auto &p : v) {
    cin >> p;
    s ^= p;
    p = p ^ (p - 1);
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  if (!s) return 0;
  sort(v.begin(), v.end(), greater<int>());
  vector<int> basis;
  int cnt = 0;
  for (auto &p : v) {
    for (auto b : basis) p = min(p, p ^ b);
    if (p) {
      basis.push_back(p);
      if (mb(s) == mb(p)) s ^= p, ++cnt;
    }
    if (!s) return cnt;
  }
  return -1;
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int k, s;
  cin >> k >> s;

  int count = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      int l = s - i - j;
      if (0 <= l && l <= k) {
        count++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   int n;cin>>n;
   VI a(n);
   rep(i,n)cin>>a[i];
   int G=a[0];
   rep(i,n){
      G=GCD(a[i],G);
   }
   if(G!=1){
      cout<<"not coprime"<<endl;
      return 0;
   }
   int b[MAX6];
   CLR(b);
   rep(i,n){
      b[a[i]]++;
   }
   for(int i=2;i<MAX6;i++){
      int sum=0;
      for(int j=i;j<MAX6;j+=i){
         sum+=b[j];
      }
      if(sum>1){
         cout<<"setwise coprime"<<endl;
         return 0;
      }
   }
   cout<<"pairwise coprime"<<endl;
}

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

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

	int a_500;
	a_500 = x / 500;

	x -= a_500 * 500;

	int a_5;
	a_5 = x / 5;

	int answer = a_500 * 1000 + a_5 * 5;

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],p,vis[3];
char s[1000005];

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<n;i++) a[i]=abs(s[i]-s[i+1]),vis[a[i]]=1;
	if(!vis[1]) for(int i=1;i<n;i++) a[i]/=2;
	else for(int i=1;i<n;i++) a[i]%=2;
	int S=n-2;
	for(int i=0;i<n-1;i++) if((S&i)==i) p+=a[i+1];
	int op=p%2;
	if(!vis[1]) if(op) op=2;
	printf("%d\n",op);

	return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int D = in.nextInt();
        int i = 1;
        while (true){
            if(i%2==1){
                C -= B;
                if(C <= 0){
                    System.out.print("Yes");
                    break;
                }

            }
            else{
                A -= D;
                if(A <= 0){
                    System.out.print("No");
                    break;
                }

            }
            i++;
        }

    }

}


Measured memory_bytes: 35804
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, S: str):
    stones = [1 if s == "#" else 0 for s in S]
    acc = [0]+list(accumulate(stones))
    counter = 0
    m = INF
    for i in range(N+1):
        m = min(m, (acc[i]) + (N-i-(acc[N]-acc[i])))
    print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


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

using namespace std;

int now=INT_MAX;
string s;

int main() {
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++) {
		if(s[i]=='C') {
			now=i;
		}
		if(s[i]=='F' and now<i) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main(){
    size_t N;
    cin >> N;
    map<unsigned long, unsigned long> a;
    unsigned long ans0{0}, ans1{0};
    for(unsigned long i = 0, A; i < N; ++i){
        cin >> A;
        if(++a[A] == 2){
            a[A] = 0;
            if(ans0 < A)swap(ans0, A);
            if(ans1 < A)swap(ans1, A);
        }
    }
    cout << ans0 * ans1 << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  vl X(N);
  rep(i,N) {
cin >>X.at(i);
  }
  vector<pl> vec(N);
  rep(i,N) {
    vec.at(i).first=X.at(i);
    vec.at(i).second=i;
  }
  
  
  
  
  
  
  
  
  sort(all(vec));
  sort(all(X));
 vector<pl> b(N);
  rep(i,N) {
 if(i<=N/2-1) {
   b.at(i).first=X.at(N/2);
   b.at(i).second=vec.at(i).second;
 }
    else {
      b.at(i).first=X.at(N/2-1);
      b.at(i).second=vec.at(i).second;
                   }
                   }
      
  vector<pl> fin(N);
  rep(i,N) {
    fin.at(i).first=b.at(i).second;
    fin.at(i).second=b.at(i).first;
  }
  sort(all(fin));
  
  					rep(i,N) {
                     cout<<fin.at(i).second<<endl;
                   }
                   
                   }

  
  

Measured memory_bytes: 13184
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n;
  cin >> n;
  vector<int> vc(n);
  for (int i = 0; i < n; i++) cin >> vc[i];
  for (int i = 0; i < n; i++) {
    if (vc[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int pr = 1;
  for (int i = 0; i < n; i++) {
    pr *= vc[i];
    if (pr > (int)1e18 or pr <= 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << pr << endl;
  return 0;
}


Measured memory_bytes: 3992
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        s: String,
        mut c: String,
    }

    let mut flag = false;

    if s == c {
        flag = true;
    } else {
        for _ in 0..s.len() {
            let last_c = c.pop().unwrap();
            c = format!("{}{}", last_c, c);
            if s == c {
                flag = true;
            }
        }
    }

    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
    
}


Measured memory_bytes: 2176
s = input()

a_cnt = s.count('a')
b_cnt = s.count('b')
c_cnt = s.count('c')

if abs(a_cnt - b_cnt) <= 1 and abs(a_cnt - c_cnt) <= 1 and abs(b_cnt - c_cnt) <= 1:
    print('YES')

else:
    print('NO')

Measured memory_bytes: 39152
import math

h, w = map(int, input().split(" "))
aL = [list(input()) for _ in range(h)]

for i in reversed(range(h)):
    if len(set(aL[i])) == 1 and aL[i][0][0] == ".":
        del aL[i]

for i in reversed(range(w)):
    for j in range(len(aL)):
        if aL[j][i] == "#":
            break
    else:
        for k in range(len(aL)):
            del aL[k][i]

for a in aL:
    print("".join(a))

Measured memory_bytes: 9008
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
using namespace std;
#define LATTE 10000

int main(){
	int a,b;
	cin>>a>>b;
	printf("%d %d\n",a*b,(a+b)*2);
    return 0;
}

Measured memory_bytes: 1144
main = getLine >>= print . solve . map read . words

solve (a:b:h:m:_) = sqrt ((xa - xb)^2 + (ya - yb)^2)
  where da = 2 * pi * (60 * h + m) / (60 * 12)
        xa = a * cos(da)
        ya = a * sin(da)
        db = 2 * pi * m / 60
        xb = b * cos(db)
        yb = b * sin(db)

Measured memory_bytes: 4520
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X;
	X.resize(N);
	for (int i = 0; i < N; ++i) {
		X[i].resize(D);
		for (int j = 0; j < D; ++j) {
			int x;
			cin >> x;
			X[i][j] = x;
		}
	}

	int count = 0;
	for (int i = 0; i < N; ++i) {
		for (int i2 = i; i2 < N; ++i2) {
			double dist = 0;
			if (i2 == i)continue;
			for (int j = 0; j < D; ++j) {
				dist += pow(abs(X[i][j] - X[i2][j]), 2);
			}

			dist = sqrt(dist);
			if (fmod(dist, 1) == 0) {
				++count;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int N, i, j;
double P[3000];
double d[3000][3000], ans;

int main(){
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%lf", P+i);
	}
	d[0][0] = 1;
	for(i=1; i<=N; i++){
		for(j=0; j<=i; j++){
			if(j==0){
				d[i][0] = (1-P[i-1])*d[i-1][0];
			}else{
				d[i][j] = (1-P[i-1])*d[i-1][j] + P[i-1]*d[i-1][j-1];
			}
		}
	}
	ans = 0;
	for(i=N/2+1; i<=N; i++){ans += d[N][i];}
	printf("%.10lf\n", ans);
}


Measured memory_bytes: 68864
import numpy as np
H, W = (int(x) for x in input().split())
h, w = (int(x) for x in input().split())
board = np.tile([0],(H,W))

def Counting(b):
    ret = 0
    for i in range(H):
        for j in range(W):
            if b[i][j] == 0:
                ret += 1
    return ret

for i in range(h):
    for j in range(W):
        board[i][j] = 1
for j in range(w):
    for i in range(H):
        board[i][j] = 1

print(Counting(board))

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

int main() {
    int n, d, x;
    int fir = 0;

    cin >> n >> d >> x;

    for (int j = 0; j < n; j++) {
        int tmp;
        cin >> tmp;
        fir += d/ tmp;
        if (d % tmp != 0) fir++;
    }

    fir += x;
    cout << fir << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Comparator;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt();
        ArrayList<Long> list = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            list.add(readLong());
        }

        list.sort(Comparator.naturalOrder());
        int count = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                for (int k = j + 1; k < n; k++) {
                    long li = list.get(i), lj = list.get(j), lk = list.get(k);
                    if (li == lj || lj == lk) {
                        continue;
                    }

                    if (li + lj > lk) {
                        count++;
                    }
                }
            }
        }

        System.out.print(count);
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 33264
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class Math {
    ll mod = 1e9+7;
  public:
    template<typename T> 
    T gcd(T a, T b){
        if(b==0) return a; 
        return gcd(b, a%b);
    }

    template<typename T>
    T lcm(T a, T b){
        return a*(b/gcd(a, b));
    }

    template<typename T>
    T keta(T num){
        T k=0; 
        while(num>0){ 
            num/=10;
            k++;
        }
        return k;
    }

    template<typename T>
    T powpow(T num1, T num2){
        T res = 1;
        while(num2 > 0){
            res *= num1;
            res %= mod;
            num2--;
        }
        return res%mod;
    }

    template<typename T1, typename T2>
    ll powl(T1 a, T2 b){
        ll res = 1;
        while(b > 0){
            res *= a;
            b--;
        }
        return res;
    }

    template<typename T1, typename T2>
    ll ceil(T1 a, T2 b){
        return (a+b-1)/b;
    }
};

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

    ll a, b, c;
    Math m;
    cin >> a >> b >> c;

    if(a%2==1 || b%2==1 || c%2==1){
        cout << 0 << endl;
        return  0;
    }

    if(a==b && b==c){
        cout << -1 << endl;
        return 0;
    }

    ll cnt = 0;
    while(true){
        if((a+b) / m.powl(2, cnt) % 2 == 1) break;
        if((b+c) / m.powl(2, cnt) % 2 == 1) break;
        if((c+a) / m.powl(2, cnt) % 2 == 1) break;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
  int n;
  cin >>n;
  
  vector<int> vec(n);
  bool ans=true;
  
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    vec[i]=x;
  }
  
  if(n==1){
    cout << "Yes" <<endl;
    return 0;
  }
  
  for(int i=n-1;i>0;i--){
    if(vec[i-1]>vec[i]+1){
      ans=false;
      break;
    }
    else if(vec[i-1]==vec[i]+1){
      vec[i-1] -= 1;
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" <<endl;
  
  return 0;
}

Measured memory_bytes: 640
s = gets.chomp

loop do
  if s[-5..-1] == 'dream' || s[-5..-1] == 'erase'
    s.slice!(-5..-1)
  elsif s[-6..-1] == 'eraser'
    s.slice!(-6..-1)
  elsif s[-7..-1] == 'dreamer'
    s.slice!(-7..-1)
  else
    puts 'NO'
    exit
  end
  if s.empty?
    puts 'YES'
    exit
  end
end


Measured memory_bytes: 2044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100010
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
struct stu{
	int num,id;
}a[N];
int n;
bool cmp(stu x,stu y){
	return x.num<y.num;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i].num=read();
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		printf("%d ",a[i].id);
	}
	return 0;
}


Measured memory_bytes: 1536
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
	static final long C =  1000000007;
	static final int CY = 1000000000;
	StringBuilder sb;
	public void calc() {
		sb = new StringBuilder();


		FastScanner sc = new FastScanner();

		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i=0; i < n; i++) {
			a[i] = sc.nextInt();
		}




		long ans = a[0] -1;
		a[0] = 1;

		long min = 2;

		for (int i=1; i < n; i++) {
			if (a[i] > min) {
				ans += (a[i]-1) / min;
				a[i] = 1;
			}else if (min == a[i]){
				min++;
			}
		}

		System.out.print(ans);
	}



	public static void main(String[] args) {
		Main main = new Main();
		main.calc();

	}
	static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			}else{
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
		private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
		private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
		private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int n;
  double td;
  string ts;
  double ans = 0.0;
  vector<pair<string,double>> x;
  cin >> n;
  REP(i,n){
      cin >> td >> ts;
      x.pb(make_pair(ts,td));
    }
  
  REP(i,n){
      if(x[i].first == "BTC"){
          ans += (x[i].second * 380000.0);
        }else{
            ans += x[i].second;
          }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include <algorithm>
#include <functional>
#include<cmath>
#include<numeric>

#define lcm(a, b, c) (a*b)/c

using namespace std;

int gcd(int max , int min){
int amari;
while(1)
{
amari=max%min;
if(amari==0) return min;
max=min;
min=amari;
}
}

int main(){
	int a,b;
	while(cin>>a>>b)
	{
		int saidai,saisyou;
		long long int kari=0;
		saidai = gcd( max(a,b) , min(a,b) );
		kari = b/saidai;
		saisyou =kari*a;

		cout<<saidai<<" "<<saisyou<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n,K=input().split()

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r]

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,int(K)+1):
    print(cmb(int(n)-int(K)+1,int(i))*cmb(int(K)-1,int(i)-1)%mod)


Measured memory_bytes: 4596
#include <iostream>

using namespace std;

int main(){
  
  int n, m;
  cin >> n >> m;
  
  for(int i = 0; i < m; i++){
    int a;
    cin >> a;
    n -= a;
  }
  
  if(n >= 0){
    cout << n << endl;
  } else {
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D.at(i);

    sort(all(D));

    int ans = D.at(D.size() / 2) - D.at(D.size() / 2 - 1);

    cout << ans << endl; 
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import collections
import math


class Vector2(collections.namedtuple("Vector2", ["x",  "y"])):

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):  # norm
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def dot(self, other):  # dot product
        return self.x * other.x + self.y * other.y

    def cross(self, other):  # cross product
        return self.x * other.y - self.y * other.x


if __name__ == '__main__':

    n = int(input())
    
    for _ in range(n):
        l = list(map(int, input().split()))
        s1 = Vector2(l[2], l[3]) - Vector2(l[0], l[1])
        s2 = Vector2(l[6], l[7]) - Vector2(l[4], l[5])

        if abs(s1.dot(s2)) == 0:
            print(1)
        elif abs(s1.cross(s2)) == 0:
            print(2)
        else:
            print(0)



Measured memory_bytes: 6080
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
using namespace std;
long long x,y,z;
int main(){
	scanf("%lld %lld %lld",&x,&y,&z);
	if((x%2==1)||(y%2==1)||(z%2==1)){printf("%d\n",0);return 0;}
	for(int i=1;i<=50000000;i++){
		long long x_=(y+z)/2;
		long long y_=(x+z)/2;
		long long z_=(x+y)/2;
		x=x_,y=y_,z=z_;
		if((x%2==1)||(y%2==1)||(z%2==1)){printf("%d\n",i);return 0;}
	}printf("-1\n");
	return 0;
}

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

int main() {
  int A,B;
  cin>>A>>B;
  vector<int> p;
  p.push_back(A);
  for(int i=1;i<=60;i++){
    p.push_back(A-i);
    p.push_back(A+i);
  }
  vector<int> q(101);
  for(int i=0;i<B;i++){
    int a;
    cin>>a;
    q.at(a)++;
  }
  for(int i=0;i<110;i++){
    if(p.at(i)<0||p.at(i)>100){
      cout<<p.at(i)<<endl;
      break;
    }
    else if(q.at(p.at(i))==0){
      cout<<p.at(i)<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

char c;
void solve() {
    cin >> c;
    if (isupper(c)) cout << 'A';
    else cout << 'a';
    cout << '\n';
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


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

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

Node *sum,*num;

void xu(int k);
Node* fan(int k);
void delete(int k);
void malon(Node *x);
void rin(Node *x);

int main(){
	int i,n,x;	scanf("%d",&n);
	char rum[10];

	for(i=0;i<n;i++){
		scanf("%s",rum);
		if(rum[0]=='i'){
			scanf("%d",&x);
			xu(x);

		}else if(rum[0]=='p'){
			malon(sum);
			printf("\n");
			rin(sum);
			printf("\n");
		}else if(rum[0]=='f'){
			scanf("%d",&x);
			if(fan(x)!=num)printf("yes\n");
			else printf("no\n");
		}else{
			scanf("%d",&x);
			delete(x);
		}
	}
	return 0;
}

void xu(int k){
	Node *y=num, *x=sum, *z;

	z=(Node*)malloc(sizeof(Node));

	z->key=k;	z->left=num;	z->right=num;

	while(x!=num){
		y=x;
		if(k < x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;

	if(y==num)sum=z;
	else{
		if(k < y->key){
			y->left = z;
		}else{
			y->right=z;
		}
	}
}

Node* fan(int k){
	Node* p=sum;

	while(p!=num){
		if(p->key==k){
			return p;
		}

		if(k < p->key)p=p->left;
		else p=p->right;
	}

	return num;
}

void delete(int k){
	Node *tgt=fan(k),*ma,*lon;

	if(tgt->left==num || tgt->right==num){
		ma=tgt;
	}else{
		ma=tgt->right;
		while(ma->left!=num)ma=ma->left;
	}

	if(ma->left!=num){
		lon=ma->left;
	}else{
		lon=ma->right;
	}
	if(lon!=num)	lon->parent=ma->parent;

	if(ma->parent==num){
		sum=lon;
	}else{
		if(ma==ma->parent->left){
			ma->parent->left=lon;
		}else{
			ma->parent->right=lon;
		}
	}

	if(ma!=tgt)tgt->key=ma->key;

	free(ma);
	return;
}

void malon(Node* x){
	if(x==num)return;
    malon(x->left);
	printf(" %d",x->key);
	malon(x->right);
}
void rin(Node* x){
	if(x==num)return;
	printf(" %d",x->key);
	rin(x->left);
	rin(x->right);
}



Measured memory_bytes: 20536
#include <iostream>
#include <vector>
#include <sstream>
#include <cstdlib>
#include <iterator>
#include <algorithm>
using namespace std;
vector<string> split(const string &str, char sep = ' ') {
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

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

    string input;
    getline( cin, input);
    vector<string> splited = split(input);
    vector<int> casted;
    for(int i = 0; i < std::end(splited) - std::begin(splited); i++) {
        casted.push_back(atoi(splited[i].c_str()));
    }

    std::sort(casted.begin(), casted.end());

    cout << casted[0] << ' ' << casted[1] << ' ' << casted[2] << endl;
    return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long n)
{
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p)
  {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0)
    {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}
int main()
{
  string s, t;
  cin >> s >> t;
  bool ok = true;
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] != t[i])
    {
      ok = false;
    }
  }
  if (ok)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3600