akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        queue<int> que;
        long long employeeSales[4001] = {};
        for (int i = 0; i < n; i++) {
            int employee, price, num;
            cin >> employee >> price >> num;
            employeeSales[employee] += (long long) price * num;
            que.push(employee);
        }
        bool NAFlag = true;
        while (!que.empty()) {
            int i = que.front();
            que.pop();
            if (employeeSales[i] >= 1000000) {
                cout << i << endl;
                employeeSales[i] = -1;
                NAFlag = false;
            }
        }
        if (NAFlag) {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    sort(a.begin(), a.end());
    bool ans = false;
    rep(i, n-1){
        if (a[i] == a[i+1]) {ans = true; break;}
    }
    if (ans) puts("NO");
    else puts("YES");
}


Measured memory_bytes: 1400
#include <stdio.h>
 
int main(void)
{
    float xs[2], ys[2], eqs[2];
    float x, y;
 
    while (~scanf("%f %f %f %f %f %f", xs, ys, eqs, xs + 1, ys + 1, eqs + 1)){
        x = (eqs[0] * ys[1] - eqs[1] * ys[0]) / (xs[0] * ys[1] - xs[1] * ys[0]);
        y = (eqs[1] * xs[0] - eqs[0] * xs[1]) / (xs[0] * ys[1] - xs[1] * ys[0]);
 
        if (x == 0.0) x = 0.0;
        if (y == 0.0) y = 0.0;

        printf("%.3f %.3f\n", x, y);
    }
 
    return (0);
}

Measured memory_bytes: 648
#include<stdio.h>

int main()
{
	int n, a, b;
	scanf("%d", &n);
	if (n == 1)
		printf("Hello World\n");
	else
	{
		scanf("%d%d", &a, &b);
		printf("%d\n", a + b);
	}

	return 0;
}

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

//#include "atcoder/all"
//using namespace atcoder;

ll V[3005][3005];
ll dp[3005][3005][4];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	rep(i,k){
		int r, c;
		ll v;
		cin >> r >> c >> v;
		--r; --c;
		V[r][c] += v;
	}
	rep(i,h){
		rep(j,w){
			rep(l,4){
				chmax(dp[i+1][j][0], dp[i][j][l]);
				if(l < 3) chmax(dp[i+1][j][0], dp[i][j][l] + V[i][j]);
				chmax(dp[i][j+1][l], dp[i][j][l]);
				if(l < 3) chmax(dp[i][j+1][l+1], dp[i][j][l] + V[i][j]);
			}
		}
	}
	ll ans = 0;
	rep(l,3) chmax(ans, dp[h-1][w-1][l] + V[h-1][w-1]);
	chmax(ans, dp[h-1][w-1][3]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 355856
n, q = list(map(int, input().split()))
s = input()
ran = [list(map(int, input().split())) for i in range(q) ]

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

for l, r in ran:
    print(table[r-1]  - table[l - 1] )


Measured memory_bytes: 30660
# 貪欲法 + 山登り法 + スワップ操作
import time
s__ = time.time()
limit = 1.9
#limit = 10

from numba import njit
import numpy as np

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26, dtype=np.int64)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dv = cs * ((i+1) - ls)
        s -= dv.sum()
    return s

@njit('i8[:]()', cache=True)
def greedy():
    ts = np.array([0] * d, dtype=np.int64)
    for i in range(d):
        mx = -1e10
        mxt = None
        for t in range(1, 26+1):
            ts[i] = t
            s = total_satisfaction(ts, i + 1)
            if s > mx:
                mx = s
                mxt = t
        ts[i] = mxt
    return ts

@njit('i8(i8, i8[:])', cache=True)
def loop(mxsc, ts):
    it = 50
    rds = np.random.randint(0, 4, (it,))
    rdd = np.random.randint(1, d, (it,))
    rdq = np.random.randint(1, 26, (it,))
    rdx = np.random.randint(1, 12, (it,))
    for i in range(it):
        bk1 = 0
        bk2 = 0
        if rds[0] == 0:
            # trailing
            di = rdd[i]
            qi = rdq[i]

            bk1 = ts[di]
            ts[di] = qi
        else:
            # swap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = xi + xi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            ts[di] = bk2
            ts[xi] = bk1

        sc = total_satisfaction(ts, d)

        if sc > mxsc:
            #print(mxsc, '->', sc)
            mxsc = sc
        else:
            # 最大値を更新しなかったら戻す
            if rds[0] == 0:
                ts[di] = bk1
            else:
                ts[di] = bk1
                ts[xi] = bk2

    return mxsc

ts = greedy()
mxsc = total_satisfaction(ts, d)
mxbk = mxsc

s_ = time.time()
mxsc = loop(mxsc, ts)
e_ = time.time()

consume = s_ - s__
elapsed = e_ - s_
#print('consume:', consume)
#print('elapsed:', elapsed)

if consume < limit:
    lp = int((limit - consume)/ elapsed)
    #print('loop', lp)
    for _ in range(lp):
        mxsc = loop(mxsc, ts)

for t in ts:    print(t)
#print(mxbk, mxsc)
#print(time.time() - s__)


Measured memory_bytes: 123280
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    char table['Z']['Z'];
    table['H']['H'] = 'H';
    table['H']['D'] = 'D';
    table['D']['H'] = 'D';
    table['D']['D'] = 'H';

    int a, b;

    scanf("%c %c", &a, &b);

    OUT(table[a][b]);

    return 0;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const ll MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値


//グローバル変数
vector<long long> fact, fact_inv, inv;

const int MAX_N = 5000;
 
long long Com[MAX_N][MAX_N];
 
/* init_nCk:二項係数のための前処理
    計算量:O(MAX_N*MAX_N)
*/
void init_nCk() {
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_N; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_N; j++) {
            Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]);
        }
    }
}
 
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return Com[n][k];
}

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    vector<ll> v(N);
    REP(i,N) cin>>v[i];
    ll cnt=0;
    sort(v.begin(),v.end(),greater<ll>());

    long double ans=0.0;
    ll start_pos;
    REP(i,N){
        if(i<A) ans+=(v[i]);
        if(v[i]==v[A-1]){
            if(cnt==0) start_pos=i;
            cnt++;
        }
    }

    init_nCk();

    ll tmp=0;

    if(start_pos==0){
        REP2(i,A,min(cnt,B)+1){
            tmp+=nCk(cnt,i);
        }
    }else{
        tmp+=nCk(cnt,A-start_pos);
    }
    
    

    ans/=A;
    cout.precision(20);
    cout<<fixed<<ans<<endl;
    cout<<tmp<<endl;
    
}

Measured memory_bytes: 195712
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;

template <typename T>
void read(T &x)
{
    static char ch;
    for (ch = getchar(); !isdigit(ch); ch = getchar()) ;
    for (x = 0; isdigit(ch); ch = getchar())
        x = (x<<3)+(x<<1)+ch-'0';
}

int main()
{
    int a[3];
    for (int i = 0; i < 3; ++i) read(a[i]);
    sort(a, a+3);
    if (a[0] == a[1] && a[0] == 5 && a[2] == 7)
    {
        puts("YES");
    }
    else
        puts("NO");
}


Measured memory_bytes: 256
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
while True:
    M,F,R = map(int,input().split())
    if M == -1 and F == -1 and R == -1:
        break
    if M == -1 or F == -1:
        print("F")
    elif M+F >= 80:
        print("A")
    elif M+F >= 65:
        print("B")
    elif M+F >= 50:
        print("C")
    elif M+F >= 30:
        if R >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5604
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    a = [int(x) for x in input().split()]
    e = defaultdict(int)
    o = defaultdict(int)
    for i in range(n):
        if i % 2:
            e[a[i]] += 1
        else:
            o[a[i]] += 1
    ee = n // 2
    oo = n // 2 + 1
    x = [(e[el], el) for el in e] + [(0, 0)]
    y = [(o[el], el) for el in o] + [(0, 0)]
    x.sort(reverse=True)
    y.sort(reverse=True)
    ans = n
    if x[0][1] == y[0][1]:
        ans = min(ans, n - x[0][0] - y[1][0])
        ans = min(ans, n - x[1][0] - y[0][0])
    else:
        ans = n - x[0][0] - y[0][0]
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


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

int board[10][10];

void fill(int x, int y){
	if(0<=x && x<10 && 0<=y && y<10){
		board[y][x]++;
	}
}

int main(){
	int x, y, size;
	while(~scanf("%d,%d,%d", &x, &y, &size)){
		if(size >= 1){ // small
			fill(x, y);
			fill(x+1, y);
			fill(x-1, y);
			fill(x, y+1);
			fill(x, y-1);
		}
		if (size >= 2) { // medium
			fill(x+1, y+1);
			fill(x+1, y-1);
			fill(x-1, y+1);
			fill(x-1, y-1);
		}
		if(size >= 3){ // large
			fill(x+2, y);
			fill(x-2, y);
			fill(x, y+2);
			fill(x, y-2);
		}
	}
	int num_zero = 0;
	int deepest = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if(board[j][i] == 0){
				num_zero++;
			}
			if(deepest < board[j][i]){
				deepest = board[j][i];
			}
		}
	}
	cout << num_zero << endl;
	cout << deepest << endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x, y;
    vector<int> start(n+1, 1), dp(n+1, 0), from(n+1, 0);
    vector<vector<int>> to(n+1);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        x.push_back(a);
        y.push_back(b);
        from[b]++;
        to[a].push_back(b);
        if(start[b]){
            start[b] = 0;
        }
    }

    // rep2(i, 1, n+1){
    //     cout << from[i] << " ";
    // }
    // cout << endl;

    rep2(i, 1, n+1){
        if(start[i]){
            queue<int> q;
            q.push(i);
            while(!q.empty()){
                int top = q.front();
                q.pop();
                if(from[top]>1){
                    from[top]--;
                }else{
                    int len = to[top].size();
                    rep(j, len) { 
                        dp[to[top][j]] = max(dp[top] + 1, dp[to[top][j]]);
                        q.push(to[top][j]); 
                    }
                }
            }
        }
    }

    int maxim = 0;
    rep2(i, 1, n+1){
        maxim = max(maxim, dp[i]);
        // cout << dp[i] << " ";
    }
    // cout << endl;

    cout << maxim << endl;
    return 0;
}

Measured memory_bytes: 10732
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

string A; cin >> A;
int n = A.size();

VI cnt(26, 0);
for(char c: A) ++cnt[c - 'a'];

i64 ans = 1;

rep(i, 0, 26) rep(j, i+1, 26){
    ans += cnt[i] * cnt[j];
}


cout << ans << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 720
import java.util.*;
import java.text.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] arr = new char[h][w];
    int[][] d = new int[h][w];
    int[] dx = {1, 0, -1, 0};
    int[] dy = {0, 1, 0, -1};
    boolean[][] flag = new boolean[h][w];
    Queue<Pair> queue = new ArrayDeque<>();

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        for (int i=0; i<h; i++) {
            arr[i] = sc.next().toCharArray();
        }

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                d[i][j] = Integer.MAX_VALUE;
            }
        }

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (arr[i][j] == '#') {
                    d[i][j] = 0;
                    queue.add(new Pair(i, j));
                }
            }
        }

        bfs();

        int cnt = 0;
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (arr[i][j] == '#') continue;
                cnt = Math.max(cnt, d[i][j]);
//                System.out.println(d[i][j]);
            }
        }

        System.out.println(cnt);

    }

    void bfs() {
        while (!queue.isEmpty()) {
            Pair pair = queue.peek();
            int y = pair.y;
            int x = pair.x;
            flag[y][x] = true;
            for (int i=0; i<4; i++) {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if (ny<0 || h<=ny || nx<0 || w<=nx) continue;
                if (arr[ny][nx] == '#') continue;
                if (flag[ny][nx]) continue;
                d[ny][nx] = d[y][x] + 1;
                queue.add(new Pair(ny, nx));
                flag[ny][nx] = true;
            }
            queue.poll();
        }
    }

    class Pair {
        int y, x;

        public Pair(int y, int x) {
            this.y = y;
            this.x = x;
        }
    }



}

Measured memory_bytes: 89040
# coding: utf-8


def main():
    l, r = list(map(int, input().split(" ")))
    
    ans = 3000
    for i in range(l, r):
        for j in range(i+1, r+1):
            candidate = (i * j) % 2019
            if candidate < ans:
                ans = candidate
            if ans == 0:
                return ans
    return ans


print(main())
        



Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

char patterns[4][2] = {{'R', 'Y'}, {'B', 'G'}, {'Y', 'R'}, {'G', 'B'}};

signed main(){
    int h, w, d;
    cin >> h >> w >> d;

    map<int, map<int, char> > mp;
    reppp(i, 1-h, w-1){
        int p = ((i-(1-h))/d) % 4;
        reppp(j, 0, w+h-2){
            mp[i][j] = patterns[p][(j/d) % 2];
            //cout << mp[i][j];
        }
        //cout << endl;
    }

    repp(y, h){
        repp(x, w){
            cout << mp[x-y][x+y];
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
    
    int r,c;
    cin >> r >> c;
    int list[r+1][c+1];
    for ( int i = 0 ; i < r+1 ; i++ ){
        for ( int j = 0 ; j < c+1 ; j++ ){
            list[i][j] = 0;
        }
    }
    
    for ( int i = 0 ; i < r ; i++ ){
        for ( int j = 0 ; j < c ; j++ ){
            cin >> list[i][j];
        }
    }
    for ( int i = 0 ; i < r ; i++ ){
        for ( int j = 0 ; j < c ; j++ ){
            list[i][c] += list[i][j];
            list[r][j] += list[i][j];
            list[r][c] += list[i][j];
        }
    }
    for ( int i = 0 ; i < r+1 ; i++ ){
        for ( int j = 0 ; j < c+1; j++ ){
            cout << list[i][j] ;
            if ( j == c) break;
            cout << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Dice[] list = new Dice[n];
        
        for(int i = 0; i < n; i++) {
            list[i] = new Dice(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
        }
        
        for(int i = 0; i < n; i++) {
        	
            for(int j = i+1; j < n; j++) {
            	
                if(solve(list[i],list[j],0)) {
                    System.out.println("No");
                    return;
                }
            }
        }
        
        System.out.println("Yes");
    }
    
    public static boolean solve(Dice f, Dice dice,int count) {
    	
        if(dice.Top == f.Top && dice.S == f.S && dice.Bottom == f.Bottom && dice.E == f.E && dice.N == f.N && dice.W == f.W)
        	return true;
        
        if(count == 6) 
        	return false;
        
        Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnN();
        
        if(solve(f,tmp,count+1)) {
            return true;
        }
        
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        
        if(solve(f,tmp,count+1)) {
            return true;
        }
        
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnE();
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnW();
        
        if(solve(f,tmp,count+1)) {
            return true;
        }
          
        return false;
    } 
}
  
class Dice {
    int Top;
    int Bottom;
    int N;
    int S;
    int W;
    int E;
    
    Dice(int a, int b, int c, int d, int e, int f) {
        Top = a;
        S = b;
        E = c;
        W = d;
        N = e;
        Bottom = f;
    }
    
    public void TurnN() {
        int tmp = Top;
        Top = S;
        S = Bottom;
        Bottom = N;
        N = tmp;
    }
    
    public void TurnW() {
        int tmp = Top;
        Top = E;
        E = Bottom;
        Bottom = W;
        W = tmp;
    }
    
    public void TurnE() {
        int tmp = Top;
        Top = W;
        W = Bottom;
        Bottom = E;
        E = tmp;
    }
    
    public void TurnS() {
        int tmp = Top;
        Top = N;
        N = Bottom;
        Bottom = S;
        S = tmp;
    }
}



Measured memory_bytes: 93960
N, K = (int(x) for x in input().split())
h = [[input().split() for i in range(2)] for _ in range(K)]
a = [0] * (N+1)
a[0] = 1
for i in range(0, K):
    for j in range(0, int(h[i][0][0])):
        a[int(h[i][1][j])] = 1
print(a.count(0))

Measured memory_bytes: 9524
/**
 *   
 *   Date: 10 August 2019
 *   Time: 19:27:16
**/
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
map<string,ll> mp,mp1;
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n,d,d1,sum=0;
	string s1;
	cin>>n;
	string st[n+2];
	for(ll i=1;i<=n;i++)
	{
		cin>>s1;
		sort(s1.begin(),s1.end());
		mp[s1]+=1;
		st[i]=s1;
	}
	for(ll i=1;i<=n;i++)
	{
		if(mp1.find(st[i]) != mp1.end())
			continue;
		d=mp[st[i]];
		mp1[st[i]]++;
		d1=d*(d-1)/2;
		sum+=d1;

	}
	cout<<sum<<endl;

return 0;
}

Measured memory_bytes: 22912
#include<iostream>
#include<string>
using namespace std;
string a;
int a1,b,c,as;
int main()
{
    cin>>a;
    a1=a.size();
    for(int i=0; i<a1; i++)
	{
        if(b==c)
		{
            b++;
			if(a[i]=='p') as--;
        }
        else
		{
            c++;
            if(a[i]=='g') as++;
        }
    }
    cout<<as<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,fl[200005];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		if (x>y) swap(x,y);
		if (x==1) fl[y]|=1;
		if (y==n) fl[x]|=2;
		if (fl[x]==3||fl[y]==3)
			return puts("POSSIBLE"),0;
	}
	puts("IMPOSSIBLE");
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int N,M,num=0;
  scanf("%d%d",&N,&M);
  int s[N],c[M];
  int d[]={100,10,1};
  int digit[N];
  for (int i = 0; i < N; i++){digit[i]=-1;}
  
  if (M==0){
    switch (N)
    {
    case 1:
      num=0;
      break;
    case 2:
      num=10;
      break;
    case 3:
      num=100;
      break;
    default:
      break;
    }
  }else{
    for (int i = 0; i < M; i++)
    {
      scanf("%d%d",&s[i],&c[i]);
      if (digit[s[i]-1]==-1)
      {
        digit[s[i]-1]=c[i]*d[3-N+(s[i]-1)];
      }else if (digit[s[i]-1]/d[3-N+(s[i]-1)]!=c[i])
      {
        num=-1;
      }
    }

    if (num!=-1)
    {
      for (int i = 0; i < N; i++)
      {
        if (digit[i]!=-1)
        {
          num+=digit[i];
        }else if (N>1&&i==0&&digit[i]!=0){
          num+=d[3-N+i];
        }
      }
    }
  }

  if (N>1&&s[0]==1&&c[0]==0)
  {
    puts("-1");
  }else{
    printf("%d",num);
  }
  
  return 0;
}

Measured memory_bytes: 1700
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int a,b;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
		
	cin >> a >> b;
	
	cout << a*b-(a+b)+1 << '\n';
	
}


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

using namespace std;

int N, M;
int dim[50 + 10];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		dim[a]++;
		dim[b]++;
	}
	
	for (int i = 0; i < N; i++)cout << dim[i] << endl;

	return 0;
}

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

typedef long long LL;
const int M=405;
LL a[M];
LL dp[M][M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		a[i]+=a[i-1];
	memset(dp,0x3f,sizeof(dp));
	for(int i=1;i<=n;i++)
		dp[i][i]=0;
	for(int len=2;len<=n;len++)
		for(int l=1,r=l+len-1;r<=n;l++,r++)
		{
			for(int k=l;k<r;k++)
				dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]);
			dp[l][r]+=a[r]-a[l-1];
		}
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 1536
n=int(input())
e=[0 for i in range(n+1)]
for i in range(2,n+1):
  for j in range(2,i+1):
    if i==1:
      break
    while i%j==0:
      i//=j
      e[j]+=1

def num(k):
  ret=0
  for i in range(n):
    if e[i]>=k-1:
      ret += 1
  return ret
print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

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

int a,b;

int main()
{
	cin >> a >> b;
	for(int i=1;i<10000;i++)
	{
		if(i*8/100 == a && i/10 == b)
		{
			cout << i;
			return 0;	
		}	
	}	
	puts("-1");
	return 0;
} 

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

# define fr first
# define sc second
# define ll unsigned long long
# define mk make_pair
# define pb emplace_back
# define sz(s) (int)s.size()
# define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

int n, m, ans;
int x[N], y[N], z[N];

int main () {
    scanf("%d%d", &n, &m);
    for(int i = 1, l; i <= n; i++) {
        scanf("%d", &l);
        x[l]++;
        y[l % m]++;
    }
    for(int i = 1; i <= 100001; i++) {
        z[i % m] += x[i] / 2;
    }

    for(int i = 0; i <= m / 2; i++) {
        if(i == (m - i) % m) {
            ans += y[i] / 2;
            continue;
        }
        int o = (m - i) % m;
        ans += min(y[i], y[o]);
        if(y[i] > y[o]) {
            ans += min((y[i] - y[o]) / 2, z[i]);
        }
        else {
            ans += min((y[o] - y[i]) / 2, z[o]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;

bool op(Pll a, Pll b) {
    return a.second < b.second;
}

int main() {
    int N; cin >> N;
    vector<Pll> AB(N); for (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;
    if (N % 2 == 1) {
        ll lef, rig;
        sort(AB.begin(), AB.end(), less<Pll>());
        lef = AB[(N-1)/2].first;
        sort(AB.begin(), AB.end(), op);
        rig = AB[(N-1)/2].second;
        cout << rig - lef + 1 << endl;
    } else {
        ll lef1, rig1, lef2, rig2;
        sort(AB.begin(), AB.end(), less<Pll>());
        lef1 = AB[N/2-1].first;
        lef2 = AB[N/2].first;
        sort(AB.begin(), AB.end(), op);
        rig1 = AB[N/2].second;
        rig2 = AB[N/2-1].second;
        cout << (rig1 + rig2) - (lef1 + lef2) + 1 << endl;
    }
}

Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		Scanner in = new Scanner(System.in);
		
		int x = in.nextInt();
		
		if(x>= 400 && x<=599) {
			System.out.println(8);
		}
		else if(x>= 600 && x<=799) {
			System.out.println(7);
		}
		else if(x>= 800 && x<=999) {
			System.out.println(6);
		}
		else if(x>= 1000 && x<=1199) {
			System.out.println(5);
		}
		else if(x>= 1200 && x<=1399) {
			System.out.println(4);
		}
		else if(x>= 1400 && x<=1599) {
			System.out.println(3);
		}
		else if(x>= 1600 && x<=1799) {
			System.out.println(2);
		}
		else {
			System.out.println(1);
		}

	}

}


Measured memory_bytes: 26980
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;
int main(){
	int n,m; cin >> n >> m;
	if(n == 1 && m == 0){
		cout << 0 << endl;
		return 0;
	}
	vector<int> da(n,-1);
	bool ju = false;
	rip(i,m,0){
		int s,c;
		cin >> s >> c;
		s--;
		if(da[s] == -1 || da[s] == c){
			da[s] = c;
		}
		else{
			ju = true;
		}
	}
	if(ju){
		cout << -1 << endl;
		return 0;
	}
	if(n>1 && da[0] == 0){
		cout << -1 << endl;
		return 0;
	}
	int now = 1;
	int ans = 0;
	rip(i,n,0){
		ans*=10;
		if(da[i] >= 0) ans += da[i];
		else if(ans == 0) ans += 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if (c<b&&b<a) {
		printf("%d %d %d\n",c,b,a);
	} else if (c<a&&a<b) {
			printf("%d %d %d\n",c,a,b);
	} else if (b<a&&a<c) {
			printf("%d %d %d\n",b,a,c);
	} else if (b<c&&c<a) {
			printf("%d %d %d\n",b,c,a);
	} else if (a<c&&c<b) {
			printf("%d %d %d\n",a,c,b);
	} else if (a<b&&b<c) {
			printf("%d %d %d\n",a,b,c);
	} else if (a==b&&b<c) {
			printf("%d %d %d\n",a,b,c);
	} else if (b==c&&c<a) {
			printf("%d %d %d\n",b,c,a);
	} else if (a==c&&c<b) {
			printf("%d %d %d\n",a,c,b);
		} else {
			printf("%d %d %d\n",a,b,c);
		}
	return 0;
}

Measured memory_bytes: 596
// https://atcoder.jp/contests/agc025/tasks/agc025_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

const int MOD = 998244353;
const int SZ = 3e5;

template <int N, typename T, T M> struct factorial_mod {
    T mod[N + 1];
    T inv_mod[N + 1];

    constexpr factorial_mod() : mod(), inv_mod() {
        mod[0] = 1;
        for (int i = 0; i < N; ++i) {
            mod[i + 1] = (mod[i] * (i + 1)) % M;
        }
        inv_mod[N] = power(mod[N], M - 2);
        for (int i = N - 1; i >= 0; --i) {
            inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
        }
    }

    constexpr T power(T a, T b) {
        T r = 1;
        while (b > 0) {
            if ((b & 1) != 0)
                r = (r * a) % M;
            a = (a * a) % M;
            b >>= 1;
        }
        return r;
    }

    constexpr T permutation(T n, T r) { return (mod[n] * inv_mod[n - r]) % M; }
    constexpr T combination(T n, T r) {
        return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
    }
    constexpr T homogenious(T n, T r) {
        return (n == 0 and r == 0 ? 1 : combination(n + r - 1, r));
    }
};
factorial_mod<SZ, long long, MOD> facmod;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    for (int i = 0, j = n; i <= n && i * a <= k; i++) {
        while (i * a + j * b > k)
            j--;
        if (i * a + j * b == k) {
            ans += facmod.combination(n, i) * facmod.combination(n, j);
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8340
# -*- coding: utf-8 -*-
s = input()
flag = True
c = 0
if s[0] != "A":
    flag = False
else:
    s = list(s)
    s[0] = "a"
    s = "".join(s)
    for i in range(2, len(s)-1):
        if s[i] == "C":
            s = list(s)
            s[i] = "c"
            s = "".join(s)
            c += 1
    if c != 1:
        flag = False
    else:
        t = s.lower()
        if t != s:
            flag = False



if flag:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3064
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b = sc.nextInt(),k=sc.nextInt();
        Set<Integer> ans = new TreeSet<>();
        if(a+k>b||b-k<a){
            for(int i = a;i<=b;i++){
                System.out.println(i);
            }
        } else {
            for(Integer i = a;i<a+k;i++){
                ans.add(i);
            }
            for(Integer i = b;i>b-k;i--){
                ans.add(i);
            }
            for(Integer s :ans){
                System.out.println(s);
            }
        }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
char a[10];
int main()
{
	scanf("%s",a);
	switch(a[0])
	{
		case 'M':printf("6\n");break;
		case 'W':printf("4\n");break;
		case 'F':printf("2\n");break;
		default:break;
	}
	if(a[0]=='T')
	{
		if(a[1]=='U')printf("5\n");
		else printf("3\n");
	}
	else if(a[0]=='S')
	{
		if(a[1]=='A')printf("1\n");
		else printf("7\n");
	}
}
 

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

#include <stdio.h>

void quicksort(int a[], int left, int right, int b[])
{

	int p;	//中央値
	int L = left, R = right;		//ループ中で変化するleft、right
	int temp;
	p = a[(left + right) / 2];

	while (1)
	{
		while (a[L] < p) L++; while (a[R] > p)
			R--;
		
		if (L >= R)
			break;

		temp = a[R];
		a[R] = a[L];
		a[L] = temp;
    temp = b[R];
		b[R] = b[L];
		b[L] = temp;
		L++;
		R--;
	}

	if (left < L - 1) quicksort(a, left, L - 1, b); if (right > R + 1)
		quicksort(a, R + 1, right, b); 
	
}

int main(){
  int N;
  cin >> N;
  int a[N];
  int b[N];
  rep(i, N){
    cin >> a[i];
    b[i] = i+1;
  }
  quicksort(a, 0, N-1, b);
  rep(j, N){
    cout << b[j] << " ";
  }
  return 0;
}


Measured memory_bytes: 1536
import math

A, B, H, M = [int(a) for a in input().split()]
h_d = -2*math.pi/12
m_d = -2*math.pi/60

h_s = h_d*(H+M/60) + math.pi/2
m_s = m_d*M + math.pi/2

h_y = A*math.sin(h_s)
h_x = A*math.cos(h_s)
m_y = B*math.sin(m_s)
m_x = B*math.cos(m_s)

x = h_x - m_x
y = h_y - m_y

ans = math.sqrt(pow(x,2)+pow(y,2))
print("{:.20f}".format(ans))


Measured memory_bytes: 9576
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll MAX = 910000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 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;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
    ll N , M; cin >> N >> M;
    if((N + M) % 3 != 0){
      cout << 0 << endl;
      return 0;
    }

    ll cnt = (N + M) / 3;

    ll ans = COM(cnt , M - cnt);
    cout << ans << endl;

}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> A(h);//h行分の.#の入る箱を用意しておく。
  rep(i,h){
	  cin>>A[i];
	}
	//#のある行をとりあえずマークする
	vector<bool> B(h,false);
	vector<bool> C(w,false);
  rep(i,h){
	  string a=A[i];
	  rep(j,w){
	  if(a.at(j)=='#'){
		B[i]=true;
		C[j]=true;
		}
		}
	}
	
	//これでとりあえずマーキングはできた。
	rep(i,h){
		string b =A[i];
		bool k = false;
		rep(j,w){
		  char c =b.at(j);
		  if(B[i]&&C[j]){
			  cout << c ;
			  k =true;
			}
		  }
		  if(k){
		  cout<<endl;}
	  }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n,k;cin>>n>>k;
  ll ans=LLONG_MAX;
  if(n<k){
    ans=min(n,k-n);
  }else{
    ans=min(n%k,abs(n%k-k));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    string s,t;
    cin >> s >> t;
    int c1[30],c2[30];
    int len = s.length();
    for(int i = 0; i < 30; i++){
        c1[i] = c2[i] = 0;
    }
    for(int i = 0; i < len; i++){
        c1[s[i]-'a']++;
        c2[t[i]-'a']++;
    }

    sort(c1,c1+30); sort(c2,c2+30);

    for(int i = 0; i < 30; i++){
        if(c1[i] != c2[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n,k,cnt;
int a[200005];
int in,out;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  FOR(i,n){
    cin>>in;
    if(a[in]==0) cnt++;
    a[in]++;
  }
  sort(a,a+n+1);

  int i=0,count=0;
  while(count<cnt-k){
    out+=a[i];
    if(a[i]>0) count++;
    i++;
  }
  cout<<out<<endl;
  return 0;
}



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


int main()
{
    vector<int> v;
    int N;
    cin >> N;
    int a;
    int m=1;
    int m2=1;
    rep(i, N){
        cin >> a;
        if (a > m & m > m2) m2 = m;
        if (a <= m & a > m2) m2 = a;
        if (a > m) m = a;
        v.push_back(a);
    }
    rep(i, N){
        if (v[i] == m) cout << m2 << endl;
        else cout << m << endl;
    }

    return 0;
}



Measured memory_bytes: 2548
from heapq import heappush,heappop
n,m = (int(i) for i in input().split())
a = [-int(i) for i in input().split()]
x = []
for i in a: heappush(x,i)
for i in range(m):
    p = heappop(x)+1
    heappush(x,p//2)
print(-sum(x))

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

int main()
{
    int N;
    cin >> N;

    if(N%10 == 2 or N%10 == 4 or N%10 == 5 or N%10 == 7 or N%10 == 9)
        cout << "hon";
    else if(N%10 == 3)
        cout << "bon";
    else
        cout << "pon";
}

Measured memory_bytes: 3636
n = int(input())
x = list(map(int, input().split()))

x.sort()

mean = sum(x)/n
med = int(n / 2)

if mean - int(mean) < 0.5:
    mean = int(mean)
elif mean - int(mean) > 0.5:
    mean = int(mean) + 1
else:
    if n % 2 == 0:
        if (x[med-1] + x[med])/2 <= mean:
            mean = int(mean)
        else:
            mean = int(mean) + 1
    else:
        if x[med] <= mean:
            mean = int(mean)
        else:
            mean = int(mean) + 1
sum = 0

for i in range(n):
    sum += (x[i]-mean)**2

print(sum)

Measured memory_bytes: 9224
#include <stdio.h>

int main(void)
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	if(a > b){
		x=a;
		a=b;
		b=x;
	}
	if(b > c){
		x=b;
		b=c;
		c=x;
	}
	if(a > b){
		x=a;
		a=b;
		b=x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;

}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			while(!(a <= b && b <= c)){ //ソートできるまでやる
				if(a > b) {
					a = a ^ b;
					b = a ^ b;
					a = a ^ b; //aとb入れ替え
				}
				if(b > c) {
					b = b ^ c;
					c = b ^ c;
					b = b ^ c; //bとc入れ替え
				}
			}
			System.out.println(a + " " + c);
		}
	}
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);

	string str;
	cin >> str;

	int result = 0;
	for (auto& c:str){
		if (c == 'g'){
			result++;
		}
		else{
			result--;
		}
	}

	cout << (result / 2);

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string k;
	cin>>k;
	int d;
	cin>>d;
	//dp[0][0]=1;
	vector< vector<int> >dp(d,vector<int>(2));
	dp[0][0]=1;
//	dp[0][1]=1;
	int n=k.length();
	for(int i=0;i<n;i++)
	{
	//	cout<<"s";
		vector< vector<int> >new_dp(d,vector<int>(2));
		for(int sum=0;sum<d;sum++)
		{
			//cout<<"x";
			for(bool j:{false,true})
			{
				for(int digit=0;digit<10;digit++)
				{
					if(digit>k[i]-'0'&& !j)
					{
						break;
					}
					new_dp[(sum+digit)%d][j||(digit< k[i]-'0')]=(new_dp[(sum+digit)%d][j||(digit< k[i]-'0')]+dp[sum][j])%mod;
				
				}
			}
		}
		dp=new_dp;
	}
	int ans=(dp[0][false]+dp[0][true])%mod;
	ans--;
	if(ans==-1)
	{ans=mod-1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3688
using System;
public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        var W = new int[n + 1];
        var E = new int[n + 1];
        var ans = n;
        W[0] = 0;
        E[0] = 0;
        
        for(var i = 1;i < n + 1;i++){
            if(s[i - 1] == 'W'){
                W[i] = W[i - 1] + 1;
                E[i] = E[i - 1];
            }else{
                W[i] = W[i - 1];
                E[i] = E[i - 1] + 1;
            }
        }
        
        for(int j = 1;j < n + 1;j++){
            ans = Math.Min(ans,W[j - 1] + E[n] - E[j]);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 14432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

int main(){
    int n;
    cin >> n;
    double x;
    string u;
    double ans = 0;
    rep(i, n){
        cin >> x >> u;
        if(u == "BTC") ans += x*380000.;
        else ans += x;
    }
    cout << fixed << setprecision(15) << ans << endl;

}



Measured memory_bytes: 256
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

string solve(int a, int b, int c, int d, char A, char B){
	string s = "";
	int n = a + b;
	int len = n / (b + 1);
	int l = 0, r = n / len + 1;
	while(l + 1 < r){
		int md = l + r >> 1;
		if(md * len + (b - md) / len <= a)
			l = md;
		else
			r = md;
	}
	int lf = l, rg = (b - lf) / len;
	a -= lf * len + rg;
	REP(i, c, d){
		if(i <= lf * (len + 1)){
			if(!(i % (len + 1)))
				s += B;
			else
				s += A;
		}
		else if((n + 1 - i) <= rg * (len + 1)){
			if(!((n + 1 - i) % (len + 1)))
				s += A;
			else
				s += B;
 		}
		else{
			if(i <= lf * (len + 1) + a)
				s += A;
			else
				s += B;
		}
	}
	return s;
}

int q, a, b, c, d;

int main(){
	for(scanf("%d", &q); q--;){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		string s = "";
		if(a == b){
			REP(i, c, d){
				if(i & 1)
					s += 'A';
				else
					s += 'B';
			}
		}
		else if(a > b)
			s = solve(a, b, c, d , 'A', 'B');
		else{
			s = solve(b, a, a + b - d + 1, a + b - c + 1, 'B', 'A');
			reverse(s.begin(), s.end());
		}
		printf("%s\n", s.c_str());
	}
	return 0;
}



Measured memory_bytes: 384