akhauriyash/Code-Regression huggingface dataset:
'use strict'

function main(input) {
  input = input.split(' ').map(v => ~~v)

  const a = input[0]
  const b = input[1]
  const k = input[2]

  let cnt = []

  for (let i = 1; i <= 100; i++) {
    if (a % i == 0 && b % i == 0) {
      cnt.push(i)
      //   console.log(cnt, i)
    }
  }
  cnt.reverse()
  console.log(cnt.slice(k - 1).shift())
  //   console.log(gcd(input[0], input[1]))
  //   console.log(Math.min(cnt, input[2]))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 11468
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	string A,B,C;
	cin>>A;
	cin>>B;
	cin>>C;
	int i;
	int num=0;
	for (i=0;i<N;i++){
		if (A[i]==B[i] && B[i]==C[i]){
		}else if (A[i]==B[i] && B[i]!=C[i] || A[i]==C[i] && B[i]!=C[i] || B[i]==C[i] && A[i]!=B[i]){
			num++;
		}else if (A[i]!=B[i] && B[i]!=C[i]&&A[i]!=C[i]){
			num+=2;
		}
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int price[1000],weight[1000];
	int weight_MAX;
	int treasure;
	int i,j;
	int ans_p,ans_w,time;
	int dp[10000];

	time = 1;

	scanf("%d",&weight_MAX);

	while(weight_MAX != 0){

		scanf("%d",&treasure);

		for(i = 0; i < treasure; i++){
			scanf("%d,%d",&price[i],&weight[i]);
		}

		for(i = 0; i <= weight_MAX + 1; i++){
			dp[i] = 0;
		}

		for(i = 0; i < treasure; i++){
			for(j = weight_MAX; j >= weight[i]; j--){
				if(dp[j - weight[i]] + price[i] > dp[j]){
					dp[j] = dp[j - weight[i]] + price[i];
				}
			}
		}

		ans_p = 0;
		ans_w = 0;
		
		for(i = 0;i <= weight_MAX; i++){
			if(ans_p < dp[i]){
				ans_p = dp[i];
				ans_w = i;
			}
		}
		printf("Case %d:\n%d\n%d\n",time,ans_p,ans_w);

		time++;

		scanf("%d",&weight_MAX);
	}
	return 0;
}

Measured memory_bytes: 1040
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();

    int N = fs.nextInt();
    int[] D = new int[N];
    for (int i = 0; i < N; i++) D[i] = fs.nextInt();
    int ans = 0;
    for (int i = 0; i < N; i++)
      for (int j = 0; j < i; j++) ans += D[i] * D[j];
    System.out.println(ans);
  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
    return buffer[ptr++];
    else
    return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
    ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
    throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
    throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
      throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
    throw new NumberFormatException();
    return (int) nl;
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& e : a) cin >> e;
  for (int i = n - 1; i > 0; i--) {
    cout << a[i] << " ";
  }
  cout << a[0] << endl;
  return 0;
}


Measured memory_bytes: 3080
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int n,m;
  while(1){
    scanf("%d %d\n",&m,&n);
    if(n==0 && m==0){
      break;
    }
    vector<string> x;
    int end=0,i,j=1,a[1010],l,k;
    string s;
    for(i=1;i<=m;i++){
      a[i]=1;
    }
    x.push_back("a");
    for(i=1;i<=n;i++){
      if(i%15==0){
        x.push_back("FizzBuzz");
      }
      else if(i%3==0){
        x.push_back("Fizz");
      }
      else if(i%5==0){
        x.push_back("Buzz");
      }
      else{
        x.push_back(to_string(i));
      }
    }
    for(i=1;i<=n;i++){
      cin >> s;
      if(end==1){
        continue;
      }
      if(s!=x[i]){
        a[j]=0;
      }
      l=j;
      while(1){
        j++;
        if(j>m){
          j=1;
        }
        if(a[j]==1){
          break;
        }
      }
      int sum=0;
      for(k=1;k<=m;k++){
        if(a[k]==1){
          sum++;
        }
      }
      if(sum==1){
        end=1;
      }
    }
    int b=0;
    for(i=1;i<=m;i++){
      if(a[i]==1){
        if(b==0){
          b=1;
          printf("%d",i);
        }
        else{
          printf(" %d",i);
        }
      }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int h, w;
  cin >> h >> w;
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for (int i = 0; i < w; i++) {
      if (s[i] == '#') {
        cnt++;
      }
    }
  }

  if (cnt == h + w - 1) {
    puts("Possible");
  } else {
    puts("Impossible");
  }

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最大公約数
 //__lcm 最小公倍数

int main() {
  double a,b;
  cin>>a>>b;
  cout<<a/b;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::priority_queue;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli N, in, ans, swap;
lli zero = 0;
vector<lli> P;
bool flag = false;

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

	cin>> N;
	for(lli i = 1; i <= N; i++){
		cin >> in;
		in -= i;

		if(in == 0){
			zero++;
		}else{
			if(zero % 2 ==1) ans += zero/2+1;
			else ans += zero/2;

			zero = 0;
		}
		P.push_back(in);
	}
	if(zero != 0){
		if(zero % 2 ==1) ans += zero/2+1;
		else ans += zero/2;
	}

	cout << ans;

  return 0;
}


Measured memory_bytes: 1400
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto M = RD!long;

	auto p = new long[8][](N);
	foreach (i; 0..N)
	{
		auto x = RD!long;
		auto y = RD!long;
		auto z = RD!long;
		foreach (j; 0..8)
		{
			p[i][j] += j & 0b001 ? x : -x;
			p[i][j] += j & 0b010 ? y : -y;
			p[i][j] += j & 0b100 ? z : -z;
		}
	}

	long ans;
	foreach (i; 0..8)
	{
		p.sort!((a, b) => a[i] > b[i])();
		long s;
		foreach (j; 0..M) s += p[j][i];
		ans = max(ans, s);
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[4][4];
	for(int i=1;i<4;i++){
		for(int j=1;j<4;j++) cin>>a[i][j];
	}
	if((a[1][2]+a[2][3]+a[3][1]+a[1][3]+a[2][1]+a[3][2])==(a[1][1]+a[2][2]+a[3][3])*2) cout<<"Yes\n";
	else  cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)


def good(ub):
    cnt = 0
    for a in A:
        base = 1
        while (a // base) > ub:
            base *= 2
            cnt += 1
            if cnt > M:
                return False
    return True


import numpy
import scipy
from collections import deque
#https://atcoder.jp/contests/abc141/tasks/abc141_d
#D - Powerful Discount Tickets
"""
need to consider the case that ticket is not enough to lower everything
"""
N = gi()
M = gi()
A = [0] * N

for i in range(N):
    A[i] = gi()

A.sort()
low = 0
high = A[N - 1]

while low < high:
    mid = (low + high) // 2
    if (good(mid)):
        high = mid
    else:
        low = mid + 1

after = []
remains = M
for a in A:
    base = 1
    while a // base > low:
        base *= 2
        remains -= 1

    after.append(a // base)

after.sort()

ans = 0
for i in range(N - 1, -1, -1):
    if remains:
        remains -= 1
        ans += after[i] // 2
    else:
        ans += after[i]

print(ans)


Measured memory_bytes: 27904
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  int a[1000000];
  int N=1000000;
  for(int i=0 ; i<N;i++)
    a[i]=1;

  for(int i=2; i<sqrt(N);i++){
    if(a[i]){
      for(int j=0 ; i*(j+2)<N;j++){
          a[i*(j+2)]=0;
      }
    }
  }
  int n;
  while(cin >>n){
  int sum=0;
  for(int i=2;i<=n;i++)
        sum+=a[i];
        cout << sum<<endl;
  }
}



Measured memory_bytes: 6988
import numpy as np

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(-1, 102))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()


Measured memory_bytes: 27104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i=0,n,kazu=0;
  cin>>n;
  
  while(i<n){
    int a,b;
    cin>>a>>b;
    kazu+=b-a+1;
    i++;
  }
  cout<<kazu<<endl;
 
}

Measured memory_bytes: 3568
/*計数ソート*/
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *a, *b;
  int c[VMAX+1];
  int n, i, j, k;
  
  scanf("%d", &n);
  
  a = malloc(sizeof(int)*n+sizeof(int));
  b = malloc(sizeof(int)*n+sizeof(int));

  scanf("%d", &a[0]);
  k = a[0];
  for (i=1; i<n; i++){
    scanf("%d", &a[i]);
    if (a[i]>k)
      k = a[i];
  }
  
  for (i=0; i<=k; i++){
    c[i] = 0;
  }
  
  for (j=0; j<n; j++){
    c[a[j]]++;
  }

  for (i=1; i<=k; i++){
    c[i] += c[i-1];
  }
  
  for (j=n-1; j>=0; j--){
    b[c[a[j]]-1] = a[j];
    c[a[j]]--;
  }

  
  for (i=0; i<n-1; i++){
    printf("%d ", b[i]);
  }
  printf("%d\n", b[n-1]); 
  
  return 0;
}



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

using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  vector<int> xs;
  vector<int> ys;
  {
    int x;
    for(int i = 0; i < N; ++i) {
      cin >> x;
      xs.push_back(x);
    }
    sort(xs.begin(), xs.end());
  }
  {
    int y;
    for(int i = 0; i < M; ++i) {
      cin >> y;
      ys.push_back(y);
    }
    sort(ys.begin(), ys.end());
  }

  if(X >= Y) {
    cout << "War" << endl;
    return 0;
  }
  if(ys.front() <= X) {
    cout << "War" << endl;
    return 0;
  }
  if(Y <= xs.back()) {
    cout << "War" << endl;
    return 0;
  }

  if(xs.back() < ys.front()) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
def resolve():
    x = int(input())
    five = []
    for i in range(-1000, 1001):
        five.append(i ** 5)

    for i in range(len(five)):
        for j in range(len(five)):
            if x == abs(five[i] - five[j]):
                if five[i] >= five[j]:
                    print("{} {}".format(i - 1000, j - 1000))
  
                else:
                    print("{} {}".format(j - 1000, i - 1000))

                    exit()

resolve()

Measured memory_bytes: 9228
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//* vamsicool007    You are never wrong to do the right thing    vamsicool007 *
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define int long long
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
const int N=200005;
vector<int>vis(N);
vector<vector<int>>adj(N);
void dfs(int v){vis[v]=1;for(auto i:adj[v]){if(!vis[i]){dfs(i);}}return;}
bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
int root(int a[],int i){while(a[i]!=i){a[i]=a[a[i]];i=a[i];}return i;}
void unionn(int a[],int i,int j){int root_i=root(a,i);int root_j=root(a,j);a[root_i]=root_j;return;}
// void fun()
// {
//     #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     #endif
// }

signed main()
{
    flash;
    //fun();
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        int m;
        cin>>m;
        if(n>m)
            cout<<"safe";
        else
            cout<<"unsafe";
    }
    return 0;
}

Measured memory_bytes: 9412
$h,$w = gets.split.map(&:to_i)
$s = []
$h.times do |i|
  $s[i] = gets.chomp.split("")
end

def mines(h,w)
  sum = 0
  (h-1..h+1).each do |i|
    next if i < 0 || i > $h - 1
    (w-1..w+1).each do |j|
      next if j < 0 || j > $w - 1
      sum += 1 if $s[i][j] == "#"
    end
  end
  return sum
end

$h.times do |h|
  $w.times do |w|
    next if
    print $s[h][w] == '#' ? "#" : mines(h,w)
  end
  print "\n"
end


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

long long int dp[5][40001] = {};

int main() {

  dp[0][0] = 1;

  for ( long long int i = 1; i < 200; i++ ) {

    long long int x = i * i;

    for ( long long int j = 0; j < 4; j++ ) {

      for ( long long int k = 0; k + x < 40000; k++ ) {

	dp[j+1][k+x] += dp[j][k];

      }

    }

  }

  while( true ) {

    long long int in;
    cin >> in;
    if ( in == 0 ) break;

    cout << dp[1][in] + dp[2][in] + dp[3][in] + dp[4][in] << endl;

  }

  return 0;

}

Measured memory_bytes: 2408
a=int(input())
if a%1.08==0:
    print(int(a/1.08))
else:
    ans=[0]*3
    ans[0]=int(a/1.08)-1
    ans[1]=int(a/1.08)
    ans[2]=int(a/1.08)+1
    for i in range(4):
        if i==3:
            print(':(')
            break
        if int(ans[i]*1.08)==a:
            print(ans[i])
            break

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    static int[][] memo;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long sum = 0;
        memo = new int[202][202];
        for(int i = 1; i<=k; i++) {
            for(int j = 1; j<=k; j++) {
                for(int l = 1; l<=k; l++) {
                    sum += gcdgcd(i,j,l);       
                }
            }
        }
        p(sum);
    }

    public static int gcd(int a, int b) {
        if(b>a) {
            int t = a;
            a = b;
            b = t;
        }
        if(b==0) return a;
        if(memo[b][a%b]==0) memo[b][a%b]= gcd(b, a%b);
        return memo[b][a%b];
    }

    public static int gcdgcd(int a, int b, int c) {
        return gcd(a, gcd(b, c));
    }

    public static <T> void p(T message) {
        System.out.println(message);
    }

    public static <T> void pp(T message) {
        System.out.print(message);
    }
}

Measured memory_bytes: 37612
N = int(input())
Xs = input().split()

X =[]
for i in Xs:
	X.append(int(i))

minnum = 10000000000

for i in range(101):
	sumnum = 0
	for j in X:
		sumnum += (i-j)*(i-j)
	
	minnum = min(sumnum,minnum)

print(minnum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
long long x;
cin>>x;
if(x==6){
    cout<<1;
    return 0;
}
long long res;
if(x%11==0){
    res=0;
}
else{
    if(x%11>6){
        res=2;
    }
    else{
        res=1;
    }
}
cout<<(x/11*2)+res;



    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    sort(a);
    int ans = 0;
    int x = 1;

    for(int i=n-1;i>=0;i--){
        if(x%2==0){
            ans-=a[i];
        }else{
            ans+=a[i];
        }
        x++;
    }

    cout << ans << endl;
}

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

int dat[2002];
vector<int> graph[2002];
bool visit[2005];
int n;

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

vector<int> merge(vector<vector<int>> vvt, int head)
{
	int total = 0;
	for (auto &&v : vvt) total += v.size();
	vector<int> ret(total + (head >= 0));
	int ptr = 0;
	if (head >= 0) ret[ptr++] = head;
	priority_queue<tuple<int, int, int>> pq;
	for (int i = 0; i < vvt.size(); i++)
	{
		pq.emplace(vvt[i][0], i, 0);
	}
	while (pq.empty() == false)
	{
		int val, idx, nxt;
		tie(val, idx, nxt) = pq.top();
		pq.pop();
		ret[ptr++] = val;

		if (nxt + 1 < vvt[idx].size())
			pq.emplace(vvt[idx][nxt + 1], idx, nxt + 1);
	}
	return ret;
}

vector<int> process(int t)
{
	vector<vector<int>> vvt;
	visit[t] = true;

	for (int nxt : graph[t])
	{
		if (visit[nxt]) continue;
		vvt.emplace_back(process(nxt));
	}

	return merge(vvt, t);
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &dat[i]);
	}

	sort(dat, dat + n);

	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (gcd(dat[i], dat[j]) > 1)
			{
				graph[i].push_back(j);
				graph[j].push_back(i);
			}
		}
	}

	for (int i = 0; i < n; i++) sort(graph[i].begin(), graph[i].end());

	vector<vector<int>> vvt;

	for (int i = 0; i < n; i++)
	{
		if (visit[i]) continue;
		vvt.emplace_back(process(i));
	}

	auto ret = merge(vvt, -1);

	for (int t : ret) printf("%d ", dat[t]);
	printf("\n");
}


Measured memory_bytes: 17920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


struct Point
{
	double x, y;
};

void koch(int n, Point a, Point b)
{
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;
	
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	
	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}


int main()
{
	Point a, b;
	int n;
	
	scanf("%d", &n);
	
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, std::int64_t>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  cpp_int a, b, c; cin >> a >> b >> c;

  bool res = (4*a*b < (c-a-b)*(c-a-b) ) && (c-a-b > 0);
  auto ans = res ? "Yes" : "No";
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

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

	int now =d[0];
	int ct=0;
	int ans =0;
	for(int i=1; i<n; i++){
		if(now >= d[i]){
			ct++;
		}else {
			ct =0;
		}
		now = d[i];
		ans = max(ans,ct);
	}
	writeln(ans);

}




Measured memory_bytes: 640
from bisect import bisect_left

N = int(input())
A = [int(input()) for i in range(N)]
LIS = []

for i in range(N):
    index = bisect_left(LIS, A[i])
    if index >= len(LIS):
        LIS.append(A[i])
    else:
        LIS[index] = A[i]

print(len(LIS))


Measured memory_bytes: 10348
import java.util.Scanner;

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

		int N = sc.nextInt();

		int[] B = new int[N - 1];
		for (int i = 0; i < N - 1; i++) {
			B[i] = sc.nextInt();
		}

		// 例
		// B={2 3 4 8 4 5}
		// A={1 2 4 3 2 3 2}

		// 各要素が最大になるように、Aを作り、和を求めれば良い。
		// A_0とA_Nは例外だが、1<= i <=N-1については、
		// A_i=min(B_i-1, B_i)でよい

		int[] A = new int[N];

		A[0] = B[0];
		A[N - 1] = B[N - 2];

		for (int i = 1; i <= N - 2; i++) {
			A[i] = Math.min(B[i - 1], B[i]);
		}

		int ans = 0;

		for (int i = 0; i < N; i++) {
			ans += A[i];
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1,t2;
    ll a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    if(t1*a1+t2*a2==t1*b1+t2*b2){
    	cout << "infinity"<<endl;
    	return 0;
    }
    if((a1<b1&&a2<b2)||(a1>b1&&a2>b2)){
    	cout << 0<<endl;
    	return 0;
    }
    if(a1<b1){
    	swap(a1,b1);
    	swap(a2,b2);
    }
    ll m=t1*a1-t1*b1;
    ll n=-t2*a2+t2*b2;
    if(m>n){
    	cout << 0<<endl;
    	return 0;
    }
    ll ans=1;
    ll maki=n-m;
    ll niko=m/maki;
    ans+=niko*2;
    if(m%maki==0){
    	ans--;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from itertools import permutations
from math import sqrt

def solve():
    input = sys.stdin.readline
    N = int(input())
    C = [[int(i) for i in input().split()] for _ in range(N)]
    totalDist = 0
    count =0 
    for order in permutations(range(N)):
        count += 1
        dist = 0
        for i in range((N-1)):
            X = C[order[i]]
            Y = C[order[i+1]]
            dist += sqrt((X[0] - Y[0]) ** 2 + (X[1] - Y[1]) ** 2)
        totalDist += dist
    print(totalDist / count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,neg=0,sum=0,mn=1000000001; cin>>n; 
    vi a(n);
    for (int i=0;i<n;i++) {
    	cin >> a[i];
    	if (a[i]<0) neg++;
    	sum += abs(a[i]);
    	mn = min(mn,abs(a[i]));
    } 
    if (neg&1) sum -= 2*mn;
    printf("%lld\n",sum);
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
/*



*/

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  int f = 0;
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] > a[i-1]) {
      if (f == -1) {
	f = 0;
      }	else if (f == 0) {
	f = 1;
	++ans;
      }
    } else if (a[i] < a[i-1]) {
      if (f == 1) {
	f = 0;
      } else if (f == 0) {
	f = -1;
	++ans;
      }
    }
  }
  if (!f) ++ans;
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4184
(n,m,l)=  map(int,input().split())

g1 = []
for i in range(0,n):
    g1.append(list(map(int,input().split())))

g2 = []
for i in range(0,m):
    g2.append(list(map(int,input().split())))

for i in range(0,n):
    t = []
    for j in range(0,l):
        sum = 0
        for k in range(0,m):
            sum += g1[i][k]*g2[k][j]
        t.append(sum)
    print (' '.join(map(str,t))) 


Measured memory_bytes: 6308
import java.util.*;
import java.io.*;

public class Main {
    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static final FS sc = new FS();
    static final PrintWriter out = new PrintWriter(System.out);
    static final int mod = 1000000007;

    public static void main(String[] args) {

        solve();
        out.close();

    }

    static void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a + b >= 10) {
            out.println("error");
        } else {
            out.println(a + b);
        }
    }
}


Measured memory_bytes: 32828
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define LL long long
using namespace std;
const int N=2e6+1000;
const LL P=998244353;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

int main(){
	int d,t,s;
	cin>>d>>t>>s;
	t=t*s;
	if(t>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    long long int N,A,B;
    cin >> N >> A >> B;
    long long int MA = B * (N-2);
    long long int MI = A * (N-2);

    long long int ANS = MA - MI + 1;

    cout << max(ANS,0LL) << endl;
    
}

Measured memory_bytes: 256
# frozen_string_literal: true

n, m = gets.split(' ').map(&:to_i)
list = gets.split(' ').map(&:to_i)
calc = Array.new(n)
(0...m).each do |_|
  n1, n2 = gets.split(' ').map(&:to_i)
  if list[n1 - 1] == list[n2 - 1]
    calc[n1 - 1] = 1
    calc[n2 - 1] = 1
  elsif list[n1 - 1] > list[n2 - 1]
    calc[n2 - 1] = 1
  else
    calc[n1 - 1] = 1
  end
end
puts calc.filter(&:nil?).count


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

const int maxn = 1e5 + 10;
int h[maxn], dp[maxn];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &h[i]);
    }

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    printf("%d\n", dp[n]);
}

Measured memory_bytes: 1024
from math import gcd as gcd
K=int(input())

ans1 = 0
ans2 = 0
ans3 = 0

for i in range(K):
    for j in range(i+1,K):
        for k in range(j+1, K):
            ans1 += gcd(gcd(i+1,j+1), k+1)

for i in range(K):
    for j in range(i+1,K):
        ans2 += gcd(i+1,j+1)

for i in range(K):
    ans3+=i+1

print(ans1*6+ans2*6+ans3)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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


    string s,t;cin >> s >> t;
    int l=s.size();


    int n=l;
    while(n--)
    {
        if(s == t)return cout << "Yes",0;
        string temp=s.substr(0,l-1);
        char ch=s[l-1];
        s=s[l-1]+temp;


    }

    cout << "No",0;



}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    double x[N], y[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    double total_dist = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (i == j) continue;
            total_dist += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }

    printf("%.12f\n", total_dist * 2.0 / (double)N);

    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< int > A(N);
  map< int, int > mp;
  REP(i, N) {
    cin >> A[i];
    mp[A[i]]++;
  }

  int tmp = 0;
  EACH(mi, mp) {
    tmp += max(0, mi.second - 1);
  }

  tmp %= 2;

  int ans = mp.size() - tmp;
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 5376
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.E
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();
			int n = cin.nextInt();
			var a = new List<List<int>>(n);

			for (int i = 0; i < n; i++)
			{
				a.Add(new List<int>(cin.ArrayInt(n - 1)));
			}

			int ans = 0;
			bool valid = false;
			var progress = new List<int>(n);
			var check = new List<bool>(n);
			var checkallfalse = new List<bool>(n);
			var seen = new List<int>();
			var seennext = new List<int>();
			int fin = 0;
			for (int i = 0; i < n; i++)
			{
				progress.Add(0);
				check.Add(false);
				checkallfalse.Add(false);
				seen.Add(i);
			}

			while (fin < n * (n - 1))
			{
				ans++;

				foreach (var i in seen)
				{
					if (progress[i] < n - 1)
					{
						int j = a[i][progress[i]] - 1;
						if (!check[i] && !check[j] && a[j][progress[j]] - 1 == i)
						if (a[j][progress[j]] - 1 == i)
						{
							progress[i]++;
							progress[j]++;
							check[i] = true;
							check[j] = true;
							valid = true;
							fin += 2;
							seennext.Add(i);
							seennext.Add(j);
						}
					}
				}

				check = new List<bool>(checkallfalse);

				seen = new List<int>(seennext);
				seennext.Clear();

				if (!valid) { ans = -1; break; }

				valid = false;
			}

			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

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

int main() {
    int N,t=0,x=0;
    cin >> N;
    vector<int> s(N);

    rep(i,N) {
        cin >> s.at(i);
        t += s.at(i);
    }
    sort(s.begin(), s.end());

    if(t%10 == 0) {
        while(s.at(x)%10 == 0) {
            x++;
            if(x == N)
                break;
        }
        if(x != N)
            t -= s.at(x);
        else
            t = 0;
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=1e6;
int n,a[N],sum[N],x;
signed main(){
	n=read();
	for(int i=1;i<=n;i++) x=read(),++sum[++a[x]];
	for(int i=1;i<=n+5;i++) sum[i]+=sum[i-1];
	for(int i=1;i<=n;i++){
		int ans=0;
		int l=1,r=n+5;
		while(l<=r){
			int mid=(l+r)>>1;
			if(mid*i<=sum[mid]) ans=mid,l=mid+1;
			else r=mid-1;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(void){
    
    int A, B, C;
    
    cin >> A >> B >> C;
    
    if(A != B && A != C) cout << A << endl;
    else if(B != A && B != C) cout << B << endl;
    else cout << C << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
use strict;
use warnings;

my $n = <STDIN>;
chomp($n);

my @lines;
my $cnt =0;
while ($cnt < $n){
my $line = <STDIN>;
  chomp($line);
  push(@lines, $line);
  $cnt++;
}

my $result = {
    "AC" =>0,
    "WA" =>0,
    "TLE" =>0,
    "RE" =>0
};

foreach my $text (@lines){
    my $len = length($text);
    if ($len > 1 && $len < 4){
        if ($text =~ /^AC$|^WA$|^RE$|^TLE$/){
            $result->{$text}++;
        }
    }
}

print("AC x $result->{AC}\n");
print("WA x $result->{WA}\n");
print("TLE x $result->{TLE}\n");
print("RE x $result->{RE}\n");

Measured memory_bytes: 12768
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int A, B;
int cnt = 0;

int calc[sze];
int dp[sze];
int a[20][20];
bool did[sze];

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

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

	for (int i = 0; i < 1 << n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			for (int z = j+1; z < n; z++)
			{
				if (((1 << j) & i) && ((1 << z) & i))
				{
					calc[i] += a[j][z];
				}
			}
		}
	}

	for (int m = 0; m < 1 << n; m++)
	{
		for (int s = m; s; s = (s - 1)&m)
		{
			maxi(dp[m], calc[s] + dp[m^s]);
		}
	}


	cout << dp[(1 << n) - 1];
	return 0;
}

Measured memory_bytes: 15488
n = int(input())
#a,b = map(int,input().split())
#li = list(map(int,input().split()))
li = []
for i in range(1,int(n**0.5//1)+1):
    if n%i == 0:
        li.append(i+n//i-2)
        #print(i,n//i)
if len(li)!=0:
    print(min(li))
else:
    print(n-1)

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


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int mn, mx;
  mn = a[0];
  mx = a[0];
  rep(i,n){
    if (mn > a[i]) mn = a[i];
    if (mx < a[i]) mx = a[i];
  }
  cout << mx - mn << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 1000000
typedef long long ll;


int main(){
  int D,G;
  cin>>D>>G;
  int p[200];
  ll c[200];
  for(int i=0;i<D;i++){
    cin>>p[i]>>c[i];
  }
  ll dp[20][2000]={0};
  for(int i=0;i<D;i++){
    for(int j=0;j<=i*100;j++){
      for(int k=0;k<=p[i];k++){
        ll score=(i+1)*100*k;
        if(k==p[i]) score+=c[i];
        dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+score);
      }
    }
  }
  int ans;
  for(int i=0;i<2000;i++){
    if(dp[D][i]>=G){
      ans=i;
      break;
    } 
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 512
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define endl "\n"
#define oo 0x3f3f3f3f3f3f3f3fLL
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define setdp memset(dp,-1,sizeof(dp))
#define db(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int A[maxn];
int R[maxn];
int L[maxn];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    File();
    int n;

    cin >> n;
    for (int i=0; i<n; i++)
    {
        cin >> A[i];
        L[i] = R[i] = A[i];
    }
    for (int i=0; i<n; i++)
        L[i] = __gcd(L[i], L[i-1]);
    for (int i=n-1; i>=0; i--)
        R[i] = __gcd(R[i], R[i+1]);

    int ans = 0;
    for (int i=0; i<n; i++)
        ans = max(ans,__gcd(L[i-1], R[i+1]));

    cout << ans;
}


Measured memory_bytes: 4788
N = int(input())
S = input()
maxy= 0

for i in range(N-1):
    Sl = set(S[:i+1])
    Sr = set(S[i+1:])

    counter = 0
    for j in Sl:
        if j in Sr:
            counter += 1
    maxy = max(maxy, counter)
    
print(maxy)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int A[n];
    for(int i=0; i<n; i++)
    {
        cin>>A[i];
    }
    int sum=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            sum+=A[i]*A[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B
import Data.IORef

main :: IO ()
main = do
    [w, h, n] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    as <- mapM newIORef [0, w, 0, h]
    replicateM_ n $ do
        [x, y, a] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
        bs <- mapM readIORef as
        let i = a - 1
            f = [max, min] !! (i `mod` 2)
            j = [x, y] !! (i `div` 2)
        writeIORef (as !! i) (f (bs !! i) j)
    [x1, x2, y1, y2] <- mapM readIORef as
    print $ max 0 (x2 - x1) * max 0 (y2 - y1)


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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

string S;

signed main() {
    cin >> S;
    if (S.size() >= 4) {
        if (S[0] == 'Y' && S[1] == 'A') {
            if (S[2] == 'K' && S[3] == 'I') {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256