akhauriyash/Code-Regression huggingface dataset:
a = int(input())
b= int(input())
c = int(input())
d = int(input())
e = int(input())
l = [] 
for i in [a,b,c,d,e]:
    if i % 10 != 0: 
        l.append(i//10*10+10-i)
print(sum([a,b,c,d,e])+sum(sorted(l)[:-1]))

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;

void solve()
{
	ll n, m; cin >> n >> m;
	vector<pair<ll, ll>> s;
	for (int i = 0; i < n; ++i)
	{
		ll a, b; cin >> a >> b;
		s.pb({a, b});
	}
	sort(all(s));
	ll cnt = 0, i = 0, c = 0;
	ll last = 0;
	while (c < m)
	{
		last = i;
		cnt += s[i].first * s[i].second;
		c += s[i].second;
		i++;
	}
	cout << cnt - (c - m) * s[last].first;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 5296
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<int long long,int long long>
#define vi          vector<int long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int long long)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(int long long i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  2007
ll n;
std::vector<pii> a(N);

ll dp[N][N];
ll func(ll pos,ll st,ll en)
{
    if(pos==(n))
        return 0;
    if(dp[pos][st]!=-1)
        return dp[pos][st];
    ll res=(abs(a[pos].S-st)*a[pos].F)+func(pos+1,st+1,en);
    res=max(res,(abs(a[pos].S-en)*a[pos].F)+func(pos+1,st,en-1));
    return dp[pos][st]=max(dp[pos][st],res);
}
int main()
{
    
    io
    
    cin>>n;
    memset(dp,-1,sizeof(dp));
    rep(i,0,n)
    {
        ll x;
        cin>>x;
        a[i]={x,i};
    }
    sort(all(a));
    reverse(all(a));
    cout<<func(0,0,n-1);
    
}

Measured memory_bytes: 35240
# include <cstdio>

static const int maxn = 100 + 2;
int a[maxn], n;

void print_out() {
	for (int i = 0; i < n-1; i++) printf("%d ", a[i]);
	printf("%d\n", a[n-1]);
}

int main() {
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	while (scanf("%d", &n) == 1) {
		for (int i = 0; i < n; i++) scanf("%d", &a[i]);
		print_out();
		int v, j;
		for (int i = 1; i < n; i++) {
			v = a[i];
			j = i - 1;
			while (j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			print_out();
		}
	}
	return 0;
}



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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%ull",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define MOD 1000000007
#define var    int i,j,k,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll n,m,a[200005];
vector<ll> pos,neg,n1;

ll chk(ll x)
{
    ll c=0;
    //cout<<"K "<<x<<endl;
    for(int i=0;i<n;i++)
    {
        ll y=inf;
        if(x<0 && pos[i]==0)continue;
        if(pos[i]>0)
        {
            y=x/pos[i];
            if(abs(x)%pos[i]!=0 && x<0)y--;
            //cout<<x<<" o "<<pos[i]<<" "<<x/pos[i]<<endl;
        }
        c+=(upper_bound(neg.begin(),neg.end(),y)-neg.begin());
        //cout<<y<<" "<<(upper_bound(neg.begin(),neg.end(),y)-neg.begin())<<" ";
        ll z=(upper_bound(pos.begin(),pos.end(),y)-pos.begin())-(i+1);
        if(z<0)z=0;
        //cout<<z<<endl;
        c+=z;
    }
    //cout<<c<<endl;
    if(x<=0)return c;
    n1.clear();
    for(int i=0;i<m;i++)
    {
        n1.pb(abs(neg[i]));
    }
    sort(n1.begin(),n1.end());

    for(int i=1;i<=m;i++)
    {
        ll y=x/(n1[i-1]);
        ll z=(upper_bound(n1.begin(),n1.end(),y)-n1.begin())-i;
        if(z<0)z=0;
        c+=z;
    }
    return c;
}
map<ll,ll> mp;
int main()
{
    ll var;
    sfl(n);sfl(k);
    for(i=0;i<n;i++)
    {
        sfl(a[i]);
        if(a[i]>=0)pos.pb(a[i]);
        else neg.pb(a[i]);
        mp[a[i]]++;
    }
    ll sz=n;
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());
    m=neg.size();
    n=pos.size();

    l=-1e18,r=1e18;
    while(l<=r)
    {
        mid=(l+r)/2;
        c=chk(mid);
        //cout<<c<<endl;
        if(c>=k)
        {
            z=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<z<<endl;
}


Measured memory_bytes: 17264
#include<iostream>
using namespace std;
int main(){
	int n,m;
	int t;
	int i,j,k;
	int a,b;
	bool s=false;
	
	cin>>n>>m>>t;
	
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			a=i*m+j*n-i*j*2;
			if(a==t){
				s=true;
				break;
			}
		}
		if(s)break;
	}
	if(s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Range Set Counter
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<int> v;
    ::std::unordered_map<T, int> Map;
    ::std::vector<::std::vector<int> > data;
    int kind;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_.size()){
        int sz = v_.size(); kind = 0;
        for(int i=0;i<sz;i++){
            T t = v_[i];
            if (Map.count(t)){
                data[Map[t]].push_back(i);
            }else{
                Map[t] = kind++;
                data.push_back(::std::vector<int>());
                data.back().push_back(i);
            }
            v[i] = Map[t];
        }
    }
    int query(T x){
        if (!Map.count(x)) return 0;
        return data[Map[x]].size();
    }
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!Map.count(x)) return 0;
        int xi = Map[x];
        auto right = ::std::upper_bound(data[xi].begin(),data[xi].end(),b);
        auto left  = ::std::lower_bound(data[xi].begin(),data[xi].end(),a);
        return right-left;
    }
    int query(int k, T x){
        if (!Map.count(x)) return -1;
        int xi = Map[x];
        auto ret = ::std::upper_bound(data[xi].begin(),data[xi].end(),k);
        if (ret==data[xi].end()) return -1;
        return *ret;
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; string s;
    cin>>n>>s;
    vector<char> a(n);
    rep(i,n) a[i] = s[i];
    RangeSet<char> rs(a);

    int ans=0;
    rep(i,10)rep(j,10)rep(k,10){
        int idx = rs.query(-1, (char)(i+'0'));
        if (idx==-1) continue;
        idx = rs.query(idx, (char)(j+'0'));
        if (idx==-1) continue;
        idx = rs.query(idx, (char)(k+'0'));
        if (idx==-1) continue;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int T[1001];
int A[1001];
int N;
long long a,b;
int main(){
	cin>>N;
	REP(i,N){
	   cin>>T[i]>>A[i];
	}
	a=T[0];
	b=A[0];
	for(int i=1;i<N;i++){
//	cout<<i<<" "<<a<<" "<<b<<endl;
	    long long c=0,d=0;
	    long long t1,a1;
	    t1=a;
	    if(t1%T[i]!=0)t1+=T[i]-t1%T[i];
	    a1=t1/T[i]*A[i];
	    if(a1<b)c=-1;
	    
	    long long t2,a2;
	    a2=b;
	    if(a2%A[i]!=0)a2+=A[i]-a2%A[i];
	    t2=a2/A[i]*T[i];
	    if(t2<a)d=-1;
	    
//	    cout<<"test"<<t1<<" "<<a1<<" "<<t2<<" "<<a2<<endl;
	    if(c==-1){
	       a=t2;
	       b=a2;
	       continue;
	    }
	    if(d==-1){
	       a=t1;
	       b=a1;
	       continue;
	    }
	    if(t1<t2){
	       a=t1;
	       b=a1;
	    }else{
	       a=t2;
	       b=a2;
	    }
	}
        cout<<a+b<<endl;
	return(0);
}

Measured memory_bytes: 256
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()

    sum = 0
    for i in range(1, n + 1):
        if i % 3 != 0 and i % 5 != 0:
            sum += i
    print(sum)


if __name__ == "__main__":
    main()


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

import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()


x = ni()

print((x//500)*1000+((x%500)//5)*5)

Measured memory_bytes: 3064
import math
from itertools import chain, combinations



D, G = map(int, input().split())
p = []
c = []

for _ in range(D):
    p_in, c_in = map(int, input().split())
    p.append(p_in)
    c.append(c_in)

# ボーナスを使う

def powerset(itr):
    s = list(itr)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))


# フルコン時の点数
fullcon = []
for i in range(D):
    score = 100 * (i + 1) * p[i] + c[i]
    fullcon.append(score)


use_flag_itr = range(D)
use_flag_set = powerset(use_flag_itr)

mincount = 100 * 10

for use_flag in use_flag_set:
    fullscore = 0
    fullcount = 0
    for i in use_flag:
        fullcount += p[i]
        fullscore += fullcon[i]

    remain = G - fullscore

    if remain <= 0:
        if mincount > fullcount:
            mincount = fullcount 
        continue



    for i in reversed(range(D)):
        if i in use_flag:
            continue

        score = 100 * (i + 1) 
        if score * p[i] > remain:
            new_count = fullcount +  int(math.ceil(remain / score))
            if mincount > new_count:
                mincount = new_count
        break

print(mincount)



Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n; cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[n/2] - d[n/2-1] << endl;

  return 0;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define nl '\n'
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << (x) << endl;

// template starts
typedef long long int ll;
// template ends here
//#define endl '\n'

const int MAXN = 200005;
int key[MAXN], dist[MAXN];

int get_key(int k){
	while(k != key[k]) k = key[k];
	return k;
}

void join(int k1, int k2){
	int g1 = get_key(k1), g2 = get_key(k2);
  	int d1 = dist[g1], d2 = dist[g2];
  
  if(d1 > d2){
  	key[g2] = g1; 
  }
  else if(d1 < d2){
	key[g1] = g2;
  }
  else{
	key[g1] = g2;
    dist[g2]++;
  }
}
void solve(){
	int N, Q;
  	cin >> N >> Q;
  	while(Q--){
		int t, u, v;
      	cin >> t >> u >> v;
      	if(t == 0) join(u,v);
      	else cout << (get_key(u) == get_key(v)) << "\n";
    }
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();
	srand(time(0));
	int T;
    for(int i = 1; i < MAXN; i++){
      key[i] = i;
      dist[i] = 1;
    }
	//cin >> T;
	T = 1;
    while(T--){
		solve();
	}
	
	//cout << getCurrentTime() << endl;
	return 0;
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  if(A == 0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = N / (A+B) * A;
  ans += min(N % (A+B), A);
  cout << ans << endl;

  return 0;
}


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

using namespace std;

class IntStack {
private:
	const static int MAX = 300;
	int s[MAX];
	int top;

public:
	IntStack();
	bool isEmpty();
	bool isFull();
	void push(int);
	int pop();
};

int main(void) {
	string str;
	int a, b;
	IntStack s;

	while (cin >> str) {
		if (str == "+"){
			a = s.pop();
			b = s.pop();
			s.push(b + a);
		}
		else if (str == "-") {
			a = s.pop();
			b = s.pop();
			s.push(b - a);
		}
		else if (str == "*") {
			a = s.pop();
			b = s.pop();
			s.push(b * a);
		}
		else {
			s.push(stoi(str));
		}
	}

	cout << s.pop() << "\n";

	cin >> a;
	return 0;
}


IntStack::IntStack() {
	top = 0;
}

bool IntStack::isEmpty() {
	return top == 0;
}

bool IntStack::isFull() {
	return top >= MAX - 1;
}

void IntStack::push(int n) {
	if (isFull()) {
		cout << "error: over flow\n";
		return;
	}
	top++;
	s[top] = n;
}

int IntStack::pop() {
	if (isEmpty()) {
		cout << "error: under flow\n";
		return '\0';
	}
	top--;
	return s[top + 1];
}

Measured memory_bytes: 3220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

int w, h;
vector<vector<bool>> seen;
vii field;

void dfs(int r, int c){
    seen[r][c] = true;
    rep(i, 8){
        int nr = r + dy[i];
        int nc = c + dx[i];

        if(nr < 0 || nc < 0 || nr >= h || nc >= w) continue;
        if(field[nr][nc] == 0) continue;
        if(seen[nr][nc]) continue;
        
        dfs(nr, nc);
    }
}

int main() {
    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0) return 0;
        field.assign(h, vi(w));
        rep(i, h){
            rep(j, w){
                cin >> field[i][j];
            }
        }
        
        int cnt = 0;
        seen.assign(h, vector<bool>(w, false));
        rep(i, h){
            rep(j, w){
                if(seen[i][j]) continue;
                if(field[i][j] == 0) continue;
                dfs(i, j);
                cnt++;
            }
        }

        cout << cnt << endl;
    }
}


Measured memory_bytes: 3220
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().rstrip()

lst=[0]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        lst.append(lst[i-1]+1)
    else:
        lst.append(lst[i-1])

for i in range(q):
    l,r=map(int,input().split())
    print(lst[r-1]-lst[l-1])

Measured memory_bytes: 11712
#include <bits/stdc++.h>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int K;
	cin >> K;
	vector<int> list{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	cout << list[K-1] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> botton = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			botton.add(Integer.parseInt(sc.next()) - 1);
		}
		sc.close();

		int count = 0;
		int now = 0;

		for(int i = 0; i <= N ;i++) {
			if(now == 1) {
				System.out.println(count);
				return;
			}
			if(count == N) {
				System.out.println(-1);
				return;
			}
			count++;
			now = botton.get(now);
		}
	}

}

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

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    s1.at(0) -= 32;
    s2.at(0) -= 32;
    s3.at(0) -= 32;

    cout << s1.at(0) << s2.at(0) << s3.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define y1 _y1
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

namespace{
	const int mod=1e9+7,N=2e6+5;
	int power(int x,int p){
		int res=1;
		for(;p;p>>=1,x=(ll)x*x%mod)
			if(p&1)res=(ll)res*x%mod;
		return res;
	}
	int mul(int x,int y){
		return (ll)x*y%mod;
	}
	int fix(int x){
		return x>=mod?x-mod:x;
	}
	void add(int &x,int y){
		x=(x+y>=mod?x+y-mod:x+y);
	}
	int fac[N],rev[N];
	int C(int n,int m){
		return m<0||m>n?0:mul(fac[n],mul(rev[m],rev[n-m]));
	}
	void init(int lim=int(2e6+2)){
		fac[0]=1;
		rep(i,1,lim) fac[i]=mul(fac[i-1],i);
		rev[lim]=power(fac[lim],mod-2);
		per(i,lim,1) rev[i-1]=mul(rev[i],i);
	}
}

int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int ans;

int f(int x,int y){
	return fix(C(x+y+2,x+1)+mod-1);
}

int g(int x1,int x2,int y1,int y2){
	if(x1>x2) swap(x1,x2);
	if(y1>y2) swap(y1,y2);
	int res=f(x2,y2);
	add(res,mod-f(x1-1,y2));
	add(res,mod-f(x2,y1-1));
	add(res,f(x1-1,y1-1));
	return res;
}

int main(){
	read(x1),read(x2),read(x3);
	read(x4),read(x5),read(x6);
	read(y1),read(y2),read(y3);
	read(y4),read(y5),read(y6);
	init();
	rep(i,x3,x4){
		int A=g(i-x1,i-x2,y3-y1-1,y3-y2-1);
		int B=g(x5-i,x6-i,y5-y3,y6-y3);
		int C=g(i-x1,i-x2,y4-y1,y4-y2);
		int D=g(x5-i,x6-i,y5-y4-1,y6-y4-1);
		add(ans,mul(mul(A,B),mod-i-y3+1));
		add(ans,mul(mul(C,D),i+y4));
	}
	rep(i,y3,y4){
		int A=g(x3-x1-1,x3-x2-1,i-y1,i-y2);
		int B=g(x5-x3,x6-x3,y5-i,y6-i);
		int C=g(x4-x1,x4-x2,i-y1,i-y2);
		int D=g(x5-x4-1,x6-x4-1,y5-i,y6-i);
		add(ans,mul(mul(A,B),mod-i-x3+1));
		add(ans,mul(mul(C,D),i+x4));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	cout<<min({a,b,c})+min(d,e)-50<<endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define show(v) for(int i : v)cout << i << " ";cout << endl;
#define sall(v) sort(v.begin(), v.end());

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int inf = 1e9;
int mod = 1e9 + 7;
const int MAXN = 1000005;
int a[MAXN];

//vector<int> g[MAXN];
//vector<bool> was;
//vector<int> d, a;
//int n, m, k, c;
//
//void dfs(int v) {
//    was[v] = true;
//    d[v] = c;
//    for(int to : g[v]){
//        if(!was[to]){
//            dfs(to);
//        }
//    }
//}
//
//
//void solve() {
//    cin >> n >> m >> k;
//    c = 0;
//    d.assign(n, 0);
//    a.assign(k, 0);
//    was.assign(n, false);
//    for(int i = 0;i < k;i++){
//        cin >> a[i];
//        a[i]--;
//    }
//    for(int i = 0;i < n;i++){
//        int x, y;
//        cin >> x >> y;
//        g[x].pb(y);
//        g[y].pb(y);
//    }
//    for(int i = 0;i < n;i++){
//        if(!was[i]){
//            dfs(i);
//            c++;
//        }
//    }
//
//}

int main(){
    faster
    for(int i = 1;i < MAXN;i++){
        for(int j = 1;j < MAXN;j++){
            if(i * j >= MAXN)break;
            a[i * j]++;
        }
    }
    int n; cin >> n;
    int cnt = 0;
    for(int i = 1;i <= n;i++){
        int s = n - i;
        cnt += a[s];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 7592
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a, b, c;
  cin >> a >> b >> c;
  REP2(i,1,10000){
    if((a * i) %b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>

using namespace std;

int main()
{
    int n;
    int check[2][26]={0};
    int count[100]={0};
    char buf[100];
    cin >> n;
    cin >> buf;
    int maxcount=0,ret=0;
    int check2[26];

    for(int i=0;i<n;i++){
        check[0][buf[i]-'a']=1;
        for(int i=0;i<26;i++)
            check2[i]=0;
        for(int j=i+1;j<n;j++){
            if((check[0][buf[j]-'a']==1)&&(check2[int(buf[j]-'a')]!=1)){
                count[i]++;
                check2[int(buf[j]-'a')]=1;
            }
        }
        if(count[i]>count[ret]){
            ret=i;
        }
    }
    cout << count[ret];
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
const ll p=1000000007;
const int N=100010;
int cmp(pii a,pii b)
{
    if(a.first!=b.first)
        return a.first<b.first;
    return a.second>b.second;
}
int n,m,t,t2;
int a[N],b[N],d[N];
pii c[N];
ll e[N];
ll add(ll a,ll b)
{
    a+=b;
    return a>=p?a-p:a;
}
void add(int x,ll v)
{
    for(;x<=t2;x+=x&-x)
        e[x]=add(e[x],v);
}
ll sum(int x)
{
    ll s=0;
    for(;x;x-=x&-x)
        s=add(s,e[x]);
    return s;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)
        if(a[i]>b[1]&&a[i]<b[m])
        {
            int x=lower_bound(b+1,b+m+1,a[i])-b;
            if(b[x]==a[i])
                continue;
            c[++t]=pii(a[i]-b[x-1],b[x]-a[i]);
            d[++t2]=b[x]-a[i];
        }
    sort(d+1,d+t2+1);
    t2=unique(d+1,d+t2+1)-d-1;
    for(int i=1;i<=t;i++)
        c[i].second=lower_bound(d+1,d+t2+1,c[i].second)-d;
    sort(c+1,c+t+1,cmp);
    t=unique(c+1,c+t+1)-c-1;
    ll ans=1;
    for(int i=1;i<=t;i++)
    {
        ll s=sum(c[i].second-1)+1;
        ans+=s;
        add(c[i].second,s);
    }
    ans%=p;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
/** || By The Name of Allah, Who Created Me. || **/

/**
	* Author   : Farid ul Islam Chy.
	* ID       : 1512020238.
	* Batch    : 38th.
	* Semester : 4C(E).
	* Team     : LU_AntiVirus.

	* Leading University, Sylhet.
**/

#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <cstdio>
#include <vector>
#include <cstring>
#include <utility>
#include <ctype.h>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdlib.h>
#include <fstream>

using namespace std;

#define ll    		    long long int
#define SS		    stringstream
#define pb    		    push_back
#define ull    		    unsigned long long int
#define MII        	    map <int,int>
#define MSI        	    map <string,int>
#define MIS        	    map <int,string>
#define MLI         	    map <long long int,int>
#define MIL        	    map <int,long long int>
#define MLL        	    map <ll,ll>
#define VS        	    vector <string>
#define VI        	    vector <ll>
#define VC        	    vector <char>
#define ForA(n)  	    for (int i=0; i<n; i++)
#define ForA2(n)  	    for (int j=0; j<n; j++)
#define ForA3(n)  	    for (int k=0; k<n; k++)
#define ForAS(n)  	    for (int i=n; i>0; i--)
#define ForN(n)  	    for (int i=1; i<=n; i++)
#define ForN2(n)  	    for (int j=1; j<=n; j++)
#define ForN3(n)  	    for (int k=1; k<=n; k++)
#define ForD(m,n)  	    for (int i=m; i<=n; i++)
#define ForD2(m,n)  	    for (int j=m; j<=n; j++)
#define ForD3(m,n) 	    for (int k=m; k<=n; k++)
#define SortA(n,x) 	    sort(n,n+x)
#define SortS(s)  	    sort(s.begin(), s.end())
#define SortRS(s)  	    sort(s.rbegin(), s.rend())
#define Search(s)           s.begin(), s.end()
#define SortSG(n)	    sort(n.begin(), n.end(), greater<int>())
#define Cin(a)		    cin>>a
#define GCin(a)		    getline(cin,a)
#define Cin2(a,b)	    cin>>a>>b
#define Cin3(a,b,c)	    cin>>a>>b>>c
#define Cin4(a,b,c,d)	    cin>>a>>b>>c>>d
#define PI 		    3.1415926535897932384626433832795l
#define Ignore		    cin.ignore()

int isprime(ll n){
     ll i;
     if(n==2) return 1;
     if(n%2==0) return 0;
     for(i=3;i<=sqrt(n);i+=2)
         if(n%i==0) return 0;
     return 1;
}

bool cmp(string i,string j){
    return i+j<j+i;
}

string ConvertItoS(ll n){
    SS a; a<<n;
    return a.str();
}

//ll ConvertStoI(string s){
//   return stoi(s);
//}

int main(){
    //freopen("in.txt","r",stdin)
    //freopen("out.txt","w",stdout)
    //cout<<fixed<<setprecision(2);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	VI(v);
	ll m;

	ForA(10){
	    Cin(m);
	    v.pb(m);
	}
	SortS(v);
	ll len=v.size();
	cout<<v[len-1]<<endl;
	cout<<v[len-2]<<endl;
	cout<<v[len-3]<<endl;
	
    return 0;
}

Measured memory_bytes: 3128
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    
	    TreeMap <String, Integer> s = new TreeMap <String, Integer>();
	    
	    String S = "";
	    for (int i = 0; i<N; i++){
			S = sc.next();
 
			if (s.containsKey(S)) 
				s.put(S, s.get(S) + 1);
			 else 
				s.put(S, 1);
		}
	    
	    TreeMap <String, Integer> t = new TreeMap <String, Integer>();
	    int M = sc.nextInt();
	    String T = "";
	    for (int i = 0; i<M; i++){
			T = sc.next();
 
			if (t.containsKey(T)) 
				t.put(T, t.get(T) + 1);
			 else 
				t.put(T, 1);
		}
	    
	    int max = 0;
	    while (s.isEmpty()==false) {
	    	String temp = s.firstKey();
	    	
	    	if (t.containsKey(temp)){
	    		max = Math.max(max, s.get(temp)-t.get(temp));
	    		s.pollFirstEntry();
	    	}
	    	else {
	    		max = Math.max(max, s.get(temp));
	    		s.pollFirstEntry();
	    	}
	    }
	    sc.close();
	    
	    System.out.println(max);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  V a(n);
  VIN(a);
  V one(0), two(0), three(0);
  I t=1;
  REP(i,n){
    if (one.size() == a.at(i) && two.size() == a.at(i) && three.size() == a.at(i)){
      // three
      t *= 3;
      one.push_back(i);
    }else if (one.size() == a.at(i) && two.size() == a.at(i)){
      // two
      t *= 2;
      one.push_back(i);
    }else if (two.size() == a.at(i) && three.size() == a.at(i)){
      // two
      t *= 2;
      two.push_back(i);
    }else if (one.size() == a.at(i) && three.size() == a.at(i)){
      // two
      t *= 2;
      one.push_back(i);
    }else if (one.size() == a.at(i)){
      // one
      one.push_back(i);
    }else if (two.size() == a.at(i)){
      // one
      two.push_back(i);
    }else if (three.size() == a.at(i)){
      // one
      three.push_back(i);
    }else{
      cout << 0 << endl;
      return 0;
    }
    t %= MOD;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 2296
H,W = [int(x) for x in input().split()]
A = [input() for _ in range(H)]
char_cnts = [0]*26
for a in A:
    for c in a:
        char_cnts[ord(c)-97] += 1
if(H==1 or W==1):
    num_cnt1 = 0
    for i in char_cnts:
        if(i%2==1):
            num_cnt1 += 1
        if(num_cnt1>1):
            print('No')
            break
    else:
        print('Yes')

elif(H==2 and W==2):
    for i in char_cnts:
        if(i%4!=0):
            print('No')
            break
    else:
        print('Yes')
elif(H==2 or W==2):
    for i in char_cnts:
        if(i%2!=0):
            print('No')
            break
    else:
        print('Yes')
else:
    cnt = (H//2)*(W//2)
    for i in char_cnts:
        cnt -= i//4
        if(cnt<=0):
            print('Yes')
            break
    else:
        print('No')


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    vector<int> v(1e5+10);

    REP(i, n){
        int a;
        cin >> a;
        v[a]++;
    }

    auto fn = [](const pair<int,int>& a, const pair<int,int>& b){return a.second%2 < b.second%2;};

    vector<
        priority_queue<
            pair<int,int>,
            vector<pair<int,int>>,
            decltype(fn)
        >
    >
    que(
        m,
        priority_queue<
            pair<int,int>,
            vector<pair<int,int>>,
            decltype(fn)
        >(fn)
    );
    
    REP(i, v.size()){
        if(v[i] == 0) continue;
        que[i%m].push(make_pair(i, v[i]));
    }

    int ans = 0;

    REP(i, m){
        int a = i, b = (m - i) % m;
        if(a == b){
            int cnt = 0;
            while(!que[a].empty()){
                cnt += que[a].top().second;
                que[a].pop();
            }
            ans += cnt / 2;
            continue;
        }
        while(!que[a].empty() && !que[b].empty()){
            auto p = que[a].top();
            que[a].pop();
            auto q = que[b].top();
            que[b].pop();
            p.second--;
            q.second--;
            ans++;
            if(p.second > 0) que[a].push(p);
            if(q.second > 0) que[b].push(q);
        }
        while(!que[a].empty()){
            ans += que[a].top().second / 2;
            que[a].pop();
        }
        while(!que[b].empty()){
            ans += que[b].top().second / 2;
            que[b].pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    vector<lint> A(N, 0);
    for(int i = 0; i < N; i++){
        int num;
        cin >> num;
        A[num - 1]++;
    }
    sort(all(A), greater<>());
    lint sum[N + 1];
    sum[N] = 0;
    for(int i = N - 1; i >= 0; i--){
        sum[i] = sum[i + 1] + A[i];
    }
    for(int i = 0; i < N; i++){
        int low = -1, high = i; // [low, high)
        while(low + 1 < high){
            lint mid = (low + high) / 2;
            if(sum[mid + 1] < A[mid] * (i - mid)){
                low = mid;
            }else{
                high = mid;
            }
        }
        cout << sum[low + 1] / (i - low) << endl;
    }
}


Measured memory_bytes: 5504
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 , MAX = 8000 + 20 , SZ = 4000 + 20 , C = SZ / 2 , mod = 1e9 + 7 ;
int n , a[N] , b[N] ;

int ans , rev2 ;

int val[SZ][SZ] ;

int fac[MAX] ;

inline int pw (int a , int b) {
	int res = 1 ;
	while (b) {
		if (b & 1) res = 1ll * res * a % mod ;
		a = 1ll * a * a % mod ;
		b >>= 1 ;
	}
	return res ;
}

void pre () {
	fac[0] = 1 ;
	for (int i = 1 ; i < MAX ; i ++) fac[i] = 1ll * fac[i - 1] * i % mod ;
	rev2 = pw(2 , mod - 2) ;
}

inline int Comb (int n , int k) {
	if (k < 0 || k > n) return 0 ;
	return 1ll * fac[n] * pw(fac[k] , mod - 2) % mod * pw(fac[n - k] , mod - 2) % mod ;
}

inline void add (int &a , int b) {
	a += b ;
	if (a >= mod) a -= mod ;
}

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

	pre() ;

	cin >> n ;

	for (int i = 0 ; i < n ; i ++) cin >> a[i] >> b[i] ;

	for (int i = 0 ; i < n ; i ++) val[-a[i] + C][-b[i] + C] ++ ;

	for (int i = 0 ; i < SZ - 5 ; i ++)
		for (int j = 0 ; j < SZ - 5 ; j ++) {
			add(val[i + 1][j] , val[i][j]) ;
			add(val[i][j + 1] , val[i][j]) ;
		}

	for (int i = 0 ; i < n ; i ++) add(ans , val[a[i] + C][b[i] + C]) ;

	for (int i = 0 ; i < n ; i ++) ans = (ans + mod - Comb(2 * (a[i] + b[i]) , 2 * a[i])) % mod ;

	ans = 1ll * ans * rev2 % mod ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 65024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());

        int longest = 0;
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
            longest = Math.max(longest, a[i]);
        }
        scan.close();

        int ok = longest;
        int ng = 0;
        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            if (isOK(k, a, mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        System.out.println(ok);
    }

    private static boolean isOK(int k, int[] a, int bound) {
        int count = 0;
        for (int ai : a) {
            if (ai % bound == 0) {
                count += ai / bound - 1;
            } else {
                count += ai / bound;
            }
        }
        return count <= k;
    }
}


Measured memory_bytes: 60764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextIntSlice(size int) []int {
	re := make([]int, size)
	for i := 0; i < size; i++ {
		re[i] = nextInt()
	}
	return re
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextIntSlice(n)

	now := 1
	c := 0
	for {
		if now == 2 {
			fmt.Println(c)
			return
		}
		if c >= n {
			fmt.Println(-1)
			return
		}
		c++
		now = a[now-1]
	}
}


Measured memory_bytes: 2048
def BFS(L):
    Visit=[]
    now=[]

    L_temp=L.copy()
    Visit.extend(L_temp[0])
    now.extend(L_temp[0])

    L_temp.remove(L_temp[0])

    # L_temp.pop(L_t)
    l_n=0
    while 0 < len(L_temp) and 0 < len(now):
        now_t=now[0]
#         print('======')
#         print(Visit)
#         print(L_temp)
        l=L_temp[l_n]
        l_n+=1
#         print(L_temp)
#         print(now)
#         print(l)
        for t_n in range(len(l)):
            t_n_r = 1-t_n
            if now_t == l[t_n] :
                if l[t_n_r] not in Visit:
                    Visit.append(l[t_n_r])
                now.append(l[t_n_r])
                L_temp.remove(l)
                l_n=0

        if l_n == len(L_temp):
            now=now[1:]
            l_n=0   
    
    return(Visit)

N,M=[int(x) for x in input().split()]
L=[]
for i in range(M):
    L.append([int(x) for x in input().split()])

# A=[int(x) for x in read_input().split()]
# B=[int(x) for x in read_input().split()]

ans=0
for l in range(len(L)):
    L_temp=L.copy()
    L_temp.pop(l)
    
    visit=BFS(L_temp)
    len_visit=len(visit)
    
    if len_visit!=N:
        ans+=1

print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Text;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        int q = sc.NextInt();
        int[] a = new int[q];
        for (int i = 0; i < q; i++)
        {
            a[i] = sc.NextInt() - 1;
        }

  
        var count = new int[n];
        for (int i = 0; i < q; i++)
        {
            count[a[i]]++;
        }
        
        
        Console.WriteLine(string.Join("\n",(new int[n]).Select((i,index)=>k-q+count[index] > 0?"Yes":"No")));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

int main() {
  int m;
  cin >> m;
  vector<int> a(1);
  cin >> a[0];
  int n = 1;
  rep(i, m - 1) {
    int b;
    cin >> b;
    if (b != a[n - 1]) {
      a.push_back(b);
      n++;
    }
  }
  if (n == 1) {
    cout << 1000 << endl;
    return 0;
  }
  ll kab = 0;
  ll money = 1000;
  if (a[1] > a[0]) {
    kab += money / a[0];
    money -= kab * a[0];
  }
  REP(i, 1, n - 1) {
    if (a[i - 1] < a[i] && a[i] > a[i + 1]) {
      money += kab * a[i];
      kab = 0;
    }
    if (a[i - 1] > a[i] && a[i] < a[i + 1]) {
      kab += money / a[i];
      money -= kab * a[i];
    }
  }
  money += kab * a[n - 1];
  cout << money << endl;
}

Measured memory_bytes: 3600