akhauriyash/Code-Regression huggingface dataset:
object Main extends App {
  loop(EmptyHeap)

  def loop(heap: LeftistHeap): Unit = {
    val op: Array[String] = io.StdIn.readLine().split(" ")
    op(0) match {
      case "end" =>
      case "insert" => loop(heap.insert(op(1).toInt))
      case "extract" =>
        println(heap.findMax)
        loop(heap.deletedMax)
      case _ => throw new Error("Unknown operation")
    }
  }

  sealed trait LeftistHeap {
    def rank: Int
    def merge(that: LeftistHeap): LeftistHeap
    def insert(x: Int): LeftistHeap = merge(HeapNode(1, x, EmptyHeap, EmptyHeap))
    def findMax: Int
    def deletedMax: LeftistHeap
  }
  case object EmptyHeap extends LeftistHeap {
    def rank: Int = 0
    def merge(that: LeftistHeap): LeftistHeap = that
    def findMax: Int = throw new Error("Heap is Empty")
    def deletedMax: LeftistHeap = EmptyHeap
  }
  case class HeapNode(rank: Int, elem: Int, left: LeftistHeap, right: LeftistHeap) extends LeftistHeap {
    def findMax: Int = elem
    def deletedMax: LeftistHeap = left.merge(right)
    def merge(that: LeftistHeap): LeftistHeap = {
      def make(x: Int, a: LeftistHeap, b: LeftistHeap): LeftistHeap = {
        if (a.rank >= b.rank) HeapNode(b.rank + 1, x, a, b)
        else HeapNode(a.rank + 1, x, b, a)
      }
      that match {
        case EmptyHeap => this
        case HeapNode(_, y, l2, r2) =>
          if (elem > y) make(elem, left, that.merge(right))
          else make(y, l2, r2.merge(this))
      }
    }
  }
}


Measured memory_bytes: 505104
<?php

list($n) = explode(' ', trim(fgets(STDIN)));
$a_list = explode(' ', trim(fgets(STDIN)));

$buka = array_count_values($a_list);
for ($i = 1; $i <= $n; ++$i) {
    echo ($buka[$i] ?? 0) . PHP_EOL;
}


Measured memory_bytes: 37796
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;
    int res = 0;

    rep (i, 1, n) {
        int x; cin >> x;
        if ((i & 1) && (x & 1)) res++;
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3636
using System;

namespace A
{
    class Calc
    {
        public int fib(int n, ref int[] f)
        {
            if (n <= 1)
            {
                return 1;
            }
            else
            {
                if (f[n]!=0)
                {
                    return f[n];
                }
                else
                {
                    f[n] = fib(n - 1, ref f) + fib(n - 2, ref f);
                }
            }
            return f[n];
        }
    }

    class A
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            int[] f = new int[n+1];
            Calc calc = new Calc();
            Console.WriteLine(calc.fib(n,ref f));
        }
    }
}



Measured memory_bytes: 9232
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, q;
string t,d,s;
bool checkl(int mid){
    rep(i,q){
        if(mid==-1)return true;
        if(mid==n)return false;
        if(s[mid]==t[i]){
            if(d[i]=='L'){
                mid--;
            }
            else{
                mid++;
            }
        }
    }
    if(mid==-1)return true;
        if(mid==n)return false;
    return false;
}
bool checkr(int mid){
    rep(i,q){
        //cout<<mid<<" ";
        if(mid==-1)return false;
        if(mid==n)return true;
        if(s[mid]==t[i]){
            if(d[i]=='L'){
                mid--;
            }
            else{
                mid++;
            }
        }
    }
    if(mid==-1)return false;
    if(mid==n)return true;
    return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>q>>s;
    t="";
    d="";
    for (int i = 0; i < q; i++)
    {
        char temp,temp1;
        cin >> temp>>temp1;
        t+=temp;
        d+=temp1;
    }
    int l=-1;int r=n;
    while(r-l>1){
        int mid=(r+l)/2;
        if(checkl(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    int llimit=l;
    l=-1;
    r=n;
    while(r-l>1){
        int mid=(r+l)/2;
        //cout<<mid<<"\n";
        if(checkr(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
        //cout<<"\n";
    }
    //cout<<llimit<<" "<<r<<"\n";

    cout<<n-(llimit+1)-(n-r)<<"\n";
}


Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(y).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<ll> mi(2,2e9),ma(2,-2e9);
    for(int i=0;i<N;i++){
        ll x,y;
        cin >> x >> y;
        chmin(mi[0],x-y);
        chmin(mi[1],x+y);
        chmax(ma[0],x-y);
        chmax(ma[1],x+y);
    }
    cout << max(ma[0]-mi[0],ma[1]-mi[1]) << "\n";
}

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

int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int cnt =0;
bool x=true;
  rep(i,N){
x=true;
    for(int j=i+1;j<N;j++){
      if(vec.at(i)==vec.at(j)){
        x=false;
      }
    }
if(x){
cnt+=1;}
  }
  cout<<cnt;}
  


Measured memory_bytes: 3612
/*****************************************************

@author: vichitr
Compiled On: 18th Aug 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;

int n;
vector<int> adj[N]; 
bool vis[N];
int ans[N];

void dfs(int v, int x)
{
    ans[v] += x;
    vis[v] = 1;
    for(auto i: adj[v])
    {
        if(!vis[i])
        {
            dfs(i, ans[v]);
        }
    }
}

void solve()
{
    int n, q; cin>>n>>q;
    for(int i=1;i<n;i++)
    {
        int x, y; cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    while(q--)
    {
        int p, x; cin>>p>>x;
        ans[p] += x;
    }
    dfs(1, 0);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}

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

/*****************************


****************************/

Measured memory_bytes: 21376
h,w = map(int,input().split())

a = []
for _ in range(h):
    wk = input()

    if '#' in wk:
        a.append(wk)

t = []
for j in zip(*a):
    if '#' in j:
        t.append(j)

for list in zip(*t):
    print("".join(list))

Measured memory_bytes: 38384
def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n + 1

s = int(input())
ans= [s]
i = 0
while True:
    s = f(ans[i])
    if s in ans:
        print(i+2)
        break
    else:
        ans.append(s)
        i +=1

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;
const int INF = 1e18 + 239;

int add(int a, int b) {
	return (a + b) % MOD;
} 

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int n;
vector<vector<pair<int, int>>> g;

void dij(int st, vector<int> &d, vector<int> &cnt) {
	d.resize(n, INF);
	cnt.resize(n, 0);
	d[st] = 0;
	cnt[st] = 1;
	set<pair<int, int>> s;
	s.insert({d[st], st});
	while (!s.empty()) {
		int v = s.begin()->second;
		s.erase(s.begin());
		for (auto t : g[v]) {
			if (d[t.first] + t.second == d[v]) {
				cnt[v] = add(cnt[v], cnt[t.first]);
			}
		}
		for (auto t : g[v]) {
			if (d[t.first] > d[v] + t.second) {
				s.erase({d[t.first], t.first});
				d[t.first] = d[v] + t.second;
				s.insert({d[t.first], t.first});
			}
		}
	}
}

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

	int m, s, t;
	cin >> n >> m >> s >> t;
	g.resize(n);
	s--;
	t--;
	while (m--) {
		int u, v, c;
		cin >> u >> v >> c;
		c *= 2;
		u--;
		v--;
		g[u].push_back({v, c});
		g[v].push_back({u, c});
	}
	vector<int> ds, cnts, dt, cntt;
	dij(s, ds, cnts);
	dij(t, dt, cntt);
	int ans = mul(cnts[t], cnts[t]);
	for (int i = 0; i < n; i++) {
		if (ds[i] + dt[i] == ds[t] && ds[i] == dt[i]) {
			int v = mul(cnts[i], cntt[i]);
			v = mul(v, v);
			ans = sub(ans, v);
		}
	}
	for (int i = 0; i < n; i++) {
		for (auto x : g[i]) {
			if (ds[x.first] + x.second + dt[i] == ds[t]) {
				if (ds[x.first] < ds[t] / 2 && ds[t] / 2 < ds[x.first] + x.second) {
					int v = mul(cnts[x.first], cntt[i]);
					v = mul(v, v);
					ans = sub(ans, v);
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int MAX = 100;
const int BLACK = 0;
const int WHITE = 1;
/* global variables */
vector<vector<int> > G(MAX, vector<int>(MAX, 0));
int H, W;
vector<int> dx {0, 0, 1, -1};
vector<int> dy {1, -1, 0, 0};
/* function */
int bfs() {
    vector<vector<int> > visited(MAX, vector<int>(MAX, 0));
    queue<pii> q;
    q.push(pii(0, 0));
    visited[0][0] = 1;
    while (!q.empty()) {
        pii tmp = q.front(); q.pop();
        int x = tmp.first, y = tmp.second;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || H <= nx || ny < 0 || W <= ny) continue;
            if (G[nx][ny] == BLACK || visited[nx][ny] != 0) continue;
            visited[nx][ny] = visited[x][y] + 1;
            q.push(pii(nx, ny));
        }
    }
    return visited[H-1][W-1];
}
/* main */
int main(){
    cin >> H >> W;
    char c;
    int cntBlack = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> c;
            if (c == '#') {
                cntBlack += 1;
                G[i][j] = BLACK;
            }
            else G[i][j] = WHITE;
        }
    }
    int path = bfs();
    if (path == 0) cout << -1 << '\n';
    else cout << H * W - path - cntBlack << '\n';
}


Measured memory_bytes: 384
#B - Shift only
N = int(input())
A = list(map(int,input().split()))

def div_2():
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] //=  2
        else :
            return False
    return A

count = 0
while True:
    if div_2() != False:
        count += 1
    else:
        break
print(count)

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision

    int n ; cin>>n;
    vi h(n+1);
    vi dp(n+1);
    repA(i,1,n)    cin>>h[i];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    repA(i,3,n){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n]<<endl;
} 

Measured memory_bytes: 1024
import java.util.Scanner;

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

       for(;;){
           int n=scan.nextInt();
           int x=scan.nextInt();

           if(n==0 && x==0){
               break;
           }
           int i,j,k;
           int count=0;

           for(i=1;i<=n;i++){
               for(j=i+1;j<=n;j++){
                   for(k=j+1;k<=n;k++){

                       if(i+j+k==x){
                           count++;
                       }
                   }
               }
           }

           System.out.println(count);
       }
    }
}



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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

bool isOk(int x, vector<bool> ngs) {
  string xx = to_string(x);
  for (char c : xx) {
    if (ngs.at(c - '0')) {
      return false;
    }
  }
  return true;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  rep(i, k) cin >> d.at(i);
  vector<bool> ngs(10, false);
  rep(i, k) {
    int ngi = d.at(i);
    ngs.at(ngi) = true;
  }
  int res = n;
  while (!isOk(res, ngs)) {
    res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
 
vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main() {
  string s;
  cin >> s;
  rep(i, week.size()) {
    if (s == week[i]) cout << 7 - i << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    System.out.println(n*n*n);
  }
}

Measured memory_bytes: 24012
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] a = new int[m];
        int sum = 0;
        for(int i = 0; i < m; i++){
            a[i] = scan.nextInt();
            sum += a[i];
        }
        if(sum > n){
            System.out.println(-1);
        }else{
            System.out.println(n - sum);
        }
    }
}

Measured memory_bytes: 39460
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main() {
  int n;
  cin >>n;
  int a[n];
  rep(i,n)cin >> a[i];
  int b[1000010]={};
  rep(i,n)b[a[i]]++;

  bool flag1=0;
  for(int i=2;i<=1000000;i++){
    int sum=0;
    for(int j=i;j<=1000000;j+=i){
      sum+=b[j];
    }
    if(sum>1)flag1=1;
  }

  int ans=0;
  rep(i,n){ans=__gcd(ans,a[i]);}

  if(flag1==0){cout << "pairwise coprime" << endl;}else if(flag1==1 && ans==1){cout << "setwise coprime" << endl;}else{cout << "not coprime" <<endl;}
}

Measured memory_bytes: 11408
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, k = inpl()
ans = [0] * (k+1)
for i in range(k, 0, -1):
    ans[i] = pow(k // i, n, mod)
    for j in range(2, k+1):
        if i * j > k:
            break
        ans[i] -= ans[i * j]

# print(ans)
print(sum([ans[i]*i%mod for i in range(1,k+1)])%mod)

'''
1以上K以下の整数からなる長さNの数列{A_1,...A_N}を考える。
K^N個考えられる数列のgcd(A_1,...A_N)の和を求め、10^9+7で割った余りを出力せよ。

term:
2<=N<=10**5
1<=K<=10**5
input:
3 2
output:
    9
'''

'''
K^N個の数列すべてに対してgcdを計算しているとO((K^N)*(N+logK))になり間に合わない。
そこで、問題を
「1<=X<=Kに対してgcd(A_1,...A_N)=Xとなる数列A_iがいくつあるか」
という問題に読み替える。
Xが最大公約数であるためには{A_1,...A_N}がすべてXの倍数でなければならない。
K以下でXの倍数である数の個数はK//Xで求められる。
これらによって構成される数列は(K//X)^N種類ある。
しかしgcdがXの倍数であるものも含まれてしまうのでそれを包除原理で除く。
ex)
    K=4,N=3のとき(4,4,4)はすべて2の倍数だがgcdは4。
    したがって{(4//2)^3-(4//(2*2))^3}%modとする。
'''

Measured memory_bytes: 76368
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut ss: Vec<String> =
        (0..n).map(|_| input()).collect();

    let mut m = (b'a'..b'z'+1)
                .map(|c| c as char)
                .map(|c| (c, 0)).collect::<HashMap<_, _>>();
    for c in ss[0].chars() {
        let mut x = m.get_mut(&c).unwrap();
        *x += 1;
    }
    for s in ss.into_iter() {
        let mut mt = (b'a'..b'z'+1)
            .map(|c| c as char)
            .map(|c| (c, 0)).collect::<HashMap<_, _>>();
        for c in s.chars() {
            let mut x = mt.get_mut(&c).unwrap();
            *x += 1;
        }
        for y in (b'a'..b'z'+1).map(|c| c as char).into_iter() {
            let x = m.get_mut(&y).unwrap();
            *x = min(x.clone(), mt[&y].clone());
        }
    }
    let mut ans = String::new();
    for v in (b'a'..b'z'+1).map(|c| c as char) {
        for _ in 0..m[&v] {
            ans.push(v);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++mp[x];
  }
  vector<int> a, ans(n, 0);
  a.reserve(mp.size());
  for (const auto& pr : mp) {
    a.push_back(pr.second);
  }
  sort(begin(a), end(a), greater<int>());
  int cur = a.back(), p = (int)a.size() - 1, add = 0;
  for (int i = (int)a.size() - 1; i >= 0; --i) {
    cur = max(cur, a[i]);
    while (p >= 0 && a[p] <= cur) {
      --p;
    }
    while (add >= i - p) {
      int cmp = (p < 0) ? inf : a[p];
      int val = min(cmp - cur, add / (i - p));
      cur += val;
      add -= val * (i - p);
      while (p >= 0 && a[p] <= cur) {
        --p;
      }
    }
    ans[i] = cur;
    add += cur;
  }
  for (int val : ans) {
    cout << val << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 16640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ull unsigned long long
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=tmp*10+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll tmp=1; for(;b;b>>=1){if(b&1)tmp=tmp*a%mod; a=a*a%mod;} return tmp;}
using namespace std;
ll a[200010],sum[200010];
int n;
int main()
{
	int i;
	n=read();
	for(i=1;i<=n;i++)a[i]=read(),sum[i]=sum[i-1]+a[i];
	sort(sum,sum+n+1); sum[n+1]=-1;
	ll ans=0,cnt=0;
	for(i=0;i<=n;i++){
		++cnt;
		if(sum[i]!=sum[i+1])ans+=cnt*(cnt-1)/2,cnt=0;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
   char a[4],b[4],c[4];
    while(cin>>a[0])
    {
        for(int i=1;i<3;i++)
          {cin>>a[i];}
          cout<<a[0];
          for(int i=0;i<3;i++)
          {
              cin>>b[i];
          }
         cout<<b[1];
          for(int i=0;i<3;i++)
          cin>>c[i];
                    cout<<c[2]<<endl;


    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m; // 猫の集団の数、餌入れの数
        cin >> n >> m;
        if(m == 0)
            return 0;

        vector<int> cx(n), cy(n), catNum(n);
        for(int i=0; i<n; ++i)
            cin >> cx[i] >> cy[i] >> catNum[i];

        vector<int> x(m);
        for(int i=0; i<m; ++i)
            cin >> x[i];

        if(n == 0){
            cout << 0 << endl;
            continue;
        }

        vector<vector<pair<pair<int, int>, int> > > dist(n, vector<pair<pair<int, int>, int> >(m));
        vector<int> eat(m, 0);
        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                dist[i][j].first.first = (cx[i] - x[j]) * (cx[i] - x[j]) + cy[i] * cy[i];
                dist[i][j].first.second = x[j];
                dist[i][j].second = j;
            }
            sort(dist[i].begin(), dist[i].end());
            eat[dist[i][0].second] += catNum[i];
        }

        vector<int> select(n, 0);
        vector<bool> erase(m, false);
        int ret = *max_element(eat.begin(), eat.end());
        for(int i=0; i<m-1; ++i){
            int k = max_element(eat.begin(), eat.end()) - eat.begin();
            erase[k] = true;
            for(int j=0; j<n; ++j){
                eat[dist[j][select[j]].second] -= catNum[j];
                while(erase[dist[j][select[j]].second])
                    ++ select[j];
                eat[dist[j][select[j]].second] += catNum[j];
            }
            ret = min(ret, *max_element(eat.begin(), eat.end()));
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 12000
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let K: usize = sc.get();
    let h: Vec<usize> = sc.vec(N);
    let mut ans = 0;
    for i in 0..N {
        if h[i] >= K {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
from collections import defaultdict


def main():
    N, *a = map(int, open(0).read().split())
    d = defaultdict(lambda: 0)
    ratemax = 0
    for x in a:
        if 1 <= x <= 399:
            d[0] += 1
        elif 400 <= x <= 799:
            d[1] += 1
        elif 800 <= x <= 1199:
            d[2] += 1
        elif 1200 <= x <= 1599:
            d[3] += 1
        elif 1600 <= x <= 1999:
            d[4] += 1
        elif 2000 <= x <= 2399:
            d[5] += 1
        elif 2400 <= x <= 2799:
            d[6] += 1
        elif 2800 <= x <= 3199:
            d[7] += 1
        else:
            ratemax += 1
    print(len(d) if len(d) else 1, len(d) + ratemax)
    return


main()


Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);


void solve() {
    ll n, d;
    cin >> n >> d;
    ll cmp = d*d;
    ll ans = 0;
    for(ll i = 0; i<n; i++) {
        ll x, y;
        cin >> x >> y;
        ll curr = x*x + y*y;
        if(curr <= cmp) ans ++;
    }
    cout << ans << '\n';
}

int main() {_
    int t = 1;
    //cin >> t;
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
n,m,x,y=input().split()
#print(n,m,x,y)
a=input().split()
b=input().split()
#print(a,b)
flag=0
for z in range(int(x)+1,int(y)+1):
  flag1=0
  for i in range(int(n)):
    if int(a[i]) < z:
      flag1+=1
  flag2=0
  for j in range(int(m)):
    if z <= int(b[j]):
      flag2+=1
  if flag1==int(n) and flag2==int(m):
    flag=1
print('No War' if flag==1 else 'War')

Measured memory_bytes: 3188
import sys
lines=sys.stdin.readlines()
for line in lines:
    H,W=map(int,line.split())
    if H == W == 0: break
    for i in range(H):
        unit='#.' if i % 2 == 0 else '.#'
        print((unit*((W+1)//2))[0:W])
    print('')

Measured memory_bytes: 7720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  string n;

  cin >> n;

  if (n.find('7')!=string::npos){
    cout <<  "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zxgbs(ll a,ll b)
{
	ll l,r;
	l=(max(a,b));
	r=min(a,b);
	int sum = 1;
	if(l%r == 0)
	{
		return l;
	} 
	while(l%r)
	{
		ll k = l%r;
		l=max(r,k);
		r=(min(r,k));	
	}
	sum = r;
	return (a*b)/sum;
}
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll zd = zxgbs(c,d);
	a--;
	ll A = a-((a/c)+(a/d)-(a/zd));
	ll B = b-((b/c)+(b/d)-(b/zd));
	cout<<B - A<<endl;
	return 0;
}

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

namespace KEYPC2019_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToList();
            var B = Console.ReadLine().Split().Select(long.Parse).ToList();

            var dif = new long[N];
            var check = new int[N];
            for (int i = 0; i < N; i++)
            {
                dif[i] = A[i] - B[i];
                check[i] = A[i] - B[i] >= 0 ? 0 : 1;
            }

            if (check.Sum() == 0)
            {
                Console.WriteLine(0);
                return;
            }

            if (dif.Sum() < 0)
            {
                Console.WriteLine(-1);
                return;
            }

            dif = dif.OrderByDescending(x => x).ToArray();

            var r = dif.Where(x => x < 0).Sum();
            var cnt = dif.Count(d => d < 0);
            foreach (var i in dif)
            {
                r += i;
                cnt++;
                if (r >= 0) break;
            }

            Console.WriteLine(cnt);
        }
    }
}


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

int main() {
	bool check = false;
	int c11, c12, c13, c21, c22, c23, c31, c32, c33;
	cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23 >> c31 >> c32 >> c33;
	if (c11 - c12 == c21 - c22 && c11 - c12 == c31 - c32) {
		if (c11 - c13 == c21 - c23 && c11 - c13 == c31 - c33) {
			check = true;
		}
	}
	if (check) cout << "Yes";
	else cout << "No";
}

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

int n,m;

signed main()
{
	scanf("%d%d",&n,&m);
	if(n%m==0){
		printf("0");
		return 0;
	}
	printf("1");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  char c;
  c = getchar();
  if (c == 'A') {
    putchar('T');
  } else if (c == 'T') {
    putchar('A');
  } else if (c == 'G') {
    putchar('C');
  } else {
    putchar('G');
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int 
#define pb push_back
using namespace std;

const int INF= 1e9 +5;
typedef std::vector<int> vi;
typedef pair<int,int> ii;



int main() {

	//freopen("input.txt", "r", stdin); 
  	//freopen("output.txt", "w", stdout); 

  	string s;
  	cin>>s;
  	int n=s.length();
  	vi v(n,1);
  	
  	int i=0;
  	while(i<n)
  	{
  		if(s[i]=='R')
  		{
  			int j=i+1;
  			int c=0;
  			while(s[j]=='R' && j<n)
  			{
  				c++;
  				j++;
  			}
  			v[j]+=(ceil((double)c/2));
  			v[j-1]+=(c/2);

  			i=j;
  		}
  		else
  		{
  			int j=i+1;
  			int c=0;
  			while(s[j]=='L' && j<n)
  			{
  				c++;
  				j++;
  			}

  			v[i-1]+=(ceil((double)c/2));
  			v[i]+=(c/2);
  			i=j;

  		}
  	}
  	for(int i=0;i<n-1;i++)
  	{
  		if(s[i]=='R' && s[i+1]=='L')
  		{i++;
  			continue;
  		}
  		else
  		{
  			v[i]=0;
  		}
  	}
  	if(s[n-2]=='L')
  	{
  		v[n-1]=0;
  	}
  	for(auto x:v)
  	{
  		printf("%d ",x);
  	}


	
	return 0;
}

Measured memory_bytes: 1024
K, S = 5, 15
K, S = map(int,input().split())


def calculate(k, s):
    result = 0
    for x in range(k, -1, -1):
        if x > s:
            continue

        for y in range(k, -1, -1):
            if y > s:
                continue
            z = s - x - y

            if z > k:
                continue

            if z < 0:
                continue

            result = result + 1


    print(result)


calculate(K, S)

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+100;
const ll inf = 1e12;
const ll mod = 1e9+7;

ll a[MAX],tree[MAX];
ll last[MAX],cnt[MAX],n;
vii query[MAX];

ll accum(ll id){
	ll ret = 0;
	while(id>0){
		ret += tree[id];
		id -= (id & -id);
	}
	return ret;
}

ll que(ll l,ll r){
	return accum(r)-accum(l-1);
}

void add(ll id,ll aum){
	while(id<=n){
		tree[id]+=aum;
		id += (id & -id);
	}
}

ll ans[MAX];

int main(){
	fastio;
	f(i,0,MAX) last[i] = -1;
	ll l,r,q;
	cin  >> n >> q;

	f(i,1,n+1) cin >> a[i];
	f(i,0,q){
		cin >> l >> r;
		query[r].push_back({l,i});
	}
	f(i,1,n+1) {
		if (last[a[i]] != -1) --cnt[last[a[i]]], add(last[a[i]],-1);
		last[a[i]] = i;
		cnt[last[a[i]]]++;
		add(last[a[i]],1);

		for(ii qq: query[i]){
		
			ll sum = que(qq.first,i);

			ans[qq.second] = sum;
		}
	}
	f(i,0,q) cout << ans[i] << endl;
	
}

Measured memory_bytes: 63788
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define X real()
#define Y imag()
typedef complex<double> P;

double cross(P a,P b){return a.X*b.Y-a.Y*b.X;}
int main(){
	
	double a,b;
	vector<P> p;
	while(scanf("%lf,%lf",&a,&b)!=EOF){
		p.push_back(P(a,b));
	}
	
	double sum = 0;
	reps(i,1,p.size()-1){
		sum += cross(p[i]-p[0],p[i+1]-p[0])/2;
	}
	
	printf("%.9lf\n",fabs(sum));
	
}

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

void trace(int *A, int N);
void insertionSort(int *A, int N);


int main() {
	int N;
	int A[1000];

	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	trace(A, N);
	insertionSort(A, N);

	return 0;
}


void trace(int *A, int N)
{
	int i;

	for (i = 0; i < N; i++) {
		if (i > 0)cout << " ";
		cout << A[i];
	}
	cout << endl;
}

void insertionSort(int *A, int N) {
	int i, j, v;

	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while ( j >= 0 && A[j] > v ) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif



int main()
{
	static char s[128];
	static char t[128];
	static char u[128];
	cin >> s;
	int n = strlen(s);
	int i;
	char c;
	int ans = 99999;
	ran (c, 'a', 'z'+1) {
		copy(s, s+n, t);
		int l = 0;
		for (;;) {
			ran (i, 0, n-l) if (c != t[i])
				goto cont;
			break;
		cont:
			l++;
			rep (i, n-l) {
				if (t[i] == c || t[i+1] == c)
					u[i] = c;
				else
					u[i] = t[i];
			}
			copy(u, u+n-l, t);
			t[n-l] = 0;
			//puts(t);
		}
		ans = min(ans, l);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char ch[1001];
    int i=0,a=0;
    while(1){
        scanf("%s",ch);
        if(ch[0]=='0')break;
        while(1){
            if(ch[a]=='\0')break;
            i+=ch[a]-'0';
            a++;
        };
        printf("%d\n",i);
        a=i=0;
    };
return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans;
  cin>>n;
  if(n<105){
    ans=0;
  }
  else if(n<135){
    ans=1;
  }
  else if(n<165){
    ans=2;
  }
  else if(n<189){
    ans=3;
  }
  else if(n<195){
    ans=4;
  }
  else{
    ans=5;
  }
  cout<<ans;
}

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

int main(void){
    int a, t[4];
    cin >> a;
    for (int i = 0; i < 4; i++){
        t[i] = a % 10;
        a /= 10;
    }

    string s;
    if ( t[0] == t[1] || t[1]== t[2] || t[2] == t[3] )
        s = "Bad";
    else
        s = "Good";

    cout << s << endl;

}


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int H, W;
    cin >> H >> W;
    char a[110][110], grid[110][110];
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < H+2; i++)
    {
        for(int j = 0; j < W+2; j++)
        {
            if(i==0||i==H+1)
                grid[i][j] = '#';
            else{
                if(j==0||j==W+1)
                    grid[i][j] = '#';
                else
                    grid[i][j] = a[i - 1][j - 1];
            }
        }
    }
    
    for(int i = 0; i < H+2; i++)
    {
        for(int j = 0; j < W+2; j++)
        {
            cout << grid[i][j];
        }
        cout << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
// 0166
#include <iostream>
#include <math.h>
#define  PI   3.14159265
using namespace std;

void area_com(int m, double &s){
	int d, deg = 0;

	for(int i=1;i<m;i++){
		cin>>d;
		s += sin(d*PI/180);
		deg += d;
	}
	s += sin((360-deg)*PI/180);
}

int main(){
	while(1){
		int m, n;
		double s1 = 0, s2 = 0;

		cin>>m;
		if(m == 0)
			break;
		
		area_com(m, s1);
		
		cin>>n;
		area_com(n, s2);

		if(fabs(s1-s2) < 0.0000001)
			cout<<"0"<<endl;
		else if(s1 > s2)
			cout<<"1"<<endl;
		else
			cout<<"2"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; ++i){
  	cin >> a[i];
  	sum += a[i];
  }

  sort(a.rbegin(), a.rend());
  if(sum % (4 * m) == 0){
  	if(a[m-1] < sum / (4 * m)){
  		cout << "No" << endl;
  	}
  	else cout << "Yes" << endl;
  }
  else{
  	if(a[m-1] <= sum / (4 * m)){
  		cout << "No" << endl;
  	}
  	else cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b;

    cin >> a>> b;

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

Measured memory_bytes: 256
package main

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

func main() {
	n := readi()

	d := divisor(n)
	s := strconv.Itoa(d[len(d)/2])
	fmt.Println(len(s))
}

// func divisor(n int) (res []int) {
// 	for i := 1; i <= n; i++ {
// 		if n%i == 0 {
// 			res = append(res, n/i)
// 		}
// 	}
// 	return
// }

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    vector<int> v(4);
    REP(i,4) v[i] = s[i] - '0';
    int ans = 0;

    while(true) {
        int tmp = v[0];
        REP(i,3) {
            if ((ans >> i) % 2 == 0) tmp += v[i+1];
            else tmp -= v[i+1];
        }
        if (tmp == 7) break;
        ans++;
    }

    REP(i,3) {
        char c = (ans >> i) % 2 == 0 ? '+' : '-'; 
        cout << v[i] << c;
    }
    cout << v[3] << "=7" << endl;

    return 0;
}

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

using namespace std;

static int member[101010];

void solve()
{
  int n, a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    member[a]++;
    member[b + 1]--;
  }
  partial_sum(begin(member), end(member), begin(member));
  for(int i = 101009; i > 0; i--) {
    if(member[i] >= i - 1) {
      cout << i - 1 << "\n";
      return;
    }
  }
}

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

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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k, a, b; cin >> k >> a >> b;
    cout << (a <= b / k * k ? "OK" : "NG") << endl;
    return 0;
}


Measured memory_bytes: 3648