akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int>>adj,int parent[],int root,int vis[])
{
    vis[root]=1;
    for(auto a:adj[root])
    {
        if(vis[a]==0)
        {
            parent[a]=root;
            dfs(adj,parent,a,vis);
        }
    }
}
int main()
{
    int n,i,j,m,k,u,v;
    cin>>n>>m;
    int parent[n+1]={0};
    int vis[n+1]={0};
    vector<vector<int>>adj(n+1);
    for(i=1;i<=m;i++)
    {
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    parent[1]=-1;
    int dist[n+1]={0};
    queue<int>q;
    vis[1]=1;
    q.push(1);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(auto a:adj[x])
        {
            if(vis[a]) continue;
            dist[a]=dist[x]+1;
            q.push(a);
            vis[a]=1;
            parent[a]=x;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(i=2;i<=n;i++)
    {
        cout<<parent[i]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 10868
from sys import stdin
from heapq import heappush, heappop
solution = [i for i in range(1, 16)] + [0]
sol_idx = (15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
MAX_DEPTH = 45
count = 0
neighbor = (
    (1, 4),
    (0, 2, 5),
    (1, 6, 3),
    (2, 7),
    (0, 5, 8),
    (1, 4, 6, 9),
    (2, 5, 7, 10),
    (3, 6, 11),
    (4, 9, 12),
    (5, 8, 10, 13),
    (6, 9, 11, 14),
    (7, 10, 15),
    (8, 13),
    (9, 12, 14),
    (10, 13, 15),
    (11, 14)
)
distance = (
    (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    (0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6),
    (1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4, 4, 3, 4, 5),
    (2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3, 5, 4, 3, 4),
    (3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2, 6, 5, 4, 3),
    (1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5),
    (2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4),
    (3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3),
    (4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2),
    (2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4),
    (3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3),
    (4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2),
    (5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1),
    (3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3),
    (4, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2),
    (5, 4, 3, 4, 4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1),
    (6, 5, 4, 3, 5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0)
)
def get_diff(B):
    return sum([distance[v][i] for i, v in enumerate(B)])
def get_next_board(board, space, prev):
    for nxt in neighbor[space]:
        if nxt == prev: continue
        b = board[:]
        b[space], b[nxt] = b[nxt], 0
        yield b, nxt
def answer_is_odd(board):
    return sum(divmod(board.index(0), 4)) % 2
def search(board):
    lower = get_diff(board)
    start_depth = lower
    if (lower % 2) ^ answer_is_odd(board): start_depth += 1
    for limit in range(start_depth, MAX_DEPTH + 1, 2):
        get_next(board, limit, 0, board.index(0), None, lower)
        if count > 0: return limit
def get_next(board, limit, move, space, prev, lower):
    global count
    if move == limit:
        if board == solution: count += 1
    else:
        for b, nxt in get_next_board(board, space, prev):
            p = board[nxt]
            new_lower = lower - distance[p][nxt] + distance[p][space]
            if new_lower + move <= limit:
                get_next(b, limit, move + 1, nxt, space, new_lower)
boad = [int(a) for _ in range(4) for a in stdin.readline().split()]
print(search(boad))

Measured memory_bytes: 7972
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    speed_up;
    int n, cnt = 0, st = 0, mx, i, j, mx2;
    cin>>n;
    int a[n];
    int b[n] = {};
    for(i = 0; i<n; i++)
    {
        cin>>a[i];
    }
    mx = *max_element(a, a+n);
    
    j = 0;
   while(j<=mx)
   {st = 0;
    for(i = 0; i<n; i++)
    {
        if(b[i]<a[i])
        {
            b[i]++;
            if(st == 0)
            {
                cnt++;
                st = 1;
            }
        }
        else if(b[i]>=a[i]) st = 0;
    }
    j++;
  
   }

   cout<<cnt<<endl;




  return 0;
}



Measured memory_bytes: 3600
N = int(input())
Pi_lis = map(int, input().split(" "))

min_Pj = 99999999
ans = 0
for Pi in Pi_lis:
    if min_Pj >= Pi:
        ans += 1
        
    min_Pj = min(min_Pj, Pi)
    
print(ans)
    
    

Measured memory_bytes: 17940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C;
  cin>>A>>B>>C;
  if(A==B && B!=C){
  cout<<"Yes";
  }
  else if(B==C && C!=A){
  cout<<"Yes";
  }
  else if(A==C && C!=B){
  cout<<"Yes";
  }
  else{
  cout<<"No";
  }
}

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

int main()
{
    int16_t k,a,b;
    bool f = false;
    cin >> k;
    cin >> a >> b;
    for (int i = a; i<=b; i++) {
        if (i%k == 0){
            f = true;
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    ll n;
    cin>>n;
    pair<ll,ll> ab[n];
    rep(i,n){
        int a,b;cin>>a>>b;
        ab[i] = make_pair(b,a);
    }

    sort(ab,ab+n);
    ll rec=0;
    rep(i,n){
        if(rec+ab[i].second > ab[i].first){
            cout<<"No";
            return 0;
        }
        else rec += ab[i].second;
    }
    cout<<"Yes";
    return 0;
}

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

int exp(int n, int m){
  int ans=1;
  for(int i=0;i<m;i++){
    ans=ans*2;
  }
  return ans;
}

int main(void){
  int n,m;
  cin>>n>>m;
  cout<<(1900*m+100*(n-m))*exp(2,m)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>12){cout<<b<<endl;}
  else if(a>5){cout<<b/2<<endl;}
  else cout<<0<<endl;
}

Measured memory_bytes: 256
#import <stdio.h>
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
int main() {
    long n,k,x,y;
    scanf("%ld %ld %ld %ld",&n,&k,&x,&y);
    printf("%ld", MIN(n,k)*x + MAX(n-k,0)*y);
}


Measured memory_bytes: 7496
H, W = map(int, input().split())
A = [0]
idx_list = []
for i in range(H):
    L = list(map(int, input().split()))
    M = []
    for j in range(W):
        M.append([i+1, j+1])
    if i%2 != 0:
        L.reverse()
        M.reverse()
    idx_list.extend(M)
    for j in range(W):
        A.append((A[-1]+L[j])%2)
A = A[1:-1]
N = sum(A)
print(N)
if N != 0:
    a = A.index(1)
    iter = 0

    while iter<N:
        if A[a] == 1:
            print(idx_list[a][0], idx_list[a][1], idx_list[a+1][0], idx_list[a+1][1])
            iter += 1
        a += 1

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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
#define endl '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define mm(X) memset((X), 0, sizeof((X)))
#define deb(x) cout<<#x<<" "<<x<<endl;



void solve() {
	int n;
	cin >> n;
	int a[n][3];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	if (n == 1) {
		int max1 = a[0][0];
		rep(i, 1, 3) {
			max1 = max(max1, a[0][i]);
		}
		cout << max1;
		return;
	}
	int dp[n][3];
	mm(dp);
	rep(i, 0, 3) {
		dp[0][i] = a[0][i];
	}
	int ans = INT_MIN;
	for (int i = 1; i < n; i++) {

		for (int j = 0; j < 3; j++) {
			if (j == 0)
				dp[i][j] = a[i][j] + max(dp[i - 1][j + 1], dp[i - 1][j + 2]);
			else if (j == 2)
				dp[i][j] = a[i][j] + max(dp[i - 1][j - 1], dp[i - 1][j - 2]);
			else
				dp[i][j] = a[i][j] + max(dp[i - 1][j - 1], dp[i - 1][j + 1]);
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans;
	// cout << endl << dp[n - 1][0] << " " << dp[n - 1][1] << " " << dp[n - 1][2];
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int tc; cin >> tc;
	// for (int t = 1; t <= tc; t++) {
	//cout << "Case #" << t  << ": ";
	solve();
	// }
}

Measured memory_bytes: 5932
n,k=map(int, input().split())
s=input()

for i in range(len(s)):
    if i==k-1:
        if s[k-1]=='A':
            print('a',end='')
        elif s[k-1]=='B':
            print('b',end='')
        elif s[k-1]=='C':
            print('c',end='')
    else:
        print(s[i],end='')

print()


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

ans = float('inf')
for i in range(1, N):
    a = str(i)
    b = str(N - i)
    if ans > sum(map(int, list(a))) + sum(map(int, list(b))):
        ans = min(ans, sum(map(int, list(a))) + sum(map(int, list(b))))

print(ans)


Measured memory_bytes: 43368
#include <iostream>

using namespace std;
typedef long long ll;
ll n,t[400010] = {},h[200010],a[200010];
void build() { 
  for (int i = n - 1; i > 0; --i) t[i] = max(t[i<<1],t[i<<1|1]);
}

void modify(int p, ll value) {
  for (t[p += n] = value; p > 1; p >>= 1) t[p>>1] = max(t[p],t[p^1]);
}

ll query(int l, int r) {
  ll res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = max(res,t[l++]);
    if (r&1) res = max(res,t[--r]);
  }
  return res;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	int i;
	for(i=0;i<n;i++) cin >> h[i];
	for(i=0;i<n;i++) cin >> a[i];
	build();
	for(i=0;i<n;i++){
		ll res = query(1,h[i]);
		modify(h[i],a[i] + res);
	}
	cout << query(1,n+1) << endl;
}

Measured memory_bytes: 6528
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int S = int.Parse(Console.ReadLine());
        int h = S / 3600;
        int m = S % 3600 / 60;
        int s = S % 60;
        Console.WriteLine("{0}:{1}:{2}", h, m, s);
    }
}

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

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x
#define p2(x) (1LL<<x)
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MAXS = 325;
const int SUPERS = 1000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
ll val[5],re,p[5],t[5],cnt=1,n;
//......Funcs............
ll sum(ll a,ll b)
{
    return (a+b)%MD;
}
ll mu(ll a,ll b)
{
    return (a*b)%MD;
}
ll mn(ll a,ll b)
{
    return(a-b+MD)%MD;
}
bool cmp(ll a,ll b)
{
    return 4.0/t[a]*val[a]<4.0/t[b]*val[b];
}
//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    rep(i,0,3)cin>>val[i],p[i]=i,t[i]=cnt,cnt*=2;
    cin>>n;
    n*=4;
    sort(p,p+4,cmp);
    rep(j,0,3)
    {
        int i=p[j];
        re+=(n/t[i])*val[i];
        n-=(n/t[i])*t[i];
        //cout<<t[i]<<' '<<val[i]<<endl;
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string ball[10] = {"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "},i;
	int b = 0;
	while(cin >> i,!cin.eof()){
		if(b)cout<<endl;
		b?:b=1;
		while(i.size() < 5)i = '0' + i;
		for(int k=0;k<8;k++){
			for(int l=0;l<5;l++){
				cout << ball[i[l]-'0'][k];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 900
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include<bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define ll long long
#define vi vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pb push_back
#define str string
#define mod 998244353
#define pi 3.14159265
using namespace std;
void dfs(vi edge[],ll vis[],ll &value,int i)
{
    if(!vis[i])
    {
        value++;
        vis[i]=1;
        for(int j=0;j<edge[i].size();j++)
        {
            if(!vis[edge[i][j]])
            dfs(edge,vis,value,edge[i][j]);
        }
    }
}
int main()
{
    FASTIO;
    ll n,m,ans;
    cin >> n >> m;
    ll a[m+1],b[m+1];
    rep(i,m)
    {
        cin >> a[i] >> b[i];
    }
    vi edge[n+1];
    ll vis[n+1];
    rep(i,m)
    {
        edge[a[i]].pb(b[i]);
        edge[b[i]].pb(a[i]);
    }
    ans=-1;
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++)
    {
        if(vis[i])
        continue;
        ll value=0;
        dfs(edge,vis,value,i);
        ans=max(ans,value);
    }
    cout << ans << endl;
}


Measured memory_bytes: 28580
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import GHC.Magic (oneShot)

main :: IO ()
main = do
  Just (n,_) <- BS.readInt <$> BS.getLine
  as <- VU.unfoldrN n (BSL.readInt . BSL.dropWhile (<'-')) <$> BSL.getContents
  putStrLn $ if query as then "first" else "second"

query :: VU.Vector Int -> Bool
query = VU.any odd


Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>

int main() {
    std::string ans = "CODEFESTIVAL2016";
    std::string s;

    std::cin >> s;

    int count = 0;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] != ans[i])count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    vector<string> s(n);
    map<string,ll> count;
    rep(i, n){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        count[s[i]]++;
    }
    ll ans = 0;
    for(auto it : count){
        ans += (it.second * (it.second - 1)) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18304
#include "bits/stdc++.h"
using namespace std;


int main() {
	int a;
	cin >> a;
	if (a <= 111) {
		cout << 111 << endl;
	}
	if (111<a&&a<=222) {
		cout << 222 << endl;
	}
	if (222 < a && a <= 333) {
		cout << 333 << endl;
	}
	if ( 333< a && a <= 444) {
		cout << 444 << endl;
	}
	if (444 < a && a <=555) {
		cout <<555 << endl;
	}
	if (555 < a && a <= 666) {
		cout << 666 << endl;
	}
	if (666 < a && a <= 777) {
		cout << 777 << endl;
	}
	if (777 < a && a <= 888) {
		cout << 888 << endl;
	}
	if (888 < a && a <= 999) {
		cout << 999 << endl;
	}


}


Measured memory_bytes: 256
N, M, X = map(int, input().split(' '))

list_A = [int(A) for A in input().split(' ')]

left, right = 0, 0

if X > list_A[len(list_A) - 1]:
    print(0)
    exit()

if X < list_A[0]:
    print(0)
    exit()

for A in list_A:
    if X > A:
        left += 1
        continue
    right += 1

print(min(left, right))



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
    char c;
    c=getchar();
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        cout<<"vowel"<<endl;
        else cout<<"consonant"<<endl;
    return 0;
}

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

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

    for(int i = 0; i < 4; i++) {
        if(s[i] == '+') {
            num += 1;
        }
        else {
            num -= 1;
        }
    }

    cout << num << endl;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
b = []
for i in range(a[0]):
    b.append(list(map(int, input().split())))
c = 0
for i in range(0, a[0]):
    if (b[i][0])**2 + (b[i][1])**2 <= (a[1])**2:
        c = c + 1
    else:
        c = c
print(c)

Measured memory_bytes: 45456
while True:
    try:
        spam=map(int, input().split(' '))
        spam = [i for i in spam]
        spam.sort()
        cola = spam[0] * spam[1]
        while True:
            if spam[0] == 0:
                print('{} {}'.format(spam[1],int(cola/spam[1])))
                break
            pre = spam[0]
            spam[0] = spam[1] % spam[0]
            spam[1] = pre
    except:
        break

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

/**
 * 掛け算を使う方法
 *
 * @author kou
 *
 */
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = Integer.parseInt(scan.next());
        }
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            c[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += (binarySearchA(a, b[i]) + 1) * (n - binarySearchC(c, b[i]));
        }

        System.out.println(ans);
    }

    private static long binarySearchA(int[] array, int key) {
        int ok = -1;
        int ng = array.length;

        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if (array[mid] < key) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        return ok;
    }

    private static long binarySearchC(int[] array, int key) {
        int ng = -1;
        int ok = array.length;

        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            if (array[mid] > key) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        return ok;
    }

}


Measured memory_bytes: 65412
#include<stdio.h>
int main(){
	int n,k,i,j,s[101]={0},t[101],a;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++)scanf("%d",&t[i]);
	for(i=0;i<k;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a);
			if(t[i]!=a)s[t[i]-1]++;
			else s[j]++;
		}
	}
	for(i=0;i<n;i++)printf("%d\n",s[i]);
	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<vector>

using namespace std;

int main(){
    long H,W;
    cin>>H>>W;
    vector<string> vec(H);
    for(auto&x : vec)
    {
        cin>>x;
    }

    for(long i=0;i<vec.size();++i){
        if(vec[i][0]=='.'){
            bool c=true;
            for(long k=1;k<W;++k){
                if(vec[i][k]!='.'){
                    c=false;
                }                
            }
            if(c){
                vec.erase(vec.begin()+i);
                i--;
            }
        }
    }

    for(long i=0;i<vec[0].size();++i){
        if(vec[0][i]=='.'){
            bool c=true;
            for(long k=1;k<vec.size();++k){
                if(vec[k][i]!='.'){
                    c=false;
                }                
            }
            if(c){
                for(long k=0;k<vec.size();++k){
                    vec[k].erase(vec[k].begin()+i);               
                }
                i--;
            }
        }
    }

    for(auto& x : vec)
    {
        cout<<x<<endl;
    }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    cout << (s[0] == s[2]?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[100000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 1000000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	cin >> n;
	string s;
	cin >> s;
	string a = "", b = "";
	for (int i = 0; i < n; i++) {
		if (i < n / 2) {
			a += s[i];
		}
		else {
			b += s[i];
		}
	}
	if (a == b) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#define mod 1000000007
using namespace std;
typedef long long ll;
char str[100001];
ll dp[100001];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",str);
	for(int i=1;i<n;i++)
	{
		if(str[i]=='C'&&str[i-1]=='A')
		{
			dp[i]=dp[i-1]+1;
		}
		else dp[i]=dp[i-1];
	}
	int l,r;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&l,&r);
		l--;
		r--;
		ll sum=dp[r];
		if(l-1>=0) sum-=dp[l-1];
		if(str[l]=='C'&&l-1>=0&&str[l-1]=='A') sum--;
		printf("%lld\n",sum);
	}
}

Measured memory_bytes: 1664
#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 sll;
typedef  double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    long double a,b,c;
    cin>>a>>b;
    c=a*b;
    cout<<(ll)trunc(c);
    subt;
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <cmath>

using namespace std;

int const NMAX = 1e5;
int const INF = 1e9;

int nStones;
int hopLim;
int ans;
int dp[1+NMAX];
int heights[1+NMAX];

int costOfHop(int from, int to) {
  return abs(heights[from]-heights[to]);
}

int main() {
  cin >> nStones >> hopLim;
  for(int i=1; i<=nStones; i++) {
    cin >> heights[i];  
  }

  dp[1] = 0;
  dp[2] = dp[1] + costOfHop(1, 2);
  
  for(int i=3; i<=nStones; i++) { 
    int lim = min(i-1, hopLim);
    dp[i] = INF;
    for(int j=0; j<=lim; j++){
      dp[i] = min(dp[i-j] + costOfHop(i-j, i), dp[i]);   
    }
  }
  cout << dp[nStones];
  return 0;
}

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

int main(){
  int i,j,a,b,c,con=0;
  while(cin >> a){
    if(con != 0) cout << endl;
    con++;
    for(j=0;j<=5;j+=5){
      b = a;
      for(i=10000;i>=1;i/=10){
	if(b/i == j || b/i == j+1 || b/i == j+2 || b/i == j+3 || b/i == j+4) cout << "*";
	else cout << " ";

        c = b / i;
	b = b - c * i;

      }
      cout << endl;
    }
    
    cout << "=====" << endl;
    
    for(j=0;j<5;j++){
      b = a;
      for(i=10000;i>=1;i/=10){
	if(b/i == j || b/i == j+5) cout << " ";
	else cout << "*";

	c = b / i;
	b = b - c * i;

      }
      cout << endl;
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll Mod = 1000000007;

int main(){
  int a,b;
  cin >> a >> b;
  if(abs(a - b) > 1){
    cout << max(a,b) * 2 - 1;
  }else{
    cout << a + b;
  }
}


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

void z_algorithm(const string& S, vector<int>& ret) {
    ret.resize(S.size(), 0);
    int i = 1, j = 0;
    ret[0] = S.size();
    while (i < S.size()) {
        while (i+j < S.size() and S[j] == S[i+j]) j++;
        ret[i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while (i+k < S.size() and k+ret[k] < j) {
            ret[i+k] = ret[k];
            k++;
        }
        i += k;
        j -= k;
    }
}

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

    int ans = 0;
    rep(i, N) {
        string T = S.substr(i);
        vector<int> lcp;
        z_algorithm(T, lcp);

        rep(j, T.size()) {
            int l = min(lcp[j], j);
            ans = max(ans, l);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool isPrime (int a){
    int counter=0;
    for(int i=2;i<=a/2;i++)
        if(a%i==0)counter++;

    if(counter==0)return true;

    else
    return false;

}
int main(){
    int num,i;
    //cout<<"Enter x number\n";
    cin>>num;
    for(i=num;!isPrime(i);i++);
    cout<<i;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;




int main(){
	while(1){
		int n;
		scanf("%d",&n);
		if(n == 0) break;
		int ma,mi,sum = 0,point;
		for(int i = 0;i < n;i++){
			scanf("%d",&point);
			sum += point;
			if(i == 0){
				ma = point;
				mi = point;
			}
			ma = max(ma,point);
			mi = min(mi,point);
		}
		printf("%d\n",(sum-ma-mi)/(n-2));
		
	}
}


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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    int n, m;
    cin >> n >> m;
    vi a(n);
    rep(i, n) cin >> a[i];

    long long sum = 0;
    rep(i, n) sum += a[i];

    sort(a.begin(), a.end(), greater<int>());

    if (a[m - 1] < 0.25 * sum / m) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import * as fs from 'fs'

const reader = (data: string) =>
  data
    .split('\n')
    .join(' ')
    .split(' ')
    .map(t => parseInt(t, 10))

function Main(input) {
  const r = parseInt(input, 10)

  console.log(r * r)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S==U) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
#define F first
#define S second

int dp[100009];

signed main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int,vector<int>,greater<int> >q;
  r(i,n){
    int a;
    cin>>a;
    q.push(a);
  }

  vector<P>v;

  r(i,m){
    int a,b;
    cin>>a>>b;
    v.push_back(P(-b,a));
  }

  sort(v.begin(),v.end());

  r(i,v.size()){
    int b=-v[i].F;
    int c=v[i].S;
    while(c&&q.top()<b){
      //cout<<q.top()<<endl;
      q.pop();
      q.push(b);
      c--;
    }
  }

  int sum=0;
  while(!q.empty())sum+=q.top(),q.pop();
  cout<<sum<<endl;
}

Measured memory_bytes: 3188
from collections import deque
N,K=map(int,input().split())
P=list(map(int,input().split()))

cnt=0
ans=0
buf=0
buf_2=0
q=deque([])
cnt=0
for i in range(N):
    cnt+=1
    buf=P[i]*(P[i]+1)//2/P[i]
    q.append(buf)
    buf_2+=buf
    if cnt>=K:
        if ans<buf_2:
            ans=buf_2
        buf_2-=q.popleft()
    # if len(q)==K:
    #     if sum(q)>ans:
    #         ans=sum(q)
    #     q.popleft()
print(ans)


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

int main() {
	int a, b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<2;i++){
    	if(a>b) {ans+=a; a--;}
    	else {ans+=b; b--;}
    }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#define int long long
#define MOD 998244353ll
using namespace std;

int n,a[200010],num[1000010],val[1000010];

inline int my_pow(int x,int y)
{
	if(y==0) return 1;
	if(y==1) return x;
	int res=my_pow(x,y/2);
	if(y%2==0) return (res*res)%MOD;
	else return (((res*res)%MOD)*x)%MOD;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		num[a[i]]++;
	}
	for(int i=1000000;i>=1;i--){
		int cnt=0ll,now=0ll;
		for(int j=1;j*i<=1000000;j++){
			cnt=(cnt+((num[j*i]*(j*i))%MOD))%MOD;
			now=(now+((num[j*i]*(((j*i)*(j*i))%MOD))%MOD))%MOD;
		}
		cnt=(((cnt*cnt)%MOD)+MOD-now)%MOD;
		val[i]=cnt;
		for(int j=2;j*i<=1000000;j++) val[i]=(val[i]+MOD-val[j*i])%MOD;
	}
	int ans=0;
	for(int i=1;i<=1000000;i++){
		ans=(ans+((val[i]*my_pow(i,MOD-2))%MOD))%MOD;
	}
	cout<<(ans*my_pow(2,MOD-2))%MOD<<endl;
	return 0;
}

Measured memory_bytes: 20804
# coding: utf-8
N, M = gets.split.map {|e| e.to_i}
sub = []
M.times do |i|
  _sub = gets.split
  sub << [_sub[0].to_i, _sub[1]]
end

wc = 0
ac = 0

# 結果テーブル作成
ansA = Array.new(N, 0)
# 提出分ループ
# WAの間だけカウントアップ
sub.each do |submit|
  no = submit[0]
  result = submit[1]
  if ansA[no-1] != "AC"
    if result == "AC"
      ac += 1
      wc += ansA[no-1]
      ansA[no-1] = "AC"
    else
      ansA[no-1] +=1
    end
  else
  end
end

puts "#{ac} #{wc}"



Measured memory_bytes: 22652
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
 
#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fe(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;
 
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
 
template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

int N;
int dp[11][11]={0};
int main()
{
	while(cin >> N,N){
		int K=0;
		rep(i,11){
			rep(j,11){
				dp[i][j]=inf;
			}
		}
		rep(i,11){
			dp[i][i]=0;
		}
		rep(i,N){
			int a,b,c;
			cin >> a >> b >>c;
			K=max(K,max(a,b));
			dp[a][b]=c;
			dp[b][a]=c;
		}
		K++;
		rep(i,K){
			rep(j,K){
				rep(k,K){
					dp[j][k]=min(dp[j][k],dp[i][j]+dp[i][k]);
				}
			}
		}
		int ans=inf;int id;
		rep(i,K){
			int t=0;
			rep(j,K){
				t+=dp[i][j];
			}
			if(ans > t){
				ans=t;
				id=i;
			}
		}
		printf("%d %d\n",id,ans);

	}
	return 0;
}

Measured memory_bytes: 1144
# include <iostream>
# include <math.h>

using namespace std;

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

	int* A = new int[N];
	int* B = new int[N];

	for (int i = 0; i < N; i++)
	{
		B[i] = 0;
	}
	for (int i = 1; i < N; i++)
	{
		cin >> A[i];
		B[A[i]-1]++;
	}

	for (int i = 0; i < N; i++)
	{
		cout << B[i] << endl;
	}

	return 0; 
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> num(k,0);
    for(int i=1;i<=n;i++){
        num[i%k]++;
    }
    ll ans = 0;
    for(int a=0;a<k;a++){
        int b = (k-a)%k;
        int c = (k-a)%k;
        if((b+c)%k != 0) continue;
        ans += num[a]*num[b]*num[c];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
def main():
    n = int(input())
    a_list = []
    b_list = []
    for _ in range(n):
        a, b = map(int, input().split())
        a_list.append(a)
        b_list.append(b)
    a_sorted = list(sorted(a_list))
    b_sorted = list(sorted(b_list))
    if n%2:
        print(b_sorted[n//2]-a_sorted[n//2]+1)
    else:
        print((b_sorted[n//2-1]+b_sorted[n//2]-a_sorted[n//2-1]-a_sorted[n//2])+1)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 29352
-- List of Top 3 Hills
import Control.Monad  -- replicateM
import Data.List      -- sortBy
import Data.Ord       -- comparing Down

main = replicateM 10 getLine >>= putStr . solve
-- main = replicateM 10 getLine >>= putStr . unlines . map show . solve

-- solve :: [String] -> [Int]
-- solve = take 3 . sortBy (comparing Down) . map read

solve :: [String] -> String
solve = unlines . map show . takeTop3 . map read

takeTop3 :: [Int] -> [Int]
takeTop3 = take 3 . sortBy (comparing Down)
-- import Control.Monad
-- replicateM :: Monad m => Int -> m a -> m [a]
-- perform the action n times, gathering the results

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main() {
    string s;
    cin >> s;
    int n= s.size();
    vi siro(n, 0);
    int su = 0;
    rep(i, n) {
        if (s[i] == 'B') su++;
        siro[i] = su;
    }
    ll ans = 0;
    rep(i, n) {
        if (s[i] == 'W') ans += siro[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1412
N, M = map(int, input().split())
H = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  G[a].append(b)
  G[b].append(a)

ans = 0
for i in range(N):
  m = 0
  for g in G[i]:
    m = max(m, H[g])
  if H[i] > m:
    ans += 1

print(ans)

Measured memory_bytes: 29504
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int N; cin >> N;
	multiset<int,greater<int>> p;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		p.insert(a);
	}
	int ans=0;
	auto itr=p.begin();
	ans += *itr/2;
	itr++;
	for (; itr != p.end(); itr++) {
		ans += *itr;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main(){
    cin >> n;
    vl dp(13, 0);
    rep(i, n) {
        cin >> x;
        dp[x]++;
    }

    if (dp[12] > 1) {
        cout << 0 << endl;
        return 0;
    }
    if (dp[0] > 0) {
        cout << 0 << endl;
        return 0;
    }
    vl V,A,B;
    A.push_back(0);
    rep(i, 13) {
        if (dp[i] > 2) {
            cout << 0 << endl;
            return 0;
        }
        if (dp[i] == 2) {
            A.push_back(i);
            A.push_back(24 - i);
        }
        if (dp[i] == 1)V.push_back(i);
    }

    rep(i,1 << V.size()) {
        B = A;
        rep(j, V.size()) {
            if (i & (1 << j)) {
                B.push_back(V[j]);
            }
            else B.push_back(24 - V[j]);
        }

        sort(all(B));
        k = 24-B.back();
        //cout<<k<<endl;
        rep(j, B.size() - 1) {
            k = min(k, B[j + 1] - B[j]);
        }

        ans = max(ans, k);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  map<string, int> v;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    v[s]++;
  }
  int m; cin >> m;
  for(int i = 0; i < m; i++){
    string s; cin >> s;
    v[s]--;
  }
  int ans = 0;
  for(auto it : v) ans = max(ans, it.second);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
stocker = []

N = int(input())
pastwd = input()
stocker.append(pastwd)

for i in range(1,N):
  curwd = input()
  if (pastwd[-1] != curwd[0]) or curwd in stocker:
    print("No")
    exit()
  stocker.append(curwd)
  pastwd = curwd

print("Yes")

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;
typedef vector < pll > vll;

const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1e9;

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b & 1) tmp = mulMod(tmp,a);
	return tmp;
}

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

//////////////////////////////////////////////

const int N = 1e5;

vi G[N + 5];
int vis[N + 5][3];
int n,m,st,en;
vi pr;
bool flag[10*N + 5];

void gprime(){
	int MX = 10*N;
	REP(i,2,MX){
		if(flag[i]) continue;
		pr.PB(i);
		REP(j,i,MX/i){
			flag[j*i] = true;
		}
	}
}

int find(int v){
	int l = 0, r = (int)pr.size()-1, mid, ret = -1;
	while(l <= r){
		mid = (l + r) / 2;
		if(pr[mid] >= v){
			r = mid - 1;
			ret = mid;
		}
		else l = mid + 1;
	}
	return ret;
}

int solve(){
	queue< pii > pq;
	pq.push(MP(0,st));
	int now, step, nxt, ret = INF, v;
	while(!pq.empty()){
		now = pq.front().SE;
		step = pq.front().FI;
		pq.pop();
		if(now == en){
			v = find(step);
			if(v != -1 && (pr[v] - step) % 2 == 0) ret = min(ret,pr[v]);
			else if(v+1 < (int)pr.size() && (pr[v+1] - step) % 2 == 0) ret = min(ret, pr[v+1]);
		}
		if(vis[now][step%2] || step > 3*N) continue;
		vis[now][step%2] = true;
		FOR(i,G[now].size()){
			nxt = G[now][i];
			if(!vis[nxt][(step+1)%2]){
				pq.push(MP((step+1), nxt)); 
			}
		}
	}
	if(ret == INF) ret = -1;
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(flag,0,sizeof flag);
	memset(vis,0,sizeof vis);
	gprime();
	cin >> n >> m >> st >> en;
	int u,v;
	FOR(i,m){
		cin >> u >> v;
		G[u].PB(v);
		G[v].PB(u);
	}
	
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 10860
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    char c;
    cin >> c;
    if (islower(c))
        cout << 'a' << endl;
    else
        cout << 'A' << endl;
}

Measured memory_bytes: 3656
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		double a=Double.parseDouble(scan.next());
    		double b=Double.parseDouble(scan.next());
    		
    		System.out.print((int)Math.ceil((a+b)/2));
    				
 
     
    }
    }
// end 

Measured memory_bytes: 21844
n,a,b = map(int,input().split())

mod = 10**9+7

all_combi = pow(2,n,mod)




p = 1
q = 1

for i in range(b):
    
    p *= n-i
    p %= mod
    q *= i+1
    q %= mod
    
    if i==a-1:
        nca = p * pow(q,-1,mod) % mod
        
    if i==b-1:
        ncb = p * pow(q,-1,mod) % mod

        
ans = all_combi -nca -ncb -1
ans %= (10**9+7)
    
print(ans)

Measured memory_bytes: 9144
# ABC129C - Typical Stairs
import sys
input = sys.stdin.readline

def main():
    n, m = tuple(map(int, input().split()))
    A = set(map(int, [input() for _ in range(m)]))
    MOD = 10 ** 9 + 7
    a, b = 1, 1 if not 1 in A else 0
    for i in range(2, n + 1):
        if i in A:
            a, b = b, 0
        else:
            a, b = b, (a + b) % MOD
    print(b)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18336
//
// Created by Myabu on 2020/01/20.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


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

    long long even = 2;
    long long odd = 1;

    for (int i = 0; i < N; ++i) {
        if(i%2==0){
            even = even + odd;
        }else{
            odd = odd + even;
        }
    }

    if(N%2 == 0){
        cout<<even<<endl;
    }else{
        cout<<odd<<endl;
    }



    return 0;
}

Measured memory_bytes: 256