akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void chmin(int &a, int b) { a = min(a, b); }

const int INF = 10000;
int dp[1<<14][14];
int cost[14][14];

int overlap(string a, string b) {
    int n = min((int)a.size(), (int)b.size());
    for (int i=n; i>=1; --i) {
        if (a.substr((int)a.size()-i) == b.substr(0, i)) return i;
    }
    return 0;
}

void refine(int &n, vector<string> &vs) {
    vector<string> tmp;
    for (int i=0; i<n; ++i) {
        bool add = true;
        for (int j=0; j<n; ++j) {
            if (i == j) continue;
            if (vs[j].find(vs[i]) != string::npos) {
                add = false;
                break;
            }
        }
        if (add) tmp.push_back(vs[i]);
    }
    n = tmp.size();
    vs = tmp;
}

int main() {
    int n;
    while (cin >> n) {
        if ( ! n) break;
        vector<string> vs(n);
        for (int i=0; i<n; ++i) cin >> vs[i];
        refine(n, vs);

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

        for (int i=0; i<n; ++i)
            dp[1<<i][i] = (int)vs[i].size();

        for (int i=0; i<n; ++i)
            for (int j=0; j<n; ++j) {
                if (i == j) continue;
                cost[i][j] = (int)vs[j].size() - overlap(vs[i], vs[j]);
            }

        for (int i=1; i<(1<<n); ++i)
            for (int j=0; j<n; ++j) {
                if ( ! ((i >> j) & 1)) continue;
                for (int k=0; k<n; ++k) {
                    if (k == j || ((i >> k) & 1)) continue;
                    chmin(dp[i|(1<<k)][k], dp[i][j] + cost[j][k]);
                }
            }

        int ans = INT_MAX;
        for (int i=0; i<n; ++i) chmin(ans, dp[(1<<n)-1][i]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4004
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []S = new int[n + 1];
		for(int i = 0; i < n; i++) {
			S[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		int []T = new int[q];
		for(int i = 0; i < q; i++) {
			T[i] = scan.nextInt();
		}
		scan.close();
		int sum = 0;
		for(int i = 0; i < q; i++) {
			if(search(S, n, T[i]) == 1) {
				sum ++;
			}
		}
		System.out.println(sum);
	}
	public static int search(int A[], int n, int key) {
		int i = 0;
		A[n] = key;
		while(A[i] != key) {
			i ++;
		}
		if(i != n) {
			return 1;
		}
		return 0;
	}
}



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

int main(){
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    char * s = malloc(N*sizeof(char));
    scanf("%s",s);
    
    int i;
    int passed = 0;
    int overseas = 0;
    for(i = 0; i < N; i++){
        switch(s[i]){
            case 'a':
                if(passed < A+B){
                    printf("Yes\n");
                    passed++;
                }else{
                    printf("No\n");
                }
                break;
            case 'b':
                if(passed < A+B && overseas < B){
                    printf("Yes\n");
                    passed++;
                    overseas++;
                }else{
                    printf("No\n");
                }
                break;
            case 'c':
                printf("No\n");
                break;
        }
    }
    return 0;
}

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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
int main()
{
	ll N, K; cin >> N >> K;
	ll x[100];
	ll R = 0;
	rep(i, 0, N) {
		cin >> x[i];
		R += ((x[i] > K - x[i]) ? K - x[i] : x[i]);
	}

	cout << 2 * R << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		double L = 0;
		Scanner sc = new Scanner(System.in);
		L = sc.nextInt();
		double X = (L / 3) * (L / 3) * (L / 3);
		//String max = BigDecimal.valueOf(X).toPlainString();
		System.out.println(X);
		sc.close();
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
string ans="{",s,t,m;
int main(){
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		m=s;
		for(int j=i;j<i+t.size();j++){
			if(m[j]=='?')m[j]=t[j-i];
			else if(m[j]!=t[j-i]||j>=s.size())goto u;
		}
		for(int j=0;j<m.size();j++){
			if(m[j]=='?')m[j]='a';
		}
		ans=min(m,ans);
		u:;
	}
	if(ans=="{")cout<<"UNRESTORABLE"<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n;
	lint k; scanf("%d%lld",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	vector<int> next(n);
	{
		vector<int> first(2e5+2,-1);
		rep(i,n) if(first[a[i]]==-1) first[a[i]]=i;

		vector<int> nearest(2e5+2,-1);
		for(int i=n-1;i>=0;i--){
			if(nearest[a[i]]==-1){
				next[i]=first[a[i]];
			}
			else{
				next[i]=nearest[a[i]];
			}
			nearest[a[i]]=i;
		}
	}

	int per=1;
	{
		int p=0;
		do{
			if(p>=next[p]) per++;
			p=(next[p]+1)%n;
		}while(p!=0);
	}

	if(k%per==0) return 0;

	k=(k-1)%per;

	int p=0;
	while(k>0){
		if(p>=next[p]) k--;
		p=(next[p]+1)%n;
	}

	vector<int> ans;
	while(p<n){
		if(p>=next[p]) ans.emplace_back(a[p]), p++;
		else           p=next[p]+1;
	}
	rep(i,ans.size()) printf("%d%c",ans[i],i+1<ans.size()?' ':'\n');

	return 0;
}


Measured memory_bytes: 4832
import math
import bisect
import collections
import itertools
import sys
sys.setrecursionlimit(100000000)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True

N,M=imn()
a = []
b = []
visited = [False for _ in range(N)]
graph = [[False for _ in range(50)] for _ in range(50)]
    
for i in range(M):
    v1,v2 = map(lambda x:int(x)-1, input().split())
    a.append(v1)
    b.append(v2)
    graph[v1][v2] = graph[v2][v1] = True

def dfs(v):
    visited[v] = True
    #print(graph[v])
    for v2 in range(N):
        if graph[v][v2] == False: continue
        if visited[v2]: continue
        dfs(v2)

ans = 0

for i in range(M):
    v1 = a[i]
    v2 = b[i]
    graph[v1][v2] = graph[v2][v1] = False
    
    for i in range(N): visited[i] = False

    dfs(0)
    
    for j in range(N):
        if visited[j] == False:
            ans += 1
            break

    graph[v1][v2] = graph[v2][v1] = True

print(ans)

Measured memory_bytes: 3424
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    l = sorted([A, B, C], reverse=True)
    print(10*l[0]+l[1]+l[2])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n,i,j,ans = 0,k;
	cin >> n;
	vector< ll >v(n);
	for(i = 0; i < n; i++)cin>>v[i];
	if(n < 3){
		cout << 0 << nl;
		return;
	}
	rep(i,0,n){
		rep(j,i+1,n){
			rep(k,j+1,n){
				if(v[i] != v[j] and v[j] != v[k] and v[k] != v[i]){
					if(v[i]+v[j] > v[k] and v[i]+v[k]>v[j] and v[k]+v[j]>v[i])ans++;
				}
			}
		}
	}
	cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
   //  cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+')cout << a + b << endl;
	else cout << a - b << endl;





	return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
#define SEND_HELP ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define BR cerr<<endl
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
	#ifndef ONLINE_JUDGE
        freopen("inputf.in", "r", stdin);
    #endif
    SEND_HELP

    int x;
    cin >> x;
    cout << 1 - x;

    return 0;
}

/*

*/

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>

using namespace std;

typedef long long ll;

void Solve() {
    ll a, b, c, d, C = 0, tot;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    tot = a + b;
    ll k = (a >= b) ? (a - 1) / (b + 1) + 1 : (b - 1) / (a + 1) + 1, ans = a + b;
    if(k == 1) ans = a < b ? 0 : a + b; else
    for(ll l = 0, r = a + b; l <= r; ) {
        ll md = (l + r) / 2;
        ll tmpa = a - md, tmpb = b - (md - 1) / k;
        if((tmpa + 1) * k < tmpb) r = md - 1; else {
            l = md + 1;
            ans = md;
        }
    }
    ans += ans / k;
    for(int i = c; i <= ans && i <= d; i++) putchar(i % (k + 1) ? 'A' : 'B');
    for(int i = max(ans + 1, c); i <= d; i++) putchar((a + b + 1 - i) % (k + 1) ? 'B' : 'A');
    putchar('\n');
}

int main() {
    int Q;
    scanf("%d", &Q);
    while(Q--) Solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int s,k,i,j,ans=0;
    scanf("%d %d",&k,&s);
    for(i=0;i<=k;i++){
        for(j=0;j<=k;j++){
            if(i+j<=s && i+j>=s-k) ans++;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
def getIntList():
    return list(map(int, input().split()))

def main():
    
    N,M = map(int,input().split())
    A = getIntList()

    for i in range(M):
        N -= A[i]
    
    if N >= 0:
        print(N)
    else:
        print(-1)

    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 10192
#include <stdio.h>

int main(){
  
  char S[3];
  int i;
  for(i = 0 ; i < 3 ; i++){
    scanf("%s",&S[i]);
  }
  
  int a = 0 , b = 0 , c = 0 ;
  for(i = 0 ; i < 3 ; i++){
    if(S[i] == 'a') a++;
    if(S[i] == 'b') b++;
    if(S[i] == 'c') c++;
  }
  
  if(a == 1&&b == 1&&c == 1) printf("Yes");
  else printf("No");
  
  return 0 ;
  
}

Measured memory_bytes: 128
import datetime

try:
	while 1:
		s = raw_input().split()
		s[0] = int(s[0])
		s[1] = int(s[1])
		
		if s[0] + s[1] == 0:
			exit()
		
		n = datetime.date(2004, s[0], s[1]).weekday()
		
		if n == 0:
			print("Monday")
		elif n == 1:
			print("Tuesday")
		elif n == 2:
			print("Wednesday")
		elif n == 3:
			print("Thursday")
		elif n == 4:
			print("Friday")
		elif n == 5:
			print("Saturday")
		elif n == 6:
			print("Sunday")
except:
	pass

Measured memory_bytes: 4428
import qualified Data.ByteString.Char8 as B
import Data.Bool

data Factor = Zero | One | Two deriving (Eq, Show)

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readInts :: B.ByteString -> [Int]
readInts = map readInt . B.words

main = do
  n <- readLn
  as <- readInts <$> B.getLine
  putStrLn $ bool "No" "Yes" (adjacent4 n as)

adjacent4 n as
  | length fs == n = length (filter (== Two) fs) >= div (length fs) 2
  | otherwise = length (filter (== Two) fs) >= div (length fs + 1) 2
  where
    fs = filter (/= One) (map factors2 as)

factors2 x
  | mod x 4 == 0 = Two
  | mod x 2 == 0 = One
  | otherwise = Zero

Measured memory_bytes: 4732
N = int(input())
def kakuwa(n):
    res = 0
    while n > 0:
        res += n%10
        n //=10
    return res

ans = 10000
for a in range(1,N):
    s = kakuwa(a)+kakuwa(N-a)
    if(s < ans):
        ans = kakuwa(a)+kakuwa(N-a)
print(ans)
    

Measured memory_bytes: 2940
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		ans = gcd(ans,a) ;
	}
	cout << ans << endl ;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

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



void solve(){
	ll n,ans=0;
	cin>>n;
	if(n==1) ans =1;
	else	
		for(int b=1;b<=n;b++){
			for(int p=2;p<=n;p++){
				ll x  = pow(b,p);
				if(x>n) break;
				ans=max(ans,x);
			}
		}
	cout<<ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
map<string,int> m;
int main(){
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>s;
		m[s]++;
	}
	cout<<"AC"<<" x "<<m["AC"]<<endl;
	cout<<"WA"<<" x "<<m["WA"]<<endl;
	cout<<"TLE"<<" x "<<m["TLE"]<<endl;
	cout<<"RE"<<" x "<<m["RE"];
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    mat memo(2,vec(N,0));
    ll ans = 0, last = -1;
    while(last != 0){
        if(last == -1) last = 0;
        rep(i,N){
            a[i] += last - memo[0][i];
            ll num_choice = a[i] / N;
            a[i] %= N;
            memo[1][i] = num_choice;
            ans += num_choice;
        }
        last = 0;
        rep(i,N) last += memo[1][i];
        swap(memo[0], memo[1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  long long a=2,b=1,c;
  for(i=2;i<=n;i++){
    c=b;
    b+=a;
    a=c;
  }
  printf("%lld\n",b);
  return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
a_l = list(map(int, input().split()))
a_l.sort(reverse=True)

m_count = 0
while True:
    max_price = a_l[0]//2
    for j in range(n):
        if a_l[j] >= max_price:
            a_l[j] //= 2
            m_count += 1
            if m_count == m:
                break
        else:
            break
        if m_count == m:
            break
    a_l.sort(reverse=True)
    if m_count == m:
        break

ans = 0
for i in range(n):
    ans += a_l[i]
print(ans)

Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 2e5 + 10; 
int n, a[N], b[N], s, ca[N], cb[N], res; char ch[N]; vector<int> v;
signed main() {
	scanf ("%s", ch + 1); n = strlen (ch + 1); int t = 1;
	for (int i = 1; i <= n; ++i) s += ch[i] - 48;
	for (int i = n; i >= 1; --i) ca[i] = ca[i + 1] + (ch[i] == '0');
	for (int i = 1; i <= n; ++i) cb[i] = cb[i - 1] + (ch[i] == '0');
	for (int i = 1; i <= n; ++i) {
		if (ch[i] == '1') res += (cb[i] + (i % 2 == 0)) / 2 + ca[i] * (t & 1) + (i & 1);
		else t = 0; ++t;
	//	if (ch[i] == '1') printf ("%lld\n", (cb[i] + (i % 2 == 0)) / 2 + ca[i] + (i & 1));
	} res += ((s - 1) / 2 + 1) * ((s - 1) / 2) + (s % 2 == 0) * (s / 2);
//	printf ("%lld %lld\n", s, ((s - 1) / 2 + 1) * ((s - 1) / 2) + (s % 2 == 0) * (s / 2));
	return printf ("%lld\n", res), 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, std::vector<long long> X) {
    int ans = 0, tmp = inf;
    rep(x, 101) {
        int t = 0;
        rep(i, N) {
            t += (X[i] - x) * (X[i] - x);
        }
        chmin(tmp, t);
    }
    cout << tmp << endl;
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> X(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

int N;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<int> d(N);
    REP(i, 0, N) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << '\n';
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
  int n;
  std::cin >> n;
  int N = 3 * n;
  std::vector<int> a(N);
  for (int i = 0; i < N; i++) std::cin >> a[i];
  sort(a.begin(), a.end());
  long long res = 0;
  int cnt = 0;
  for (int i = N - 2; i >= 0; i -= 2) {
    res += a[i];
    cnt++;
    if (cnt == n) break;
  }
  std::cout << res << std::endl;
}

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

int main() {
  string s;
  cin>>s;
  int n = s.size();
  const int MOD = 1000000007;

  int table[n][13];
  for(int i=0; i<n; i++) {
    for(int j=0; j<13; j++) {
      table[i][j] = 0;
    }
  }
  if(s[0]=='?') {
    for(int i=0; i<10; i++) table[0][i] = 1;
  }
  else {
    table[0][(int)(s[0]) -48] = 1;
  }

  const int trans[13] = {0,10,7,4,1,11,8,5,2,12,9,6,3};

  for(int i=1; i<n; i++) {
    // cout<<(int)(s[i])<<endl;
    if(s[i]=='?') {
      for(int add=0; add<10; add++) {
        for(int j=0; j<13; j++) {
          table[i][(trans[j]+add)%13] += table[i-1][j];
          table[i][(trans[j]+add)%13] = table[i][(trans[j]+add)%13]%MOD;
        }
      }
    }
    else {
      int add = (int)(s[i]) -48;
      for(int j=0; j<13; j++) {
        table[i][(trans[j]+add)%13] = table[i-1][j];
      }
    }
  }

  cout<<table[n-1][5]<<endl;


  return 0;
}

Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  char s;
  bool y = false;
  for(int i = 0; i < n; i++){
    cin >> s;
    if(s == 'Y') y = true;
  }
  
  if(y){ 
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}  

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	set <string> st;
	string s; 
	while (n--)
		cin>>s, st.insert(s);
	cout<<st.size()<<endl; 
	return 0;
}


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

bool is_prime(int x) {
  if (x == 1) return false;
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}


int main() {
  int X;
  cin >> X;
  while (true) {
    if (is_prime(X)) break;
    X++;
  }
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var arr=(Arr.shift()).split(" ").map(Number);
   if(arr.join("")=="00000")break;
   var y=(Arr.shift()).split(" ").map(Number);
   (function(N, A, B, C, X){
      var i=0;
      while(true){
         if(y[0]==X)y.shift();
         if(y.length==0){console.log(i);break;}
         X=((A*X)+B)%C;
         i++;
         if(i==10001){console.log(-1);break;}
      }
   }).apply(null,arr);
}

Measured memory_bytes: 11044
n=int(input())
ac=0
wa=0
tle=0
re=0

for _ in range(n):
    s=input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    else:
        re+=1


print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int N;
    double sum=0, all=1, X[8], Y[8];
    vector<int> v;
    cin >> N;
    for(int i=1;i<=N;i++) all = all * i;
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i];
    for(int i=0;i<N;i++) v.push_back(i);
    do {
        for(int i=0; i<v.size()-1; i++) sum += sqrt(pow((X[v[i+1]]-X[v[i]]), 2.0) + pow((Y[v[i+1]]-Y[v[i]]), 2.0))/all;
    } while (next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(7) << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
lli W,H,x,y;
  cin>>W>>H>>x>>y;
  double div;
  if(W==2*x)
  {
    div =W*H;
    div/=2;
printf("%.20lf", div);
    if(H==2*y)
    cout << " " << 1 << endl;
    else
    cout << " " << 0 << endl;
  }
  else{
   div =W*H;
    div/=2;
printf("%.20lf", div);
     cout << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) {
		dump("error");
		return 0;
	}
	dump(a+b)
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  vector<vector<int>> v(N,vector<int>(2));
  for(int i = 0; i < N; i++) cin>>v[i][0]>>v[i][1];
  vector<int> w(N);
  for(int i = 0; i < N; i++) w[i]=i;
  double ans = 0;
  int total=0;
  do{
    for(int i = 0; i < N-1; i++){
      int dx = v[w[i]][0]-v[w[i+1]][0];
      int dy = v[w[i]][1]-v[w[i+1]][1];
      ans+=sqrt(dx*dx+dy*dy);
    }
    total++;
  }while(next_permutation(w.begin(),w.end()));
  cout<<fixed<<setprecision(10);
  cout<<ans/total<<endl;
}

Measured memory_bytes: 256
n = int(input())
li = set()
lis = []
l = list(map(int,input().split()))
for i in range(n):
    if l[i] not in li:
        li.add(l[i])
    else:
        lis.append(l[i])
        li.remove(l[i])
if len(lis) < 2:
    print("0")

else:
    lis = sorted(lis)
    print(lis[-1] * lis[-2])

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

int main() {
int64_t N,K,sum=0;
cin>>N>>K;
vector<int64_t>A(N);
for(int i = 0; i < N; i++) { cin >> A[i]; }
sort(A.begin(),A.end());
  if(N<=K)cout<<0<<endl;
  else{
for(int i =N-1; i>N-1-K;i--){A[i]=0;}
for(int i=0;i<N;i++){sum+=A[i];}
 cout<<sum<<endl;}
}

Measured memory_bytes: 1792
#!/usr/bin/env ruby
n, x = STDIN.readline.strip.split(' ').map(&:to_i)

def make_size_map(n)
  size_map = []
  l = 1
  for i in 1..n do
    l = 1 + l + 1 + l + 1
    size_map[i] = l
  end
  size_map
end

# B BPPPB P BPPPB B
# 1 23456 7 89012 3
def count_patty(n, x)
  size_map = make_size_map(n)
  l = size_map[n]
  if n == 0
    1
  elsif x == 1
    0
  elsif x == l
    2 * count_patty(n-1, (l-3)/2) + 1
  elsif x == (l+1)/2
    count_patty(n-1, (l-3)/2) + 1
  elsif x > (l+1)/2
    count_patty(n-1, (l-3)/2) + 1 + count_patty(n-1, x-((l-3)/2+2))
  elsif x < (l+1)/2
    count_patty(n-1, x-1)
  end
end

puts count_patty(n, x)

Measured memory_bytes: 2044
import math

N = int(input())
pt = 1
pa = 1
for i in range(N):
    t, a = map(int, input().split())

    t_ratio = pt // t
    a_ratio = pa // a
    if pt % t != 0:
        t_ratio += 1
    if pa % a != 0:
        a_ratio += 1
    min_ratio = max(t_ratio, a_ratio)
    pt = t * min_ratio
    pa = a * min_ratio

print(pt+pa)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
using p = pair<long long, int>;
#define INF 100000000

int main(){
	long long x;
	cin >> x;
	
	for(int a = 1; a < 1000; a++){
		long long a5 = 1;
		rep(i,5) a5*=a;
		long long seki = x/a5;
		long long amari = x % a5;
		
		long long z = 1-seki;
		long long b5 = a5*z -amari;
		for(int i = -1000; i< 1000; i++){
		    long long ans = 1;
		    rep(j,5) ans*=i; 
			if(b5 == ans){
			
				printf("%d %d\n",a,i);
				return 0;
			} 
		}
	}	
	
	
}

Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
   int n;
   cin >> n;
   vector<int> v(n);
   vector<int> q(n);
   rep(i,n) {
       cin >> v[i];
       q[i] = v[i];
   }
   sort(v.begin(),v.end());
   int x,y;
   x = v[n/2 -1],y = v[n/2];

   for (int i = 0;i < n;i++){
       if (q[i] <= x) cout << y << endl;
       else cout << x << endl;
   }
   return 0;

}

Measured memory_bytes: 3712
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let good_odds = vec!['R', 'U', 'D'];
    let good_evens = vec!['L', 'U', 'D'];
    for (idx, c) in (1..).zip(s.iter()) {
        let step = idx % 2;
        if step == 1 && !good_odds.contains(&c) {
            println!("No");
            return;
        } else if step == 0 && !good_evens.contains(&c) {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <cstdio>
using namespace std;

int main() {
	int n;
	int temp, min=1000000000, p_max=-1000000000;
	scanf("%d",&n);
	scanf("%d",&min);
	for(int i=1; i<n; ++i) {
		scanf("%d",&temp);
		if(temp-min>p_max) p_max=temp-min;
		if(min>temp) min=temp;
	}
	printf("%d\n",p_max);
	return 0;
}

Measured memory_bytes: 2728
s=input()
n=len(s)

#開始が0の場合の回数
kaishi0=0
for i in range(n):
  kaishi0+=abs(int(s[i])-i%2)

#開始が1の場合の回数
kaishi1=0
for i in range(n):
  kaishi1+=abs(int(s[i])-((i+1)%2))

print(min(kaishi0,kaishi1))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
#define sort(x) sort((x).begin(), (x).end())
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}
const int maxn = 100000+5;

int d[maxn];

int main(){
    //freopen("input.txt", "r", stdin);
    fastio();

    string s;
    cin>>s;
    int len = s.size();
    int cnt1 = 0, cnt2 = 0;
    for(int i = 0 ; i< len; ++i){
        if(s[i] == '0') cnt1++;
        else cnt2++;
    }

    cout<<2* min(cnt1, cnt2)<<endl;

    return 0;
}


Measured memory_bytes: 512
from collections import deque

S = input()
B = deque()
res = 0
for s in range(len(S)):
    B.append(S[s])
Q = int(input())
for q in range(Q):
    A = list(map(str, input().split()))
    if int(A[0]) == 1:
        if res == 0:
            res = 1
        else:
            res = 0
    else:
        if int(A[1]) == 1:
            if res == 0:
                B.appendleft(A[2])
            else:
                B.append(A[2])
        else:
            if res == 0:
                B.append(A[2])
            else:
                B.appendleft(A[2])
if res == 0:
    print(''.join(B))
else:
    B.reverse()
    print(''.join(B))

Measured memory_bytes: 8692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int[] t = new int[q];
		for (int i = 0; i < q; i++) {
			t[i] = sc.nextInt();
		}

		int count = 0;
		for (int i = 0; i < q; i++) {
			for (int j = 0; j < n; j++) {
				if (t[i] == s[j]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);

	}

}



Measured memory_bytes: 40120
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong();
		String b=sc.next();	
		b=b.replace(".", "");
		
		int b2 = Integer.valueOf(b);
		
		System.out.println(a*b2/100);
	}
}

Measured memory_bytes: 35780
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	string s;
	while(getline(cin,s),s != "0"){
		istringstream iss(s);
		vector<int> v; int x;
		while(iss>>x) v.push_back(x);
		int one = 0,ans = 0;
		FOR(i,sz(v)) {
			if(v[i] == 1) one++;
			else ans += min(10,v[i]);
		}
		ans += one;
		for(int i = 0; i < one; i++){
			if(ans + 10 > 21) break;
			ans += 10;
		}
		cout << (ans>21?0:ans) << endl;
	}

	return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT cin.tie(0); ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

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

    ll ans = 0;
    rep(i, S.length() - 1) {
        if (S[i] != S[i + 1]) 
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	string ans = "";
	if (s.size() < 26) {
		vector<int> used(26, 0);
		for (int i = 0; i < s.size(); ++i) {
			used[s[i] - 97] = 1;
		}
		for (int i = 0; i < 26; ++i) {
			if (used[i] == 0) {
				ans += s + char(i + 97);
				break;
			}
		}
		cout << ans << endl;
		exit(0);
	}

	int pos = 25;
	char prev = s[25];
	for (int i = 24; i >= 0; --i) {
		if (s[i] > prev) pos = i;
		else break;
		prev = s[i];
	}
	if (pos == 0) {
		cout << -1 << endl;
		exit(0);
	}

	ans += s.substr(0, pos - 1);
	vector<int> unused(26, 0);
	for (int i = 25; i >= pos; --i) {
		unused[s[i] - 97] = 1;
	}
	char q = s[pos - 1];
	for (int i = 0; i < 26; ++i) {
		if (unused[i] == 1 && char(i + 97) > q) {
			ans += char(i + 97);
			break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from operator import itemgetter
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
lr = sorted([[xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]] for i in range(n)], key=itemgetter(1,0))

cnt = 1
cl = lr[0][0]
cr = lr[0][1]
for l,r in lr[1:]:
    if cr<=l:
        cr = r
        cl = l
        cnt += 1

print(cnt)

Measured memory_bytes: 50172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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



int main(int argc, const char * argv[]) {
    
   
    
    
    int a; cin >> a;
    string s; cin >> s;
    
    if(a < 3200) cout << "red" << endl;
    else cout << s << endl;
    
    return 0;
    
    

    
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int sx=in(),sy=in(),tx=in(),ty=in(),i;
	int x=tx-sx;
	int y=ty-sy;
	rep(i,y)printf("U");
	rep(i,x)printf("R");
	rep(i,y)printf("D");
	rep(i,x+1)printf("L");
	rep(i,y+1)printf("U");
	rep(i,x+1)printf("R");
	printf("DR");
	rep(i,y+1)printf("D");
	rep(i,x+1)printf("L");
	printf("U\n");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
constexpr auto MAX = 10E9+1;
using namespace std;
using ll = long long;
using VI = vector<int>;

int main()
{
    char a;
    cin >> a;
    if (a >= 65 && a <= 90) {
        cout << 'A' << endl;
    }
    else {
        cout << 'a' << endl;
    }

    return 0;
}


Measured memory_bytes: 3604
#!/usr/bin/env python3

n = int(input())
data = input()
a = data.split(" ")
count = 0
sum = 0
i = 0
while i < n:
    if int(a[i])%2==0:
        a[i]=int(a[i])/2
        count+=1
        if count%n==0:
            sum+=1
        i += 1
    else:break
    if i==n:i -= n
    
print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

// sepで区切る
vector<string> split(const string &str, char sep) {
    vector<string> v;
    auto first = str.begin();
    while( first != str.end() ) {
        auto last = first;
        while( last != str.end() && *last != sep ) ++last;
        v.push_back(std::string(first, last));
        if( last != str.end() ) ++last;
        first = last;
    }
    return v;
}

int main(void) {
    while(1) {
        string s, t;
        cin >> s;
        if(s == ".") break;
        cin >> t;

        if(s == t) {
            cout << "IDENTICAL\n";
            continue;
        }

        auto vs = split(s, '\"'), vt = split(t, '\"');
        if(vs.size() != vt.size()) {
            cout << "DIFFERENT\n";
            continue;
        }
        
        ll cnt = 0;
        bool diff = false;
        const ll sz = vs.size();
        REP(i, sz) {
            if(i%2==0) {
                if(vs[i] != vt[i]) {
                    diff = true;
                    break;
                }
            } else if(vs[i] != vt[i]) {
                cnt++;
            }
        }
        if(cnt > 1) diff = true;

        if(diff) cout << "DIFFERENT\n";
        else cout << "CLOSE\n";
    }

    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define REP(i, n, s) for (LL i = (s); i < (n); i++)
#define MOD 1000000007
using namespace std;
typedef long long int LL;
typedef long double LD;

int N, A;

LL _pow(LL a, LL k) {
	LL res = 1;
	while (k > 0) {
		if (k&1 == 1) res = (res * a) % MOD;
		a = a * a % MOD;
		k >>= 1;
	}
	return res;
}

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

	cin >> N;
	priority_queue<int, vector<int>, greater<int> >que;
	REP(i, N, 0) {
		cin >> A;
		que.push(A);
	}

	int a = 1;
	if (N&1 == 1) {
		if (que.top() != 0) {
			cout << "0" << endl;
			return 0;
		}
		que.pop();
		a = 2;
	}
	for (int i = a; i < N; i += 2) {
		int v1 = que.top();
		que.pop();
		int v2 = que.top();
		que.pop();
		if (v1 != i || v2 != i) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << _pow(2, N/2) << endl;

	return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}

Measured memory_bytes: 256