akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	char c;
	cin >> c;
	string result = "consonant";
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
		result = "vowel";
	}
	cout << result << endl;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
n,x = map(int, input().split())
a = [int(i) for i in input().split()]
b = [a[i] for i in range(n)]

ret = sum(a)
for k in range(n):
    for i in range(n):
        b[i] = min(b[i], a[(i+n-k)%n])
    ret = min(ret, k*x+sum(b))
print(ret)


Measured memory_bytes: 3188
#include <stdio.h>

int main () {
  int a,b,c;
  int x,n;
  x = 0;
  n = 0;
  scanf ("%d %d %d",&a,&b,&c);
  for (x=a;x<=b;x++) {
      if ((c/x)*x == c) {
        n ++;
      }
  }
  printf ("%d\n",n);
  return 0;
}

Measured memory_bytes: 596
s = input()
t = input()

def checking(check_dict, key, val, yes_ans):
    if key in check_dict:
        if check_dict[key] == val:
            pass
        else:
            print('No')
            yes_ans = False
            return yes_ans
    else:
        check_dict[key] = val
    return yes_ans


t_dict = {}
s_dict = {}
yes_ans = True

for t_val, s_val in zip(t, s):
    yes_ans = checking(t_dict, t_val, s_val, yes_ans)
    if yes_ans == False:
        break
    yes_ans = checking(s_dict, s_val, t_val, yes_ans)
    if yes_ans == False:
        break

if yes_ans:
    print('Yes')

Measured memory_bytes: 3632
class BinaryTree():
    def __init__(self):
        self.root = None

    def insert(self, insert_node):
        p = None
        r = self.root
        while r:
            p = r
            if insert_node.value < r.value:
                r = r.left
            else:
                r = r.right

        if not p:
            self.root = insert_node
        elif insert_node.value < p.value:
            p.left = insert_node
        else:
            p.right = insert_node

    def find(self, find_value):
        r = self.root
        while r:
            if find_value == r.value:
                return "yes"
            if find_value < r.value:
                r = r.left
            else:
                r = r.right
        return "no"

    def delete(self, delete_value):
        flag = None
        p = None
        r = self.root
        while True:
            if delete_value == r.value:
                if r.left == None and r.right == None:
                    if flag == "l":
                        p.left = None
                    else:
                        p.right = None
                    return
                elif r.left == None:
                    if flag == "l":
                        p.left = r.right
                    else:
                        p.right = r.right
                    return
                elif r.right == None:
                    if flag == "l":
                        p.left = r.left
                    else:
                        p.right = r.left
                    return
                else:
                    r2 = r.right
                    while r2:
                        p = r2
                        r2 = r2.left
                    swap_value = p.value
                    self.delete(swap_value)
                    r.value = swap_value
                    return
            elif delete_value < r.value:
                p = r
                r = r.left
                flag = "l"
            else:
                p = r
                r = r.right
                flag = "r"

class Node():
    def __init__(self, value, left, right):
        self.value = value
        self.left  = left
        self.right = right

    def pre_order_search(self):
        l = self.left
        r = self.right
        print("",self.value, end="")
        if l:
            l.pre_order_search()
        if r:
            r.pre_order_search()

    def in_order_search(self):
        l = self.left
        r = self.right
        if l:
            l.in_order_search()
        print("",self.value, end="")
        if r:
            r.in_order_search()

m = int(input())
tree = BinaryTree()

for i in range(m):
    inp = input().split()
    if inp[0] == "insert":
        tree.insert(Node(int(inp[1]), None, None))
    elif inp[0] == "find":
        print(tree.find(int(inp[1])))
    elif inp[0] == "delete":
        tree.delete(int(inp[1]))
    else:
        tree.root.in_order_search()
        print()
        tree.root.pre_order_search()
        print()

Measured memory_bytes: 87240
#ifndef DEBUG
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,popcnt,tune=native")
#endif // DEBUG
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;
inline ll read()
{
    int ch=getchar(),f=1;
    ll ans=0;
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=0;
    for(;ch>='0'&&ch<='9';ch=getchar())
        ans=(((ans<<2)+ans)<<1)+(ch^'0');
    return f?ans:-ans;
}
int n;
const int maxn=105;
double a[maxn];
typedef pair<double,double> pdd;
double f[maxn][maxn];
int main()
{
    n=read();
    //generate_n(a+1,n,read);
    for(int i=1;i<=n;++i)
        scanf("%lf",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;++i)
        f[i][i]=a[i];
    for(int i=2;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
        {
            int l=j,r=j+i-1;
            if(r>n)continue;
            for(int k=l;k<r;++k)
            {
                f[l][r]=max(f[l][r],(f[l][k]+f[k+1][r])/2);
            }
        }
    }
    printf("%.10f",f[1][n]);
    //cout << "Hello world!" << endl;
    return 0;
}


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

long long x,y,tmp;
int pjg;

int main(){
    cin>>x>>y;
    tmp=x;
    pjg=0;
    while(tmp<=y){
        pjg++;
        tmp*=2;
    }
    printf("%d\n",pjg);
}


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

using namespace std;

int main(){

    string S;

    cin >> S;

    int tnum = S.size();

    if(S[tnum-1] != 's'){
        cout<< S +"s" <<endl;
    }
    else{
        cout<<S +"es" <<endl;
    }
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    long long int a,b,c,d,ans;
    cin>>a>>b>>c>>d;
    ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define mer(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;

//vector<char> vc;
vector<string> vs;



int main() {
	int N;
	ll ans = 0;
	cin >> N;
	v.resize(N);
	rep(i, 0, N)cin >> v[i];
	sort(v.begin(), v.end());
	ans += v[N-1];
	N -= 2;
	rep(i, 0, N / 2) {
		//cout <<"add "<< v[N - i] << '\n';
		ans += 2 * v[N - i];
	}
	if (N % 2 == 1) {
		//cout << "add " << v[N - N / 2] << '\n';
		ans += v[N - N / 2];
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4016
while line = gets
  a, b, c, d, e, f = line.split.map(&:to_i)

  x = ((e * c - b * f) / (a * e - b * d).to_f).round(4)
  y = ((a * f - d * c) / (a * e - b * d).to_f).round(4)

  x = x.abs if x.zero?
  y = y.abs if y.zero?

  printf("%4.3f %4.3f\n", x, y)
end

Measured memory_bytes: 8744
#include<iostream>
using namespace std;
int main(void)
{
    int W=0,k=0,toku[11],A,ta;
    for(int i=0;i<10;i++){
        cin>>toku[i];
    }
    for(int i=0;i<3;i++){
            A=0;
        for(int j=0;j<10;j++){
            if(A<toku[j]){
                A=toku[j];
                ta=j;
            }
        }
        W+=A;
        toku[ta]=0;
    }
       for(int i=0;i<10;i++){
        cin>>toku[i];
    }
    for(int i=0;i<3;i++){
            A=0;
        for(int j=0;j<10;j++){
            if(A<toku[j]){
                A=toku[j];
                ta=j;
            }
        }
        k+=A;
        toku[ta]=0;
    }
    cout<<W<<" "<<k<<"\n";
}

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

// コンテスト中のみ
#define int long long


#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
int MOD = 1000000007;
const int inf = 1001001001;
const ll INF = 1LL << 60;

int tenmod[1000100];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int k; cin >> k;
	int now = 1;
	rep(i, 1000010) {
		tenmod[i] = now;
		now *= 10; now %= k;
	}
	int sum = 0;
	for (int i = 0; ; i++) {
		if (i >= 1000010) {
			cout << -1 << endl; return 0;
		}
		sum += (7 % k)*tenmod[i];
		sum %= k;
		if (sum  == 0) {
			cout << i + 1 << endl; return 0;
		}
	}
	return 0;
}

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

string ans[2] = {"Alice", "Brown"};

int main(){
  long long x, y;
  cin >> x >> y;
  int u;
  if (max(x-y, y-x) < 2) u = 1;
  else u = 0;
  cout << ans[u] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
int dp[100][100][4];//0 右に動いた直後　1 北に動いた直後　2　ずっと右　3　ずっと北
while(1){
int w,h;
cin>>w>>h;
if(w==0&&h==0)
	break;
for(int i=0;i<w;i++){
for(int ii=0;ii<h;ii++){
	dp[i][ii][0]=0;
	dp[i][ii][1]=0;
	dp[i][ii][2]=0;
	dp[i][ii][3]=0;
	if(i==0){
		dp[i][ii][3]=1;
	}
	if(ii==0){
		dp[i][ii][2]=1;
	}
}
}


for(int i=1;i<w;i++){
for(int ii=1;ii<h;ii++){
	dp[i][ii][0]=(dp[i-1][ii][3])%100000;
	dp[i][ii][1]=(dp[i][ii-1][2])%100000;
	dp[i][ii][2]=(dp[i-1][ii][0]+dp[i-1][ii][2])%100000;
	dp[i][ii][3]=(dp[i][ii-1][1]+dp[i][ii-1][3])%100000;

}
}

cout<<(dp[w-1][h-1][0]+dp[w-1][h-1][1]+dp[w-1][h-1][2]+dp[w-1][h-1][3])%100000<<endl;
}

}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   long double sm,b,h;
   cin >> sm;
   long double l = sm;
   l /= 3;
   sm -= l;
   b = sm/2;
   h = sm-b;
   long double ans = l*b*h;
   cout << setprecision(14) << fixed << ans << '\n';
   return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    a--, b--;
    mat<char> grid = mmat<char>(100, 100);
    rep (i, 50)
        rep (j, 100)
            grid[i][j] = '.';
    rep (i, 50)
        rep (j, 100)
            grid[i + 50][j] = '#';

    rep (i, a) {
        int row = i / 50 * 2 + 51;
        int col = (i % 50) * 2;
        grid[row][col] = '.';
    }
    rep (i, b) {
        int row = i / 50 * 2;
        int col = (i % 50) * 2;
        grid[row][col] = '#';
    }

    print(100, 100);
    rep (i, 100) {
        rep (j, 100)
            cout << grid[i][j];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y[ohara],sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
pair<double,ll> p[ohara];
double ans;
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>x[i]>>y[i];
    rep(i,n){
        double theta;
        if(x[i]==0){
            if(y[i]==0){
                theta=0.0;
            }
            else if(y[i]>0){
                theta=90.0;
            }
            else{
                theta=270.0;
            }
        }
        else if(y[i]==0){
            if(x[i]>0){
                theta=0.0;
            }
            else{
                theta=180.0;
            }
        }
        else{
            theta=atan((double)abs(y[i])/(double)abs(x[i]));
            theta=theta*180.0/M_PI;
            if(x[i]<0&&y[i]>0){
                theta=180.0-theta;
            }
            else if(x[i]<0&&y[i]<0){
                theta=theta+180.0;
            }
            else if(x[i]>0&&y[i]<0){
                theta=360.0-theta;
            }
        }
        p[i]=m_p(theta,i);
    }
    sort(p,p+n);
    rep(i,n){
        p[i+n]=p[i];
    }
    rep(i,2*n){
        ll nowx=0,nowy=0;
        double now=0.0;
        U_MAP vi;
        rrep(j,i,2*n){
            if(vi[p[j].se]==1)break;
            vi[p[j].se]=1;
            nowx+=x[p[j].se];
            nowy+=y[p[j].se];
            now=max(now,sqrt(nowx*nowx+nowy*nowy));
        }
        ans=max(ans,now);
    }
    doublecout(ans);
    return 0;
}

Measured memory_bytes: 4352
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define inf 0x3f3f3f3f
int main()
{
	int a[105]={0};
	int n,k; 
	cin>>n>>k;
	while(k--) {
		int t=0,m;
		cin>>t;
		for(int i=1; i<=t; i++) {
			cin>>m;
			a[m]++;
		}
	}
	int cnt=0;
	for(int i=1; i<=n; i++) {
		if(a[i]==0) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
} 

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

int main(void)
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int b[n], c[n];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = 0; i < n - 1; i++)
        cin >> c[i];
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        sum += b[a[i] - 1];
        if(i > 0 && a[i] - a[i - 1] == 1)
            sum += c[a[i] - 2];
    }
    cout << sum << endl;
    return 0;
}   

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

int main() {
  
  int N; cin >> N; int count = 0;
  
  for (int i = 1; i <= N; i++) {
    int p; cin >> p;
    if (i != p) count++;
  }
  
  if (count <= 2) cout << "YES" << endl;
  
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 256
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

div = 10**9+7

patterns = [[0 for _ in range(W)] for __ in range(H)]
patterns[0][0] = 1


for y in range(H):
    for x in range(W):
        if x + 1 < W and field[y][x+1] != '#':
            patterns[y][x+1] += patterns[y][x] % div
        if y + 1 < H and field[y+1][x] != '#':
            patterns[y+1][x] += patterns[y][x] % div

print(patterns[-1][-1] % div)

Measured memory_bytes: 90716
from collections import deque
q=deque();K=int(input());q+=[(1,1)];m={}
while len(q):
 n,s=q.pop()
 if not n in m:m[n]=s;q+=[(n*10%K,s)];q.appendleft(((n+1)%K,s+1))
print(m[0])

Measured memory_bytes: 24312
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

char f[100][100];
string dp[100][100];
int dx[]={1,0};
int dy[]={0,1};

bool comp(string s,string t){ // ?s>t
    if(s.size()>t.size())return true;
    if(s.size()<t.size())return false;
    for(int i=0;i<s.size();i++){
        if(s[i]>t[i])return true;
        if(s[i]<t[i])return false;
    }
    return false;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    int h,w;
    while(cin >> w >> h,h&&w){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> f[i][j];
                dp[i][j]="";
            }
        }
        queue<pair<pair<int,int>,string>> q;
        string res="";
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if('1'<=f[i][j]&&f[i][j]<='9'&&dp[i][j]==""){
                    dp[i][j]+=f[i][j];
                    q.push(make_pair(make_pair(i,j),dp[i][j]));
                    while(q.size()){
                        auto p=q.front(); q.pop();
                        //cout << p.first.first << " " << p.first.second << " " << p.second << endl;
                        if(!comp(p.second,dp[p.first.first][p.first.second])&&p.second!=dp[p.first.first][p.first.second])continue;
                        for(int k=0;k<2;k++){
                            int nx=p.first.first+dx[k],ny=p.first.second+dy[k];
                            if(0<=nx&&nx<h&&0<=ny&&ny<w){
                                string r=dp[p.first.first][p.first.second];
                                if('0'<=f[nx][ny]&&f[nx][ny]<='9'){
                                    r+=f[nx][ny];
                                    if(comp(r,dp[nx][ny])){
                                        dp[nx][ny]=r;
                                        q.push(make_pair(make_pair(nx,ny),r));
                                    }
                                }
                            }
                        }
                    }
                }
                if(comp(dp[i][j],res)){
                    res=dp[i][j];
                }
            }
        }
        cout << res << endl;
    }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll q;
    cin >> q;
    priority_queue<ll> a_former;
    priority_queue<ll, vector<ll>, greater<ll>> a_latter;
    ll sum_former = 0, sum_latter = 0;
    ll b_all = 0;
    vector<pair<ll, ll>> ans;
    rep(i, q) {
        ll temp;
        cin >> temp;
        if (temp == 1) {
            ll a, b;
            cin >> a >> b;
            b_all += b;
            if (a_former.size() > a_latter.size()) {
                ll t = a_former.top();
                if (a >= t) {
                    a_latter.push(a);
                    sum_latter += a;
                } else {
                    a_former.pop();
                    sum_former -= t;
                    a_former.push(a);
                    sum_former += a;
                    a_latter.push(t);
                    sum_latter += t;
                }
            } else {
                if (a_former.empty()) {
                    a_former.push(a);
                    sum_former += a;
                } else {
                    ll t = a_latter.top();
                    if (a <= t) {
                        a_former.push(a);
                        sum_former += a;
                    } else {
                        ll t = a_latter.top();
                        if (a <= t) {
                            a_former.push(a);
                            sum_former += a;
                        } else {
                            a_latter.pop();
                            sum_latter -= t;
                            a_latter.push(a);
                            sum_latter += a;
                            a_former.push(t);
                            sum_former += t;
                        }
                    }
                }
            }
        } else {
            ll x = a_former.top();
            ll result = (x * a_former.size() - sum_former) +
                        (sum_latter - x * a_latter.size()) + b_all;
            ans.push_back(make_pair(x, result));
        }
    }

    rep(i, ans.size()) { cout << ans[i].first << " " << ans[i].second << endl; }

    return 0;
}



Measured memory_bytes: 5868
#include <stdio.h>
#include <algorithm>
typedef long long ll;

int main(void) {
  ll i, j, n, ans = 0;
  scanf("%lld", &n);
  ll l[n];
  for(i = 0; i < n; ++i) scanf("%lld", &l[i]);
  std::sort(l, l + n);
  for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) 
    ans += std::lower_bound(l, l + n, l[i] + l[j]) - l - j - 1;
  printf("%lld", ans);
  return 0;
}

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

int main() {
	int n, r;
	cin >> n >> r;
	int ans;
	if(n >= 10) ans = r;
	else ans = r + 100 * (10 - n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll n,k;
ll ar[200];
ll postf[200];
ll cnt=0;
ll arr[100005][102];
ll pre[100005][102];

// ll initializedp(ll i,ll ke)
// {
//     if(arr[i][ke]!=-1)   return arr[i][ke];
//     cnt++;
//     if(i==n)
//     {
//         arr[i][ke]=1;
//         return 1;
//     }
//     ll sum=0;
//     for(int j=ar[i];j>=0;j--)
//     {
//         if(ke-j<=postf[i+1])
//         {
//             sum = (sum+solve(i+1,k-j))%MOD;
//         }
//         else
//         {
//             break;
//         }
//     }
//     // trace(i)
//     // trace(ke)
//     // trace(sum)
//     arr[i][ke] = sum;
//     return sum;
// }

int main()
{
    IOS
    cin>>n>>k;
    REP(i,n)
    {
        REP(j,k+1)
        {
            arr[i][j] = -1;
        }
    }
    ll sum=0;
    REP(i,n)
    {
        cin>>ar[i];
    }
    for(int i=n-1;i>=0;i--)
    {
        sum = add(sum,ar[i]);
        postf[i]=sum;
    }
    if(k>postf[0])
    {
        cout<<0<<endl;
        return 0;
    }   
    
    FOR(i,0,k+1,1)
    {
        if(i<=ar[n-1])
        {
            // cout<<"here\n";
            arr[i][n-1] = 1;
        }
        else
        {
            arr[i][n-1] = 0;
        }
    }
    sum=arr[0][n-1];
    pre[0][n-1]=arr[0][n-1];

    FOR(i,1,k+1,1)
    {
        sum = (sum+arr[i][n-1])%MOD;
        pre[i][n-1] = sum;
    }
    for(int i=n-2;i>=0;i--)
    {   
        ll sum=0;
        for(int j=0;j<=k;j++)
        {
            if(j>ar[i])
                arr[j][i] = sub(pre[j][i+1], pre[j-ar[i]-1][i+1]);
            else
            {
                arr[j][i] = pre[j][i+1];
            }
            
            sum = add(sum,arr[j][i]);
            pre[j][i]=sum;
        }
    }
    /*
    REP(i,k+1)
    {
        REP(j,n)
        {
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    REP(i,k+1)
    {
        REP(j,n)
        {
            cout<<pre[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    */
    cout<<arr[k][0]<<endl;
    
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int h, w;
    cin >> h >> w;
    rep(i, w + 2)
    {
        cout << "#";
    }
    cout << endl;
    string s;
    rep(i, h)
    {
        cin >> s;
        cout << "#" + s + "#" << endl;
    }
    rep(i, w + 2)
    {
        cout << "#";
    }
    cout << 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;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<int> PQ;

int main(){

  char t[200006];

  scanf("%s", t);

  int n;
  int i;
  n = strlen(t);

  for(i = 0;i < n;i++){
    if(t[i] == '?') t[i] = 'D';
  }

  printf("%s\n", t);
  return 0;
}


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

int n,m;
int v[100][100];
bool used[100][100];
int dir[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

void dfs(int i, int j){
    if((v[i][j]==0) || (used[i][j]==true)){
        return;
    }
    used[i][j]=true;
    rep(k,8){
        if(i+dir[k][0]<=n-1 && 0<=i+dir[k][0]){
            if(j+dir[k][1]<=m-1 && 0<=j+dir[k][1]){
                dfs(i+dir[k][0],j+dir[k][1]);
            }
        }
    }
    return;
}

int main(){
    vector<int> ans;

    while(true){
        cin >> m >> n;
        if(n==0 && m==0)break;
        rep(i,n){
            rep(j,m){
                cin >> v[i][j];
            }
        }

        int res=0;
        rep(i,n){
            rep(j,m){
                used[i][j]=false;
            }
        }
        rep(i,n){
            rep(j,m){
                if(v[i][j]==1 && used[i][j]==false){
                    dfs(i,j);
                    res++;
                }
            }
        }
        ans.push_back(res);
    }

    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3224
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int R = I.nextInt();
		int G = I.nextInt();
		int B = I.nextInt();
		int K = I.nextInt();
		int op = 0;
		while (G<=R) {
			G*=2;
			op++;
		}
		while (B<=G) {
			B*=2;
			op++;
		}
		O.pln(op<=K?"Yes":"No");
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25600
n = int(input())
lis = list(map(int, input().split()))

def _filtter(lis, val):
    return [x for x in lis if x % val != 0]


def filtter(lis):

    filtter_val = (3, 5)
    for val in filtter_val:
        lis = _filtter(lis, val)
        if len(lis) == 0:
            return 'APPROVED'
    return 'DENIED'
            
print(filtter([x for x in lis if x % 2 == 0]))


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
#include <map>
using namespace std;

int main()
{
	int cnt = 0;
	string w, t;

	cin >> w;
	for (int i = 0; i < w.length(); i++)
	{
		if (isupper(w[i]))
		{
			w[i] = tolower(w[i]);
		}
	}
	while (cin >> t)
	{
		if (t == "END_OF_TEXT")
		{
			break;
		}

		for (int i = 0; i < t.length(); i++)
		{
			if (isupper(t[i]))
			{
				t[i] = tolower(t[i]);
			}
		}

		if (t == w)
		{
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T, typename U>
ostream& operator<<(ostream& o, const pair<T,U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T>>& v) {
  o << "[";
  for (const vector<T>& x : v)
    o << x << ",\n";
  return o << "]";
}

const int INF = 1e18;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string t;
  cin >> t;
  int cnt = 0;
  for (int i=0; i<t.size(); ++i) {
    if (t[i] == 'D' || t[i] == '?') {
      ++cnt;
      if (i > 0 && t[i-1] == 'P')
        ++cnt;
    }
    if (t[i] == '?')
      t[i] = 'D';
  }
  cout << t << endl;
}


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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int ans=1;
  for(int i=1; i<n; i++) if(s[i]!=s[i-1]) ans++;
  cout << ans << endl;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,b,c;

  cin>>a>>b>>c;

  cout<<a*b/2<<endl;
 
  
  return 0;

}


Measured memory_bytes: 256
from itertools import product
def solve():
    card_org = list(map(int,input().split()))
    K = int(input())
    comb = list(product(range(3), repeat=K))

    for c in comb:
        card = card_org[:]
        if card[1] > card[0] and card[2] > card[1]:
            print('Yes')
            return

        for i in range(K):
            card[c[i]] *= 2
        
            if card[1] > card[0] and card[2] > card[1]:
                print('Yes')
                return
    
    print('No')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 65240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int seki = a * b;
 
  if (seki % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	bool ok = true;
	if (A[0] != 0){
		ok = false;
	}
	for (int i = 1; i < N; i++){
		if (A[i] > A[i - 1] + 1){
			ok = false;
		}
	}
	if (!ok){
		cout << -1 << endl;
	} else {
		long long sum = 0;
		for (int i = 1; i < N; i++){
			if (A[i] == A[i - 1] + 1){
				sum++;
			} else {
				sum += A[i];
			}
		}
		cout << sum << endl;
	}
}

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

string s;
int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	t = s.size() - 2;
	cout<<s[0]<<t<<s[s.size()-1];
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

		String str = scan.next();
		char[] c = str.toCharArray();

		int count = 0;
		for(int i = 1; i < str.length(); i++){
			if(c[i] != c[i-1]){
				count ++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 27092
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

ll dp[200010][2][3];

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for( auto &k : a ) cin >> k;
	dp[0][1][0] = a[0];
	dp[0][0][0] = 0;
	for( int i = 1; i < n; ++i ){
		dp[i][1][0] = dp[i-1][0][0] + a[i];
		dp[i][1][1] = dp[i-1][0][1] + a[i];
		dp[i][1][2] = dp[i-1][0][2] + a[i];
		dp[i][0][0] = dp[i-1][1][0];
		dp[i][0][1] = max(dp[i-1][0][0], dp[i-1][1][1]);
		dp[i][0][2] = max(dp[i-1][0][1], dp[i-1][1][2]);
	}
	if( n%2 == 0 ) cout << max(dp[n-1][1][1], dp[n-1][0][0]) << endl;
	else cout << max(dp[n-1][0][1], dp[n-1][1][2]) << endl;
}

Measured memory_bytes: 13520
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1e-9;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

  int n,m;
  cin>>n>>m;
  UnionFind tree(n);
  rep(i,m) {
    int x,y,z;
    cin>>x>>y>>z;
    tree.unite(x-1,y-1);
  }
  set<int> s;
  rep(i,n) {
    s.insert(tree.root(i));
  }
  cout << s.size() << endl;




  return 0;
}


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

int main()
{
    int N, l, r;
    int sum = 0;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}


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

ans = 0
def dfs(x, visited):
    global ans
    if len(visited) == N:
        ans += 1
        return

    for b in ab[x]:
        if b not in visited:
            dfs(b, visited + [b])
    return

dfs(0, [0])
print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "yes" : "no");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string S;
  cin >> S;
  vector<int> alphabet(30);
  rep(i, S.size())
  {
    alphabet[S[i] - 'a']++;
  }
  bool is_ok = true;
  rep(i, 30)
  {
    if (alphabet[i] > 1)
      is_ok = false;
  }
  printYesNo(is_ok);
  return 0;
}

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

int main() {
	
	string s;
	int m, h, n;
	
	while (true){
		cin >> s;
		
		if (s == "-") break;
		else cin >> m;
		
		int n = 0;
		for (int i = 0; i < m; i++) {
			cin >> h;
			n += h;
		}
		for (int i = n % s.size(); i < s.size(); i++) 
			cout << s[i];
		
		for (int i = 0; i < n % s.size(); i++) 
			cout << s[i];
		
		cout << "\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll n; cin >> n;
	vector<ll> a( n );
	rep( i, n ) cin >> a[i];
	map<ll, ll> c, d;
	rep( i, n ) c[a[i]]++;
	reps( i, n ) d[c[i]]++;
	vector<ll> sumkd( n + 2 ), sumxd( n + 2 );
	rep( i, n + 1 )
	{
		sumkd[i + 1] = sumkd[i] + i * d[i];
		sumxd[i + 1] = sumxd[i] + d[i];
	}

	vector<ll> f( n + 1 );
	reps( x, n )
		f[x] = ( ( sumkd[x] - sumkd[0] ) + x * ( sumxd[n] - sumxd[x] ) ) / x;
	sort( ALL( f ) );

	reps( k, n )
	{
		if ( k == 1 ) cout << n << endl;
		else
		{
			auto it = lower_bound( ALL( f ), k );
			cout << n - ( it - f.begin() ) + 1 << endl;
		}
	}

	return ( 0 );
}


Measured memory_bytes: 49792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    long long ans=1e9;
    for(int i=-100; i<=100; i++){
        long long tmp=0;
        for(int j=0; j<n; j++){
            tmp += pow(a[j]-i,2);
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
n,p = map(int,input().split())
s=input()
ans = 0
l = [0 for i in range(p)]
l[0] = 1
z = 0
ten = 1
tmp = 0
if p == 2 or p == 5:
    if p == 2:
        for i in range(n):
            if int(s[i])%2 == 0:
                ans+=i+1
    if p == 5:
        for i in range(n):
            if int(s[i])%5 == 0:
                ans+= i+1
    
else:
    for i in s[::-1]:
        i = int(i)
        tmp=(tmp+i*ten)%p
        ten = (ten*10)%p
        l[tmp]+=1
for i in l:
    ans+= i*(i-1)//2
print(ans)



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

using namespace std;

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1e9+7
#define FOR(i,j,n)    for(ull i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    ll k,x;
    cin>>k>>x;
    if(500*k >= x){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[3005][3005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    memset(dp, 0, sizeof(dp));
    ll N = S.length();
    ll M = T.length();
    REP(i, N) {
        REP(j, M) {
            dp[i + 1][j + 1] = std::max({dp[i][j], dp[i][j + 1], dp[i + 1][j]});
            if (S[i] == T[j])
                dp[i + 1][j + 1] = std::max(dp[i + 1][j + 1], dp[i][j] + 1);
        }
    }
    string ans = "";
    ll x = dp[N][M];
    ll n = N, m = M;
    while (x > 0) {
        while (n > 0 && dp[n - 1][m] == x)
            n--;
        while (m > 0 && dp[n][m - 1] == x)
            m--;
        ans.push_back(T[m - 1]);
        x--;
        n--;
        m--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		int X = int.Parse(Console.ReadLine());
		bool a = true;
		long ans = 0;
        
		while (a)
		{
			ans++;
			if (ans * (ans + 1) / 2 >= X)
			{
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
N = int(input())
P = []
for i in range(N):
    Xi, Li = map(int, input().split())
    P.append((Xi + Li, Xi - Li))

P.sort()
ans = 0
t = -1000000000
for p in P:
    if p[1] >= t:
        ans += 1
        t = p[0]
print(ans)


Measured memory_bytes: 16988
#include<stdio.h>

int dp[50];
int fib(int);

int main(){
  int n,i;
  for(i=0;i<50;i++)dp[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}

int fib(int n){
  if(n==0 || n==1)return dp[n]=1;
  if(dp[n]!=-1)return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}



Measured memory_bytes: 2104
#include <stdio.h>
int main (void)
{ int a;
  int b;

  scanf("%d",&a);
  scanf("%d",&b);

  if(a>b){printf("a > b\n");}
  if(a==b){printf("a == b\n");}
  if(a<b){printf("a < b\n");}

return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long k;
  cin >> k;
  vector<pair<int, int>> ab(n);
  for (int i = 0; i < n; i++) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());
  long long cnt = 0;
  for (auto [a, b] : ab) {
    cnt += b;
    if (cnt >= k) {
      cout << a << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3904
#include <stdio.h>
main(){
	int a,b,c,x,y;
	y=0;     
	scanf("%d%d%d",&a,&b,&c);
	for(x=a;x<=b;x++){
		if(c%x==0)
		y++;    
	}    
	printf("%d\n",y);
	return 0;
} 

Measured memory_bytes: 596