akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,K;
ll A[200009],B[200009];
map<ll,int> dic;

struct BinaryIndexTree{
    int N;
    vector<int> bit;
    BinaryIndexTree(int n): N(n),bit(n+1,0){}
    void add(int a,int w){
        for(int x=a+1;x<=N;x+=x&(-x)) bit[x]+=w;
    }
    int total(int a){
        int ret=0;
        for(int x=a+1;x>0;x-=x&(-x)) ret+=bit[x];
        return ret;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>K;
    rep(i,N) cin>>A[i];
    rep(i,N) A[i]-=K;
    rep(i,N-1) A[i+1]+=A[i];
    rep(i,N) B[i]=A[i];
    sort(B,B+N);
    
    int cnt=0;
    rep(i,N){
        if(dic.count(B[i])==0){
            dic[B[i]]=cnt++;
        }
    }
    
    BinaryIndexTree bit(cnt);
    ll total=0;
    rep(i,N){
        int a=dic[A[i]];
        total+=bit.total(a);
        bit.add(a,1);
        if(A[i]>=0) total++;
    }
    cout1(total)
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

double get_dist(ll x1, ll y1, ll x2, ll y2) {
    ll dx = x1 - x2;
    ll dy = y1 - y2;
    return sqrt(dx * dx + dy * dy);
}

template<class T>
struct Dijkstra {
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<int> path;
    
    Dijkstra() {}
    Dijkstra(int n) {
        graph.resize(n);
        dist.resize(n);
        prev.resize(n);
    }
    
    void add_edge(int from, int to, T cost) {
        graph[from].emplace_back(to, cost);
    }
    
    void get_distance(int from) {
        priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
        fill(dist.begin(), dist.end(), inf);
        fill(prev.begin(), prev.end(), -1);
        dist[from] = 0;
        pq.push(make_pair(0, from));
        while(!pq.empty()) {
            pair<T, int> p = pq.top(); pq.pop();
            if (dist[p.second] < p.first) continue;
            for (auto e : graph[p.second]) {
                if (dist[e.first] > (dist[p.second] + e.second)) {
                    dist[e.first] = dist[p.second] + e.second;
                    prev[e.first] = p.second;
                    pq.push(make_pair(dist[e.first], e.first));
                }
            }
        }
    }
    
    void get_path(int to) {
        path = vector<int>(0);
        for (; to != -1; to = prev[to]) {
            path.push_back(to);
        }
        reverse(path.begin(), path.end());
    }
    
private:
    vector<vector<pair<int, T>>> graph;
    vector<T> prev;
};

struct S {
    ll x, y, r;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll xs, ys, xg, yg;
    cin >> xs >> ys >> xg >> yg;
    ll n;
    cin >> n;
    vector<S> vs(n);
    rep(i, n) cin >> vs[i].x >> vs[i].y >> vs[i].r;
    Dijkstra<double> di(n + 2);
    {
        double d = get_dist(xs, ys, xg, yg);
        di.add_edge(0, 1, d);
        di.add_edge(1, 0, d);
    }
    rep(i, n) {
        double d = max(0.0, get_dist(xs, ys, vs[i].x, vs[i].y) - vs[i].r);
        di.add_edge(0, i + 2, d);
        di.add_edge(i + 2, 0, d);
    }
    rep(i, n) {
        reps(j, i + 1, n) {
            double d = max(0.0, get_dist(vs[i].x, vs[i].y, vs[j].x, vs[j].y) - vs[i].r - vs[j].r);
            di.add_edge(i + 2, j + 2, d);
            di.add_edge(j + 2, i + 2, d);
        }
    }
    rep(i, n) {
        double d = max(0.0, get_dist(xg, yg, vs[i].x, vs[i].y) - vs[i].r);
        di.add_edge(1, i + 2, d);
        di.add_edge(i + 2, 1, d);
    }
    di.get_distance(0);
    printf("%.10f\n", di.dist[1]);
    return 0;
}


Measured memory_bytes: 23772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>
 
 
signed main(){
	
	int n; cin >> n;
	int ans = 12345678912;
	rep(i,n+1)
	{
		int pay6 = i;
		int pay9 = n-i;
		
		int cnt = 0;
		
		while(pay6) cnt += pay6%6,pay6 /= 6;
		while(pay9) cnt += pay9%9,pay9 /= 9;
		
		ans = min(ans,cnt);	
	}
	
	cout << ans << endl;
	 
	
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int a,b,t;
    int ans=0;
    cin>>a>>b>>t;
    int aa=a;
    while(aa<=t+0.5){
        ans+=b;
        aa+=a;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
swi = []
for i in range(m):
    swi.append(list(map(int, input().split())))
p = list(map(int, input().split()))

oh = list(itertools.product(range(0, 2), repeat=n))
re = 0
for i in oh:
    for j in range(m):
        c = 0
        for k in swi[j][1:]:
            c += i[k - 1]
        if c % 2 != p[j]:
            break
    else:
        re += 1
print(re)

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

int main()
{
    ll N, T, A, h, idx = 0;
    cin >> N >> T >> A;
    ll H[N];
    while(cin >> h){
        H[idx] = h;
        idx++;
    }
    
    ll ret = 0;
    double min_res = 999999999999999.0;
    for(int j = 0; j < N; j++)
    {
        double t = (double) T - 0.006 * H[j];
        double res = abs(t - (double)A);
        if(min_res > res){
            min_res = res;
            ret = j;
        }
    }
    cout << ret + 1;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abl/tasks/abl_c
//查并集
#include <bits/stdc++.h>

using namespace std;

map<int, int> ds;
map<int, int> ranks;

int find_root(int x) {
    return x==ds[x]?x:ds[x]=find_root(ds[x]);
}

void union_set(int x, int y) {
    int x_root=find_root(x);
    int y_root=find_root(y);
    if (x_root!=y_root) {
        if (ranks[x_root]>ranks[y_root]) {
            ds[y_root]=x_root; 
        } else if (ranks[x_root]<ranks[y_root]) {
            ds[x_root]=y_root;
        } else {
            ds[x_root]=y_root;
            ranks[y_root]++;
        }
    }
}

int main() {
    int n,m;
    cin>>n>>m;

    //初始化
    for (int i=1; i<=n; i++) {
        ds[i]=i;
        ranks[i]=0;
    }

    int now=0;
    for (int i=1; i<=m; i++) {
        int x,y;
        cin>>x>>y;

        x=find_root(x);
        y=find_root(y);
        if (x==y) {
            continue;
        }

        union_set(x, y);
        now++;
    }

    cout<<n-1-now<<"\n";

    return 0;
}

Measured memory_bytes: 12860
#include <bits/stdc++.h>
using namespace std;
int main()
{
   string s="",w="";
   cin>>s;
   int l = s.length();

   for(int i=0;i<l;i++)
   {
     w = w + 'x';
   }

   cout<<w<<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;

int p[1000];
int main() {
	int n, m;
	while (cin >> n >> m, n) {
		int sum = 0;
		rep(i, n) {
			scanf("%d", &p[i]);
			sum += p[i];
		}
		sort(p, p + n, greater<>());
		for (int i = m - 1; i < n; i += m) {
			sum -= p[i];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3204
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;

    vector<vector<ll>> v(N);

    vector<int> P(M), Y(M);
    REP(i, M) {
        cin >> P[i] >> Y[i];

        v[P[i] - 1].pb(Y[i]);
    }

    REP(i, N) {
        sort(ALL(v[i]));
    }

#define out cout << setfill('0') << right << setw(6)
    REP(i, M) {
        out << P[i];

        int o = lower_bound(ALL(v[P[i] - 1]), Y[i]) - v[P[i] - 1].begin() + 1;
        out << o << endl;
    }
}


Measured memory_bytes: 7808
#include <stdio.h>
  
#define nil -1
  
struct Node{
  int y; 
  int l; 
  int r; 
};
  
void preorder(int u);
void inorder(int u);
void postorder(int u);
  
struct Node T[100000];
int n;
  
main(){
  int i,j,v,c,root;
  
  scanf("%d",&n); 
  
  for(i=0;i<n;i++){
    T[i].y=nil;
    T[i].l=nil;
    T[i].r=nil;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&v); 
  
    for(j=0;j<2;j++){
      scanf("%d",&c); 
  
      if(j==0){
    T[v].l=c;  
      } else {
    T[v].r=c;
      }
    T[c].y=v;       
    }
  }
  
  for(i=0;i<n;i++){
    if(T[i].y==nil){
      root=i;
      break;
    }
  }
  
  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");
   
  return 0;
}
  
  
void preorder(int u){
  
  printf(" %d",u);
  if(T[u].l!=nil) preorder(T[u].l);
  if(T[u].r!=nil) preorder(T[u].r);
  
}
  
void inorder(int u){
  
  if(T[u].l!=nil) inorder(T[u].l);
  printf(" %d",u);
  if(T[u].r!=nil) inorder(T[u].r);
}
  
void postorder(int u){ 
   
  if(T[u].l!=nil) postorder(T[u].l);
  if(T[u].r!=nil) postorder(T[u].r);
  printf(" %d",u);
  
}

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

char field[2001][2001];
vector<vector<int>> x_right, x_left, y_up, y_down;

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> A(n), L(n), R(n);
    rep(i, n) cin >> A[i];

    L[0] = A[0];
    for (int i = 1; i < n - 1; ++i) {
        L[i] += L[i - 1] + A[i];
    }

    reverse(all(A));
    R[0] = A[0];
    for (int i = 1; i < n - 1; ++i) {
        R[i] += R[i - 1] + A[i];
    }

    int ans = inf;
    rep(i, n - 1) {
        ans = min(ans, abs(L[i] - R[n - 2 - i]));
    }

    cout << ans << endl;

    return 0;
}

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

int main(void) {
	int N;
	scanf("%d", &N);
	bool ans = false;
	if (N / 100 == 7) ans = true;
	N %= 100;
	if (N / 10 == 7) ans = true;
	N %= 10;
	if (N / 1 == 7) ans = true;
	printf(ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3720
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    C = input()
    forward = 0
    back = N - 1
    cnt = 0
    while forward < back:
        if C[forward] == 'R' and C[back] == 'W':
            forward += 1
            back -= 1
        elif C[forward] == 'R' and C[back] == 'R':
            forward += 1
        elif C[forward] == 'W' and C[back] == 'W':
            back -= 1
        else:
            cnt += 1
            forward += 1
            back -= 1
    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 67764
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>city(n);
  rep(i,n)cin>>city[i];
  int l,q;
  cin>>l>>q;
  int nl=n,c=0;
  while(nl>0){c++;nl/=2;}
  vector<vector<int>>db(n,vector<int>(c,n));
  int r=0;
  rep(i,n)
  {
    while(r+1<n&&city[r+1]<=city[i]+l)r++;
    db[i][0]=r;
  }
  rep(i,c-1)
  {
    rep(j,n)
    {
      db[j][i+1]=db[db[j][i]][i];
    }
  }
  rep(i,q)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b)swap(a,b);
    int cnt=0;
    for(int j=c-1;j>=0;j--)
    {
      if(db[a][j]<b)
      {
        a=db[a][j];
        cnt+=1<<j;
      }
    }
    cout<<cnt+1<<"\n";

  }
  cout<<flush;


  return 0;

}


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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Man[] arr = new Man[n];
		for (int i = 0; i < arr.length; i++) {
			Man m = new Man();
			m.i = i;
			m.a = sc.nextInt();
			arr[i] = m;
		}
		sc.close();

		Arrays.parallelSort(arr, (x, y) -> x.a - y.a);

		for (int i = 0; i < arr.length; i++) {
			System.out.println(arr[i].i + 1);
		}
	}

	static class Man {
		int i, a;
	}
}


Measured memory_bytes: 67424
S = list(map (int, list(input())))
ans1 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            ans1 += 1
    else:
        if S[i] == 1:
            ans1 += 1
print(min(ans1,len(S)-ans1))

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

int main() {
	int n; cin >> n;
	int mx = 1;
	for (int i = 2; i * i <= n; ++i) {
		int s = i;
		while (s * i <= n)
			s *= i;
		mx = max(s, mx);
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;
ll i,j;

/*


*/
ll modexpo(ll x,ll n,ll M){
    if(n==0)return 1;
    else if(n%2==0)return modexpo((x*x)%M,n/2,M);
    else return(x*modexpo((x*x)%M,(n-1)/2,M))%M;
}
void solve(){
    in(n);
    ll ans=modexpo(10,n,mod);
    ll hatao=(2*modexpo(9,n,mod))%mod;
    hatao=(hatao-modexpo(8,n,mod)+mod)%mod;
    ll final=(ans-hatao+mod)%mod;
    ce(final%mod);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

Measured memory_bytes: 3612
import queue
k = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)
for i in range(k):
    x = q.get()

    if x%10 != 0:
        q.put(10*x+x%10-1)
    q.put(10*x+x%10)
    if x%10 != 9:
        q.put(10*x+x%10+1)
print(x)


Measured memory_bytes: 12452
#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

ll n, k;
ll h[200002];

int main(){
    IOS;
    cin >> n >> k;
    F0R(i,n){
        cin >> h[i];
    }
    S0RT(h,n);
    ll moves = 0;
    R0F(i,n){
        if(k > 0){
            k--;
            continue;
        }
        else{
            moves += h[i];
        }
    }
    cout << moves;
    return 0;
}

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

using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 6  && a <= 12) cout << b/2 << endl;
    else if (a <= 5) cout << 0 << endl;
    else cout << b << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>

int x,y;
int map[105][105]={};


int rec(int p,int q){
	int r=0;
	if(p<0 || q<0 || p>=105 || q>=105 || map[p][q]==-1)return 0;
	else if(map[p][q]==1)return 1;

	map[p][q]=-1;
	
	r+=rec(p-1,q); r+=rec(p+1,q);
	r+=rec(p,q+1); r+=rec(p,q-1);
	if(q%2==1){
		r+=rec(p+1,q+1); r+=rec(p+1,q-1);
	}
	else{
		r+=rec(p-1,q+1); r+=rec(p-1,q-1);
	}
	return r;
}

int main(void){
	int a,b,c,d;
	scanf("%d%d", &x, &y);
	for(int i=0;i<y;i++){
		for(int j=0;j<x;j++){
			scanf("%d", &(map[j+1][i+1]));
		}
	}
	printf("%d\n",rec(0,0));
	return 0;
}

Measured memory_bytes: 1888
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int a,b;
   cin >> a >> b;

   if(a <= b) cout << a << endl;
   else cout << a-1 << endl;


   return 0;
}

Measured memory_bytes: 256
var
	s:array[1..100]of String[100];
	h,w,i,j,k:Longint;
	f:Boolean;
	b:array[1..100]of Boolean;
begin
	readln(h,w);
	for i:=1 to h do readln(s[i]);
	for j:=1 to w do begin
		b[j]:=false;
		for i:=1 to h do
			if s[i][j]='#' then begin
				b[j]:=true;
				break;
			end;
	end;
	for i:=1 to h do
		for j:=1 to w do
			if s[i][j]='#' then begin
				for k:=1 to w do
					if b[k] then write(s[i][k]);
				writeln('');
                break;
            end;
end.


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	unordered_map<int,int>mp;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(mp.count(a[i])==0){
			mp[a[i]]=0;
		}
		mp[a[i]]++;
	}
	long patt=0;
	for(auto x:mp){
		patt+=(long)x.second *(x.second-1)/2;
	}
	for(int i=0;i<n;i++){
		cout<<patt-mp[a[i]]+1<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 8392
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main()
{
    long long int n;
    long long int a[100010];
    long long int b[100010];
    long long int ans = 0;
    int cnt = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            a[i] *= -1;
            cnt++;
        }
    }

    sort(a,a+n);

    if (cnt%2) {
        a[0] = (a[0]*-1);
    }
    

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

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    ll X;
    cin >> X;

    vector<ll> look;
    map<ll, ll> arr;

    ll i = 0;

    while (true)
    {
        ll curr = i * i * i * i * i;
        if (i > 200)
            break;

        look.push_back(curr);
        arr[curr] = i;

        look.push_back(-1 * curr);
        arr[-curr] = -i;

        i++;
    }

    for (ll x : look)
    {
        for (ll y : look)
        {
            if (x - y == X)
            {
                cout << arr[x] << " " << arr[y];
                return 0;
            }
        }
    }
}

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

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    ll A[1009], B[1009], C[1009];
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    vector<ll> E;
    rep(i, X) {
        rep(j, Y) {
            E.push_back(A[i] + B[j]);
        }
    }

    sort(E.begin(), E.end(), greater<ll>());

    vector<ll> ans;
    int n = min((int)E.size(), K);
    rep(i, n) {
        rep(j, Z) {
            ans.push_back(E[i] + C[j]);
        }
    }

    sort(ans.begin(), ans.end(), greater<ll>());

    rep(i, K) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 43236
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

#define yes printf("Yes\n")
#define Yes printf("YES\n")
#define no printf("No\n")
#define No printf("NO\n")

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 1e16;
const string sp = " ";
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = max(a, b);
		return true;
	}
	return false;
}
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = min(a, b);
		return true;
	}
	return false;
}

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}


signed main() {
	int n;
	cin >> n;
	printf("%.10Lf\n", (double)((n+1) / 2) / n);
}


Measured memory_bytes: 384
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b,x;
	cin>>a>>b>>x;
	if(a<=x&&x<=a+b) cout<<"YES";
	else cout<<"NO";
	return 0;
}


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

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    ll n;
    cin >> n;

    int cnt = 0;
    // (n-1)%k == 0
    ++cnt; // k == n-1
    for (ll i=2; i*i<=n-1; ++i)
    {
        if ((n-1)%i==0)
        {
            // debug(i, (n-1)/i);
            cnt += 2;
            if ((n-1)/i == i)
                --cnt;
        }
    }
    // cout << cnt << endl;

    // n%k == 0
    ++cnt; // k == n
    for (ll i=2; i*i<=n; ++i)
    if (n%i == 0)
    {
        ll j = n/i;
        if (i==j)
        {
            ++cnt;
            continue;
        }
        while (j%i == 0)
            j /= i;
        if (j%i == 1)
            ++cnt;
    }
    if (n==2) --cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, ll> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const ll mod=1e9+7;


int main(){
    int r,c;
    cin>>r>>c;
    char grid[r][c];
    ll dp[r][c];
    //ll inf=1e8;
    //初期化
    fill(dp[0],dp[r],0);
    rep(i,r){
        rep(j,c){
            cin>>grid[i][j];
            //経路の確認
            //cout<<grid[i][j];
        }//cout<<endl;
    }
    dp[0][0]=1;
    rep(i,r){
        rep(j,c){
            //スタートはそのまま
            if (i==0 && j==0) continue;
            //'#'なら強制的に0
            else if (grid[i][j]=='#') dp[i][j]=0;
            //上の端なら左横からのみ
            else if (i==0) dp[i][j]=dp[i][j-1];
            //左端なら上からのみ
            else if (j==0) dp[i][j]=dp[i-1][j];
            else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            //cout<<dp[i][j]<<endl;
        }
    }
    cout<<dp[r-1][c-1]%mod;
}


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

#define      ll      long long int

int main( )
{
    ll n, i, j, k, l;
    ll g = 0;
    ll x;
    cin >> n >> x;
    for (i = 1; i <= n; i++) {
        cin >> j;
        g = __gcd(abs(j - x), g);
    }
    cout << g << '\n';
    return 0;
}


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

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

using namespace std;

const int INF=1<<29;

template<class T>
class network{
	struct edge{
		int to,rev;
		T capa,flow;
		edge(int to,int rev,const T& capa,const T& flow):to(to),rev(rev),capa(capa),flow(flow){}
	};

	int s,t;
	vector<vector<edge>> G;

	vector<int> layer,now;

	bool make_layer(){
		int n=G.size();
		rep(u,n) layer[u]=(u==s?0:-1);

		queue<int> Q; Q.emplace(s);
		while(!Q.empty() && layer[t]==-1){
			int u=Q.front(); Q.pop();
			for(const edge& e:G[u]) if(layer[e.to]==-1 && e.capa-e.flow>0) {
				layer[e.to]=layer[u]+1;
				Q.emplace(e.to);
			}
		}
		return layer[t]!=-1;
	}

	T augment(int u,const T& water){
		if(u==t) return water;

		for(int& i=now[u];i<G[u].size();i++){
			edge& e=G[u][i];
			if(layer[e.to]>layer[u] && e.capa-e.flow>0){
				T w=augment(e.to,min(water,e.capa-e.flow));
				if(w>0){
					e.flow+=w;
					G[e.to][e.rev].flow-=w;
					return w;
				}
			}
		}
		return 0;
	}

public:
	network(int n,int s,int t):s(s),t(t){
		G.resize(n);
	}

	void add_directed_edge(int u,int v,const T& capa){
		G[u].emplace_back(v,G[v].size()  ,capa,0);
		G[v].emplace_back(u,G[u].size()-1,   0,0);
	}

	T maximum_flow(){
		int n=G.size();
		layer.resize(n);

		T res=0;
		while(make_layer()){
			now.assign(n,0);
			for(T water=1;water>0;res+=water) water=augment(s,numeric_limits<T>::max());
		}
		return res;
	}
};

int main(){
	int h,w; scanf("%d%d",&h,&w);
	char B[100][101];
	rep(i,h) scanf("%s",B[i]);

	int sx,sy,tx,ty;
	rep(i,h) rep(j,w) {
		if(B[i][j]=='S') tie(sy,sx)=tie(i,j);
		if(B[i][j]=='T') tie(ty,tx)=tie(i,j);
	}

	network<int> G(2*h*w,sy*w+sx+h*w,ty*w+tx);
	rep(i,h) rep(j,w) if(B[i][j]!='.') {
		G.add_directed_edge(i*w+j,i*w+j+h*w,1);
		rep(k,h) if(k!=i && B[k][j]!='.') G.add_directed_edge(i*w+j+h*w,k*w+j,INF);
		rep(k,w) if(k!=j && B[i][k]!='.') G.add_directed_edge(i*w+j+h*w,i*w+k,INF);
	}

	int ans=G.maximum_flow();
	printf("%d\n",ans<INF?ans:-1);

	return 0;
}


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

typedef long long ll;

using namespace std;

int main(){
  ll N; cin >> N;
  
  vector<ll> t(N + 1); vector<ll> x(N + 1); vector<ll> y(N + 1);
  
  t[0] = 0; x[0] = 0; y[0] = 0;
  
  for(ll i = 1; i <= N; i++){cin >> t[i] >> x[i] >> y[i];}
  
  bool flag = true; 
  
  for(ll i = 1; i <= N; i++){
    ll T = t[i] - t[i-1];
    ll X = x[i] - x[i-1];
    ll Y = y[i] - y[i-1];
    if((abs(X) + abs(Y)) <= T  && (abs(X) + abs(Y)) % 2 == T % 2 ){ flag = true;}
  else{ flag = false;}}
  
  if(flag){cout << "Yes" << endl;}
  else{cout << "No"<< endl; }
  return 0;}
    

Measured memory_bytes: 2560
import std.stdio, std.string, std.algorithm, std.range, std.conv;

void main() {
  const s = readln.chomp;
  const t = readln.chomp;
  
  size_t[][] dp;
  dp.length = s.length+1;
  foreach (ref x; dp) x.length = t.length+1;
  
  foreach (i; 1..s.length+1) foreach (j; 1..t.length+1) {
    if (s[i-1] == t[j-1]) {
      dp[i][j] = dp[i-1][j-1] + 1;
    } else {
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  
  string ans;
  size_t x = t.length, y = s.length;
  while (x > 0 && y > 0) {
    if (dp[y][x] == dp[y-1][x]) {
      --y;
    } else if (dp[y][x] == dp[y][x-1]) {
      --x;
    } else {
      --x;
      --y;
      ans ~= s[y];
    }
  }
  ans.retro.to!string.writeln;
}

Measured memory_bytes: 74236
#include<stdio.h>

int main(void)
{
  int n = 0;
  int x = 0;
  int w[100] = {0};
  int i, j;
  int buffer = 0;
  int leastSum = 0;

  scanf("%d%d", &n, &x);
  for(i=0; i<n; i++){
    scanf("%d", &w[i]);
    leastSum += w[i];
  }

  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      if(w[i] > w[j]){
	         buffer = w[i];
	         w[i] = w[j];
	         w[j] = buffer;
      }
    }
  }

  printf("%d\n", n + (x-leastSum)/w[0] );

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <bits/stdtr1c++.h>

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define ran(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))

using namespace std;

void backtrack(long long x, long long y, long long d, long long cur, long long& res){
    if (d == 10) return;
    if (x == y) res = min(res, cur);

    backtrack(-x, y, d + 1, cur + 1, res);
    if (x < y) backtrack(y, y, d + 1, cur + y - x, res);
    if (x < -y) backtrack(-y, y, d + 1, cur + -y - x, res);
}

long long solve(long long x, long long y){
    long long res = 1LL << 50;
    backtrack(x, y, 0, 0, res);
    return res;
}

int main(){
    long long x, y;
    scanf("%lld %lld", &x, &y);
    printf("%lld\n", solve(x, y));
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    ans = s.count('R') * s.count('G') * s.count('B')
    for i in range(n-2):
      for j in range(i+1, n-1):
        if j - i > n - j - 1:
          break
        if s[i] != s[j] and s[j] != s[2*j-i] and s[2*j-i] != s[i]:
          ans -= 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9120
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll A, B;
int score(ll x) {
	return (A * x )/ B - A * (x / B);
}
double Score(ll x) {
	return ((double)A * x) / B - A * ((double)x / B);
}

void BS(ll a, ll b) {
	if (a + 1 == b || a == b) {
		ll ans = max(score(a), score(b));
		cout << ans;
		return ;
	}
	if (b - a < 10000) {
		ll ans = 0;
		for (ll i = 0; a + i <= b; i++)
			ans = max(ans, score(a + i));
		cout << ans;
		return ;
	}
	ll c = (a + b) / 2;
	ll p = score(a);
	ll q = score(b);
	ll r = score(c);
	//	cout << p << " " << r << " " << q << endl;
	if (p > q) {
		BS(a, c);
	}
	else if (p < q) {
		BS(c, b);
	}
	else {
		int d = (a + c) / 2;
		int e = (c + b) / 2;
		if (Score(d) < Score(e)) {
			BS(a, c);
		}
		else {
			BS(c, b);
		}
	}
	return ;
}


int main() {
	string S;
	int i, j, k;
	//ll N, M, K;
	//int N, M, K;
	
	ll N, x;
	cin >> A >> B >> N;
	if (A == 1 || B == 1) {
		cout << 0;
		return 0;
	}
	cout << score(min(B-1,N));


	return 0;

}


Measured memory_bytes: 3596
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 300005;
int a[N], cnt[N], D[N];
int n;
int prefD[N], sufD[N];
int f[N];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	up(i,1,n){
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i=0;i<=n;++i) D[cnt[i]]++;
	for(int i=1;i<=n;++i) prefD[i] = prefD[i-1] + D[i] * i;
	for(int i=n;i>=1;--i) sufD[i] = sufD[i+1] + D[i];
	for(int i=1;i<=n;++i){
		// cerr << prefD[i] << ' ' << sufD[i+1] << '\n';
		f[i] = (prefD[i] + sufD[i+1] * i)/i;
	}
	int curPos = n;
	up(k,1,n) {
		while (curPos >= 1 && f[curPos] < k) curPos--;
		if (f[curPos] >= k) cout << curPos << '\n';
		else cout << 0 << '\n';
	}
}

Measured memory_bytes: 9440
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define LL long long
#define ll long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

string a[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<7;++i)
    {
        if(a[i]==s)
        {
            if(i!=6)
            {
                cout<<7-(i+1)<<endl;
            }
            else
            {
                cout<<7<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let mut a: usize;
	let mut v = vec![0_usize; n+1];
	let mut cnt: usize = 0;
	for i in 1..n+1 {
		a = read();
		if i > a {
			cnt += v[i-a];
		}
		if i+a <= n {
			v[i+a] += 1;
		}
	}
	println!("{}", cnt);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+5;
int a[maxn],b[maxn];
int n,m;
inline bool check(int v){
	int ans=0;
	for(int i=1;i<=n;i++){
		if(v<a[i]*b[i])ans+=a[i]-v/b[i];
		if(ans>m)return 0;
	}
	return ans<=m;
}
inline bool cmp(int x,int y){
	return x>y;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1,cmp);
	int l=0,r=a[n]*b[1],ans=0;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5888
#include<cstdio>
using namespace std;
int main(){
    long a[10000],b[10000],as=0,bs=0,n,sa=0,sb=0;
    scanf("%ld",&n);
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
        as+=a[i];
    }
    for(int i=0;i<n;i++){
        scanf("%ld",&b[i]);
        bs+=b[i];
        if(a[i]>b[i]){
            sa+=a[i]-b[i];
        }
        else{
            sb+=(b[i]-a[i])/2+(b[i]-a[i])%2;
        }
    }
    if(as>bs||bs-as<sa||(bs-as)<sb){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
}

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

class Program
{
    public static void Main(string[] args)
    {
        var xy = Console.ReadLine().Split().Select(n => long.Parse(n)).ToArray();
        Console.WriteLine(Math.Abs(xy[0] - xy[1]) > 1 ? "Alice" : "Brown");
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vll a(n), b(n);
    for(auto& e : a) cin >> e;
    for(auto& e : b) cin >> e;

    int res = 0;
    rrep(k, 30){
        for(auto& e : b){
            e %= bit(k + 1);
        }
        sort(_all(b));

        int cnt = 0;
        for(auto& e : a){
            e %= bit(k + 1);
            rep(i, 2){
                ll l = (2*i + 1) * bit(k) - e;
                ll r = (2*i + 2) * bit(k) - e;
                auto itr = lower_bound(_all(b), l);
                cnt += (lower_bound(_all(b), r) - itr);
                cnt %= 2;
            }
        }
        if(cnt == 1){
            res += bit(k);
        }
    }

    cout << res << endl;

    return 0;
}


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

int main()
{
  int n;
  scanf("%d",&n);
  static char M[310][310];
  for(int i=0;i<n;i++){
    scanf("%s",M[i]);
  }
  int ans=0;
  for(int x=0;x<n;x++){
    bool F=0;
    for(int i=0;i<n&&!F;i++){
      for(int j=0;j<n&&!F;j++){
	if(M[i][(j+x)%n]!=M[j][(i+x)%n]){
	  F=1;
	}
      }
    }
    if(!F){
      ans+=n;
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

int main() {
	int a, b;

	cin >> a >> b;
	for (int i = 1; i <= 10010; i++) {
		if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256