akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
using ll=long long;
using namespace std;

template<typename T>
class BIT{
private:
    int n;
    vector<T> d;
public:
    BIT(int n){
        this->n=n;
        for(int i=0;i<n;i++){
            d.push_back(0);
        }
    }
    void add(int i,T x){
        //cout<<"add:"<<i<<" "<<x<<endl;
        for(i++;i<=n;i+=i&-i){
            d[i]+=x;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    T sum(int l, int r) {
        //cout<<"sum:"<<l<<" "<<r<<endl;
        return sum(r-1) - sum(l-1);
    }
};

int main(){
    int N,Q;
    cin>>N>>Q;
    vector<int> cc(N+1);
    vector<priority_queue<int,vector<int>,greater<int>>> c(N);
    int a;
    for(int i=0;i<N;i++){
        cin>>a;
        cc[i+1]=a-1;
        c[a-1].push(i+1);
    }

    vector<vector<int>> q(N+1);
    int b;
    for(int i=0;i<Q;i++){
        cin>>a>>b;
        q[a].push_back(b);
        q[a].push_back(i);
    }
    /*
    for(int i=0;i<N+1;i++){
        for(auto p:q[i]){
            cout<<p<<" ";
        }
        cout<<endl;
    }
    //*/
    vector<int> ans(Q);
    BIT<int> bit(N+2);
    for(int i=0;i<N;i++){
        if(!c[i].empty()){
            bit.add(c[i].top(),1);
            c[i].pop();
        }
    }

    for(int i=1;i<N+1;i++){
        if(!q[i].empty()){
            for(int j=0;j*2<q[i].size();j++){
                ans[q[i][2*j+1]]=bit.sum(i,q[i][2*j]+1);
            }
        }
        if(!c[cc[i]].empty()){
            //cout<<cc[i]<<endl;
            bit.add(c[cc[i]].top(),1);
            c[cc[i]].pop();
        }
    }

    for(auto p:ans){
        cout<<p<<endl;
    }

    return 0;
}

Measured memory_bytes: 62720
INF = 1e9

def MatrixChainMulti(n, p):
    dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
    
    for i in range(n+1):
        dp[i][i] = 0
        
    for l in range(1, n): # 1<= l <= n-1
        for i in range(0, n-l+1): #0<= i <= n-l
            j = i + l
            dp[i][j] = INF
            for k in range(i, j): # i<= k <= j-1
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j])
    
    return dp[1][n]

N = int(input())
p = []
a, b = list(map(int, input().split()))
p.append(a)
p.append(b)

for _ in range(N-1):
    c, d = list(map(int, input().split()))
    p.append(d)
    
print(MatrixChainMulti(N, p))

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

using namespace std;


bool ispal(string s)
{
	string temp  = s;
	reverse(temp.begin(),temp.end());

	return s==temp;

} 
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin>>s;

	int n = s.size();

	if(!ispal(s))
	{
		cout<<"No"<<'\n';
		return 0;
	}
			
	string s1 = s.substr(0,(n-1)/2);
	string s2 = s.substr((n+3)/2,n-(n+3)/2-1);

	if(ispal(s1) && ispal(s2))
	{
		cout<<"Yes"<<'\n';
	}
	else
	{
		cout<<"No"<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
(defun game-for-two (data flg)
  (cond
    ((eq data nil) 0)
    ((eq flg t)
     (+  (game-for-two (cdr data) (not flg))
	 (car data)))
    (
     (-  (game-for-two (cdr data) (not flg))
	 (car data)))))

(defun input (n data)
  (if (eq n 0)
      data
      (input (1- n) (cons (read) data))))

(format t "~A~%" (game-for-two (sort (input (read) nil) #'>) t))

Measured memory_bytes: 10848
#include <stdio.h>
int main()
{
  char ch ;
  int count[30] = {0};


  int i = 0 ;
  int n, m ;

  while( scanf("%c", &ch) != EOF ){
    if('a' <= ch && ch <= 'z' ){
      count[ch - 'a'] += 1 ;
    }else if('A' <= ch && ch <= 'Z' ){
      count[ch - 'A'] += 1 ;
    }else{
      m += 1 ;
    }
  }

  for( i = 0, ch = 'a' ; i < 26 ; i++, ch++ ){
    printf("%c : %d\n", ch, count[i]) ;
  }

  return 0 ;
}


Measured memory_bytes: 2108
#include<set>
#include<map>
#include<list>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define qread(x) x=read()
#define mes(x,y) memset(x,y,sizeof(x))
#define mpy(x,y) memcpy(x,y,sizeof(x))
#define INF 2147483647
inline int read(){
	int f=1,x=0;char ch;
	while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int n;
char s[110][20]; 
int main(){ 
    qread(n);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    for(int i=2;i<=n;i++){
    	if(s[i][1]!=s[i-1][strlen(s[i-1]+1)]){
    		printf("No\n");
    		return 0;
    	}
    	for(int j=1;j<i;j++){
    		if(strcmp(s[i]+1,s[j]+1)==0){
    			printf("No\n");
    			return 0;
    		}
    	}
    }
    printf("Yes\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
    int a,p;
    int a2,ans;
    cin>>a>>p;
    a2=a*3;
    ans=(a2+p)/2;
    cout<<ans<<endl;
    return 0;
}


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

string S;

int main() {
    cin >> S;

    int nearest_val = 0;
    for (int i = 0; i <= S.size() - 3; i++) {
        string str1 { S[i] };
        string str2 { S[i + 1] };
        string str3 { S[i + 2] };
        string target = str1 + str2 + str3;

        // cout << target << endl;

        if (abs(stoi(target) - 753) < abs(nearest_val - 753)) {
            nearest_val = stoi(target);
        }
    }

    cout << abs(nearest_val - 753) << endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> L(2*N);
  for(int &i:L)
    cin>>i;
  sort(L.begin(),L.end());
  int j=0;
  for(int i=0;i<N;i++)
    j+=L[i*2];
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <string>
#include <string.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 7;

map<int, map<int, int> >mp;
bool vis[maxn];
int in[maxn];
int color[maxn];

void dfs(int now, bool ok) {
	vis[now] = 1;
	color[now] = ok;
	for (auto it = mp[now].begin(); it != mp[now].end(); ++it) {
		if (vis[it->first] == 1) continue;
		if (it->second % 2 == 0) dfs(it->first, ok);
		else dfs(it->first, !ok);
	}
}

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

	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		mp[x][y] = z;
		mp[y][x] = z;
		in[x]++; in[y]++;
	}
	int head;
	for (int i = 1; i <= n; i++) {
		if (in[i] == 1) {
			head = i;
			break;
		}
	}

	dfs(head, 0);
	
	for (int i = 1; i <= n; i++) {
		cout << color[i] << endl;
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 27392
fn main() {
    let mut s = String::new();

    let _ = std::io::stdin().read_line(&mut s);
    
    let nums : Vec<f64> = s.lines()
        .nth(0).unwrap()
        .split_whitespace().take(2)
        .map(|x| { x.parse().unwrap() }).collect();
        
    println!("{}", ((nums[0] + nums[1]) / 2.0).ceil());
        
}


Measured memory_bytes: 4352
/* 
    
*/ 
#include <bits/stdc++.h>
#define md(x, y)  (x + y) / 2
#define ls(x)      x << 1
#define rs(x)      x << 1 | 1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
ll n, a[MAXN], x;
ll cost[MAXN];//对于最小花费是自己的，放在最后
ll dp[MAXN][50];                        
void init()
{
    for(int i = 1; i <= n; i++)
        dp[i][0] = a[i];
    int nlog = (int)log2(n);
    for(int j = 1; j <= nlog; j++)
        for(int i = 1; i <= n; i++)
            if((i + (1 << j) - 1) <= n)
                dp[i][j] = min(dp[i][j - 1], dp[i + (1 << (j - 1))][j - 1]);
}
ll rmq(int s, int e)
{
    if(s > e)   return 1e18;
    int nlog = (int)log2(e - s + 1);
    return min(dp[s][nlog], dp[e - (1 << nlog) + 1][nlog]);
}
int main()
{
    cin >> n >> x;
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    init();
    ll ans = 1e18;
    for(int k = 0; k < n; k++)  //枚举次数
    {
        for(int i = 1; i <= n; i++)
        {
            cost[i] = a[i];
            if(i > 1 && k)
            {
                int L = max(1, i - k);
                int R = i - 1;
                cost[i] = min(cost[i], rmq(L, R));
                if(i - k < 1)
                {
                    
                    int L = n + 1 - (k - (i - 1));
                    int R = n;
                    //printf("2.L = %d, R = %d\n", L, R);
                    cost[i] = min(cost[i], rmq(L, R));
                }
            }
            else if(k)
            {
                int L = n + 1 - k;
                int R = n;
                //printf("L = %d, R = %d\n", L, R);
                cost[i] = min(cost[i], rmq(L, R));
            }
            //printf("cost[%d] = %d\n", i, cost[i]);
        }
        ll sum = k * x;
        for(int i = 1; i <= n; i++) sum += cost[i];
        ans = min(sum, ans);
    }
    printf("%lld\n", ans);
    return 0;
}

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

#define ll long long

signed main()
{
  int n; cin >> n;
  int ans = 0,num = 0;
  if(n==1){
    cout << 1 << "\n";
    return 0;}

  for(int i = 1; i<=n; ++i){
    int cnt = 0;
    for(int j = i; j%2!=1; j/=2){
      //cout << j << "\n";
      ++cnt;
    }
    if(cnt > num){
      num = max(num,cnt);
      ans = i;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 300005;

int n, m;

#define lowbit(x) (x & (-x))

struct Tree
{
	int no[maxn];
	
	inline void add(int pla, int x)
	{
		for (; pla <= m; pla += lowbit(pla))
			no[pla] += x;
	}
	
	inline void add_qj(int l, int r)
	{
//		cout << "add " << l << ' ' << r << endl;
		add(l, 1);
		if (r < m)
			add(r + 1, -1);
	}
	
	inline int query(int pla)
	{
		int ans = 0;
		for (; pla; pla -= lowbit(pla))
			ans += no[pla];
		return ans;
	}
} tr;

struct QJ
{
	int l, r;
	inline int len() { return r - l + 1; }
	friend bool operator < (QJ a, QJ b)
	{ return a.r - a.l < b.r - b.l; }
} qj[maxn];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d", &qj[i].l, &qj[i].r);
	sort(qj + 1, qj + n + 1);
//	cout << "qj\n";
//	for (int i = 1; i <= n; ++i)
//		cout << qj[i].l << ' ' << qj[i].r << endl;
	int now = 1;
	for (int i = 1; i <= m; ++i)
	{
		while (now <= n && qj[now].len() < i)
		{
			tr.add_qj(qj[now].l, qj[now].r);
			now++;
		}
		int ans = n - now + 1;
//		cout << "ans = " << i << ' ' << ans << ' ' << now << endl;
		for (int j = 0; j <= m; j += i)
//		{
			ans += tr.query(j);
//			cout << j << ' ' << tr.query(j) << endl;
//		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main()
{
int n, ans=0;
cin>>n;
for(int i=105; i<=n; i+=2)
{
int a=0;
for(int j=1; j<=i; ++j)
a+=(i%j==0);
ans+=(a==8);
}
cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

const int maxn = 400000+10;
const int dem = 2;  //维数
const double INF = (1e200);

struct Point{
    double x[dem];
}p[maxn];

int n;
double minx[1<<dem], maxx[1<<dem];

long long solve() {
    int tmp = 1<<dem;

    for(int i=0; i<tmp; i++) {
        minx[i] = INF;
        maxx[i] = -INF;
    }

    for(int i=0; i<n; i++) {
        for(int j=0; j<tmp; j++) {
            int t = j;
            double s = 0;
            for(int k=0; k<dem; k++) {
                if(t & 1) s += p[i].x[k];
                else s -= p[i].x[k];
                t >>= 1;
            }
            if(maxx[j] < s) maxx[j] = s;
            if(minx[j] > s) minx[j] = s;
        }
    }

    double ans = -INF;
    for(int i=0; i<tmp; i++) {
        if(maxx[i] - minx[i] > ans)
            ans = maxx[i] - minx[i];
    }

    return ans;
}

int main(){
    cin>>n;
    for(int i=0; i<n; i++) {
            for(int j=0; j<dem; j++) {
                scanf("%lf", &p[i].x[j]);
            }
        }
    cout<<solve()<<endl;
    return 0;
}


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

ll a, b;

int main()
{
	cin >> a >> b;
	cout << max( a - b, max( a + b, a * b ) ) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL N, len, D;

void MAIN() {
    scanf("%lld%lld%lld", &N, &len, &D);

    double p;
    if (D == 0) {
	p = N;
    } else {
	p = (N-D) * 2;
    }

    double ans = p * (len - 1) / N / N;
    printf("%.12f\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
long long int fpow[150];

int main(){
		for(long long int i=0LL;i<150LL;i++){
			fpow[i]=i*i*i*i*i;
		}
	long long int n;cin>>n;
	for(long long int i=0;i<150LL;i++){
		for(long long int j=0;j<150LL;j++){
			if(fpow[i]+fpow[j]==n){
				cout<<i<<" "<<-j<<endl;
				return 0;
			}
          else if(fpow[i]-fpow[j]==n){
          	cout<<i<<" "<<j<<endl;
            return 0;
          }
		}
	}
	cout<<"Hoge"<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  	string s;
  	cin>>s;
  	long int num = 0;
  	for(long int i = 0; i<s.size(); i++)
  	{
  		num += s[i]-'0';
  	}

  	if(num%9) cout<<"No";
  	else cout<<"Yes";
}	

Measured memory_bytes: 3688
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: infer_types=True
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

from libcpp.string cimport string as Str
# define 
ctypedef long long LL

# 読み込みはpython側で行う
import sys
readline = sys.stdin.buffer.readline().rstrip

cdef LL i,j,k,_


cdef Str S = readline()
cdef Str dream = b'dream'
cdef Str dreamer = b'dreamer'
cdef Str erase = b'erase'
cdef Str eraser = b'eraser'

# 文字列処理は流石にpypy提出のほうが楽そう
# 致命的な点としては、libcpp.stringがeraseなどの文字列削除操作に対応していない点だ

cdef LL idx=S.size()
while idx>7:
    if S.substr(idx-5,5)==dream: #idxから後ろ5文字以降を表示
        idx-=5 
    elif S.substr(idx-5,5)==erase:
        idx-=5 
    elif S.substr(idx-6,6)==eraser:
        idx-=6
    elif S.substr(idx-7,7)==dreamer:
        idx-=7 
    else: break

#print(S,idx,S.substr(idx))
if S.substr(0, idx) in [dream, dreamer, erase, eraser]:
    print('YES')
else:
    print('NO')



'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 10448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int MAX = 1000005;
const long long mod = 1e9 + 7;
vector<long long> fact(MAX);
vector<long long> inv(MAX);
vector<long long> finv(MAX);

void init() {
	fact[0] = fact[1] = 1;
	inv[1] = 1;
	finv[0] = finv[1] = 1;

	for (int i = 2; i < MAX; ++i) {
		fact[i] = (fact[i - 1] * i) % mod;
		inv[i] = (mod - (mod / i)*inv[mod%i] % mod) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long nCr(int n, int r) {
	if (r > n) return 0LL;
	else if (n < 0 || r < 0) return 0LL;
	else return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int ans; cin >> ans;
	cout << (ans*(ans+1))/2 << "\n";
	return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define foi(i,n) for(int i = 0; i < n ; ++i)
#define pi pair<int,int>
#define mod 1000000007
using namespace std;

int dp[3005][3005];
// ith index , j daala
int solve(int n,string &arr){
    dp[n-1][1] = 1;
    for(int i = n-2;i>=0;i--){
        int bottom = n-i-1;
        for(int j = 1 ; j <= n-i ; j++){
            if(arr[i] == '<'){
                dp[i][j] = dp[i+1][j-1];
            }
            else{
                dp[i][j] = (dp[i+1][bottom] - dp[i+1][j-1]+mod)%mod;
            }
        }
        for(int j = 1 ; j<=n-i;j++) dp[i][j] = (dp[i][j]%mod +dp[i][j-1]%mod)%mod;
    }
    return dp[0][n];
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    foi(i,3005){
        foi(j,3005) dp[i][j] = 0;
    }
    int n;
    cin >> n;
    string arr;
    cin >> arr;
    cout << solve(n,arr);
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, N) cin >> l[i];

    sort(all(l));
    reverse(all(l));

    int ans = 0;
    rep(i, K) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::io::BufRead;
use std::collections::HashSet;

fn count<'a>(r: usize, n: &'a str) -> usize {
    if r == 0 {
        return 1;
    }
    let mut d = HashSet::new();
    let mut sum = 0;
    for (i, c) in n.chars().enumerate() {
        if d.contains(&c) {
            continue;
        }
        d.insert(c);
        sum += count(r-1, &n[i+1..]);
    }
    sum
}

fn main() {
    let mut v = String::new();
    stdin().read_line(&mut v);
    let mut c = String::new();
    stdin().read_line(&mut c);
    println!("{}", count(3, &c.trim()));
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int,int> pll;
const int maxn= 1e6+10;
const int mod =1e9+7;
const double EPS = 1e-6;
bool cmp(int x, int y)
{
    return x>y;
}
int num1[maxn];
int num2[maxn];
int num3[maxn];



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    for(int i=1;i<=a;i++)
    {
        cin >> num1[i];
    }
    for(int i=1;i<=b;i++)
    {
        cin >> num2[i];
    }
    for(int i=1;i<=c;i++)
        cin >> num3[i];
    /*for(int i=1;i<=a;i++)
        cout << num1[i];*/
    sort(num1+1,num1+a+1,cmp);
    sort(num2+1,num2+b+1,cmp);
    int len=c;
    for(int i=1;i<=x;i++)
    {
        num3[++len]=num1[i];
    }
    for(int i=1;i<=y;i++)
    {
        num3[++len]=num2[i];
    }
    sort(num3+1,num3+len+1,cmp);
    LL ans=0;
    for(int i=1;i<=x+y;i++)
    {
        ans+=num3[i];
    }
    cout << ans << endl;
    return 0;
}



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

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

  if((N%10)==3){
    cout << "bon" << endl;
  }
  else if((N%10)!=0){
    if((N%10)!=1){
      if((N%10)!=6){
        if((N%10)!=8){
          cout << "hon" << endl;
        }
        else{
          cout << "pon" << endl;
        }
      }
      else{
        cout << "pon" << endl;
      }
    }
    else{
      cout << "pon" << endl;
    }
  }
  else{
    cout << "pon" << endl;
  }
}


Measured memory_bytes: 3632
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int p = stdIn.nextInt();
        int q = stdIn.nextInt();
        int r = stdIn.nextInt();

        int min = p + q;
        if (p + r < min) {
            min = p + r;
        }
        if (q + r < min) {
            min = q + r;
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX + 1];

void maxHeapify(int i) {
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;
    
    if(l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;
    
    if(largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract() {
    int maxv;
    if(H < 1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if(key < A[i]) return;
    A[i] = key;
    while(i > 1 && A[i / 2] < A[i]) {
        swap(A[i], A[i / 2]);
        i = i / 2;
    }
}

void insert(int key) {
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main() {
    int key;
    char com[10];
    
    while(1) {
        scanf("%s", com);
        if(com[0] == 'e' && com[1] == 'n') break;
        if(com[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        }else {
            printf("%d\n", extract());
        }
    }
    
    return 0;
}


Measured memory_bytes: 6480
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;



int main(int argc, const char* argv[]){
    int n;
    cin >> n;
    int count = 0;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        if((i + 1) % 2 == 1 && num % 2 == 1)count++;
    }


    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>

#define EPS 1e-10

struct POINT_DOUBLE {
  double x;
  double y;

  bool operator == (const POINT_DOUBLE& other) const {
    return (std::abs(x - other.x) < EPS) && (std::abs(y - other.y) < EPS);
  }

  bool operator < (const POINT_DOUBLE& other) const {
    return x < other.x || (x == other.x && y < other.y);
  }
};

struct LINE_DOUBLE {
  LINE_DOUBLE() {}
  LINE_DOUBLE(const POINT_DOUBLE& pt1, const POINT_DOUBLE& pt2) {
    a = pt1.y - pt2.y;
    b = pt2.x - pt1.x;
    c = pt1.x * pt2.y - pt2.x * pt1.y;
  }

  double GetValue(const POINT_DOUBLE& pt) {
    return a * pt.x + b * pt.y + c;
  }

  double a;
  double b;
  double c;
};

std::istream& operator >> (std::istream& is, POINT_DOUBLE& p)
{
  is >> p.x >> p.y;
  return is;
}

bool getConvex(const std::vector<POINT_DOUBLE>& pts, std::vector<POINT_DOUBLE>* pConvex)
{
  if (pts.size() <= 2) {
    return false;
  }

  std::vector<POINT_DOUBLE> sorted;
  sorted.assign(pts.begin(), pts.end());
  std::sort(sorted.begin(), sorted.end());

  pConvex->clear();
  pConvex->push_back(*sorted.begin());

  while (1) {
    POINT_DOUBLE ref = *pConvex->rbegin();

    for (auto pt1 : sorted) {
      if (pt1 == ref) {
        continue;
      }
      LINE_DOUBLE line(ref, pt1);
      bool bOuterMost = true;
      for (auto pt2 : sorted) {
        if (pt2 == ref || pt2 == pt1) {
          continue;
        }
        if (line.GetValue(pt2) < 0) {
          bOuterMost = false;
        }
      }

      if (bOuterMost) {
        pConvex->push_back(pt1);
        break;
      }
    }

    if (pConvex->at(0) == *pConvex->rbegin()) {
      pConvex->pop_back();
      break;
    }
  }

  return true;
}

int main(void)
{
  char c;
  int n;

  while (1) {
    std::cin >> n;
    if (n == 0) {
      break;
    }
    std::vector<POINT_DOUBLE> pts(n);
    for (int i = 0; i < n; i++) {
      std::cin >> pts.at(i).x >> c >> pts.at(i).y;
    }
    std::vector<POINT_DOUBLE> convex;
    getConvex(pts, &convex);
    std::cout << pts.size() - convex.size() << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3112
from collections import Counter
N = int(input())
c = Counter()
for i in range(2, N + 1):
    for j in range(2, int(i ** .5) + 1):
        while i % j == 0:
            c[j] += 1
            i //= j
    if i > 1:
        c[i] += 1
mod = 10 ** 9 + 7
ans = 1
for v in c.values():
    ans = ans * (v + 1) % mod
print(ans)

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

int n  , x , y , k ;

main( ) {
	cin >> k >> n;
	vector<int> v( n );
	x = 0;
	for(int i=0;i<n;++i){
		cin >> y;
		v[ i ] = y-x;
		x = y;
	}
	v.push_back( k-x + v[ 0 ] );
	cout << k -*max_element(v.begin(),v.end());
}



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

int C, R;

bool flag[10], S[10][10000];

int count()
{
  int ans = 0;
  for(int i = 0; i < C; i++)
  {
    int tmp = 0;
    for(int j = 0; j < R; j++)
    {
      if(flag[j] == S[j][i])
        tmp++;
    }
    ans += max(R - tmp, tmp);
  }
  return ans;
}

int dfs(int n)
{
  if(n == R)
    return count();
  int ans = 0;
  flag[n] = 0;
  ans = max(ans, dfs(n + 1));
  flag[n] = 1;
  ans = max(ans, dfs(n + 1));
  return ans;
}

int main()
{
  while(true)
  {
    cin >> R >> C;
    if(!R && !C)
      break;
    for(int i = 0; i < R; i++)
      for(int j = 0; j < C; j++)
        cin >> S[i][j];
    cout << dfs(0) << endl;
  }
}

Measured memory_bytes: 1256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int countDigs(ll x)
{
	int ret = 0;  
	while(x)
	{
		ret++;
		x /= 10;
	}

	return ret;
}

ll n;

int main()
{
	ll i, j;
	cin >> n;
	int ans = 1000000;
	for(i = 1; i * i <= n; i++)
	{
		ll a = i;
		if(n % a == 0)
		{
			ll b = n / a;
			ans = min(ans, max(countDigs(a), countDigs(b)));
		}
	}

	cout << ans;

	return 0;
}
/*
	Powered by Buggy Plugin
*/



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	int n, i, j, k, max, min;
	int matrix[100][100];
	char *p;

	while(scanf("%d", &n) != EOF) {
		if (n == 0) break;
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				scanf("%d", &matrix[i][j]);
			}
		}
		for (i = 0; i < n; i++) {
			min = -1;
			for (j = 0; j < n; j++) {
				if (min == -1 || matrix[i][j] < min) {
					min = matrix[i][j];
				}
			}
			for (j = 0; j < n; j++) {
				if (matrix[i][j] == min) {
					max = -1;
					for (k = 0; k < n; k++) {
						if (max == -1 || matrix[k][j] > max) {
							max = matrix[k][j];
						}
					}
					for (k = 0; k < n; k++) {
						if (matrix[k][j] == max && k == i) {
							printf("%d\n", matrix[k][j]);
							goto out;
						}
					}
				}
			}
		}
		printf("0\n");
out:
		continue;
	}
	return 0;
}

Measured memory_bytes: 616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		BigDecimal one = new BigDecimal("1.00");
		int[] abo = {0,0,0,0};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		int cup = 0;
		int mun = 0;
		int ter = 0;
		String[] rrr;
		int st = 0,sr = 0;
		double mon = 0;
		int syo=0,hisi=0;
		double aaaa = 1;
		
		
		while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			
			if(tmp.equals("")){
				break;
			}
			
			mon = Double.parseDouble(tmp);
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			
			if(tmp.equals("")){
				break;
			}
			
			aaaa = Double.parseDouble(tmp);
			
			if(aaaa == 0.0 && mon == 0.0){
				break;
			}
			
			double oef;
			
			oef = Math.sqrt(aaaa*aaaa+mon*mon/4d);
			
			System.out.println((mon*mon+oef*mon*2d));
			
			
		}
	}

}

Measured memory_bytes: 16968
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
surveys.sort(key = lambda x:-x[2])
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        if survey[2] == 0 and before < height:
          continue
        identified = False
        break
      if before == -1:
        before = height
    if identified:
      print(x, y, before)
      break


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

int n, m;
int k[31];
int a[31][31];

int solve() {
  int i, j, ans = 0;
  int cnt[31];

  for (i = 1; i <= m; i++) {
    cnt[i] = 0;
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < k[i]; j++) {
      cnt[a[i][j]]++;
    }
  }

  for (i = 1; i <= m; i++) {
    if (cnt[i] == n) {
      ans++;
    }
  }
  return ans;
}

int main() {
  int i, j;

  cin >> n >> m;

  for (i = 0; i < n; i++) {
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> a[i][j];
    }
  }

  cout << solve() << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] nums = new int[3];
        int tmp = 0;
        boolean flag = true;
        for (int i = 0; i < 3; i++) {
            nums[i] = scan.nextInt();
        }
        for (int i = 0; flag; i++) {
            flag = false;
            for (int j = 2; j >= i + 1; j--) {
                if (nums[j] < nums[j - 1]) {
                    tmp = nums[j];
                    nums[j] = nums[j - 1];
                    nums[j - 1] = tmp;
                    flag = true;
                }
            }
        }
        for (int i = 0; i < 3; i++) {
            if (i > 0)
                System.out.print(" ");
            System.out.printf("%d", nums[i]);
        }
        System.out.print("\n");
    }
}



Measured memory_bytes: 26400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 200005;

char s[MaxN + 5];
int dp[MaxN + 5];
int pre[MaxN + 4];
int best[1 << 26];

int main()
{
	while(scanf("%s", s + 1) != EOF)
	{
		int len = strlen(s + 1);
		for(int i = 1; i <= len; i++)
			pre[i] = pre[i - 1] ^ (1 << (s[i] - 'a'));
		for(int i = 1; i <= len; i++)
			dp[i] = inf;
		dp[0] = 0;
		for(int i = 1; i <= (1 << 26); i++)
			best[i] = inf;
		best[0] = 0;
		for(int i = 1; i <= len; i++) {
			dp[i] = min(dp[i], best[pre[i]] + 1);
			for(int j = 0; j < 26; j++) {
				int tmp = pre[i] ^ (1 << j);
				dp[i] = min(dp[i], best[tmp] + 1);
			}
			best[pre[i]] = min(best[pre[i]], dp[i]);
		}
		printf("%d\n", dp[len]);
	}
	return 0;
}

Measured memory_bytes: 264192
pxylist = []
result  = []
xp1, yp1, xp2, yp2 = map(int, input ().split())

q = int(input())

def recieve():
    for i in range(q):
            pxy = list(map(int, input().split()))
            pxylist.append(pxy) 

if xp2 == xp1:
    recieve()

    for i in range(q):
        result.append([xp1, pxylist[i][1]])
elif yp1 == yp2:
    recieve()

    for i in range(q):
        result.append([pxylist[i][0], yp1])

else:
    a = (yp2 - yp1) / (xp2 - xp1)
    b = yp1 - a*xp1

    recieve()

    for i in range(q):
        pxi = pxylist[i][0]
        pyi = pxylist[i][1]
        x = (a * (pyi - b) + pxi) / (a*a + 1)
        y = a * x + b
        result.append([x, y])

for i in range(q):
    print(str(result[i][0]) + ' ' + str(result[i][1]))



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, x, y;

    cin >> a >> b >> c >> x >> y;

    int ans0 = 0;
    int ans1 = a * x + b * y;
    int ans2 = max(x, y) * c * 2;
    int d, e;

    d = e = 0;
    d = min(x, y) * 2;
    e = max(x, y) - min(x, y);

    if (max(x, y) == x) ans0 = a * e + c * d;
    else ans0 = b * e + c * d;

    Out(min(ans0, min(ans1, ans2)));

    return 0;
}


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

int main(){
    int d;
    cin >> d;
    if(d==25){
        cout << "Christmas" << endl;
    }
    else if(d==24){
        cout << "Christmas Eve" << endl;
    }
    else if(d==23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if(d==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

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

using namespace std;
#define ll long long
const int N=100005;
int n,k;
int ar[N];
int mem[N];

int solve(int ind){
    if(ind==n-1){
        return 0;
    }
    if(ind>=n){
        return 1e9;
    }
    if(mem[ind]!=-1){
        return mem[ind];
    }
    int ret=1e9;
    for(int i=1;i<=k;i++){
        ret=min(ret,solve(ind+i)+abs(ar[ind]-ar[ind+i]));
    }
    return mem[ind]=ret;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof mem);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cout<<solve(0)<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=150;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int t=0;while(x){t+=BIT[x];x-=x&-x;}return t;}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
int n;
vector<int>g[N];
int x[N],y[N];
int d[N];
void dfs(int u,int p,int dep){
	int s=0;
	for(auto v:g[u])
		if(v-p)
			dfs(v,u,dep+1),s++;
	d[dep]=max(d[dep],s);
}
LL ans,D;
void upd(){
	LL t=1;
	int i=0;
	for(;d[i];i++)
		t*=d[i];
	//cout<<i<<endl;
	
	if(i<D||(i==D&&t<ans)){
		D=i;
		ans=t;
	}
}
int main(){Accel
    cin>>n;
    D=n+1;
    ans=1e18;
    REP(i,n-1){
		cin>>x[i]>>y[i];
		g[x[i]].PB(y[i]);
		g[y[i]].PB(x[i]);
	}
	//odd
	FOR(i,1,n){
		Re(d,0);
		d[0]=1;
		dfs(i,i,1);
		upd();
	}
	//even
	REP(i,n-1){
		Re(d,0);
		d[0]=2;
		dfs(x[i],y[i],1);
		dfs(y[i],x[i],1);
		upd();
	}
    cout<<D<<" "<<ans<<endl;
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  double a, b;
  cin.scan(a, b);

  int[] a_ar, b_ar;
  int a_x = cast(int)ceil(a * 100 / 8) , b_x = cast(int)(b * 10);

  while (0.08 * a_x < a + 1) {
    a_ar ~= a_x;
    a_x++;
  }

  while (0.1 * b_x < b + 1) {
    b_ar ~= b_x;
    b_x++;
  }

  int[int] m;
  foreach (e; a_ar) {
    m[e]++;
  }
  foreach (e; b_ar) {
    m[e]++;
  }

  int mini = int.max;
  foreach (e; m.byKeyValue) {
    if (e.value == 2) {
      mini = min(mini, e.key);
    }
  }

  if (mini == int.max) {
    writeln(-1);
  } else {
    writeln(mini);
  }
}


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

using ll = long long;

int N, M;

int main()
{

  cin >> N >> M;
  vector<ll> hei(N+1);
  for(int i = 1; i<=N; i++){
    cin >> hei.at(i);
  }
  vector<vector<ll>> near(N+1);
  for(int i = 0; i<M; i++){
    int a, b;
    cin >> a >> b;
    near.at(a).push_back(hei.at(b));
    near.at(b).push_back(hei.at(a));
  }
  int count = 0;
  for(int i = 1; i<=N; i++){
    vector<ll> one = near.at(i);
    if(one.empty()){
      count++;
    }else{
      ll ma = *max_element(one.begin(), one.end());
      if(ma < hei.at(i)){
        count ++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 9812
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){

    string A;
    cin >> A;
    if(A == "a" || 
    A == "b" ||
    A == "c" ||
    A == "d" ||
    A == "e" ||
    A == "f" ||
    A == "g" ||
    A == "h" ||
    A == "i" ||
    A == "j" ||
    A == "k" ||
    A == "l" ||
    A == "m" ||
    A == "n" ||
    A == "o" ||
    A == "p" ||
    A == "q" ||
    A == "r" ||
    A == "s" ||
    A == "t" ||
    A == "u" ||
    A == "v" ||
    A == "w" ||
    A == "x" ||
    A == "y" ||
    A == "z"
    ){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }

}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

char s[100005];

int main() {

	scanf("%s",s);

	int len = strlen(s);

	int i;

	int p = 0;

	for (i = 0; i < len; i++) {
		if (s[i] == 'p') { p++; }
	}
	printf("%d\n",(len/2)-p);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>


using namespace std;

int main()
{

    while(1)
    {
        int n;
        int a[1000];
       
        cin >> n;
        if(n == 0){break;}
    
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        
        int sum = 0;
        for(int i = 0; i < n; i++)
        {
              sum += a[i];
        }
        
        double A = 1.0 * sum / n;
      
        double sum2 = 0;
          for(int i = 0; i < n; i++)
        {
            sum2 += (A - a[i]) * (A - a[i]);
         }
        
        double A2 = sqrt(sum2 / n);
        
        cout << setprecision(10) << A2 << endl;
    }   

    return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=100010,MAXM=200010;
const int inf=999999999;
int n,m;
int tot=1;
int edge[MAXM*2],nxt[MAXM*2],hd[MAXN];
inline void add_edge(register int u,register int v)
{
    edge[tot]=v,nxt[tot]=hd[u],hd[u]=tot++;
}
struct node{
    int pos,val;
    friend bool operator < (node a,node b)
    {
        return a.val>b.val;
    }
};
priority_queue<node> q;
int dis[MAXN];
bool book[MAXN];
int pre[MAXN];
int main()
{
    read(n),read(m);
    for(register int i=1;i<=m;++i)
    {
        int u,v;
        read(u),read(v);
        add_edge(u,v),add_edge(v,u);
    }
    for(register int i=1;i<=n;++i) dis[i]=(i==1)? 0:inf;
    q.push({1,0});
    while(!q.empty())
    {
        int x=q.top().pos;q.pop();
        if(book[x]) continue;
        book[x]=1;
        for(register int i=hd[x];i;i=nxt[i])
        if(dis[edge[i]]>dis[x]+1)
        {
            dis[edge[i]]=dis[x]+1;
            pre[edge[i]]=x;
            q.push({edge[i],dis[edge[i]]});
        }
    }
    putchar('Y'),putchar('e'),putchar('s'),putchar('\n');
    for(register int i=2;i<=n;++i) write(pre[i]),putchar('\n');
	return 0;
}


Measured memory_bytes: 8476
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long tmp = n;
    long result = n + 1;
    for (long i = 1; i < tmp; i++) {
      tmp = n / i;
      if (n % i == 0)
        if (result > i + tmp)
          result = i + tmp;
    }
    System.out.println(result - 2);
  }
}

Measured memory_bytes: 23764
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

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

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI3(W,a,b);
    if(a+W<b){
        print(b-a-W);
    }else if(b+W<a){
        print(a-b-W);
    }else{
        print(0);
    }
    return 0;
}

Measured memory_bytes: 256