akhauriyash/Code-Regression huggingface dataset:
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

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

  if(N.size()==1){
    cout << N << endl;
    return 0;
  }

  int n_9=0;
  for(int i=1;i<N.size();++i){
    if(N.at(i)=='9') ++n_9;
  }

  if(n_9==N.size()-1){
    cout << 9*(N.size()-1)+stoi(N.substr(0,1)) << endl;
    return 0;
  }
  
  cout << (N.size()-1)*9+stoi(N.substr(0,1))-1 << endl;
  

  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin>>n;
	int i;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(x%2==0)
		{
			if(x%3==0)
			continue;
			if(x%5==0)
			continue;
			else
			{
			cout<<"DENIED"<<endl;
			return 0;
		}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 512
/*ex3_2
series2*/
 
# include <stdio.h>
int main(void){
      //各文字の箱を作って読み取り
    int pen;
    scanf("%d", &pen);
    //一のくらいは10で割った余りとして分類できる。
    if(pen%10==3){
        printf("bon\n");
    }else if(pen%10==0 ||pen%10==1||pen%10==6||pen%10==8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }
    return 0;
}


Measured memory_bytes: 1604
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) {
		// TODO 自動生成されたメソッド・スタブ
		String[] strArray1= {"a","b","c"};	//答え
		
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		// 文字を配列に格納
		String[] strArray = str.split("");
		
		l1: for(int i=0; i<3;i++) {
			l2: for(int j=0; j<3-i; j++) {
				//if(strArray[i] == strArray1[j]) {
				if(strArray[i].equals(strArray1[j])) {
					strArray1 = remove(strArray1,strArray[i]);
					break l2;
				}
				if(j==2-i) {
					System.out.println("No");
					break l1;
				}
			}
			if(i==2) {
				System.out.println("Yes");
			break l1;
			}
		}
		
		sc.close();

	}

	private static String[] remove(String[] target, String removeStr) {
	    List<String> temp = new ArrayList<>(Arrays.asList(target));
	    temp.remove(removeStr);
	    return temp.toArray(new String[0]);
	}
}

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

int main()
{
	int A1 = 0, A2 = 0, A3 = 0, A = 0;
	std::string ans;

	std::cin >> A1 >> A2 >> A3;

	A = A1 + A2 + A3;

	ans = (A >= 22) ? "bust" : "win";

	std::cout << ans << std::endl;

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,K;
    cin>>N>>K;
    vint A(N);
    rep(i,N)cin>>A[i];

    int ans=LLONG_MAX;
    rep(i,1<<N){
        vint v;
        rep(j,N)if(i>>j&1)v.pb(j);
        if(v.size()!=K)continue;
        int cost=0;
        int pre=-1;
        for(int j=0;j<v.size();j++){
            int ma=pre;
            for(int k=(j?v[j-1]:0);k<v[j];k++)chmax(ma,A[k]);
            cost+=max(0ll,ma-A[v[j]]+1);
            pre=max(ma+1,A[v[j]]);
        }
        chmin(ans,cost);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#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>;
int main(){
  int n=0;
  string s;
  cin >> s;
  if(s=="RRR" ) n=3;
 else if(s[0]=='R' && s[1]=='R') n=2;
 else if(s[1]=='R' && s[2]=='R') n=2;
  else if(s=="SSS") n=0;
  else n=1;
  
  cout << n <<endl;
    return 0;
}


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

#define MOD_1000000007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)

using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::map;
using std::pair;
using std::priority_queue;
using std::set;
using std::string;
using std::vector;
typedef long long ll;

int N, M;
priority_queue<pair<int, int>, vector<pair<int, int> >, std::greater<pair<int, int> > > tasks;
priority_queue<int> bs;

void solve() {
  int ans = 0;
  rep1c(i, M) {
    while(!tasks.empty() && tasks.top().first <= i) {
      bs.push(tasks.top().second);
      tasks.pop();
    }
    if(!bs.empty()) {
      ans += bs.top();
      bs.pop();
    }
  }
  printf("%d\n", ans);
}

int main() {
  scanf("%d %d", &N, &M);
  rep(i, N) {
    int a, b;
    scanf("%d %d", &a, &b);
    tasks.push(make_pair(a, b));
  }
  solve();
  return 0;
}

Measured memory_bytes: 1908
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int i;
        int sum;
        while (true) {
            str = br.readLine();
            if (str.equals("0")) break;
            sum = 0;
            for (i = 0; i < str.length(); i++) {
                sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
        }
    }
}





Measured memory_bytes: 24188
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	string S;
	cin >> S;

	vector<bool> v(26);
	for (int i = 0; i < S.size(); i++) {
		int n = (int)S.at(i) - 97;

		if (v.at(n)) {
			cout << "no" << endl;
			return 0;
		}
		else {
			v.at(n) = true;
		}
	}

	cout << "yes" << endl;
}

Measured memory_bytes: 3628
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto st = readln.split;
    auto S = st[0];
    auto T = st[1];
    auto ab = readln.split.to!(int[]);
    auto A = ab[0];
    auto B = ab[1];
    if (readln.chomp == S) {
        --A;
    } else {
        --B;
    }
    writefln("%d %d", A, B);
}

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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int n;
	cin>>n;
	long long int i;
	long long int a[n];
	long long int ans=0;
	long long int mod=1000000007;
	for(i=0;i<n;i++)
		cin>>a[i];
	long long int ps[n];
	ps[n-1]=0;
	for(i=n-2;i>=0;i--)
	{
		ps[i]=ps[i+1]+a[i+1];
		if(ps[i]>=mod)
			ps[i]-=mod;
	}
	for(i=0;i<n;i++)
	{
		ans+=ps[i]*a[i];
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6716
n = int(input())
cards = list(map(int,input().split()))
cnt = 0
flag = 1
while flag:
    flag = 0
    for j in range(n-1,0,-1):

        if cards[j] < cards[j-1]:
            a = cards[j]
            b = cards[j-1]
            cards[j] = b
            cards[j-1] = a
            cnt += 1
            flag = 1

print(*cards)
print(cnt)
# #
# for j in range(10,1,-1):
#      print(j)





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

int main(){
    int n;
    cin >> n;
    long long ans = 1e18;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<long long> acc(n + 1, 0);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
    for (int i = 1; i < n; i++) ans = min(ans, abs(acc.back() - acc[i] * 2));
    cout << ans << endl;
}

Measured memory_bytes: 3328
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
        int s = int.Parse(Console.ReadLine());

        List<int> a = new List<int>();
        a.Add(s);
        while (true)
        {
            if (s % 2 == 0)
            {
                s = s / 2;
            }
            else
            {
                s = 3 * s + 1;
            }

            if (a.Contains(s))
            {
                break;
            }
            else
            {
                a.Add(s);
            }
        }


        Console.WriteLine(a.Count + 1);
    }
}

Measured memory_bytes: 13144
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char str[20];
	while(cin>>str)
	{
		for(int i=0;i<19;i++)
		{
			if(i==5||i==13)
			cout<<' ';
			else
			cout<<str[i];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W,K; cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H) cin >> S[i];

    int ans = 0;
    rep(r,1<<H) {
        rep(c,1<<W) {
            int cnt = 0;
            rep(i,H) {
                if (r&(1<<i)) continue;
                rep(j,W) {
                    if (c&(1<<j)) continue;
                    if (S[i][j]=='#') cnt++;
                }
            }
            if (cnt==K) ans++;
        }
    }

    cout << ans << ln;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a[300005];
int main()
{
    int n;
    ll ans=0,ans2=0,ans3=0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld",&a[i]);
        a[i] = a[i] - i - 1;
    }
    sort(a,a+n);
    int zho = (a[(n-1)/2]+a[n/2])/2;
    for(int i = 0; i < n; i++)
        ans = ans + abs(a[i]-zho);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;

void solve(){
    string s, t;
    cin>>s>>t;
    int n = s.size();
    int nt = t.size();
    int ans = INT_MAX;
    for(int i=0;i<n-nt+1;i++){
        int cur =0 ;
        for(int j=i;j<i+nt;j++){
            if(s[j]!=t[j-i]) cur++;
        }
        ans = min(cur, ans);
    }
    cout<<ans<<endl;
}

int main(){
    io;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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


int main(){
                                                                     

    int h, w, i, j, nk;

    char c, ck;

    string s;


    cin >> h >> w;


    for( i = 1 ; i <= h ; i = i + 1 ){

         c = 'A';

         for( j = 1 ; j <= w ; j = j + 1 ){

              cin >> s;

              if( s == "snuke" ){

                  ck = c;

                  nk = i;

                  }

              c += 1;

              }
 
         }


    cout << ck << nk << endl;
    

    return 0;

    }

Measured memory_bytes: 256
/*---> 04 April 2020 <--- > 20:00:31 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2<<"\n";
return 0;
}

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

using namespace std;


int main()
{


/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/



	//const int INF = 1e9;
	long long  a, b, n;
	cin >> a >> b >> n;

	//floor(ax/b) - a*floor(x/b)

	long long sum = 0;

	long long ans = 0;

	long long x = min(b - 1, n);

	sum =  floor(a * x / b) - (a * floor(x / b));

	cout << sum;

}

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

int main() {

  int a,b;
  cin >> a >> b;
  
  rep(i,b) {
    int x;
    cin >> x;
    a -= x;
  }
  
  if(a >= 0) cout << a << endl;
  else cout << -1 << endl;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
char a[maxn];
int n,k,ans,ok;
int main()
{
	cin >> n >> k >> (a+1);
	int ans=1;
	for(int i=2;i<=n;i++)
	{
		if( a[i]==a[i-1] )	continue;
		else
			ans++;
	}
	cout << min(n-1,(n-ans)+k*2);
}

Measured memory_bytes: 3732
from collections import deque
from collections import defaultdict
k = int(input())
s =input()
# a = list(map(int, input().split()))
# n,m = map(int, input().split())
# b = [int(input()) for _ in range(n)]

l = len(s)

if l <=k:
    print(s)
else:
    print(s[0:k] + "...")


Measured memory_bytes: 9468
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val rs = (1..n).mapIndexed { index, i ->
        val (s, p) = readLine()!!.split(" ")
        Triple(index+1, s, p.toInt())
    }

    val sorted = rs.sortedBy { it.second }

    for (city in sorted.map { it.second }.distinct()) {
        sorted.filter { it.second == city }.sortedByDescending { it.third }.forEach {
            println(it.first)
        }
    }
}

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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr int INF = 1<<30;
constexpr ll MOD = (1e9)+7;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if(A+B > N+1 || A*B < N){
        cout << -1 << endl;
        return 0;
    }
    vector<ll> ans(N), num(N);
    vector<bool> used(N);
    int idx = 0;
    for(int i=0;i<A;i++){
        for(int j=0;j<B&&(idx+(A-1-i)<N);j++){
            num[idx++] = (B-1-j)*A+i;
        }
    }
    ans = num;
    map<ll,ll> mp;
    sort(num.begin(), num.end());
    for(int i=0;i<N;i++){
        mp[num[i]] = i+1;
    }
    for(int i=0;i<N;i++){
        cout << mp[ans[i]] << " \n"[i==N-1];
    }

    return 0;
}


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

int main(){
	string str1,str2;
	cin>>str1>>str2;
	int ans=0;
	if(str1[0]==str2[0]){
		ans++;
	}
	if(str1[1]==str2[1]){
		ans++;
	}
	if(str1[2]==str2[2]){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

long long n, w, a[101], b[101], p[4][101], mx, pp[4][101];
vector <long long> v[4];
int main(){
      cin >> n >> w;
      for(int i = 1;i <= n;i ++){
             cin >> a[i] >> b[i];
             v[a[i] - a[1]].push_back(b[i]);
      }
      sort(v[0].begin(), v[0].end(), greater <long long> ());
      sort(v[1].begin(), v[1].end(), greater <long long> ());
      sort(v[2].begin(), v[2].end(), greater <long long> ());
      sort(v[3].begin(), v[3].end(), greater <long long> ());

      for(int i = 0;i < 4;i ++)
            for(int j = 0;j < v[i].size();j ++)
                     p[i][j] = v[i][j] + ((j > 0)? p[i][j - 1] : 0),
                     pp[i][j] = (j+1) * (a[1]+i);

      for(int i = 0;i <= v[0].size();i ++)
             for(int j = 0;j <= v[1].size();j ++)
                    for(int k = 0;k <= v[2].size();k ++)
                           for(int h = 0;h <= v[3].size();h ++)
                                  if(pp[0][i] + pp[1][j] + pp[2][k] + pp[3][h] <= w)
                                         mx = max(mx, p[0][i] + p[1][j] + p[2][k] + p[3][h]);
     cout << mx << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n, i, j, k, l, cnt, m;
    while(1){
        if(scanf("%d", &n)==EOF) break;
        cnt = 0;
        for(i=0; i<10; i++){
            for(j=0; j<10; j++){
                for(k=0; k<10; k++){
                    for(l=0; l<10; l++){
                        m=i+j+k+l;
                        if(m==n) cnt++;
                    }
                }
            }
        }
    printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;




/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll mod1=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[1000001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
/*
const int N=100001;
ll fact_inverse[N];
ll num_inverse[N];
ll fact[N];
void number_inverse(int m){
   num_inverse[0]=1;
   num_inverse[1]=1;
   for(int i=2;i<=N;i++){
     num_inverse[i]=num_inverse[m%i]*(m - m/i)%m;
   }
}

void factorial_inverse(int m){
   fact_inverse[0]=1;
   fact_inverse[1]=1;
   for(int i=2;i<=N;i++){
      fact_inverse[i]=(num_inverse[i]*fact_inverse[i-1])%m;
   }
}

void factorial(int m){
  fact[0]=1;
  for(int i=1;i<=N;i++)fact[i]=(i*fact[i-1])%m;
}

int modular_nCr(int n,int r,int m){
   ll res=((fact[n]*fact_inverse[r])%m *  fact_inverse[n-r])%m;
   return res;
}
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       ll n;
       cin>>n;
       ll ans=0;
       for(ll i=1;i<=n-1;i++){
          ans+=(n-1)/i;
       }
       
       //int x=sqrt(n);
      // ans-=(x-1);
       cout<<ans<<endl;
 }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[11];
	long long ans=0;
	scanf("%s",s);
	int n=strlen(s);
	for(int mask=(1<<(n-1))-1; mask>=0; --mask){
		long long sum=0,plus=0;
		for(int i=0;i<n;++i){
			plus=10*plus+s[i]-'0';
			if((mask>>i)&1)sum+=plus,plus=0;
		}
		if((mask>>(n-1))^1)sum+=plus;
		ans+=sum;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    
    // ありえる全連結成分
    for(ll L = 1; L <= N; L++){
        res += L*(N-L+1);
    }
    for(int i = 0; i < N-1;i++){
        ll u,v; cin >> u >> v;
        if(u > v) swap(u,v);
        
        // 辺u-vを追加することでいくつの連結成分の可能性がなくなるか
        res -= u*(N-v+1);
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(){
    int sum;
    string x;
    cin>>x;
    while(x[0]!='0'){
        sum=0;
        for(int i=0;i<(int)x.size();i++)sum+=x[i]-'0';
        cout<<sum<<endl;
        cin>>x;
    }
}


Measured memory_bytes: 3156
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
char s1[20],s2[20],s3[20];
void input(){
    scanf("%s%s%s",s1,s2,s3);
}

int main(){
    char captal[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    input();
    printf("%c%c%c\n",captal[s1[0]-'a'],captal[s2[0]-'a'],captal[s3[0]-'a']);
    return 0;
}

Measured memory_bytes: 128
#include <stdarg.h>
#include <stdio.h>

int max(int len, ...) {
    int i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, int);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, int);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

int main(void) {
    int A, B, C, D, E, ra, rb, rc, rd, re, m, X;
    scanf("%d%d%d%d%d", &A, &B, &C, &D, &E);
    ra = (10 - A%10)%10;
    rb = (10 - B%10)%10;
    rc = (10 - C%10)%10;
    rd = (10 - D%10)%10;
    re = (10 - E%10)%10;
    m = max(5, ra, rb, rc, rd, re);
    X = A+B+C+D+E+ra+rb+rc+rd+re-m;
    printf("%d\n", X);

    return 0;
}

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

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

int main(){
  ll n, m;
  cin >> n >> m;
  bool judge;
  ll result;
  ll s[n][m] = {};
  ll i, j;
  ll bufk;
  ll bufs;
  for(i = 0; i < n; i++){
    cin >> bufk;
    for(j = 0; j < bufk; j++){
      cin >> bufs;
      s[i][bufs - 1] = 1;
    }
  }
  for(i = 0, result = 0; i < m; i++){
    for(j = 0, judge = true; j < n; j++){
      if(s[j][i] == 0)
        judge = false;
    }
    if(judge == true)
      result++;
  }
    
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
def Double(vec):
	m=len(vec)
	res=[]
	for i in range(0,m,2):
		res.extend([vec[i],vec[i]^m,vec[i+1]^m,vec[i+1]])
	return res

def Greedy(n):
	m=1<<n
	res=[0]*m
	vis=[False]*m
	vis[0]=True
	for i in range(1,m):
		x=res[i-1]
		for j in range(n):
			if not vis[x^(1<<j)]:
				x^=1<<j
				break
		vis[x]=True
		res[i]=x
	return res

def Perfect(n):
	if n==1:
		return [0,1]
	m=1<<n
	A=Greedy(n-1)
	B=Double(Perfect(n-2))
	B.reverse()
	for i in range(m>>1):
		B[i]^=m-1
	A.extend(B)
	return A

n,a,b=map(int,input().split())
m=1<<n
c=bin(a^b).count('1')
if not c&1:
	print('NO')
	exit()
tmp=Perfect(c)
for i in range(c,n):
	tmp=Double(tmp)
p=0
q=c
ans=[0]*m
for i in range(n):
	if (a^b)>>i&1:
		for j in range(m):
			ans[j]^=(((tmp[j]>>p)^(a>>i))&1)<<i
		p+=1
	else:
		for j in range(m):
			ans[j]^=(((tmp[j]>>q)^(a>>i))&1)<<i
		q+=1
print('YES\n',' '.join(str(i) for i in ans),sep='')

Measured memory_bytes: 22840
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int stu=0,b[31]={0};
	for(int i=1;i<=28;i++)
	{
		cin>>stu;
		b[stu]=-1;
	}
	for(int i=1;i<=30;i++){
		if(b[i]!=-1)
		{
			cout<<i<<endl;
		}
	}
	return 0;
}


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

int main() {
  int x,y; cin>>x>>y;
  int sum=0;
  if (x==1) sum+=300000;
  if (y==1) sum+=300000;
  if (x==2) sum+=200000;
  if (y==2) sum+=200000;
  if (x==3) sum+=100000;
  if (y==3) sum+=100000;
  if (x==y&&x==1) sum+=400000;
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    unsigned long long int p = 1;

    scanf("%d", &N);

    for (int i = 1; i <= N; i++) {
        p = p*i;
        p = p%1000000007;
    }

    printf("%llu\n", p);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>k;
sum=0;
for(i=1;i<=k;i++){
  for(j=1;j<=k;j++){
    for(x=1;x<=k;x++)
    {
      p=__gcd(i,j);
      p=__gcd(p,x);
      sum+=p;
    }
  }
}
cout<<sum;
}


Measured memory_bytes: 3652
N, X = map(int, input().split())

a, p = [1], [1]
for _ in range(N):
    a.append(a[-1] * 2 + 3)
    p.append(p[-1] * 2 + 1)


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N - 1]:
        return f(N - 1, X - 1)
    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])


print(f(N, X))

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

int main(){
    int k, a, b;
    cin>>k>>a>>b;
    for(int i = a; i <= b; ++i){
        if (i % k == 0){
            cout<<"OK\n";
            return 0;
        }
    }
    cout<<"NG\n";
}

Measured memory_bytes: 3624
int n,m,a,b,i; char p[1009][1009];
void x(int i, int j){p[i][j]=94;p[i+1][j]=118;b--;}
int main(int j){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(i=1;i<=n;)memset(p[i++]+1,46,m);
	for(i=1;i<n&&b&&m&1;i+=2)x(i,m);
	if(b&n&m>2&n>1)x(n-1,m-2);
	for(i=1;i<n;i++)for(j=1;j<=m&&b;j++)if(p[i][j]+p[i+1][j]<99)x(i,j);
	for(i=1;i<=n;i++)for(j=1;j<m&&a;j++)if(p[i][j]+p[i][j+1]<99)p[i][j]=60,p[i][j+1]=62,a--;
	puts(a|b?"NO":"YES");
	for(i=1;!a&!b&i<=n;)puts(p[i++]+1);
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
long long int SieveNbOfDiv(long long int NumberOfDivisors[],long long  int IndexCount[], long long int Limit) { 
    for (long long int i = 1; i*i <= Limit; i++) {
        NumberOfDivisors[i*i] += 1;
        for (long long int j = i*(i+1); j <= Limit; j += i )
            NumberOfDivisors[j] += 2;
    }
    long long int Count = 0,p=0;
    for (int i = 1; i <= Limit; i++) { Count=0;
        Count += NumberOfDivisors[i];
        NumberOfDivisors[i] = Count;
        IndexCount[i] = Count;
        p=p+Count*i;
    }
    return p;
}

/*void SieveDivisors(long long int IndexCount[], long long int NumberOfDivisors[], long long int Divisors[], long long int Limit) {
    for (long long int i = 1; i <= Limit; i++) {
        Divisors[IndexCount[i-1]++] = 1;
        Divisors[IndexCount[i]-1] = i;
    }
    for (long long int i = 2; i*i <= Limit; i++) {
        Divisors[IndexCount[i*i-1]++] = i;
        for (int j = i*(i+1); j <= Limit; j += i ) {
            Divisors[IndexCount[j-1]++] = i;
            Divisors[NumberOfDivisors[j-1] + NumberOfDivisors[j] - IndexCount[j-1]] = j/i;
        }
    }
}*/
int main() {
    long long int N ; scanf("%lld",&N);
    long long int *NumberOfDivisors = (long long int*) calloc(N+1, sizeof(long long int));
    long long int *IndexCount = (long long int*) calloc(N+1, sizeof(long long int));
    long long int size = SieveNbOfDiv(NumberOfDivisors, IndexCount, N);

    printf( "%lld", size);
   /* long long int *Divisors = (long long int*) calloc(size+1, sizeof(long long int));
    SieveDivisors(IndexCount, NumberOfDivisors, Divisors, N);*/

}

Measured memory_bytes: 157952
X, Y = map(int, input().split())

ans = 0

if X == 3:
    ans += 100000
elif X == 2:
    ans += 200000
elif X == 1:
    ans += 300000

if Y == 3:
    ans += 100000
elif Y == 2:
    ans += 200000
elif Y == 1:
    ans += 300000


if ans == 600000:
    ans += 400000

print(ans)


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = N;
  for(int i=0; i<N-1; i++){
    if (S.at(i) == S.at(i+1)){
      count --;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<vector>
#define repn(i,m,n) for(i = m;i < n;i++)
#define rep(i,n) for(i = 0;i < n;i++)
#define F first
#define S second

//#define DEBUG DEBUG

using namespace std;

typedef pair<int,int> P;

char str[102];
int data[102][102];
bool done[102][102];
int H,W;
//区分けする関数
int separate(int i,int j);

int main(){
	int i,j;
	int sum[200] = {0},scor = 0;
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0)
			break;
		rep(i,H+2){
			rep(j,W+2){
				data[i][j] = 0;
				done[i][j] = false;
			}
		}
		repn(i,1,H+1){
			cin >> str;
			repn(j,1,W+1){
				switch(str[j-1]){
				case '#':
					data[i][j] = 1;
					break;
				case '*':
					data[i][j] = 2;
					break;
				case '@':
					data[i][j] = 3;
					break;
				}
			}
		}
		repn(i,1,H+1){
			repn(j,1,W+1){
				sum[scor] += separate(i,j);
			}
		}
		scor++;
	}
	rep(i,scor)
		cout << sum[i] << endl;	
	return 0;
}
int separate(int i,int j){
	queue<P> que;
	P now;

	que.push(P(i,j));
	if(done[i][j])
		return 0;
	while(!que.empty()){
		now = que.front();
		que.pop();
		if(done[now.F][now.S])
			continue;
		done[now.F][now.S] = true;
		//4辺を調べる
		if(data[now.F+1][now.S] == data[now.F][now.S]){
			if(done[now.F+1][now.S] == false){
				que.push(P(now.F+1,now.S));
			}
		}
		if(data[now.F-1][now.S] == data[now.F][now.S]){
			if(done[now.F-1][now.S] == false){
				que.push(P(now.F-1,now.S));
			}
		}
		if(data[now.F][now.S+1] == data[now.F][now.S]){
			if(done[now.F][now.S+1] == false){
				que.push(P(now.F,now.S+1));
			}
		}
		if(data[now.F][now.S-1] == data[now.F][now.S]){
			if(done[now.F][now.S-1] == false){
				que.push(P(now.F,now.S-1));
			}
		}
	}
	return 1;
}

Measured memory_bytes: 1276
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int main(){
    ll n;
    cin>>n;
    char c[30];
    rep(i,26){
        c[i+1]=(char)('a'+i);
    }
    vector<char> ans;
    while(n!=0){
        int t=n%26;
        if(t==0)t=26;
        ans.push_back(c[t]);
        n-=t;
        n/=26;
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3564
#define FNAME ""
 
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cassert>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <string>
 
#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;
 
template <class T> T sqr(const T &a) {return a * a;}
const int M = 1e6;
int a[M];
ll cnt[M];
ll ans[M];
vector<int> v;
vector<pair<int, int> > g;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        g.pb({a[i], i});
        sum += a[i];
    }    
    sort(g.begin(), g.end());
    reverse(g.begin(), g.end());
    int c = 0;
    int last = -1;
    ll cur = 0;
    for (int i = 0; i < n; i++) {
        cur += 1LL * c * (last - g[i].first);
        cnt[g[i].second] = cur;
        
        last = g[i].first;
        c++;
    }    
    int r = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > r) {
            v.pb(i);
            r = a[i];
        }
    }
    for (int i = (int)v.size() - 1; i >= 1; i--) {
        ans[v[i]] = -cnt[v[i]] + cnt[v[i - 1]];
    }
    ans[0] = sum - cnt[0];
    for (int i = 0; i < n; i++) cout << ans[i] << "\n";
    

    return 0;
}

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  map<int,int> mp;
  for(int i=0; i<N; i++){
    if(mp.count(vec.at(i))){
      mp[vec.at(i)]++;
    }
    else{
      mp[vec.at(i)] = 1;
    }
  }
  
  vector<int> num(0);
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
  num.push_back(itr->second);
  }
  
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  if(num.size() <= K){
    cout << 0 << endl;
  }
  else{
    int ans = 0;
    for(int i=K; i<num.size(); i++){
      ans += num.at(i);
    }
    cout << ans << endl;
  }
}

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

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;

    return 0;
}


Measured memory_bytes: 256
n,W = map(int,input().split())

w = []
v = []

for x in range(n):
    peso,valor = map(int,input().split())
    w.append(peso)
    v.append(valor)

dp = [0] * (W+1)

for i in range(n):
    for j in range(W,-1,-1):
        if j + w[i] <= W:
            dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i])


resposta = 0

for x in dp:
    resposta = max(x,resposta)

print(resposta)


Measured memory_bytes: 42476
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 1010
#define MOD 1000000007
using namespace std;
typedef long long ll;
char s[MAXN][MAXN];
int n,m,v,lr,ud,ev,eh;
ll k;
struct node{
	ll x[3][3];
	node operator *=(const node&t) {
		int c[3][3]={0};
		for(int i=1;i<=2;i++)
			for(int j=1;j<=2;j++)
				for(int l=1;l<=2;l++)
					c[i][j]+=(x[i][l]*t.x[l][j])%MOD;
		for(int i=1;i<=2;i++)
			for(int j=1;j<=2;j++)
				x[i][j]=c[i][j]%MOD;
	}
}e,a;
ll fsp(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1ll)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1ll;	
	}
	return res;
}
int main(){
	SF("%d%d%lld",&n,&m,&k);
	for(int i=1;i<=n;i++)
		SF("%s",s[i]+1);
	for(int i=1;i<=m;i++)
		if(s[1][i]=='#'&&s[n][i]=='#')
			ud++;
	for(int i=1;i<=n;i++)
		if(s[i][1]=='#'&&s[i][m]=='#')
			lr++;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#'){
				v++;
				if(s[i-1][j]=='#')
					ev++;
				if(s[i][j-1]=='#')
					eh++;	
			}
		}
	if(ud!=0&&lr!=0){
		PF("1");
		return 0;
	}
	if(ud==0&&lr==0){
		PF("%lld",fsp(v,k-1ll));	
		return 0;
	}
	if(ud==0){
		ud=lr;
		ev=eh;
	}
	e.x[1][1]=ud;
	e.x[2][1]=ev;
	e.x[1][2]=0;
	e.x[2][2]=v;
	a.x[1][2]=1;
	if(k==0){
		PF("1\n");
		return 0;	
	}
	k--;
	while(k){
		if(k&1ll)
			a*=e;
		e*=e;
		k>>=1ll;
	}
	PF("%lld",(a.x[1][2]-a.x[1][1]+MOD)%MOD);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    rep(i, 0, n) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main(void) {
  int n;
  string s;
  cin >> n >> s;
  int count_w[n];
  count_w[n - 1] = 0;

  for (int i = n - 2; i >= 0; i--) {
    if (s[i + 1] == '.') count_w[i] = count_w[i + 1] + 1;
    else count_w[i] = count_w[i + 1];
  }

  int first_b_idx = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == '#') {
      first_b_idx = i;
      break;
    }
  }

  // cout << first_b_idx << endl;
  // for (int i = 0; i < n; i++) cout << count_w[i] << " ";
  // cout << endl;

  if (first_b_idx == -1) {
    cout << "0" << endl;
    return 0;
  }

  int min_n_change = n;
  int sum_b = 0;
  for (int i = first_b_idx; i < n; i++) {
    if (min_n_change > count_w[i] + sum_b) min_n_change = count_w[i] + sum_b;
    if (s[i] == '#') sum_b++;
  }
  cout << min_n_change << endl;
  return 0;
}


Measured memory_bytes: 1412
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long ans = 1;
                        for (int i = 1; i <= N; i++) {
                                ans *= i;
                                ans %= 1000000007;
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 23892
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func Solve() {
  NKS := NextIntVec()
  N, K, S := NKS[0], NKS[1], NKS[2]
  A := make([]int, N)
  for i := range A {
    s := S + 1
    if 1000000000 < s { s = 1 }
    A[i] = s
    if i < K { A[i] = S }
  }
  WriteIntVec(A)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 9088