akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    L = lmi()
    L.sort()
    command = [lmi() for _ in range(m)]
    command.sort(key=lambda x: x[1], reverse=True)
    ans = sum(L)
    i = 0
    for b, c in command:
        for _ in range(b):
            if i >= n:
                print(ans)
                exit()
            if L[i] < c:
                ans += (c - L[i])
            i += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 32960
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin  >> n;
  vector<vi> data(n,vi(27));
  rep(i,n){
    string s;
    cin >> s;
    rep(j,sz(s)){
      int a = s[j] - 'a';
      data[i][a]++;
    }
  }
  string ans = "";
  rep(k,27){
    int m = data[0][k];
    srep(i,1,n){
      mins(m,data[i][k]);
    }
    rep(j,m){
      ans+='a'+k;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

// return n^m
ll pow_ll(ll n, ll m) {
  ll ret = 1;
  REP(i, m) {
    ret *= n;
  }
  return ret;
}

int main() {
  ll n, k;
  cin >> n >> k;
  if (k == 1) {
      cout << 0;
  } else {
      cout << n - k;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		Arrays.sort(s);
		String name = s[0];
		int count = 0;
		int max = 0;
		Map<String, Integer> lists = new HashMap<String, Integer>();
		for (int i = 0; i < n; i++) {
			if (name.equals(s[i])) {
				count++;
			} else {
				lists.put(name, count);
				count = 1;
				name = s[i];
			}
			max = Math.max(max, count);
		}
		lists.put(name, count);
		List<String> ans = new ArrayList<String>();
		for (String key : lists.keySet()) {
			if (lists.get(key) == max) {
				ans.add(key);
			}
		}
		Collections.sort(ans);
		for(int i=0;i<ans.size();i++) {
			System.out.println(ans.get(i));
		}
	}
}

Measured memory_bytes: 79736
/*
Author: Arham_doshi
@quote "Code like there's no tommorow!"
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}





signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,x;
    double d,i,j;
    cin>>n;
    
    i=n/2;
    j=n-i;
   // d=(double)i/j
    cout<<((double)j/(double)n);
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  Int N = in();
  int Q = in();

  vector<Int> A;
  A.push_back(N);
  for (int i = 0; i < Q; ++i) {
    Int x = lin();
    while (!A.empty() && A.back() >= x) {
      A.pop_back();
    }
    A.push_back(x);
  }
  Q = A.size();
  reverse(A.begin(), A.end());

  vector<Int> W(max(A.back(), N), 0), WX(Q, 0);
  WX[0] = 1;
  for (int i = 0; i + 1 < Q; ++i) {
    Int pos = A[i];
    for (int j = i + 1; pos > 0 && j < Q; ) {
      int jj = upper_bound(A.begin() + j, A.end(), pos, [] (const Int& a, const Int& b) {
        return a > b;
      }) - A.begin();
      if (jj < Q) {
        WX[jj] += WX[i] * (pos / A[jj]);
        pos %= A[jj];
      }
      j = jj + 1;
    }
    if (pos > 0) {
      W[pos - 1] += WX[i];
    }
  }
  W[A[Q - 1] - 1] += WX[Q - 1];

  for (int v = A.back() - 2; v >= 0; --v) {
    W[v] += W[v + 1];
  }
  for (int v = 0; v < N; ++v) {
    printf("%lld\n", W[v]);
  }

  return 0;
}


Measured memory_bytes: 4212
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){

    int n; cin >> n;
    vi A(n);
    REP(i, n) cin >> A[i];

    int l=A[0], h=A[0];
    int li=0, hi=0;
    REP(i, n){
        if( l>A[i] ){
            l = A[i];
            li = i;
        }
        if( h<A[i] ){
            h = A[i];
            hi = i;
        }
    }
    cout << 2*n-1 << endl;
    if( l>=0 or l+h>=0  ){
        REP(i, n){
            A[i] += h;
            cout << hi+1 << " " << i+1 << endl;
        }
        REP(i, n-1){
            cout << i+1 << " " << i+2 << endl;
        }
    } else {
        REP(i, n){
            A[i] += l;
            cout << li+1 << " " << i+1 << endl;
        }
        for(int i=n; i>1; --i){
            cout << i << " " << i-1 << endl;
        }
    
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll p,q,r;
    cin>>p>>q>>r;
    ll a,b,c;
    a=p+q;
    b=p+r;
    c=q+r;
    cout<<min(min(a,b),c)<<endl;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
answer = [k]*n
minus = [q]*n
for i in range(q):
    k = int(input())
    minus[k-1] = minus[k-1] - 1
for i in range(n):
    answer[i] = answer[i] - minus[i]
    if answer[i] <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 10464
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);

#define maxn 10000010
using namespace std;

map<string,int>mp;
string s;

int main()
{
    fio;

    int n;
    cin>>n;



    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
    int mx=-1;
    for(auto i: mp)
    {
        mx = max(mx,i.second);
    }

    for(auto i:mp)
    {
        if(i.second==mx)
            cout<<i.first<<endl;
    }

    return 0;
}


Measured memory_bytes: 19268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// データの取得
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if(B / A > C) {
			System.out.println(C);
		}
		else {
			System.out.println(B/A);
		}
		
	}
	
}

Measured memory_bytes: 23764
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
unordered_map<ll,ll>mp;
for(ll i=0;i<n-1;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
    mp[a]++;
}
for(ll i=1;i<=n;i++)
{
    cout<<mp[i]<<endl;
}

return 0;
}


Measured memory_bytes: 13036
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d %d",&a,&s);
	d=(a+s)%3;
	f=a%3;
	g=s%3;
	if(d==0||f==0||g==0) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

typedef struct {
	double x;
	double y;
} Coord;

double area_poly( Coord *coord, int n ) {
	int i;
	double sum = 0.0;

	for ( i = 1; i <= n; i++ )
		sum += coord[ i - 1 ].x * coord[ i % n ].y - coord[ i - 1 ].y * coord[ i % n ].x;

	return sum / 2.0;
}

int main( void ) {
	int i;
	int n;
	Coord coord[ 100 ];

	scanf( "%d", &n );

	for ( i = 0; i < n; i++ )
		scanf( "%lf %lf", &coord[ i ].x, &coord[ i ].y );

	printf( "%.1f\n", area_poly( coord, n ) );

	return 0;
}

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

int main()
{
    int card = 0 ;
    bool myCard[5][201] = {0} ;
    int cardLeft[5] = {0} ;
    bool turn = true ;
    int stage = 0 ;
    bool flg = false ;

    while (1)
    {
        memset( myCard[0],false,sizeof(myCard[0]) ) ;
        memset( myCard[1],false,sizeof(myCard[1]) ) ;
        stage = 0 ;
        turn = true ;

        cin >> card ;
        if ( !card ) break ;
        cardLeft[0] = cardLeft[1] = card ;
        for ( int i = 1 ; i <= card ; i++ )
        {
            int cmp = 0 ;
            cin >> cmp ;
            myCard[0][cmp-1] = true ;
        }
        for ( int i = 1 ; i <= card*2 ; i++ )
        {
            myCard[1][i-1] = 1 ^ myCard[0][i-1] ;
        }
        //printf("%d\n",card);

        for ( int i = 0 ; i < card*2 ; i++ )
        {
            //printf("[debug]myCard:%d:[0]=%d ,[1]=%d\n",i,myCard[0][i],myCard[1][i]);
        }
        //printf("a\n");

        while (1)
        {
            turn = turn ^ 1 ;
            flg = false ;
            for ( int i = stage+1 ; i <= card*2 ; i++ )
            {
                if ( myCard[turn][i-1] == true )
                {
                    stage = i ;
                    myCard[turn][i-1] = false ;
                    cardLeft[turn]-- ;
                    flg = true ;
                    break ;
                }
            }
            if ( !flg ) stage = 0 ;
            //printf("[debug]card=%d ,turn=%d ,stage=%d ,cardLeft:[0]=%d ,[1]=%d ,flg=%d\n",card,turn,stage,cardLeft[0],cardLeft[1],flg);
            if ( !cardLeft[turn] ) break ;
        }
        cout << cardLeft[1] << endl << cardLeft[0] << endl ;
    }

    return 0 ;
}

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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) 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 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 prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

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

int main() {
    int a, b, c;
    cin3(a,b,c);
    
    if ( a+b>=c ) {
        cout1("Yes");
    } else {
        cout1("No");
    }
}



Measured memory_bytes: 256
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, K) = (input[0], input[1])
let h = (0..<N).map{_ in Int(readLine()!)!}.sort()
print((0...N-K).map{h[$0+K-1]-h[$0]}.minElement()!)

Measured memory_bytes: 4336
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	result := ""
	for n > 0 {
		n = n - 1
		result = string((n%26)+97) + result
		n = n / 26
	}

	fmt.Println(result)

}


Measured memory_bytes: 1832
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn prime_factors(n: usize) -> std::collections::HashMap<usize, usize> {
    let mut res = std::collections::HashMap::new();
    let mut n = n;

    for i in 2..(n as f32).sqrt() as usize + 1 {
        while n % i == 0 {
            *res.entry(i).or_insert(0) += 1;
            n /= i;
        }
    }

    if n > 1 {
        res.insert(n, 1);
    }

    res
}

fn main() {
    input! {
        n: usize,
    }

    if n == 1 {
        echo!(0);
        return;
    }

    let pf = prime_factors(n);
    let mut result = 0;

    for &k in pf.values() {
        let mut cnt = k;
        for i in 1..=k {
            if cnt >= i {
                cnt -= i;
                result += 1;
            }
        }
    }

    echo!(result);
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	vl v(n);
	map<ll,ll> mp;
	ll total=0;
	rep(i,0,n){
		ll a; cin>>a;
		mp[a]++;
		total+=a;
	}
	ll q; cin>>q;
	rep(i,0,q){
		int a,b; cin>>a>>b;
		int c=mp[a];
		int d=mp[b];
		total+=(b-a)*c;
		mp[a]=0;
		mp[b]+=c;
		cout<<total<<endl;
	}
	//cout<<total;
	return 0;
}

Measured memory_bytes: 9888
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    vector<int> h;
    cin >> n;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }

    bool ans = true;
    for(int i=n-1; i>0; i--){
        if(h[i-1]-h[i] > 0){
            h[i-1] -= 1;
        }
        if(h[i-1]-h[i] > 0){
            ans = false;
            break;
        }
    }

    if(ans){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    
    int h, count=0;
    for(int i=0; i<N; i++) {
        cin >> h;
        if(h>=K) {
            count++;
        }
    }
    
    cout << count << endl;

    return 0;
    
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

dy3 = x2 - x1
dx3 = -(y2 - y1)

x3 = x2 + dx3
y3 = y2 + dy3

dx4 =  - (x2 - x1)
dy4 =  - (y2 - y1)


x4 = x3 + dx4
y4 = y3 + dy4


print(x3,y3,x4,y4)

Measured memory_bytes: 3060
import math

i = list(map(int,input().split()))
N = i[0]
M = i[1]

MOD = 1000000000 + 7

diff = abs(max(M,N) - min(M,N))

if diff >= 2:
    print(0)
elif diff == 1:
    ans = (math.factorial(max(M,N)) % MOD) * (math.factorial(min(M,N)) % MOD)
    print(ans % MOD)
else:
    ans = (math.factorial(max(M,N)) % MOD) * (math.factorial(min(M,N)) % MOD) * 2
    print(ans % MOD)


Measured memory_bytes: 4096
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
using namespace std;


int main()
{	
	
	ll a, b, c;
	scanf("%lld %lld %lld", &a, &b, &c);
	
	if( (4*a*b < (c-a-b) * (c-a-b)) && (a+b<c) )
	{
		printf("Yes");}
	else{printf("No");}
}


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

using namespace std;
typedef long long ll;

void Solve()
{
    ll n, temp;
    cin>>n;
    map<ll,ll> count;

    for(int i=0;i<n-1;i++)
    {
        cin>>temp;
        count[temp]++;
    }
    for(int i=1;i<=n;i++)
        cout<<count[i]<<"\n";
}

int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
        Solve();
    return 0;
}

Measured memory_bytes: 16100
#include <stdio.h>
int main()
{
	int n,k;
	unsigned long long ans=1;
	scanf("%d%d", &n, &k);
	n--;
	ans*=k;
	k--;
	while(n>0){
		ans*=k;
		n--;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][] delta = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] g = new char[h][w];
		for (int i = 0; i < h; i++) {
			g[i] = sc.next().toCharArray();
		}

		int answer = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (g[i][j] != '.') continue;
				boolean[][] visited = new boolean[h][w];
				int[][] d = new int[h][w];
				for (int l = 0; l < h; l++) {
					Arrays.fill(d[l], 10000);
				}

				Queue<int[]> q = new LinkedList<>();
				q.offer(new int[]{i, j, 0});
				//d[i][j] = 0;
				visited[i][j] = true;
				while (!q.isEmpty()) {
					int[] p = q.poll();
					visited[p[0]][p[1]] = true;
					for (int k = 0; k < 4; k++) {
						int ny = delta[k][0] + p[0];
						int nx = delta[k][1] + p[1];
						if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
						if (g[ny][nx] != '.' || d[ny][nx] != 10000) continue;
						if (g[ny][nx] != '.' || visited[ny][nx]) continue;
						d[ny][nx] = p[2] + 1;
						q.offer(new int[]{ny, nx, p[2] + 1});
					}

					//if (q.isEmpty()) answer = Math.max(answer, p[2]);
				}

				for (int k = 0; k < h; k++) {
					for (int l = 0; l < w; l++) {
						if (d[k][l] < 10000) answer = Math.max(answer, d[k][l]);
					}
				}
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 34384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		double A = scn.nextInt();
		double B = scn.nextInt();
		double H = scn.nextInt();
		double M = scn.nextInt();

		double hx = A*Math.cos(Math.PI * 2 * (H*60+M)/720.0);
		double hy = A*Math.sin(Math.PI * 2 * (H*60+M)/720.0);
		double mx = B*Math.cos(Math.PI * 2 * M/60.0);
		double my = B*Math.sin(Math.PI * 2 * M/60.0);
		double L = Math.sqrt((hx-mx)*(hx-mx) + (hy-my)*(hy-my));
		System.out.println(L);
	}

}


Measured memory_bytes: 36008
import math
x = int(input())

n = 10**6
flag = [True]*(n+1)

for i in range(4, n+1, 2):
  flag[i] = False
  
t = int(n**0.5)+1
for i in range(3, t, 2):
  for j in range(i+i, n+1, i):
    flag[j] = False

for i in range(x,n+1):
  if flag[i]:
    print(i)
    exit()

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

vector<int> v;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a; a *= -1;
		if (v.empty() || v.back() <= a) v.push_back(a);
		else (*upper_bound(v.begin(), v.end(), a)) = a;
	}
	cout << v.size() << '\n';
	return 0;
}	

Measured memory_bytes: 892
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  string s1;
  cin>>s1;
  string s = "A";
  s += s1;
  ll ans = 0;
  rep(i,0,s.sz-1){
    if(s[i]>=s[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <regex>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    string s;
    cin >> s;
    REP(i,4) {
        cout << s[i];
    }
    cout << " ";
    REPI(i,4,s.size()) {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count = 0
for i in range(N):
    a = list(map(int, input().split()))
    sum = 0
    for j in range(len(a)):
        sum += a[j] * B[j]
    sum += C
    if sum > 0:
        count +=1
print(count) 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) cout << 0 << endl;
  else cout << 10 << endl;
}

Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
v=[0]+[-1]*~-n
p=0
for i in range(n):
  t=a[p]-1
  if v[t]>=0: l,r=v[t],i+1; break
  v[t]=i+1; p=t
print(v.index([k,l+(k-l)%(r-l)][k>l])+1)

Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename E>
struct SkewHeap{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  SkewHeap *l,*r;
  T val;
  F &f;
  G &g;
  E add,e;
  
  SkewHeap(T val,F &f,G &g,E e):val(val),f(f),g(g),add(e),e(e){l=r=NULL;}
  
  void eval(){
    if(add==e) return;
    if(l) l->add=g(l->add,add);
    if(r) r->add=g(r->add,add);
    val=f(val,add);
    add=e;
  }
  
  T top(){
    return f(val,add);
  }
  
};

template<typename T, typename E>
SkewHeap<T, E>* meld(SkewHeap<T, E> *a,SkewHeap<T, E> *b){
  if(!a) return b;
  if(!b) return a;
  if(a->top() > b->top())  swap(a,b);
  a->eval();
  a->r=meld(a->r,b);
  swap(a->l,a->r);
  return a;
}

template<typename T, typename E>
SkewHeap<T, E>* pop(SkewHeap<T, E>* a){
  a->eval();
  return meld(a->l,a->r);
};

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    r[x]+=r[y];
    p[y]=x;
  }
};


struct Arborescence{
  using P = pair<int, int>;
  using Heap = SkewHeap<P, int>;
  Heap::F f=[](P a,int b){return P(a.first+b,a.second);};
  Heap::G g=[](int a,int b){return a+b;};
  
  struct edge{
    int from,to,cost;
    edge(){}
    edge(int from,int to,int cost):from(from),to(to),cost(cost){}
  };
  
  int n;
  UnionFind uf;
  vector<edge> edges;
  vector<Heap*> come,pool;
  vector<int> used,from,cost;
  
  Arborescence(int n):n(n),uf(n),come(n,NULL),
		      used(n,0),from(n,-1),cost(n,-1){};

  void add_edge(int from,int to,int cost){
    edges.emplace_back(from,to,cost);
  }

  void input(int m,int offset=0){
    for(int i=0;i<m;i++){
      int u,v,c;
      cin>>u>>v>>c;
      add_edge(u+offset,v+offset,c);
    }
  }

  int build(int r){
    used[r]=2;
    pool.resize(edges.size(),NULL);
    for(int i=0;i<(int)edges.size();i++){
      edge &e=edges[i];
      pool[i]=new Heap(P(e.cost,i),f,g,0);
      come[e.to]=meld(come[e.to],pool[i]);
    }
    
    int res=0;
    for(int i=0;i<n;i++){
      if(used[i]) continue;
      int v=i;
      vector<int> l;
      while(used[v]!=2){
	used[v]=1;
	l.emplace_back(v);
	if(!come[v]) return -1;
	from[v]=uf.find(edges[come[v]->val.second].from);
	cost[v]=come[v]->top().first;
	come[v]=pop(come[v]);
	if(from[v]==v) continue;
	
	res+=cost[v];
	if(used[from[v]]==1){
	  int p=v;
	  do{
	    if(come[p]) come[p]->add-=cost[p];
	    if(p!=v){
	      uf.unite(v,p);
	      come[v]=meld(come[v],come[p]);
	    }
	    p=uf.find(from[p]);
	  }while(p!=v);
	}else{
	  v=from[v];
	}
      }
      for(int u:l) used[u]=2;
    }
    return res;
  }
  
};
//END CUT HERE
signed main(){
  int n,m,r;
  cin>>n>>m>>r;
  Arborescence G(n);
  G.input(m);
  cout<<G.build(r)<<endl;
  return 0;
}



Measured memory_bytes: 3256
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Prelude             hiding (gcd, lcm)
import Text.Printf         (printf)

main :: IO ()
main = do
    pairs <- map (sort . map read . words) . lines <$> getContents
    forM_ pairs $ \[a,b] -> printf "%d %d\n" (gcd b a) (lcm a b)

gcd :: Int -> Int -> Int
gcd m 0 = m
gcd m n = gcd n (m `mod` n)

lcm :: Int -> Int -> Int
lcm 0 _ = 0
lcm _ 0 = 0
lcm m n = abs $ (n `quot` gcd m n) * m

Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,X[100],sum1=0,ave;
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> X[i];
        sum1 = sum1 + X[i];
    }
    ave = (sum1 + 0.5*N) / N;

    int sum2=0;
    for (int i=0; i<N; i++) {
        sum2 = sum2 + pow((X[i]-ave),2.0);
    }
    cout << sum2 << endl;
}

Measured memory_bytes: 764
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n,k;
	cin>>n>>k;
	ll a[n];
	lp(i,0,n-1)
		cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	lp(i,0,k-1)
		sum+=a[i];
		cout<<sum<<endl;
	return 0;	
}


Measured memory_bytes: 3624
import sys
 
for line in sys.stdin:
    m, f, r = map(int, line.split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif (m + f) >= 65:
        print('B')
    elif (m + f) >= 50:
        print('C')
    elif (m + f) >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],t[N],dp[N];
int query(int x)
{
    int ans=0;
    while(x)
        ans=max(ans,t[x]),x-=x&-x;
    return ans;
}
void add(int x,int v)
{
    while(x<=n)
        t[x]=max(t[x],v),x+=x&-x;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);a[x]=i;
    }
    int ans=0,t=1;
    for(int i=2;i<=n;i++)
        if(a[i]>a[i-1]) t++;
    else
        ans=max(ans,t),t=1;
    ans=max(ans,t);
    printf("%d\n",n-ans);
}


Measured memory_bytes: 1024
import itertools
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
t=[i for i in range(N)]
S=list(itertools.permutations(t))
l=[]
for i in range(len(S)):
    sum_A=0
    for j in range(N-1):
        sum_A=((x[S[i][j]]-x[S[i][j+1]])**2+(y[S[i][j]]-y[S[i][j+1]])**2)**0.5+sum_A
    l.append(sum_A)
kaijou=1
for i in range(N):
    kaijou=kaijou*(i+1)
print(sum(l)/kaijou)

Measured memory_bytes: 9340
N=input();a=int(N[0]);b=int(N[1]);c=int(N[2]);d=int(N[3]);A=""
if a+b+c+d == 7:
    A = N[0]+"+"+N[1]+"+"+N[2]+"+"+N[3]+"=7"
elif a+b+c-d == 7:
    A = N[0]+"+"+N[1]+"+"+N[2]+"-"+N[3]+"=7"
elif a+b-c+d == 7:
    A = N[0]+"+"+N[1]+"-"+N[2]+"+"+N[3]+"=7"
elif a-b+c+d == 7:
    A = N[0]+"-"+N[1]+"+"+N[2]+"+"+N[3]+"=7"
elif a-b-c+d == 7:
    A = N[0]+"-"+N[1]+"-"+N[2]+"+"+N[3]+"=7"
elif a+b-c-d == 7:
    A = N[0]+"+"+N[1]+"-"+N[2]+"-"+N[3]+"=7"
elif a-b+c-d == 7:
    A = N[0]+"-"+N[1]+"+"+N[2]+"-"+N[3]+"=7"
else:
    A = N[0]+"-"+N[1]+"-"+N[2]+"-"+N[3]+"=7"
print(A)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
const int INF = (int)1e18 + 18 ;
const int maxx = (int) 1e6 + 6 ;
using namespace std ;
 
 
int n;
 
signed main() {

	cin >> n;

	int a[n];

	vector<int> dp(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	dp[0] = 0;
	dp[1] = dp[0] + abs(a[1] - a[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]) , dp[i - 2] + abs(a[i] - a[i - 2]));
	}

	cout << dp[n - 1] << endl;


return 0;
 
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;
#define swap(a,b)	if(a!=b){ a^=b;	b^=a;	a^=b; }
int main(){
	int n;	scanf("%d",&n);
	int a[n];	for(int i=0;i<n;i++)	scanf("%d",&a[i]);
	int r=n-1;
	//partition(a,0,r)
	int x=a[r];
	int i=0;
	for(int j=0;j<r;j++){
		if(a[j]<=x){
			swap(a[i],a[j]);
			i++;
		}
	}
	swap(a[i],a[r]);
	
	for(int j=0;j<n;j++){
		if(j)	printf(" ");
		if(j==i)	printf("[%d]",a[j]);
		else 		printf("%d",a[j]);
	}
	printf("\n");
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  if(N%2!=0){
    cout << "No" << endl;
    return 0;
  }
  if(S.substr(0,N/2) == S.substr(N/2)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,m;
  cin>>n>>m;
  ll h[n];
  fo(i,n)
  cin>>h[i];
  ll x[n+1]={0};
  ll ans[n+1]={0};
  for(ll i=0;i<m;i++)
  {
    ll a,b;
    cin>>a>>b;
    x[a]++;
    x[b]++;
    if(h[a-1]>h[b-1])
      ans[a]++;
    else if(h[b-1]>h[a-1])
      ans[b]++;
  }
  ll c=0;
  for(ll i=1;i<=n;i++)
  {
    if(x[i]==ans[i])
      c++;
  }
  cout<<c;

  return 0;
}


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

int main(){
  vector<vector<int>>a(3,vector<int>(3));
  for(int i=0; i<3; i++)
  {
    for(int j=0; j<3; j++)
    {cin >>a[i][j];}
  }
  int n; cin >>n;
  for(int h=0; h<n; h++)
  {int b; cin >>b;
    for(int i=0; i<3; i++)
    {
      for(int j=0; j<3; j++)
      {
        if(b==a[i][j]) a[i][j]=0;
      }
    }
  }
  if(a[0][2]==a[1][1] && a[0][2]==a[2][0]) {cout <<"Yes"; return 0;}
  if(a[0][0]==a[1][1] && a[0][0]==a[2][2]) {cout <<"Yes"; return 0;}
  for(int i=0; i<3; i++)
  {if(a[0][i]==a[1][i] && a[0][i]==a[2][i]) {cout <<"Yes"; return 0;}}
  for(int i=0; i<3; i++)
  {if(a[i][0]==a[i][1] && a[i][0]==a[i][2]) {cout <<"Yes"; return 0;}}
  cout <<"No";
return 0;}

Measured memory_bytes: 256
n = int(input())
count = 0

for i in range(1, n + 1):
  if i % 2 == 1:
    divisors_count = 0
    for a in range(1, i + 1):
      if i % a == 0:
        divisors_count += 1
    if divisors_count == 8:
      count += 1

print(count)

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;


void solve() { 
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<int> cnt(n + 1);
	vector<P> v;
	rep(i, n) {
		int le = i;
		while (i + 1 < n&&a[i] == a[i + 1])i++;
		cnt[i - le + 1]++;
	}
	rep(i, n + 1)if (cnt[i] > 0) {
		v.push_back({ i,cnt[i] });
	}
	
	sort(v.begin(), v.end(),greater<P>());
	rep1(k, n) {
		int le = -1, ri = n / k + 1;
		while (ri - le > 1) {
			int mid = (le + ri) / 2;
			int sup = mid * k;
			int sum = 0;
			rep(j, v.size()) {
				sum += v[j].second*min(v[j].first, mid);
				if (sum >= sup)break;
			}
			if (sum >= sup)le = mid;
			else ri = mid;
		}
		cout << le << endl;
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();

	//stop
	return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.lang.Math;

class Main{
    private final static int    DATA_TYPE_INT = 1;
    private final static double DATA_TYPE_DOUBLE = 2.0;

    public static void main(String[] args){
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        
        // 共通変数
        String str;
        //int[] num;
        //int DataType = DATA_TYPE_INT;
        double[] num;
        double DataType = DATA_TYPE_DOUBLE;
        boolean debug = false;

        // 課題別変数
        double[] position = {0, 0};
        int degree = 90;
        double[] direction = {0, 1}; // 初期方向は北

        /*
                N (y)
                ^
                |
        W <-----+-----> E (x)
                |
                v
                S
        */

        try {
            while(debug || reader.ready()){
                str = reader.readLine();

                // [0,0]が入力されたら終了
                if(str.equals("0,0")){
                    System.out.println((int)position[0]);
                    System.out.println((int)position[1]);
                    break;
                }

                // 数値データの取得
                num = getNum(str, DataType);

                // 進む
                position[0] += num[0] * direction[0];
                position[1] += num[0] * direction[1];

                // 次回の進行方向を計算
                degree -= num[1];
                direction[0] = Math.cos(Math.toRadians(degree));
                direction[1] = Math.sin(Math.toRadians(degree));
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    // ----- 自作関数（共通） ----- //
    
    private static int[] getNum(String str, int DataType){
        String[] data = str.split(" "); 
        int[] num = new int[data.length];

        for (int i = 0; i < data.length; i++){
            num[i] = Integer.parseInt(data[i]);
        }
        return num;
    }

    private static double[] getNum(String str, double DataType){
        String[] data = str.split(","); 
        double[] num = new double[data.length];

        for (int i = 0; i < data.length; i++){
            num[i] = Double.parseDouble(data[i]);
        }
        return num;
    }

}


Measured memory_bytes: 24484
#include <stdio.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

char f[16][16], g[16][16];

void rec(int x, int y) {
    if (x < 0 || x >= 8 || y < 0 || y >= 8) return ;
    if (g[x][y]) return;
    g[x][y] = 1;
    if (f[x][y] == '1') {
        rep (i, 3) rec(x+1+i, y), rec(x, y+1+i), rec(x-1-i, y), rec(x, y-1-i);
    }
}

int main() {
    int T;
    scanf("%d", &T);
    rep (_q, T) {
        rep (i, 8) scanf("%s", f[i]);
        int x, y;
        scanf("%d%d", &y, &x);
        x--, y--;
        memset(g, 0, sizeof(g));
        rec(x, y);
        printf("Data %d:\n", _q+1);
        rep (i, 8) {
            rep (j, 8) putchar(f[i][j]=='1' && g[i][j]==0 ? '1' : '0');
            putchar('\n');
        }
    }
    return 0;
}

Measured memory_bytes: 0
n=int(input())

a=input().split()
ans=1
if '0' in a:
    print(0)
else:   
    for i in range(n):
        k=int(a[i])
        if ans*k>1e18:
            print(-1)
            break
        ans*=k
        if i==n-1:
            print(ans)

Measured memory_bytes: 19292
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return int64(a)
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

func scanInt64Slice(n int64) []int64 {
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		a[i] = scanInt64()
	}
	return a
}

// var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	input := scanSlice(2)
	n := input[0]
	m := input[1]

	maze := make([]string, 0)

	// for i := 0; i < n; i++ {
	// 	maze[i] = make([]string, m)
	// }

	for i := 0; i < n; i++ {
		tmp := scanText()

		maze = append(maze, tmp)

	}
	// fmt.Println("maze : ", maze)

	queue := make([]position, 0)
	memo := make([][]int, n)
	for i := 0; i < n; i++ {
		memo[i] = make([]int, m)
	}
	dx := [4]int{-1, 1, 0, 0}
	dy := [4]int{0, 0, -1, 1}
	max := 0
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			// fmt.Println("x : ", i)
			// fmt.Println("y : ", j)

			// fmt.Println("-------------", string(maze[i][j]))
			current := string(maze[i][j])
			if current != "." {
				continue
			}
			//initialize
			memo = make([][]int, n)
			for i := 0; i < n; i++ {
				memo[i] = make([]int, m)
			}
			queue = make([]position, 0)
			////////////
			queue = append(queue, position{i, j, 0})
			memo[i][j] = -1
			for {
				if len(queue) <= 0 {
					break
				}
				cur := queue[0]
				curX := cur.x
				curY := cur.y
				curDistanse := cur.distanse
				queue = queue[1:]
				if max < curDistanse {
					max = curDistanse
				}
				for k := 0; k < 4; k++ {
					fx := curX + dx[k]
					fy := curY + dy[k]
					if fx >= 0 && fx < n && fy >= 0 && fy < m && memo[fx][fy] >= 0 && string(maze[fx][fy]) == "." {
						queue = append(queue, position{fx, fy, curDistanse + 1})
						memo[fx][fy] = -1
					}
				}

			}

		}

	}

	fmt.Println(max)

}

type position struct {
	x        int
	y        int
	distanse int
}

func binarySearch(arr []int, number int) int {

	l := -1
	r := len(arr)
	index := 0
	for {
		mid := l + (r-l)/2
		tmp := arr[mid]

		if r-l <= 1 || tmp == number {
			index = mid
			break
		} else if tmp < number {
			l = mid
		} else {
			r = mid
		}
	}
	return index
}

func factorial(n int) int64 {
	sum := int64(1)
	for i := 2; i <= n; i++ {
		sum *= int64(i)
	}
	return sum
}

func deleteNumOfArray(arr []int, position int) []int {
	left := arr[:position]
	r := arr[position+1:]
	appendArr := append(left, r...)
	return appendArr
}


Measured memory_bytes: 5504
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int a = scn.nextInt();
      	int b = scn.nextInt();
      	if((b-a)%2==0) System.out.println("Alice");
      	else System.out.println("Borys");
	}
}


Measured memory_bytes: 35552
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for j in range(m):
    ans=0
    p,x=map(int,input().split())
    for k in range(n):
        if p==k+1:
            ans += x
        else:
            ans += t[k]
    print(ans)

Measured memory_bytes: 9180
use std::io::BufRead;

macro_rules! readlines {
    ($cnt:expr) => {
        {
            let stdin = std::io::stdin();
            let mut handle = stdin.lock();
            let mut result = Vec::new();
            for i in 0..$cnt{
                let mut buf = String::new();
                handle.read_line(&mut buf);
                result.push(buf.trim().to_owned());
            }
            result
        }
    };
}

macro_rules! string2splittedvec {
    ($t:ty,$sep:expr,$line:expr) => {
        {
            $line.split($sep)
                .map(|s|s.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty,$line:expr) => {
        {
            string2splittedvec!($t,' ',$line)
        }
    };
    ($sep:expr,$line:expr) => {
        {
            $line.split($sep)
                .map(|s|s.to_owned())
                .collect::<Vec<_>>()
        }
    };
    ($line:expr)=>{
        {
            string2splittedvec!(' ',$line)
        }
    }
}

fn main(){
    let mut v = readlines!(2).into_iter().map(|s|{string2splittedvec!(u64,s)}).collect::<Vec<Vec<_>>>();
    let ans = 0;
    let n = v[0][0];
    v[1].resize(n as usize,0);
    let mut ans_array = vec![0;n as usize];
    for i in v[1].clone(){
        if i>0{
            ans_array[(i-1) as usize]+=1;
        }
    }
    for i in ans_array{println!("{}",i);}
}

Measured memory_bytes: 5732