akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(void){
  int n,m;
  cin>>n>>m;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  vector<P> ab(n);
  for(int i=0;i<n;i++){
    ab[i]=make_pair(a[i],b[i]);
  }
  sort(ab.begin(),ab.end());
  ll ans=0;
  for(int i=0;i<n;i++){
    ll num=min(m,ab[i].second);
    ans+=num*ab[i].first;
    m-=num;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <map>

using namespace std;
int main(){
    map<int,int> myMap;
    int N,count=0;
    cin>>N;
    for(int i=1;i<=N;i++){
        int temp;
        cin>>temp;

        if(myMap.find(temp)!=myMap.end()){
            if(myMap[temp]==i){
                count++;
                myMap.erase(temp);
            }
        }
        else
            myMap[i]=temp;

    }
    cout<<count;
    return 0;
}



Measured memory_bytes: 3200
#include <limits.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

namespace test {
std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
}
}  // namespace test

using namespace std;

int main(void) {
    int n; int *v, *c; 
    cin >> n;
    v = new int[n]; c = new int[n];
    
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }

    int result = 0;
    for(int i = 0; i < n; i++){
        result += (v[i] - c[i] > 0) ? v[i] - c[i] : 0;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
v = list(map(int, input().split()))
even = [[0,i] for i in range(10**5+5)]
odd = [[0,i] for i in range(10**5+5)]
numnum = 0
for i in range(n):
    if even[v[i]][0] == 0 and odd[v[i]][0] == 0:
        numnum += 1
    if i % 2 == 0:
        even[v[i]][0] += 1
    else:
        odd[v[i]][0] += 1
if numnum == 1:
    print(n // 2)
    exit()
even.sort(key=lambda x:x[0], reverse=True)
odd.sort(key=lambda x:x[0], reverse=True)
if n == 2:
    print(0)
    exit()
e0, e1, o0, o1 = even[0][1], even[1][1], odd[0][1], odd[1][1]
if e0 != o0:
    print(n - even[0][0] - odd[0][0])
elif e0 != o1 and e1 != o0:
    print(min(n - even[0][0] - odd[1][0], n - even[1][0] - odd[0][0]))
elif e0 != o1:
    print(n - even[0][0] - odd[1][0])
else:
    print(n - even[1][0] - odd[0][0])

Measured memory_bytes: 77072
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
double x=0,y=2,z=0,w=0,n=0,m=0,a=0,b=0;
string s;
std::cin >> x;
std::vector<int> v(x);
rep(i,x){
  std::cin >> v[i];
}
sort(all(v));
z=v[0]+v[1];
for(int i=2;i<=pow(2,x-2);i=i*2){
  z+=v[y]*i;
  y++;
}
std::cout << z/(pow(2,x-2)*2) << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int n, y;
    cin >> n >> y;

    int sum;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {

            int k;
            k = n - i - j;
            sum = i*10000 + j*5000 + k*1000;
            
            if (sum == y && k >= 0) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int H, W, k = 1;
  while(k >= 0){
    cin >> H >> W;
    if (H == 0 && W == 0){
      break;
    }
    for (int i = 1; i <= W; i++){
      cout << "#";
    }
    cout << endl;
    for (int x = 3; x <= H; x++){
      cout << "#";
      for (int n = 3; n <= W; n++){
	cout << ".";
      }
      cout << "#";
      cout << endl;
    }
    for (int i = 1; i <= W; i++){
      cout << "#";
    }   
    cout << endl << endl;
  }
}
  


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for (int i = 0; i < r; i++)
#define repeq(i,r) for (int i = 0; i <= r; i++)
#define isc(n) scanf("%d", &n)

int main() {
  int H, N;
  isc(H); isc(N);
  int D;
  rep(i,N) {
    int A;
    isc(A);
    D += A;
  }
  cout << (D >= H ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  vector<int> s(n);
  rep(i, n) {
    if (a[i] == b[i] && b[i] == c[i]) continue;
    if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i])
      s[i] = 1;
    else
      s[i] = 2;
  }
  int ans = 0;
  rep(i, n) ans += s[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# array = [*1..q].map { |_| gets.split.map(&:to_i) }
# n = gets.split.map(&:to_i)
# a = [*1..m].repeated_combination(n).to_a


k = gets.to_i

s = gets.chomp


if s.length > k
  puts "#{s.slice(0,k)}..."
else
  puts s
end


Measured memory_bytes: 14424
def calculation(a, b, n)
  result = (a/b).to_s
  point = result.index(".")

  sum = 0
  for i in 0..n do
    if i == result.size
      break
    end
    sum += (result[i+point, 1]).to_i
  end
  
  return sum
end

while input = gets
  values = (input.chomp).split(' ')
  puts calculation(values[0].to_f, values[1].to_f, values[2].to_f)
end

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

namespace atcoder172
{
    class Program
    {
        static void Main(string[] args)
        {


            int a = int.Parse(Console.ReadLine());

            var ans = a + a * a + a * a * a;
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 27152
#include<stdio.h>
int main()
{
    int n,k,i,sum=0,t;

    scanf("%d",&t);
    n=t;
    for(i=0;i<3;i++)
    {
        k=n%10;
        sum=k+sum*10;
        n=n/10;
    }

    if(sum==t)
       printf("Yes\n");
    else
     printf("No\n");

    return 0;
}




Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll n;
    cin >> n;
    vector<string> s(n);
    vector<ll> t(n);
    for (ll i = 0; i < n; ++i) {
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    bool flag = false;
    ll cnt = 0;
    for (ll i = 0; i < n; ++i) {
        if (flag) {
            cnt += t[i];
        }
        if (s[i] == x) {
            // catcerr << s[i] << "," << x << endl;
            flag = true;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  string s, t; cin >> s >> t;
  int n = s.size();
  int cnt = n;
  for(int i=0; i<n; i++) {
    if(s[i] == t[i]) cnt--;
  }
  cout << cnt << endl;
  return 0;
}

// EOF

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;
      int a,p;
      cin>>a>>p;
      a=a*3;
      int mn=min(a,p);
      cout<<mn+((abs(a-p))/2)<<endl;

    }

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

int main() {
  int x;
  cin >> x;
  if(x < 600) cout << "8";
  else if(x < 800) cout << "7";
  else if(x < 1000) cout << "6";
  else if(x < 1200) cout << "5";
  else if(x < 1400) cout << "4";
  else if(x < 1600) cout << "3";
  else if(x < 1800) cout << "2";
  else if(x < 2000) cout << "1";

}




Measured memory_bytes: 3632
using System;

class Program
{ 
	public static int Main()
	{
		Scanner cin = new Scanner();
		while (true)
		{
			int n = cin.nextInt();
			if (n == 0)
			{
				break;
			}
			bool[,] hasdoll = new bool[1000, 1000];
			for (int i = 0; i < n; i++)
			{
				hasdoll[cin.nextInt(), cin.nextInt()] = true;
			}
			int m = cin.nextInt();
			for (int i = 0; i < m; i++)
			{
				hasdoll[cin.nextInt(), cin.nextInt()] = true;
			}
			int[,] dp = new int[1000, 1000];
			for (int i = 0; i < 1000; i++)
			{
				for (int j = 0; j < 1000; j++)
				{
					if (hasdoll[i, j])
					{
						if (i > 0 && j > 0)
						{
							dp[i, j] = dp[i - 1, j - 1] + 1;
						}
						if (i > 0)
						{
							dp[i, j] = Math.Max(dp[i, j], hasdoll[i - 1, j] ? dp[i - 1, j] : dp[i - 1, j] + 1);
						}
						if (j > 0)
						{
							dp[i, j] = Math.Max(dp[i, j], hasdoll[i, j - 1] ? dp[i, j - 1] : dp[i, j - 1] + 1);
						}
						if (i == 0 && j == 0)
						{
							dp[i, j] = 1;
						}
					}
					else
					{
						if (i > 0 && j > 0)
						{
							dp[i, j] = dp[i - 1, j - 1];
						}
						if (i > 0)
						{
							dp[i, j] = Math.Max(dp[i, j], hasdoll[i - 1, j] ? dp[i - 1, j] - 1: dp[i - 1, j]);
						}
						if (j > 0)
						{
							dp[i, j] = Math.Max(dp[i, j], hasdoll[i, j - 1] ? dp[i, j - 1] - 1: dp[i, j - 1]);
						}
						if (i == 0 && j == 0)
						{
							dp[i, j] = 0;
						}
					}
				}
			}
			Console.WriteLine(dp[999, 999]);
		}
		return 0;
	}

}

class Scanner {
	string[] s;
	int i;

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

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

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

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

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

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

}

Measured memory_bytes: 20328
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define N 200010
using namespace std;

struct edge{int x, y, next;}a[N];
int n, l, p[N], x, flag[N], cl, d[N], b[N], ss, f[N], mex[N], x1, x2;
vector<int>son[N];

inline void add(int x, int y){a[++l].x=x; a[l].y=y; a[l].next=p[x]; p[x]=l;}

inline void dfs_circle(int x){
	flag[x]=ss; d[++cl]=x;
	for(int i=p[x]; i; i=a[i].next){
		if(flag[a[i].y]&&flag[a[i].y]<ss)continue;
		if(!flag[a[i].y]){dfs_circle(a[i].y); continue;}
		l=0; int now=cl;
		while(d[now]!=a[i].y){b[++l]=d[now]; now--;}
		b[++l]=a[i].y;
	}
	cl--;
}

inline void dfs_mex(int x){
	son[x].clear();
	for(int i=p[x]; i; i=a[i].next){
		dfs_mex(a[i].y); son[x].push_back(a[i].y);
	}
	for(int i=0; i<=son[x].size(); i++)f[i]=0;
	for(int i=0; i<son[x].size(); i++)if(mex[son[x][i]]<=son[x].size())f[mex[son[x][i]]]=1;
	for(int i=0; i<=son[x].size(); i++)if(!f[i]){mex[x]=i; break;}
}

inline int check(int w){
	mex[b[1]]=w; int x, sum;
	for(int i=2; i<=l+1; i++){
		x=b[i]; sum=son[x].size()+1;
		for(int j=0; j<=sum; j++)f[j]=0;
		for(int j=p[x]; j; j=a[j].next)if(mex[a[j].y]<=sum)f[mex[a[j].y]]=1;
		for(int j=0; j<=sum; j++)if(!f[j]){mex[x]=j; break;}
	}
	return mex[b[1]]==w?1:0;
}

int main(){
	scanf("%d", &n);
	l=0; memset(p, 0, sizeof(p));
	for(int i=1; i<=n; i++){scanf("%d", &x); add(x, i);}
	memset(flag, 0, sizeof(flag)); ss=0;
	for(int i=1; i<=n; i++)if(!flag[i]){ss++; cl=0; dfs_circle(i);}
	b[l+1]=b[1];
	memset(flag, 0, sizeof(flag));
	for(int i=1; i<=l; i++)flag[b[i]]=1;
	for(int i=1; i<=l; i++){
		x=b[i]; son[x].clear();
		for(int j=p[x]; j; j=a[j].next)if(!flag[a[j].y]){
			dfs_mex(a[j].y); son[x].push_back(a[j].y);
		}
	}
	x=b[1];
	memset(f, 0, sizeof(f));
	for(int i=p[x]; i; i=a[i].next)if(!flag[a[i].y])f[mex[a[i].y]]=1;
	x1=x2=-1;
	for(int i=0; i<=n; i++)if(!f[i]){
		if(x1==-1)x1=i; else if(x2==-1)x2=i;
	}
	if(check(x1)){printf("POSSIBLE"); return 0;}
	if(check(x2)){printf("POSSIBLE"); return 0;}
	printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 14848
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define MAX 210000
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> p;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,t;
    cin>>n>>t;
    int c[1001],x[1001];
    for(int i=0;i<n;i++){
        cin>>c[i]>>x[i];
    }
    vector<int> v;
    for(int i=0;i<n;i++){
        if(x[i]<=t){
            v.push_back(c[i]);
        }
    }
    if(v.size()==0){
        cout<<"TLE";
    }
    else{
        int z=*min_element(v.begin(),v.end());
        cout<<z;
    }



    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,n;
	char c;
	scanf("%d%d",&i,&n);
	if(i>n)
	c='>';
	if(i<n)
	c='<';
	if(i==n)
	c='=';
	if(c!='=')
	printf("a %c b\n",c);
	else printf("a == b\n");
} 


Measured memory_bytes: 2688
<?php

class Simulator
{
    public $word = array();
    public $n_operations;
    public $operations;

    public function __construct()
    {
        fscanf(STDIN, '%d', $this->n_operations);
        $this->operations = new \SplDoublyLinkedList();
        while ($this->n_operations > 0) {
            $word = trim(fgets(STDIN));
            if ($word[0] === 'i') {
                $this->operations->unshift(substr($word, 7));
            } elseif ($word[6] === 'F') {
                $this->operations->shift();
            } elseif ($word[6] === 'L') {
                $this->operations->pop();
            } else {
                foreach ($this->operations as $key => $element) {
                    if ($element === substr($word, 7)) {
                        $this->operations->offsetUnset($key);
                        break;
                    }
                }
            }
            $this->n_operations -= 1;
        }
        $this->dll2 = $this->operations;
    }

    public function getAnswer()
    {
        $str = array();
        $this->operations = $this->dll2;
        while (true) {
            try {
                $element = $this->operations->shift();
                $str[] = $element;
            } catch (Exception $e) {
                echo implode(' ', $str), PHP_EOL;
                break;
            }
        }
    }
}

$answer = new Simulator();
$answer->getAnswer();



Measured memory_bytes: 136152
H,W = map(int,input().split())
S = ["."*(W+2)]+["."+input()+"." for h in range(H)]+["."*(W+2)]

for h in range(1,H+1):
  for w in range(1,W+1):
    if S[h][w]=="#" and S[h-1][w]=="." and S[h+1][w]=="." and S[h][w-1]=="." and S[h][w+1]==".":
      print("No")
      exit()
      
print("Yes")


Measured memory_bytes: 9128
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b =  new int[a];
        for(int i=0; i < a; i++) {
            b[i] = sc.nextInt();
        }
        int count =0;
        two: for(int j =0; j < a ; j++){
            for(int k =0; k < j; k++){
                if(b[k] > b[j]){
                    continue two;
                }
                
            }
                count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n;
  cin >> n;
  ll ans=0;
  rep(i,n)ans+=((i+1)*(n-i));
  //cout << ans << endl;
  rep(i,n-1){
    ll u,v;
    cin >> u >> v;
    if(u>v)swap(u,v);
    ans=ans-(u*(n-v+1));
  }
  cout << ans << endl;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

void solve(long long X, long long Y){
    if(abs(X-Y)<=1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


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

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int n;
	cin >> n ;
	syc(n,1,100);
	string s[n][100];
	int a[100];
	int b[100];
	int c[100];
	int temp;
	
	for(int i=0;i<n;i++){
		cin >> s[i][0] >> a[i];
		b[i]=1;//point
		c[i]=i+1;//number
	}
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(s[i][0] > s[j][0]){
				b[i]++;
			}else if(s[i][0] == s[j][0] && a[i] < a[j] ){
				b[i]++;
			}else{
				b[j]++;
			}
		}
	}
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(b[i]>b[j]){
				temp=b[i];
				b[i]=b[j];
				b[j]=temp;
				temp=c[i];
				c[i]=c[j];
				c[j]=temp;
			}	
		}
	}
	
	for(int i=0;i<n;i++){
		cout << c[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    Factorial<ll> f(n*4, MOD);
    for (int i = 1; i <= k; ++i) {
        cout << f.C(k-1, i-1)*f.C(n-k+1, i) %MOD << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
N=int(input())

le = [int(input()) for i in range(N)]
status = [0 for i in range(N)]
answer=0
index=0

#同じ状態に戻ってくるとアウト

while(1):
    # print(index)
    if index==1:
        break
    
        
    answer+=1
    status[index]+=1
    if status[index]>=2:
        answer=-1
        break
    
    index = le[index]-1


print(answer)
    



Measured memory_bytes: 7888
#include<bits/stdc++.h>
using namespace std;
int dir[3001][3001];
int dp[3001][3001];
string s1,s2;

int solve(int i,int j)
{
    if(dp[i][j]!=-1)return dp[i][j];


    if(i==s1.size() || j==s2.size())
    {

        dir[i][j]=-1;
        return dp[i][j]=0;
    }

    int anss=0;
    int dik=-1;

    if(s1[i]==s2[j])
    {
        int ans=1+solve(i+1,j+1);
        if(anss<ans)
        {
            dik=0;
            anss=ans;
        }
    }
    int ans=solve(i,j+1);
    if(ans>anss)
    {
        dik=1;
        anss=ans;
    }
    ans=solve(i+1,j);
    if(ans>anss)
    {
        dik=2;
        anss=ans;
    }
    dp[i][j]=anss;
    dir[i][j]=dik;
    return dp[i][j];

}

string s;

void backtrack(int i,int j)
{
    if(i==s1.size() || j==s2.size())
    {
        return ;
    }

    if(dir[i][j]==0)
    {
        s.push_back(s1[i]);
        backtrack(i+1,j+1);
    }
    else if(dir[i][j]==1)
    {
        backtrack(i,j+1);
    }
    else if(dir[i][j]==2)
    {
        backtrack(i+1,j);
    }

}

int main()
{
    memset(dp,-1,sizeof dp);
    cin>>s1>>s2;
    int ans=solve(0,0);
   // cout<<ans<<endl;
    backtrack(0,0);
    cout<<s<<endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int count = 0;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        count += h >= k;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

long long gcd(long long a, long long b){
  while(true){
    if(a < b){
        swap(a, b);
    }
    if(!b){
        break;
    }
    a %= b;
  }

  return a;
}


int main(){
    long long A, B;
    cin >> A >> B;


    long long G = gcd(A, B);
    long long H = sqrt(G);

    long long ans = 0;
    for(long long i = 2; i <= H+1; i++){
        if(G % i == 0){
            G = G / i;
            while(G % i == 0){
                G /= i;
            }
            ans++;
            
            if(G == 1){
                break;
            }
            
            // cout << "i = " << i << endl;
            // cout << "G = " << G << endl;
        }
    }



    cout << ans+(G == 1LL ? 1LL : 2LL) << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m, a[101010];

i64 gcd(i64 x, i64 y){
	if(y == 0) return x;
	return gcd(y, x%y);
}
i64 lcm(i64 x, i64 y){
	return x*y / gcd(x,y);
}


int main(){
	cin >> n >> m;
	int bl = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	sort(a,a+n);
	
	i64 cnt = a[0]/2;
	for(int i = 0; i < n; i++){
		i64 c = lcm(cnt, a[i]/2);
		if((c-cnt) % (cnt*2) != 0){
			cout << 0 << endl;
			return 0;
		}
		cnt = c;
		if(cnt > m){
			cout << 0 << endl;
			return 0;
		}
	}
	
	cout << 1 + (m-cnt)/(cnt*2) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=3e2+10;

int Cnt[4],N;
double DP[maxm][maxm][maxm];

int main(){
	register int i,j,k;
	int x;
	scanf("%d",&N);
	for(i=1;i<=N;i++) scanf("%d",&x),Cnt[x]++;
	for(k=0;k<=N;k++){
		for(j=0;j+k<=N;j++){
			for(i=0;i+j+k<=N ;i++){
				if(!i && !j && !k) continue;
				if(i) DP[i][j][k]+=DP[i-1][j][k]*i;
				if(j) DP[i][j][k]+=DP[i+1][j-1][k]*j;
				if(k) DP[i][j][k]+=DP[i][j+1][k-1]*k;
				DP[i][j][k]=(DP[i][j][k]+N)/(i+j+k);
			}
		}
	}
	printf("%.12lf",DP[Cnt[1]][Cnt[2]][Cnt[3]]);
	return 0;
}

Measured memory_bytes: 225536
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


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;
}



int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int a_turn = a / d;
    if(a % d != 0) {
        a_turn += 1;
    }
    
    int t_turn = c / b;
    if(c % b != 0) {
        t_turn += 1;
    }
    if(t_turn <= a_turn) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long

signed main(){
    int N;
    cin>>N;
    string s;cin>>s;
    int sum[TENFIVE*3];
    rep1(i,N+1){
        if(s[i-1] == 'W'){
            sum[i]=sum[i-1]+1;
        }else{
            sum[i]= sum[i-1];
        }
        // cout<<sum[i];
    }
    // cout<<"hoge"<<endl;
    int ans=INT_MAX;
    rep1(i,N+1){
        // cout<<sum[N]-sum[i]<<" ";
        ans = min(ans, N-i-sum[N]+sum[i] +sum[i-1]);
        // cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long K, std::string S)
{

  int n = S.size();
  if (K < n)
  {
    S = S.substr(0, K);
    S += "...";
  }

  cout << S << endl;
}

int main()
{
  cout << setprecision(10);
  long long K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  solve(K, S);
  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  sort(ALL(a));
  int cur = a.at(0);
  int ans = 0;
  int count = 0;
  rep(i,n){
    if(cur==a.at(i)){
      count++;
    }else{
      if(count<cur){
        ans+=count;
      }else{
        ans+=count-cur;
      }
      cur = a.at(i);
      count = 1;
    }
  }
  if(count<cur){
    ans+=count;
  }else{
    ans+=count-cur;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f;
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt, a[210000], b[210000];
LL gcd(LL a, LL b) {
	if (a < b) gcd(b, a);
	LL r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
int main() {
	cin >> n;
	vector<LL>v;
	rep(i, n / 4 + 1) {
		v.push_back(i * 6 + 2);
		v.push_back(i * 6 + 3);
		v.push_back(i * 6 + 4);
		v.push_back(i * 6 + 6);
	}
	rep(i, n-1) {
		sum += v[i];
		cout << v[i] << endl;
	}
	v.push_back(INF);
	for (int i = 2; i <= 30000; i++) {
		auto it = lower_bound(v.begin(), v.end(), i) - v.begin();
		if (it < n - 1 && v[it] == i)continue;
		LL gc = gcd((sum + i), i);
		if (gc != 1 && (sum + i) % 6 == 0) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans;
int x[111111],y[111111];
int cnt[111111];
bool flag[111111];
signed main(){
	cin>>n>>m;
	rep(i,n)cnt[i]=1;
	rep(i,m){
		cin>>x[i]>>y[i];
		x[i]--;y[i]--;
	}
	flag[0]=true;
	rep(i,m){
		cnt[x[i]]--;cnt[y[i]]++;
		if(flag[x[i]]){
			flag[y[i]]=true;
		}
		if(cnt[x[i]]==0){
			flag[x[i]]=false;
		}
	}
	rep(i,n){
		if(flag[i] && cnt[i]!=0){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2688
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL k,q,n,x,m;
LL dd[5005],d[5005];

int main() {
	ios::sync_with_stdio(false);
	cin >> k >> q;
	for(LL i = 0;i < k;i ++) cin >> dd[i];
	
	while(q --){
		LL ans = 0,sd = 0;
		cin >> n >> x >> m; x %= m;
		for(LL i = 0;i < k;i ++){
			d[i] = dd[i] % m;
			sd += d[i];
		}
		LL td = (n - 1) / k;
		ans = n - 1; ans -= (x + sd * td) / m;
//		cout << (x + sd * td) << endl;
		for(LL i = 0;i < k;i ++) if(!d[i]) ans -= td;
		
		x = (x + sd * td) % m;
		for(LL i = 0;i < (n - 1) % k;i ++){
			if(!d[i]) ans --;
			else{
				x += d[i];
				if(x >= m){
					x -= m;
					ans --;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int check()
{
char s[15];
scanf("%s",s);
if(s[0]!='A')
return 0;
int c=0,count=0;
for(int i=2;i<(strlen(s)-1);i++)
if(s[i]=='C')
c++;
if(c!=1)
return 0;
for(int i=0;i<(strlen(s));i++)
if(s[i]<'a')
count++;
if(count!=2)
return 0;
return 1;
}

int main()
{
int ans = check();
if(ans==0)
printf("WA");
else
printf("AC");



}

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

namespace Linear_Search
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            var a = Console.ReadLine().Split();
            Console.ReadLine();
            var b = Console.ReadLine().Split();
            Console.WriteLine("{0}", a.Intersect(b).Count());
        }
    }
}

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

int main() {
	int n, k, q;
	std::cin >> n >> k >> q;

	std::vector<int> score(n, k - q);
	for (int i = 0; i < q; ++i) {
		int a;
		std::cin >> a;

		++score[a - 1];
	}

	for (auto&& e : score)
		std::cout << (e > 0 ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 1024
x1, y1, x2, y2 = list(map(int, input().split()))
a = x2 - x1
b = y2 - y1
x3 = (x2 - b)
y3 = (y2 + a)
print(x3, y3, (x3 - (y3 - y2)), (y3 + (x3 - x2)))


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

int Nmax=100010;

bool isPrime(int num) {
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0)
      return false;
  }
  return true;
}

int main(){
  int Q; cin >> Q;
  vector<int> a(Nmax,0);
  for (int i=0;i<Nmax;i++){
    if( isPrime(i) && isPrime( (i+1)/2 ) )
      a.at(i)=1;
  }
  vector<int> S(Nmax+1,0);
  for (int i=0;i<Nmax;i++){
    S[i+1]=S[i]+a[i];
  }
  for (int i=0;i<Q;i++){
    int l,r;
    cin >> l >> r;
    cout << S[r+1]-S[l] << endl;
  }
}

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

struct data {
  int sx, sy, gx, gy;
};

long long h, w;
vector<vector<long long>> a;
vector<data> ans;

void solve();

int main() {
  cin >> h >> w;
  a.resize(h);
  for(int i = 0; i < h; ++i) {
    a[i].resize(w);
    for(int j = 0; j < w; ++j) cin >> a[i][j];
  }
  solve();
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); ++i)
    cout << ans[i].sx + 1 << " " << ans[i].sy + 1 << " "
         << ans[i].gx + 1 << " " << ans[i].gy + 1 << endl;
  return 0;
}

void solve() {
  int cnt = 0, bfx = -1, bfy = -1;
  for(int i = 0; i < h; ++i) {
    if(i % 2 == 0)
      for(int j = 0; j < w; ++j) {
        if(bfx >= 0 && a[bfx][bfy] % 2) {
          ++a[i][j];
          ans.push_back({bfx, bfy, i, j});
        }
        ++cnt;
        bfx = i, bfy = j;
      }
    else
      for(int j = w - 1; j >= 0; --j) {
        if(bfx >= 0 && a[bfx][bfy] % 2) {
          ++a[i][j];
          ans.push_back({bfx, bfy, i, j});
        }
        ++cnt;
        bfx = i, bfy = j;
      }
  }
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n, k, a[200005], cnt[200005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    set<int> S;
    rep(i, 0, n) {
      cin >> a[i];
      cnt[a[i]]++;
      S.insert(a[i]);
    }
    sort(cnt, cnt+200005);
    int ans = 0, kind = S.size();
    rep(i, 0, 200006) {
      if (kind - k <= 0) break;
      if (cnt[i] > 0) {
        ans += cnt[i];
        kind--;
      }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 
 
 
	
int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
		ll n;
		cin>>n;
		
		for(ll i=1;i<=n;i++)
		{
			if((n%i)==0)
			{
				ll a = i;
				ll b = n/i;
				if((a>=1 and a<=9) and (b>=1 and b<=9))
				{
					cout<<"Yes";return 0;
				}
			}
		}
		cout<<"No";
		return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#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 a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  } else cout << "Odd" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

ll n,k; cin>>n>>k;
  vector<ll>a(n); rep(i,n){cin>>a.at(i);}
  sort(all(a));
  
  int c=1;
  rep(i,n-1){if(a.at(i)!=a.at(i+1)){c++;}}
  
  if(c<=k){cout<<0<<endl;}
  else{
 
    vector<ll>b(c); rep(i,c){b.at(i)=1;}
    int j=0;
   rep(i,n-1){
    if(a.at(i)==a.at(i+1)){b.at(j)++;}
    else{j++;}
   }
    
    sort(all(b));
    int ans=0;
    rep(i,c-k){ans+=b.at(i);}
    
  
    cout<<ans<<endl;
    
  
  
  
  
}
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 3 6");
            //safe
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("6 5 1");
            //delicious
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("3 7 12");
            //dangerous
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(pX => int.Parse(pX)).ToArray();
        int X = wkArr[0];
        int A = wkArr[1];
        int B = wkArr[2];

        if (B <= A) {
            Console.WriteLine("delicious");
        }
        else if (B <= A + X) {
            Console.WriteLine("safe");
        }
        else {
            Console.WriteLine("dangerous");
        }
    }
}


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


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {

	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}


template<typename T>
bool same(T x_b, T x_e, T y_b, T y_e) {
	for (auto i = x_b, j = y_b; i != x_e && j != y_e; ++i, ++j) {
		if (*i != *j) {
			return false;
		}
	}
	return true;
}


int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int turn = 1;
	while(a>0&&c>0){
		if (turn % 2) {
			c -= b;
		}
		else {
			a -= d;
		}
		++turn;
	}
	if (turn % 2 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

/*

*/


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S,T;
  cin >> S >> T;
  
  T.pop_back();
  
  if(S == T)
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 3636
def AreCloseEnough(x,y,d):
    if x-y <= d and x-y >= -d:
        return True
    return False

def main():
    a,b,c,d = map(int, input().strip().split())
    if AreCloseEnough(a,c,d):
        print("Yes")
        return
    if AreCloseEnough(a,b,d) and AreCloseEnough(b,c,d):
        print("Yes")
        return
    print("No")
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
ll f[35][305];
int n,C,a[15],tr[305];
int vis[15],ord[15];
double ans;
void solve(){
	memset(f,0,sizeof(f));
	f[0][a[n]*n]=1;
	int all=(1<<(n-1))-1;
	For(i,0,C*n-1){
		int id=ord[i%n];
		For(k,i,C*n) tr[k]=min(C*n,max(k,i+a[id]*n));
		if (id)
			For(j,0,all) if (!(j&(1<<(id-1))))
				For(k,i,C*n) f[j|(1<<(id-1))][tr[k]]+=f[j][k];
		For(j,0,all) f[j][i]=0;
	}
	double res=f[all][C*n];
	For(i,1,n-1) res/=C;
	ans+=res;
}
void getans(int x){
	if (x==n) return solve();
	For(i,1,n-1) if (!vis[i]){
		ord[x]=i; vis[i]=1;
		getans(x+1);
		ord[x]=0; vis[i]=0;
	}
}
int main(){
	scanf("%d%d",&n,&C);
	For(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	getans(1);
	For(i,1,n-1) ans/=i;
	printf("%.15lf\n",ans);
}

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

int main()
{
	int W,H;
	while(cin>>W>>H,  W||H)
	{
		int dp[100][100][4]={0};
		for(int x=0; x<W; x++) dp[x][0][0]=1;
		for(int y=0; y<H; y++) dp[0][y][2]=1;

		for(int x=1; x<W; x++)
		for(int y=1; y<H; y++)
		{
			dp[x][y][0] = (dp[x-1][y  ][0] + dp[x-1][y  ][1])%100000;
			dp[x][y][1] = (dp[x-1][y  ][2]                  )%100000;
			dp[x][y][2] = (dp[x  ][y-1][2] + dp[x  ][y-1][3])%100000;
			dp[x][y][3] = (dp[x  ][y-1][0]                  )%100000;
		}

		int ans=0;
		for(int i=0; i<4; i++)
		{
			ans = (ans+dp[W-1][H-1][i])%100000;
		}
		cout << ans << endl;
	}
}

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

int main(){
  int N,T;
  cin>>N>>T;
  vector<int> vec(N);
  int sum=0;
  
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
    sum+=vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  cout<<(T-sum)/vec.at(0)+N<<endl;
}

Measured memory_bytes: 256