akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF 100100

int main(void)
{
    int ans = 0;

    int h, w;
    scanf("%d%d", &h, &w);

    int s[101][101];
    rep(i, h)
    {
        char tmp[100 + 1];
        scanf("%s", tmp);
        rep(j, w)
        {
            if (tmp[j % w] == '#')
                s[i][j] = 1;
            else
                s[i][j] = 0;
        }
    }
    /*
    rep(i, h)
    {
        rep(j, w)
        {
            printf("%d", s[i][j]);
        }
        printf("\n");
    }
*/
    int dp[101][101];
    rep(i, h)
        rep(j, w)
            dp[i][j] = INF;

    dp[0][0] = s[0][0];

    rep(i, h)
    {
        rep(j, w)
        {
            if (j != w - 1)
                if (s[i][j] == 0 && s[i][j + 1] == 1)
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + s[i][j + 1]);
                else
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            if (i != h - 1)
                if (s[i][j] == 0 && s[i + 1][j] == 1)
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + s[i + 1][j]);
                else
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
/*
    rep(i, h)
    {
        rep(j, w)
        {
            printf("%d ", dp[i][j]);
        }
        printf("\n");
    }
*/

    ans = dp[h - 1][w - 1];
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
//In the name of God
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 120;
const ll maxm = 3400;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second

ll n, k, dp[maxn][maxm], ans;

int main(){
    fast_io;

    cin >> n >> k;
    ans = n * k * 500000004 % mod;
    dp[n + 1][0] = 1;
    for(ll i = n; i > 0; i--){
        for(ll j = 0; j <= k; j++){
            for(ll o = 0; o < maxm; o++){
                if(j > i){
                    dp[i][o] += dp[i + 1][o];
                    if(dp[i][o] >= mod) dp[i][o] -= mod;
                }
                else if(o + (o + j) / i < maxm){
                    dp[i][o + (o + j) / i] += dp[i + 1][o];
                    if(dp[i][o + (o + j) / i] >= mod) dp[i][o + (o + j) / i] -= mod;
                }
            }
        }
        ans = ans * (k + 1) % mod;
    }
    for(ll i = 0; i < maxm; i++){
        ans = (ans - i * dp[1][i]) % mod;
    }
    cout << (ans + mod) % mod;

    return 0;
}


Measured memory_bytes: 6268
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
int dp[1<<17];
inline void solve(void){
  int N;
  cin>>N;
  vector<int>h(N);
  ins(h);
  fill(dp,dp+(1<<17),1<<30);
  dp[0]=0;
  rep(i,N){
    chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
    chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  cout<<dp[N-1]<<endl;
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1152
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n, m, money = 0; cin >> n >> m;
  vpll A(n);
  rep(i, n)
  {
    ll a, b; cin >> a >> b;
    A[i] = mp(a, b);
  }
  sort(all(A));
  for(ll i = 0;i < n;i++)
  {
    if(A[i].second <= m)
    {
      money += A[i].first * A[i].second;
      m -= A[i].second;
    }
    else
    {
      money += A[i].first * m;
      break;
    }
  }
  fin(money);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        int s = sc.nextInt();

        List<Integer> a = new ArrayList<>();
        a.add(s);

        int number = 0;

        outside:
        while (s > 0) {
            if (s % 2 == 0) {
                s = s / 2;
                number++;

                if (a.contains(s)) {
                    break outside;
                } else {
                    a.add(s);
                }
            } else {
                s = 3 * s + 1;
                number++;
               
                if (a.contains(s)) {
                    break outside;
                } else {
                    a.add(s);
                }
            }
        }


        System.out.println(number + 1);
    }

}











Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d||abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<PI, int> PPII;

const int N = 400;
ll dp[N][N];
ll ndp[N][N];
const ll inf = 1e15;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n && n) {
    vector<PPII> pool;
    REP(i, 0, n) {
      int u, v, w;
      cin >> u >> v >> w;
      v++; // [u, v)
      pool.push_back(PPII(PI(u, v), w));
    }
    sort(pool.begin(), pool.end());
    REP(i, 0, N) {
      REP(j, 0, N) {
	dp[i][j] = -inf;
	ndp[i][j] = -inf;
      }
    }
    dp[0][0] = 0;
    REP(i, 0, n) {
      PPII cur = pool[i];
      int u = cur.first.first;
      int v = cur.first.second;
      ll w = cur.second;
      REP(j, 0, N) {
	ll &ma = ndp[v][j];
	ma = dp[v][j];
	REP(k, 0, u + 1) {
	  ma = max(ma, dp[k][j] + w); 
	}
      }
      REP(j, 0, N) {
	ll &ma = ndp[j][v];
	ma = dp[j][v];
	REP(k, 0, u + 1) {
	  ma = max(ma, dp[j][k] + w); 
	}
      }
      REP(j, 0, N) {
	REP(k, 0, N) {
	  dp[j][k] = max(dp[j][k], ndp[j][k]);
	}
      }
    }
    ll ma = 0;
    REP(i, 0, N) {
      REP(j, 0, N) {
	ma = max(ma, dp[i][j]);
      }
    }
    cout << ma << "\n";
  }
}

Measured memory_bytes: 5656
def check(ans, s):
    ret = 0
    for k in sumdic:
        if ans & k != ans:
            continue
        ret += 1
        if ret >= s:
            return True
    return False


n, k = map(int, input().split())
A = list(map(int, input().split()))
sumA = [0]
for i in range(len(A)):
    sumA.append(sumA[i] + A[i])

sumdic = [0] * (n * (n + 1) // 2)
kk = 0
for i in range(len(A)):
    # print(kk, sumdic)
    for j in range(i + 1, len(A) + 1):
        tmp = sumA[j] - sumA[i]
        sumdic[kk + j - 1 - i] = tmp
        # print(i, j)
    kk += n - i

# print(A)
# print(Counter(sumdic))
# Sumdic = Counter(sumdic)

for i in reversed(range(len(format(sumA[-1], "b")))):
    # print(i)
    if check(2 ** i, k) is True:
        ans = 2 ** i
        tmp = i
        break
else:
    print(0)
    exit()

tmp -= 1
while(tmp != -1):
    if check(ans + 2 ** tmp, k) is True:
        ans += 2 ** tmp
    tmp -= 1
print(ans)

Measured memory_bytes: 24964
s = gets.chomp
l = s.size - 1
hl = (l - 2) / 2
tl = (l + 2) / 2
if s[0..hl] == s[0..hl].reverse && s == s.reverse && s[tl..l] == s[tl..l].reverse
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Vector.Unboxed ((!), Vector, freeze)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
 
main = C.interact $ put . sol . get

get = U.unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.pack . show

sol v = minimum . fmap plen . permutations $ U.toList rs
  where
  (n,m,r) = (v!0,v!1,v!2)
  (rs,es) = U.splitAt r (U.drop 3 v)
  !tbl = wf n m es
  getw i j = tbl!((i-1)*n+j-1)
  plen p = sum $ zipWith getw p (tail p)

wf n m es = runST $ do
  tbl <- UM.replicate (n^2) (maxBound `div` 4 :: Int)
  let
    ix i j = (i-1)*n+j-1
    putw i j w = UM.unsafeWrite tbl (ix i j) w
    getw i j = UM.unsafeRead tbl (ix i j)
  forM_ [0..m-1] $ \e -> do
    let (i,j,w) = (es!(3*e),es!(3*e+1),es!(3*e+2))
    putw i j w
    putw j i w
  forM_ [1..n] $ \i -> do
    putw i i 0
  forM_ [1..n] $ \k ->
    forM_ [1..n] $ \i ->
      forM_ [1..n] $ \j -> do
        a <- getw i k
        b <- getw k j
        p <- getw i j
        putw i j (min p (a+b))
  freeze tbl

Measured memory_bytes: 7524
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;


int n;
const int maxn = 2e5;
int a[maxn], x[maxn];

signed main()
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	int t = a[n - 1];
	for(int i = 0; i < n - 1; ++i){
		t = t + (i & 1 ? a[i] : -a[i]);
	}
	x[n - 1] = t;
	x[0] = 2 * a[n - 1] - x[n - 1];
	for(int i = 1; i < n - 1; ++i){
		x[i] = 2 * a[i - 1] - x[i - 1]; 
	}
	for(int i = 0; i < n; ++i){
		cout << x[i] << ' ';
	}


    
	return 0;
}

Measured memory_bytes: 2944
from itertools import permutations
from sys import setrecursionlimit
setrecursionlimit(1000000)

def doit(a, b, c, idx):
    if (a, b, c, idx) in memo:
        return memo[a, b, c, idx]
    if idx == len(unused):
        return abs(a - needA) + abs(b - needB) + abs(c - needC)
    memo[a, b, c, idx] = min(
        doit(a, b, c, idx + 1),
        doit(a + unused[idx], b, c, idx + 1) + 10,
        doit(a, b + unused[idx], c, idx + 1) + 10,
        doit(a, b, c + unused[idx], idx + 1) + 10
    )
    return memo[a, b, c, idx]

n, needA, needB, needC = map(int, input().split())
a = [int(input()) for _ in range(n)]
ret = float('inf')
for mask in range(1 << n):
    if bin(mask).count('1') != 3:
        continue
    abc = [a[i] for i in range(n) if (mask >> i) & 1]
    unused = [a[i] for i in range(n) if not (mask >> i) & 1]
    for p in permutations(abc):
        memo = {}
        ret = min(ret, doit(p[0], p[1], p[2], 0))
print(ret)

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

def Find(x, par, diff_weight):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    px = Find(par[x], par, diff_weight)
    diff_weight[x] += diff_weight[par[x]]
    par[x] = px
    return px

def Unite(x, y, par, rank, diff_weight, w):
  w += diff_weight[x] - diff_weight[y]
  x = Find(x, par, diff_weight)
  y = Find(y, par, diff_weight)
  
  if x != y:
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      x, y =  y, x
      w = -w
    if rank[x] == rank[y]:
        rank[x] += 1
    par[x] += par[y]
    par[y] = x
    diff_weight[y] = w

def Same(x, y, par, diff_weight):
  return Find(x, par,diff_weight) == Find(y, par, diff_weight)
 
def Size(x, par):
  return -par[Find(x)]

def Weight(x, par, diff_weight):
  Find(x, par, diff_weight)
  return diff_weight[x]

def Diff(x, y, par, diff_weight):
  return Weight(y, par, diff_weight)  - Weight(x, par, diff_weight)

par = [-1]*n
rank = [0]*n
diff_weight = [0]*n
for i in range(m):
  l, r, d = map(int, input().split())
  l, r = l-1 ,r-1
  if Same(l, r, par, diff_weight) == False:
    Unite(l, r, par, rank, diff_weight, d)
  else:
    if d != Diff(l, r, par, diff_weight):
      print('No')
      exit()
print('Yes')
  

Measured memory_bytes: 97496
#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>;

ll lower(ll m) {
    ll ans = 1;
    while ( ans * (ans+1) / 2 <= m) {
        ans++;
    }

    return ans-1;
}

bool isprime(ll p) {
    if (p == 1) return false;
    for (ll i = 2; i*i <= p; i++) {
        if (p % i == 0) {
            return false;
        }
    }
    return true;
}

map<ll,ll> factor(ll x) {
    map<ll,ll> fac;
    ll p = 2;
    while (p * p <= x) {
        if (x % p == 0) {
            fac[p]++;
            x /= p;
        } else {
            p++;
        }
    }
    if (isprime(x)) fac[x]++;

    return fac;
}

void solve() {
    ll n;
    cin >> n;

    ll ans = 0;
    map<ll,ll> fac = factor(n);
    for (auto it = fac.begin(); it != fac.end(); it++) {
        ans += lower(it->second);
    }

    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3656
<?php
    // define ('DEBUG', true);
    define ('DEBUG', false);

    fscanf(STDIN, "%d", $N);
    $x = trim(fgets(STDIN));
    if (DEBUG) echo $x . PHP_EOL;
    $A = explode(" ", $x);
    if (DEBUG) echo $N . PHP_EOL;
    // if (DEBUG) var_dump($A);

    $total = array_sum($A);
    if (DEBUG) echo "total:{$total}\n";
    $one = (1 + $N) * $N / 2;
    if (DEBUG) echo "one:{$one}\n";
    $round = $total / $one;
    $round_x = $round;
    if (floor($round) != $round) {
        echo "NO\n";
        exit;
    }

    $A[] = $A[0];
    for ($i = 0; $i < $N; $i++) {
        $diff = $A[$i+1] - $A[$i] - $round;
        if (DEBUG) echo $diff . PHP_EOL;
        if ($diff >= 0) {
            if (DEBUG) echo "o";
        } else {
            if (DEBUG) echo "x {$diff}\n";
            $kaisuu = $diff / $N;
            $round_x += $kaisuu;
            if (DEBUG) echo "kaisuu:{$kaisuu}\n";
        }
    }
    // var_dump($A);

    if ($round_x == 0) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }



Measured memory_bytes: 10868
N, A, B, C, D = list(map(int, input().split()))
S = input()

DS = False
TD = False
nd = 0
ns = 0
if A + 1 == B:
    nd = 1
for x in range(A+1, max(C, D)+1):
    s = S[x-1]
    if s == '.':
        if B - 1 <= x <= D + 1:
            nd = nd + 1
        ns = 0
    else:
        nd = 0
        ns = ns + 1
    if A <= x <= C or B <= x <= D:
        if ns >= 2:
            DS = True
    if B <= x <= D + 1:
        if nd >= 3:
            TD = True

if DS == True or (D < C and TD == False):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3572
import math
def main():
  N = int(input())
  ans = [0] * N
  for i in range(N-1):
    c, s, f = map(int, input().split())
    for j in range(i + 1):
      ans[j] = f*max(math.ceil(ans[j]/f), math.ceil(s/f))+c
  for i in range(N):
    print(ans[i])
if __name__ == "__main__":
  main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int N,a,b=0;
    ll s=0;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> a;
        if (a-b>0) s+=a-b;
        b=a;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
hhh = list(map(int, input().split()))

dp = [None] * N
dp[0] = 0
dp[1] = abs(hhh[1]-hhh[0])

for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(hhh[i]-hhh[i-1]), dp[i-2]+abs(hhh[i]-hhh[i-2]))

print(dp[N-1])

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int n;
		cin >> n;
		mi mp;
		rep(i,1,n-1)
		{
			int x;
			cin >> x;
			mp[x]++;
		}
		rep(i,1,n)
		{
			cout << mp[i] << endl;
		}
	}
}


Measured memory_bytes: 16168
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  int n,a;
  cin >> n >> a;
  if((n% 500) <= a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	string s;
	cin>>s;
	if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

    return 0;
}



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

int main(){
  int a,b;
  cin>>a>>b;
  if (a==b){
    cout<<"Draw"<<endl;
  }
  else if(a==1) cout<<"Alice"<<endl;
  else if(b==1 || b>a) cout<<"Bob"<<endl;
  else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


ll cnt = 1;

ll cnt_to_2(ll n) {
	if (n == 1) {
		return cnt;
	}
	cnt++;
	n /= 2;
	return cnt_to_2(n);

}

int main() {
	
	ll h;
	cin >> h;

	ll ans = cnt_to_2(h);
	ll sum = 0;
	for (int i = 0; i < ans; ++i) {
		sum += pow(2, i);
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
ab = []
3.times do
  ab.push gets.split.map(&:to_i)
end
h = Array.new(4) { 0 }
ab.each do |e|
  h[e.first - 1] += 1
  h[e.last - 1] += 1
end
puts h.sort == [1,1,2,2] ? 'YES' : 'NO'


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] n = new int[3];
		for(int i = 0; i < 3; i++) {
			n[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			for(int j = i+1; j < 3; j++) {
				if(n[j] < n[i]) {
					int tmp = n[i];
					n[i] = n[j];
					n[j] = tmp;
				}
			}
		}

		String d = String.valueOf(n[2])+String.valueOf(n[1]);
		int ans = Integer.parseInt(d)+n[0];
		System.out.println(ans);
	}
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), ans(n);
    rep (i, n) {
        cin >> a[i];
        a[i] *= 2;
    }
    ll sum = 0;
    rep (i, n) {
        if (i % 2) sum -= a[i];
        else sum += a[i];
    }
    
    ans[0] = sum / 2;
    FOR (i, 1, n) {
        ans[i] = 2 * (a[i - 1] / 2 - ans[i - 1] / 2);
    }
    rep (i, n) {
        if (i < n - 1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 2176
N, K = map(int, input().split())

lst = []
def kakuritu(val, base):
    num = 1
    while base >= val:
        val = val * 2
        num = num / 2
    num2 = (1/N) * num
    lst.append(num2)

n = 1
while n <= N:
    kakuritu(n, K-1)
    n = n + 1
ans = sum(lst)
print(ans)

Measured memory_bytes: 6296
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int a,b,c;
    cin >> a >> b >> c;
    if(c>=a&&b>=c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(' ')))

def swap(a, b):
    return b, a

ok = 0
f = 1
for i in range(n):
    if a[i] - 1 != i:
        f = 0
if f:
    ok = 1
for i in range(n):
    for j in range(i + 1, n):
        a[i], a[j] = swap(a[i], a[j])
        f = 1
        for k in range(n):
            if a[k] - 1 != k:
                f = 0
        if f:
            ok = 1
        a[i], a[j] = swap(a[i], a[j])
print('YES' if ok else 'NO')

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
# define M_PIl        3.141592653589793238462643383279502884
using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
  ll x,n;
  cin >> x >> n;
  set<ll> s;
  for(ll i=0;i<=101;i++){
    s.insert(i);
  }
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    s.erase(a);
  }
  auto it = s.lower_bound(x);
  auto it1= s.lower_bound(x);
  it1--;
  if(*it==x){
    cout << x;
  }
  else{
    if((*it-x)>=(x-*it1)){
      cout << *it1;
    }
    else{
      cout << *it;
    }
  }
}

Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<cstdint>
#include<alloca.h>

int64_t const MOD = 1e9+7;
std::string L;
int64_t const tbl[] = {1, 3, 5, 9, 11, 15, 19, 27, 29, 33, 37, 45, 49, 57, 65, 81};

int to_num(int k, char const* p) {
  int res = 0;
  while(--k>=0) { res = res*2 + (*p++ - '0'); }
  return res;
}

bool is_zero(int k, char const* p) {
  while(--k>=0) if(*p++ != '0') return false;
  return true;
}

void minus1(int k, char const* p, char *o) {
  int i = k-1;
  for(; i >= 0; --i) {
    if(p[i] == '0') o[i] = '1';
    else {
      o[i] = '0';
      --i;
      break;
    }
  }
  for(; i >= 0; --i) o[i] = p[i];
}

int64_t full(int k) {
  int64_t res = 1;
  while(--k>=0) (res *= 3) %= MOD;
  return res;
}

int64_t count_bits_pow2(int k, char const*p) {
  int64_t res = 1;
  while(--k>=0) if(*p++ != '0') (res *= 2) %= MOD;
  return res;
}

int64_t calc(int k, char const* p) {
  if(k <= 4) return tbl[to_num(k, p)];
  int l = k/2, r = k - l;
  if(is_zero(l, p)) return calc(r, p+l);
  char *p1 = (char*)alloca(l);
  minus1(l, p, p1);
  int64_t resL = calc(l, p1)*full(r)%MOD;
  int64_t resR = count_bits_pow2(l, p)*calc(r, p+l)%MOD;
  return (resL+resR)%MOD;
}

int main() {
  std::cin >> L;
  std::cout << calc(L.size(), L.c_str()) << std::endl;
  return 0;
}


Measured memory_bytes: 512
#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>;

void Main()
{
  string s,t; cin >> s;
  cin >> t;
  int cnt = 0;
  rep(i, s.size()) {
    if (s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 3752
#include<stdio.h>
#include<string.h>
#define ll long long

int main() {
	char S[11];
	scanf("%s", S);
	int p = strlen(S) - 1;
	ll ans = 0;
	for (int i = 0; i < 1 << p; i++)
	{
		ll sum = S[0] - '0';
		for (int j = 0; j < p; j++)
		{
			if (i >> j & 1) {
				ans += sum;
				sum = S[j + 1] - '0';
			}
			else {
				sum = sum * 10 + S[j + 1] - '0';
			}
		}
		ans += sum;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

A.sort()

def check(sz):
    # print("check:", sz)
    skp = False
    cannot_eat = False
    check = sz
    for i in A:
        if skp == False and sz == i:
            skp = True
            continue

        if i > check * 2:
            cannot_eat = True
            break
        else:
            check += i
    # print("result:", cannot_eat)
    return not cannot_eat

ok = N
ng = -1


while abs(ok-ng)>1:
    mid = (ok+ng)//2

    if check(A[mid]):
        # ok
        ok = mid
    else:
        # ng
        ng = mid
    
    # print(ok, ng)

print(N-ok)

Measured memory_bytes: 85572
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W, n;
    cin >> H >> W >> n;
    vector<pair<ll, ll> > loc;
    for (int i = 0; i < n; ++i) {
        ll aa, bb;
        cin >> aa >> bb;
        for (int j = 1; j <= 3; ++j) {
            for (int k = 1; k <= 3; ++k) {
                ll h = aa - j;
                ll w = bb - k;
                if (h < 0 || H <= h + 2 ||
                    w < 0 || W <= w + 2) continue;
                loc.push_back(make_pair(h, w));
            }
        }
    }    
    sort(loc.begin(), loc.end());
    
    ll count[10];
    memset(count, 0, sizeof(ll) * 10);
    count[0] = (H - 2) * (W - 2);
    if (loc.size() > 0) {
        ll ph = loc[0].first;
        ll pw = loc[0].second;
        int t = 1;
        for (int i = 1; i < loc.size(); ++i) {
            ll h = loc[i].first;
            ll w = loc[i].second;
            if (ph == h && pw == w) {
                t++;
            } else {
                count[0]--;
                count[t]++;
                t = 1;
                ph = h;
                pw = w;
            }
        }
        count[0]--;
        count[t]++;
    }

    for (int i = 0; i < 10; ++i) {
        cout << count[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 16744
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (long n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void printArray(int[] a) {
		for(int i=0;i<a.length-1;i++) {
		System.out.print(a[i]+" ");
		}
		System.out.println(a[a.length-1]);
	}
	public static void main(String[] args) {
		String str=scan.next();
		long b=scan.nextLong();
		if(str.length()==1) {
			System.out.println(b/2);
			return;
		}
		if(str.length()==2) {
			if(str.charAt(0)==str.charAt(1)) {
				System.out.println(b);
			}
			else {
				System.out.println(0);
			}
			return;
		}
		long cnt=1;
		long ans=0;
		long sum=0;
		String fir="";
		fir+=str.charAt(0);
		str=str.substring(1,str.length());
		for(int i=0;i<str.length();) {
			if(str.charAt(0)==fir.charAt(fir.length()-1)) {
				fir+=str.charAt(0);
				str=str.substring(1,str.length());
			}
			else {
				break;
			}
		}
		String las="";
		if(str.length()>0) {
		las+=str.charAt(str.length()-1);
		str=str.substring(0,str.length()-1);
		}
		for(int i=str.length()-1;i>=0;) {
			if(str.charAt(i)==las.charAt(0)) {
				las+=str.charAt(i);
				str=str.substring(0,str.length()-1);
				i--;
			}
			else {
				break;
			}
		}
		for(int i=1;i<str.length();i++) {
			char ch=str.charAt(i-1);
			char ch2=str.charAt(i);
			if(ch==ch2) {
				cnt++;
			}
			else {
				sum+=cnt/2;
				cnt=1;
			}
		}
		sum+=cnt/2;
		ans+=sum*b;
		if(las.length()>0) {
			if(fir.charAt(0)==las.charAt(0)) {
			long uouo=0;
			uouo+=fir.length()/2;
			uouo+=las.length()/2;
			uouo+=(fir.length()+las.length())/2*(b-1);
			ans+=uouo;
		}
		else {
			long uouo=0;
			uouo+=fir.length()/2*b;
			uouo+=las.length()/2*b;
			ans+=uouo;
		}
		}
		else {
			ans+=fir.length()*b/2;
		}
		System.out.println(ans);
	}
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<double> v(n);
  rep(i, n) cin >> v[i];
  rep(i, n-1) {
    sort(ALL(v));
    int m = v.size();
    vector<double> new_vec;
    rep(i, m-2) new_vec.push_back(v[i+2]);
    new_vec.push_back((v[0]+v[1])/2);
    v = new_vec;
  }
  printf("%0.10f\n", v[0]);
}

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

int main(){
  int n, max=1, x[]={2,4,8,16,32,64};
  cin>>n;
  for(int i=0;i<6;i++){
    if(x[i]<=n&&max<x[i]) max=x[i];
  }
  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 256
A = 3.times.map{gets.split.map(&:to_i)}
N = gets.to_i
B = N.times.map{gets.to_i}

A.each_with_index do |a,i|
    a.each_with_index do |n,j|
        A[i][j] = 101 if B.include?(n)
    end
end

A.each do |a|
    if a.inject(:+) == 303
        puts "Yes"
        exit
    end
end

3.times do |i|
    if A[0][i] +   A[1][i] +   A[2][i] == 303
        puts "Yes"
        exit
    end
end

if A[0][0] + A[1][1] + A[2][2] == 303
    puts "Yes"
    exit
end

if A[0][2] + A[1][1] + A[2][0] == 303
    puts "Yes"
    exit
end

puts "No"

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

const int INF = 1e9;

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

	map<string, int> mp;
	int n;
	cin >> n;
	int max_votes = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
		max_votes = max(mp[s], max_votes);
	}
	vector<string> bests;
	for (auto const& x : mp) {
		if (x.second == max_votes)
			bests.push_back(x.first);
	}
	sort(bests.begin(), bests.end());
	for (string s : bests)
		cout << s << endl;
	return 0;
}

Measured memory_bytes: 27260
#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<char> s(n); rep(i,n) cin>>s[i];
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());
  cout<<(s.size()==3?"Three":"Four");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int N;
  cin>>N;
  vector<ll> a(N);
  rep(i,N)cin>>a[i];
  sort(a.rbegin(),a.rend());

  ll ans=0;
  ans+=a[0];
  int idx=1;
  bool f=false;
  for(int i=2;i<N;i++){
    if(f){
      ans+=a[idx];
      idx++;
      f^=true;
    }else{
      ans+=a[idx];
      f^=true;
    }
    //cout<<ans<<" "<<idx<<endl;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0;i < n;i++)cin >> h[i];
    sort(h.begin(),h.end(),greater<int>());
    int ans = 0;
    while(h[ans] >= k){
        ans++;
    }
    cout << ans << endl;
    //cin >> n;
    
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    public class UnionFind
    {
        int[] par;
        int[] size;

        public UnionFind(int N)
        {
            par = new int[N];
            size = new int[N];
            for (int i = 0; i < N; i++)
            {
                par[i] = i;
                size[i] = 1;
            }
        }

        public int Root(int x)
        {
            if (par[x] == x) return x;
            return par[x] = Root(par[x]);
        }

        public void Unite(int x, int y)
        {
            int rootX = Root(x);
            int rootY = Root(y);
            if (rootX == rootY) return;
            par[rootX] = rootY;
            size[rootY] += size[rootX];
        }

        public bool Same(int x, int y)
        {
            int rootX = Root(x);
            int rootY = Root(y);
            return rootX == rootY;
        }

        public int Size(int x)
        {
            return size[Root(x)];
        }
    }

    public class Bridge
    {
        public int A;
        public int B;

        public Bridge(int a, int b)
        {
            A = a;
            B = b;
        }
    }

    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            List<Bridge> l = new List<Bridge>();
            for (int i = 0; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');
                l.Add(new Bridge(int.Parse(s[0]), int.Parse(s[1])));
            }

            long lastNum = (long)N * (long)(N - 1) / 2;
            List<long> reslist = new List<long>();
            reslist.Add(lastNum);

            UnionFind uf = new UnionFind(N + 1);

            for (int i = M - 1; i > 0; i--)
            {
                int anum = uf.Size(l[i].A), bnum = uf.Size(l[i].B);
                lastNum = (uf.Same(l[i].A, l[i].B))? lastNum:
                    lastNum - (long)anum * (long)bnum;
                uf.Unite(l[i].A, l[i].B);
                reslist.Add(lastNum);
            }

            for(int i = reslist.Count - 1; i >= 0; i--)
            {
                Console.WriteLine(reslist[i]);
            }
        }
    }
}

Measured memory_bytes: 26436
s = gets().strip!

n0 = 0
n1 = 1
r0 = 0
r1 = 0

(0 ... s.length).each{|i|
	si = s[i].to_i

	r0 += 1 if si != n0
	r1 += 1 if si != n1

	n0 = 1 - n0
	n1 = 1 - n1
}

puts [r0, r1].min


Measured memory_bytes: 1916
#include<stdio.h>

int main(){
  int i=0,j=0,n=0,count=0,temp;
  int minj;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
        minj=j;
      }
    }
    if(i!=minj){
    temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
    count++;
    }

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



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B, Q;
  cin >> A >> B >> Q;
  llvec s(A), t(B), x(Q);
  rep(i, A) cin >> s[i];
  rep(i, B) cin >> t[i];
  rep(i, Q) cin >> x[i];

  rep(i, Q){
    ll tmp = 1e18;
    ll sind = (lower_bound(ALL(s), x[i]) - s.begin());
    ll tind = (lower_bound(ALL(t), x[i]) - t.begin());
    if(sind!=0 and tind!=B){
      tmp = min(tmp, x[i] - 2*s[sind-1]+t[tind]);
      tmp = min(tmp, -x[i] - s[sind-1]+2*t[tind]);
    }
    if(sind!=A and tind!=0){
      tmp = min(tmp, x[i] + s[sind] - 2*t[tind-1]);
      tmp = min(tmp, - x[i] + 2*s[sind] -t[tind-1]);
    }
    if(sind!=0 and tind!=0){
      tmp = min(tmp, max(x[i] - s[sind-1], x[i] - t[tind-1]));
    }
    if(sind!=A and tind!=B){
      tmp = min(tmp, max(s[sind] - x[i], t[tind] - x[i]));
    }
    cout << tmp << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3712
import sys
input=sys.stdin.readline

Xs,Ys,Xg,Yg=map(int,input().split())
N=int(input())
L=[]
L.append([Xs,Ys,0])
for i in range(N):
    x,y,r=map(int,input().split())
    L.append([x,y,r])
L.append([Xg,Yg,0])
cost=[[-1 for i in range(N+2)]for j in range(N+2)]
for i in range(N+2):
    for j in range(i,N+2):
        cost[i][j]=max(0,((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2)**0.5-L[i][2]-L[j][2])
        cost[j][i]=cost[i][j]
#print(cost)


def jdijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

#print(jdijkstra(0,N+2,(N+2)**2,cost))
ans=jdijkstra(0,N+2,(N+2)**2,cost)
print(ans[-1])


Measured memory_bytes: 85980
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N];
int a , b;
vector < int > v[N];
int col[N];
int path[N];
int siz;
int subtree[N];
int dfs(int node , int parent){
	path[++siz] = node;
	bool res = (node == n);
	subtree[node] = 1;
	for(int next : v[node]){
		if(next != parent){
			res |= dfs(next , node);
			subtree[node] += subtree[next];
		}
	}
	if(!res){
		--siz;
	}
	return res;
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i < n ; ++i){
		scanf("%d %d" , &a , &b);
		v[a].emplace_back(b);
		v[b].emplace_back(a);
	}
	dfs(1 , 0);
	int l = 1;
	int r = siz;
	while(l <= r){
		col[path[l++]] = 1;
		if(l <= r){
			col[path[r--]] = 2;
		}
	}
	if(n > 2 * subtree[path[r + 1]]){
		printf("Fennec\n");
	}
	else{
		printf("Snuke\n");
	}
}

Measured memory_bytes: 14720