akhauriyash/Code-Regression huggingface dataset:
#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;
    cin >> n;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i< n-1; i++){
        if(p[i-1] < p[i] && p[i] < p[i+1]){
            ans++;
        }
        else if(p[i-1] > p[i] && p[i] > p[i+1]){
            ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int dis(int (*A)[30], int a, int b, int D);//a番目とb番目の距離
int sq(int s);//平方数の判定

int main(void){
  int N, D, i, j, x[30][30], ans=0;
  scanf("%d %d", &N, &D);
  for(i=1; i<=N; i++){
    for(j=1; j<=D; j++){
      scanf("%d", &x[i][j]);
    }
  }
  for(i=1; i<N; i++){
    for(j=i+1; j<=N; j++){
      ans += dis(x, i, j, D);
    }
  }
  printf("%d", ans);
  return 0;
}

int dis(int (*A)[30], int a, int b, int D){
  int sum=0, i;
  for(i=1; i<=D; i++){
    sum += (A[a][i] - A[b][i])*(A[a][i] - A[b][i]);
  }
  return sq(sum);
}
int sq(int s){
  int i;
  if(s == 1) return 1;
  for(i=2; i*i <= s; i++){
    if(s == i*i) return 1;
  }
  return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
 
N = int(input())
xy = []
for _ in range(N):
    x, y = inpl()
    xy.append((x,y))
xy.sort()

edges = defaultdict(int)
edges[(0,0)] = 0
for i in range(N):
    for j in range(i+1,N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        p, q = x2-x1, y2-y1
        edges[(p,q)] += 1
 
print(N - max(edges.values()))

Measured memory_bytes: 39024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String str = new String();
		while(in.hasNext()){
			String line = in.nextLine();
			String[] Array = line.split(" ");
			int a = Integer.parseInt(Array[0]);
			int b = Integer.parseInt(Array[1]);
			if((a+b)==0){
				break;
			}
			if(a>b){
				System.out.println(b+" "+a);
			}else if(a<b){
				System.out.println(a+" "+b);
			}else{
				System.out.println(a+" "+b);
			}
		}
	}
}

Measured memory_bytes: 37996
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;


int main(){
	int n;
	cin >> n;
	int S[n];
	for(int i = 0; i < n; i++) cin >> S[i];

	int q;
	cin >> q;
	int T[q];
	for(int i = 0; i < q; i++) cin >> T[i];
	
	sort(T, T+q);
	int j = 0, cnt = 0;
	for(int i = 0; i < n && j < q; i++){
		while(S[i] > T[j] && j < q) j++;
		if(S[i]==T[j]){
			cnt++;
			j++;
		}
	}

	cout << cnt << endl;
	return 0;
	
}

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

int main() {
	int A, B, T;
	std::cin >> A >> B >> T;

	double x = T + 0.5;

	int sum = 0;

	for (int i = 1; A * i < x; i++) {
		sum += B;
	}

	std::cout << sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n;
    map<lli,lli>ma;
    for(i=2;i*i<=n;i++){
    	if(n%i==0){
    		c=0;
    		while(n%i==0){
    			c++;n/=i;
    		}
    		ma[i]=c;
    	}
    }
    if(n!=1)	ma[n]=1;
    for(auto it=ma.begin();it!=ma.end();it++){
    	a=it->first;
    	b=it->second;//cout<<b<<" ";
    	c=1;
    	while(b>=c){
    		ans++;b-=c;c++;
    	}
    }
    cout<<ans;
    
    
}


int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define INF INT_MAX
using namespace std;
int n,q;
int a[300005];
void update(int i,int x){
  i+=n-1;
  a[i] = x;
  while(i!=0){
    if(i%2==1){
      a[(i-1)/2] = min(a[i],a[i+1]);
    }
    else a[(i-1)/2] = min(a[i],a[i-1]);
    i = (i-1)/2;
  }
}
int find(int s,int t,int i,int f,int e){
  if(s<=f && e<=t) {
    //cout<<"a[i] "<<a[i]<<" "<<i<<endl;
    return a[i];
  }
  else if(t<f || s>e) return INF;
  else {
    //if(i<0) return 0;
    //cout<<s<<" "<<t<<" "<<i<<" "<<f<<" "<<e<<endl;
    return min(find(s,t,i*2+1,f,(f+e-1)/2),find(s,t,i*2+2,(f+e-1)/2+1,e));
  }
  
}
int main(){
  cin>>n>>q;
  int num=1;
  while(num<n){
    num*=2;
  }
  n = num;
  for(int i=0;i<2*n;i++) a[i] = INF;
  /*
  for(int i=0;i<n;i++){
    int c;
    cin>>c;
    update(i,c);
    
    for(int i=0;i<2*n-1;i++){
      cout<<a[i]<<endl;
    }
    
  }
  */
  for(int i=0;i<q;i++){
    int com;
    cin>>com;
    if(com==0){
      int x,y;
      cin>>x>>y;
      update(x,y);
      /*
      for(int i=0;i<2*n-1;i++){
	cout<<a[i]<<endl;
      }
      */
    }
    else if(com==1){
      int s,t;
      cin>>s>>t;
      if(s==t) cout<<a[s+n-1]<<endl;
      else cout<<find(s+1,t+1,0,1,n)<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 4088
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAX = 1e6;
const int INF = 2e9;
typedef long long ll;

int lps[202];
char str[202];

void manachers(int len) {
    int c = -1;
    int r = -1;

    for (int i = 0; i < len; ++i) {
        if (r >= i) {
            lps[i] = min(r - i, lps[c * 2 - i]);    // pos of symmetric
        } else {
            lps[i] = 0;
        }

        while ((i + lps[i] + 1) < len && (i - lps[i] - 1) >= 0 && (str[i + lps[i] + 1] == str[i - lps[i] - 1]))
            ++lps[i];

        if (r < i + lps[i]) {
            r = i + lps[i];
            c = i;
        }
    }
}

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

    char s[101];
    cin >> s;

    int len = strlen(s);
    for (int i = 0; i < len; ++i)
    {
        str[i * 2 + 1] = s[i];
    }
    len = len * 2 + 1;

    manachers(len);

    int mid = len / 2;
    int left = mid / 2;
    int right = (mid + len) / 2;
    int half = len / 2;

    //printf("%d, %d, %d, len : %d", left, mid, right, half);

    if (lps[mid] == half && lps[left] == half / 2 && lps[right] == half / 2) {
        cout << "Yes";
    } else {
        cout << "No";
    }


    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,K;
    cin >> N >> K;
    vector<int> h(N);
    vector<int> dp(N, 1001001001);
    
    rep(i,N){
        cin >> h[i];    
    }

    dp[0] = 0;
    
    rep(i,N){
        for(int j=1;j<=K;j++){
            if(j+i>=N){
                break;
            }
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
            // cout << "dp[" << i+j << "] = " << dp[i+j] << endl;
        }
    }
    
    cout << dp[N-1] << endl;
    
    return 0;
}


Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
int n;
void rotate(int r,int c,int s,vector<vector<int> > &map){
	//cout<<r<<' '<<c<<' '<<s<<endl;
	vector<vector<int> > tmp(s,vector<int>(s));
	for(int i=0;i<s;i++)
		for(int j=0;j<s;j++){
			tmp[i][j] =map[r+s-1-j][c+i];
	//	cout<<r+s-1-j<<' '<<c+i<<endl;	
		}
       for(int i=0;i<s;i++){
	       for(int j=0;j<s;j++){
	       map[i+r][j+c] = tmp[i][j];
	       
       }
       }	       
}
void reverce(int r,int c,int s,vector<vector<int> > &map){
	for(int i=0;i<s;i++)
		for(int j=0;j<s;j++){
			int nx = i+r;
			int ny = j+c;
			//cout<<nx<<   ' '<<ny<<' '<<map[nx][ny]<<endl;
			if(map[nx][ny]==1){
				map[nx][ny]=0;

			}else{
				map[nx][ny]=1;
			}
		//cout<<map[nx][ny]<<endl;
		}

}
void left(int l,vector<vector<int> > &map){
int tmp = map[l][1];
for(int i=1;i<n;i++){
map[l][i]=map[l][i+1];
}
map[l][n]=tmp;
}
void right(int l,vector<vector<int> > &map){
int tmp = map[l][n];
for(int i =n ;i>1;i--){
map[l][i]= map[l][i-1];
}
map[l][1] = tmp;

}
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
void island(int r,int c,vector<vector<int> > &map,int now){
	if(map[r][c]==now){
		map[r][c]=(now+1)%2;
	for(int i=0;i<4;i++){
		int nx =r+dx[i];
		int ny =c+dy[i];
		if(nx>=1&&ny>=1&&nx<=n&&ny<=n){
			island(nx,ny,map,now);
		}
	}
	}else{
return;
	}
	return;
}

int main(){
int m;
cin>>n>>m;
vector<vector<int> > map(n+2,vector<int>(n+2,0));
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++)cin>>map[i][j];
}

for(int i=0;i<m;i++){
int o;
cin>>o;
if(o==0){
int r,c,size,angle;
cin>>r>>c>>size>>angle;
angle/=90;
for(int j=0;j<angle;j++){
rotate(r,c,size,map);
}
}else if(o==1){
int r,c,size;
cin>>r>>c>>size;
reverce(r,c,size,map);
}else if(o==2){
int l;
cin>>l;
left(l,map);

}else if(o==3){
int l;
cin>>l;
right(l,map);
}else{
int r,c;
cin>>r>>c;
island(r,c,map,map[r][c]);
}

}
//cout<<"operand"<<endl;
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
	cout<<map[i][j];
		if(j!=n)cout<<' ';
	}
	cout<<endl;
}
return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%I64d", &x)
#define ss(s) scanf("%s", s)
#define pb push_back
#define em emplace_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1e9 + 7;
int epow(int base, int pow)
{
    int result = 1;
    while (pow)
    {
        if (!(pow % 2))
        {
            base = (base * base) % mod;
            pow /= 2;
        }
        else
        {
            result = (result * base) % mod;
            pow--;
        }
    }
    return result;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    si(n);
    double d = 2 * n * PI;
    cout << setprecision(24) << d;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T,U;
  int A,B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(U==S) A--;
  else if(U==T) B--;
  cout << A << " " << B;  
}

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

main(){

  cout<<fixed<<setprecision(10);
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<(w*h)/2<<" ";
  if(x*2==w&&y*2==h)puts("1");
  else puts("0");

}

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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
const ll mod=MOD;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll N=2000010;
vl arr(N);
void Eratosthenes(){
	for(ll i = 0; i < N; i++){
		arr[i] = 1;
	}
        arr[1]=0;
	for(ll i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
}
//素数判定O(√n)
bool is_prime(ll n){
  for(ll i=2;i*i<=n;i++){
    if(n%i==0)return false;
  }
  return n!=1;
}


int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;
  string s;cin>>s;
  deque<char>q;
  ll cr=0,cw=0;
  rep(i,n){
    if(s[i]=='R')q.push_front(s[i]);
    else q.push_back(s[i]);
  }
  ll cnt=0;
  rep(i,n){
    if(s[i]!=q[i])cnt++;
  }
  cout<<(cnt+1)/2<<endl;
}

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

using vll = std::vector<long long>;

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<vll> happiness_sum(3, vll(n));
	for (int i{}; i < 3; i++)
		scanf("%lld", &happiness_sum[i][0]);
	for (int i{1}; i < n; i++)
		for (int j{}; j < 3; j++)
		{
			long long tmp;
			scanf("%lld", &tmp);
			happiness_sum[j][i] = std::max(happiness_sum[(j + 1) % 3][i - 1], happiness_sum[(j + 2) % 3][i - 1]) + tmp;
		}
	
	long long max{};
	for (int i{}; i < 3; i++)
		max = std::max(max, happiness_sum[i][n - 1]);
	printf("%lld\n", max);

	return 0;
}

Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(10**5+100)
N, M = [int(_) for _ in input().split()]
E = [[] for _ in range(N)]

indegree = [0] * N  # 入次数
for i in range(M):
    a, b = [int(_) - 1 for _ in input().split()]
    E[a].append(b)
    indegree[b] += 1

sorted_nodes = []
dp = [0] * N


def rep(v):
    """初めて呼ばれたときに, そのノードからの最長ノード数を数えるイメージ"""
    if dp[v] != 0: return dp[v]
    for n in E[v]:
        dp[v] = max(dp[v], rep(n) + 1)
    return dp[v]


ans = 0
for i in range(N):
    ans = max(ans, rep(i))
print(ans)


Measured memory_bytes: 168140
#include<stdio.h>

int main(void)
{
	int i,j,k,v,A[100],N;
	
	scanf("%d",&N);
	for(i=0;i<=N-1;i++)
	{
		scanf("%d",&A[i]);
		printf("%d",A[i]);
		if(i!=N-1) printf(" ");
	}
	for(i=1;i<=N-1;i++)
	{
		printf("\n");
		v=A[i];
		j=i-1;
		while(j >= 0 && A[j] > v)
		{
			A[j+1]=A[j];
			j--;
		}
	    A[j+1]=v;
		for(k=0;k<=N-1;k++)
		{
			printf("%d",A[k]);
			if(k!=N-1) printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n, m, a, b, c, d;
    string s, t;
    cin >> a >> b >> c >> d;
    bool ok = false;
    if(abs(a-c)<=d ||(abs(a-b)<=d&&abs(b-c)<=d)) ok = true;
    if (ok) Yes();
    else No();
}


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




int main(){
  int n;
  cin>>n;
  int mi=100;
  int ans=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ans+=a;
    if(a%10!=0){
      mi=min(a,mi);
    }
  }
  if(ans%10!=0){
    cout <<ans;
    return 0;
  }
  if(mi%10!=0){
    cout <<ans-mi;
  }
  else{
    cout <<0;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String step = sc.next();
		boolean good = true;

		for (int i = 0; i < step.length(); i++) {
			if (i % 2 == 0) {
				if (step.substring(i, i + 1).equals("L")) {
					good = false;
				}
			} else {
				if (step.substring(i, i + 1).equals("R")) {
					good = false;
				}
			}
		}

		if (good) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const ll maxn=5e3;
ll pw(ll x, ll p){
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=mod;
        }
        x*=x;
        x%=mod;
        p>>=1;
    }
    return ret;
}
ll inv(ll x){
    return pw(x, mod-2);
}
const long double eps=1e-12;
int sign(double a){
    if (a>eps) return 1;
    else return 0;
}
signed main(){
    IOS();
    cout<<fixed<<setprecision(10);
    int a,b, c; cin>>a>>b>>c;
    if ((c-a-b)<=0){
        cout<<"No\n";
        return 0;
    }
    int sqq=SQ(c-a-b);
    bool joe=((4*a*b)<sqq);
    if (joe){
        cout<<"Yes\n";
    }
    else cout<<"No"<<endl;
}

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

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

    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    REP(i, n){
        int a;
        cin >> a;
        mp[a]++;
    }

    if(mp.size() <= k){
        cout << 0 << endl;
        return 0;
    }

    vector<int> A;
    for(auto x : mp) A.push_back(x.second);
    sort(A.begin(), A.end());
    int ans = 0;
    REP(i, mp.size() - k){
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

template <typename X>
struct SegmentTree {
    using FX = function<X(X, X)>;
    int n;
    FX fx;
    const X ex;
    vector<X> dat;
    SegmentTree(int n_, FX fx_, X ex_) : fx(fx_), ex(ex_) {
        int x = 1;
        while (n_ > x) x *= 2;
        n = x;
        dat.resize(n * 2, ex);
    }

    void set(int i, X x) {
        dat[i + n - 1] = x;
    }
    void build() {
        for (int i = n - 2; i >= 0; --i) {
            dat[i] = fx(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    void update(int i, X x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    X query(int a, int b) {
        return query_sub(a, b, 0, 0, n);
    }
    X query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return ex;
        }
        else if (a <= l && r <= b) {
            return dat[k];
        }
        else {
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
};

int main() {
    unsigned int n, q, c, x, y;
    cin >> n >> q;
    SegmentTree<unsigned int> rmq(n,
    [](unsigned int x1, unsigned int x2) -> int { return min(x1, x2); },
    (1u << 31) - 1 );
    while (q--) {
        cin >> c >> x >> y;
        if (c == 0) {
            rmq.update(x, y);
        }
        else {
            cout << rmq.query(x, y + 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
using namespace std;
/*
  1
4 2 3 5
  6
*/
class Dice {
private:
  int s[6];
public:
  Dice();
  Dice(int t[6]);
  int get(int pos);
  void set(int pos, int x);
  void move(char dir);
  bool operator==(Dice d);
};

Dice::Dice() {
  for (int i = 0; i < 6; i++) {
    s[i] = 0;
  }
}

Dice::Dice(int t[6]) {
  for (int i = 0; i < 6; i++) {
    s[i] = t[i];
  }
}

int Dice::get(int pos) {
  return s[pos];
}

void Dice::set(int pos, int x) {
  s[pos] = x;
}

bool Dice::operator==(Dice d) {
  for (int i = 0; i < 6; i++) {
    if (s[i] != d.get(i)) {
      return false;
    }
  }
  return true;
}

void Dice::move(char dir) {
  int t;
  switch (dir) {
    case 'N': {
      t = s[0];
      s[0] = s[1];
      s[1] = s[5];
      s[5] = s[4];
      s[4] = t;
      break;
    }
    case 'E': {
      t = s[3];
      s[3] = s[5];
      s[5] = s[2];
      s[2] = s[0];
      s[0] = t;
      break;
    }
    case 'W': {
      t = s[0];
      s[0] = s[2];
      s[2] = s[5];
      s[5] = s[3];
      s[3] = t;
      break;
    }
    case 'S': {
      t = s[4];
      s[4] = s[5];
      s[5] = s[1];
      s[1] = s[0];
      s[0] = t;
      break;
    }
  }
}

int main() {
  bool f = false;
  int t;
  Dice d1, d2;

  for (int i = 0; i < 6; i++) {
    cin >> t;
    d1.set(i, t);
  }

  for (int i = 0; i < 6; i++) {
    cin >> t;
    d2.set(i, t);
  }

  for (int i = 0; i < 4; i++) {
    d2.move('W');
    for (int j = 0; j < 4; j++) {
      d2.move('N');
      for (int k = 0; k < 4; k++) {
        d2.move('W');
        if (d1 == d2) {
          f = true;
        }
      }
    }
  }

  if (f) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

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


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 n, m;
	cin >> n >> m;
	vector<bool> is_safe;
	is_safe.assign(n + 1, true);
	rep(i, m) {
		int a;
		cin >> a;
		is_safe[a] = false;
	}

	vector<int> dp(n+1,0);
	dp[0] = 1;
	if (is_safe[1]) dp[1] = 1;

	for (int i = 2; i <= n; ++i) {
		if (is_safe[i - 1]) dp[i] += dp[i - 1];
		if (is_safe[i - 2]) dp[i] += dp[i - 2];
		dp[i] %= MOD;
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 







int dp[200][200];
int x[100][100],y[100][100];
int main()
{
    string s,t;
    cin>>s>>t;
    map<char,char> m1,m2;
    int f=1;
    for(int i=0;i<s.length();i++){
         char x=s[i],y=t[i];
         if(m1.find(x)!=m1.end()&&m1[x]!=y){
              f=0;break;
         }
         else {
              m1[x]=y;
              if(m2.find(y)!=m2.end()){
                   if(m2[y]!=x){
                        f=0;break;
                   }
              }
              else{
                   m2[y]=x;
              }
         }
    }
    if(f)cout<<"Yes";
    else cout<<"No";
}


























Measured memory_bytes: 3900
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
A = l[0] * 1
B = l[1] * 1

// 最大公約数
_gcd = function(m, n, t) {
	while (m % n !== 0) {
		t = n;
		n = m % n;
		m = t;
	}
	return n;
}

// 最小公倍数
_lcm = function(m, n) {
  return m * n / _gcd(m, n)
}

console.log(_lcm(A,B))

Measured memory_bytes: 7372
n = int(input())
s = input()
mya = [0]*3
       
ans = 0
for i in range(1000):
    q = '{:0=3}'.format(i)

    keta = 0
    for j in range(n):
        if s[j] == q[keta]:
            keta += 1
            if keta == 3:
                break
    if keta == 3:
        ans += 1
            
print(ans)

Measured memory_bytes: 40940
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,l,i;
	cin>>n>>l;
	string s[n];
	for(i=0;i<n;i++)cin>>s[i];
	sort(s,s+n);
	for(i=0;i<n;i++)cout<<s[i];
	cout<<endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{

    int start, ans, diff;
    int i;
    int s, t;
    char S[1000], T[1000];

    scanf("%s", S);
    scanf("%s", T);

    s = strlen(S);
    t = strlen(T);

    ans = s;

    for (start = 0; start <= s - t; start++)
    {
        diff = 0;
        for (i = 0; i < t; i++)
        {
            if (T[i] != S[start + i])
            {
                diff++;
            }
            
        }
        if (ans > diff)
        {
            ans = diff;
        }
        
    }

    printf("%d",ans);

    return 0;
}

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

int main(void) {
    int n, m;
    cin >> n >> m;
    int cand;
    for (int i = 1; i * i <= m; ++i) {
        if (i > m / n) {
            break;
        } else if (m % i == 0) {
            if (i >= n) {
                cand = max(cand, m / i);
            } else if (m / i >= n) {
                cand = max(cand, i);
            }
        }
    }
    cout << cand << "\n";
}


Measured memory_bytes: 256
n,m = map(int,input().split())
branch = dict()
for i in range(n):
	branch[i+1] = []
for i in range(m):
	a,b = map(int,input().split())
	branch[a].append(b)
	branch[b].append(a)

q = []
for i in range(len(branch[1])):
	q.append(branch[1][i])

check = False
for i in range(len(q)):
	if n in branch[q[i]]:
		check = True
		break
if check:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Measured memory_bytes: 56160
#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 n;
    cin >> n;
    ll ans = 0;
    map<pair<char, char>, ll> mp;
    rep(i, 1, n + 1) {
        string s = to_string(i);
        mp[make_pair(s.front(), s.back())]++;
    }
    for (auto i : mp) {
        auto p = i.first;
        pair<char, char> rp = make_pair(p.second, p.first);
        ans += mp[p] * mp[rp];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    if (a<b){
     cout<<"a < b"<<endl;
}    
    if (a>b){
     cout<<"a > b"<<endl;
}
   if (a==b){
       cout<<"a == b"<<endl;
} 
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

  map<char,char> memo, memo2;

  bool flg = true;
  rep(i,S.size()){
    if(memo.count(S[i]) > 0){
      if(memo[S[i]] != T[i]) flg = false;
    }
    memo[S[i]] = T[i];

    if(memo2.count(T[i]) > 0){
      if(memo2[T[i]] != S[i]) flg = false;
    }
    memo2[T[i]]= S[i];
  }

  FOR(it,memo){
    char c = it->first;
    map<char,int> visited;
    while(true){
      if(memo.count(c) == 0) break;
      if(visited.count(c) > 0){
        if(c != it->first){
          flg = false;
        }
        break;
      }
      visited[c] = 1;
      c = memo[c];
    }
  }

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

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

const ll MOD=1e9+7;
const ll MAX=5e6;

int main() {
  // Kを順番に見ていくと時間が無い
  ll N,K;cin>>N>>K;
  vector<ll> AS(N);
  vector<ll> FS(N);
  REP(i,N) cin>>AS[i];
  REP(i,N) cin>>FS[i];
  sort(ALL(AS));
  sort(ALL(FS),greater<int>());

  // ASで累積和
  vector<ll> sum(N+1,0);
  REP(i,N) sum[i+1]=sum[i]+AS[i];
  if (sum[N]<=K) {
    OUT(0);
    return 0;
  }

  auto checker = [&](ll x) {
    ll sum=0;
    REP(i,N) {
      sum += max(0LL,AS[i]-x/FS[i]);
      if (sum>K) return false;
    }
    return true;
  };

  ll left=0,right=1e12;
  while (left<right) {
    ll mid=(left+right)/2;
    checker(mid) ? right=mid : left=mid+1;
  }

  OUT(left);

  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int IINF = INT_MAX;

void chmin(int &a, int b){a=min(a,b);};


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n+2, n+1);
    vector<vector<int> > dp(n+2, vector<int>(n+2, IINF/2));
    for(int i=0;i<m;i++){
        int c, d;
        cin >> c >> d;
        a[d] = min(a[d], c);
    }
    dp[0][n+1] = 0;
    for(int i=0;i<=n;i++){
        for(int j=1;j<=n+1;j++){
            chmin(dp[i+1][min(j, a[i+1])],dp[i][j]+1);
            if(j<n+1){
                chmin(dp[i+1][min(n+1, a[i+1])], dp[i][j] + abs(i-j)*2+1);
            }
        }
    }
    cout << dp[n+1][n+1] << endl;
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	int w[100],v[100];
	for(int i=0;i<n;i++){
		cin >> v[i] >> w[i];
	}

	int DP[101][10001];

	for(int j=0;j<=m;j++)
		DP[n][j] = 0;

	for(int i=n-1;i>=0;i--){
		for(int j=0;j<=m;j++){
			if(j<w[i]){
				DP[i][j] = DP[i+1][j];
			}else{
				if(DP[i+1][j]>DP[i+1][j-w[i]]+v[i]){
					DP[i][j] = DP[i+1][j];
				}else{
					DP[i][j] = DP[i+1][j-w[i]]+v[i];
				}
			}
		}
	}
	
	cout << DP[0][m] <<endl;

	return 0;
}

Measured memory_bytes: 7024
def slove():
    import sys
    input = sys.stdin.readline
    n, x = list(map(int, input().rstrip('\n').split()))
    m = [int(input().rstrip('\n')) for _ in range(n)]
    m.sort()
    t = sum(m)
    x -= t
    print(n + x // m[0])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll n; cin>>n;
  vector<ll> P(n);
  rep(i,n){
    cin>>P[i];
    P[i]--;
  }
  vector<ll> idx(n);
  rep(i,n){
    idx[P[i]]=i;
  }

  ll ans=0;
  multiset<ll> s{-1,-1,n,n};
  rep(p,n-1,-1,-1){
    ll i=idx[p];
    auto it1=s.insert(i);
    auto it2=it1;
    ll l0,l1,r0,r1;
    l0=*(--it1);
    l1=*(--it1);
    r0=*(++it2);
    r1=*(++it2);
    ans+=(p+1)*((i-l0)*(r1-r0)+(l0-l1)*(r0-i));
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 6528
#include <stdio.h>

int main () {

    int i, j, min, N, c, x, m;
    int a[100];

    m = 0;

    scanf("%d", &N);

    for (i = 0; i < N; i++)
        scanf("%d", &a[i]);

    for (i = 0; i < N; i++) {
        min = 101;
        for (j = i; j < N; j++) {
            if (a[j] < min) {
                min = a[j];
                c = j;
            }
        }
        if (min != a[i]) {
            x = a[i];
            a[i] = a[c];
            a[c] = x;
            m += 1;
        }
    }

    for (i = 0; i < N - 1; i++)
        printf("%d ", a[i]);
        printf("%d", a[N - 1]);
        puts("");
        printf("%d\n", m);

    return 0;

}



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

const int MAX_N = (int)(3 * 1e5 + 5);

int n;
string s;

int east[MAX_N];
int west[MAX_N];

int ans = MAX_N;

int main(void){
  scanf("%d", &n);
  cin >> s;

  if (s[0] == 'E') {
    east[0] = 1;
    west[0] = 0;
  }
  else {
    east[0] = 0;
    west[0] = 1;
  }

  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == 'E') {
      east[i] = east[i - 1] + 1;
      west[i] = west[i - 1] + 0;
    }
    else {
      east[i] = east[i - 1] + 0;
      west[i] = west[i - 1] + 1;
    }
  }

  int whole_east = east[s.size() - 1];
  int whole_west = west[s.size() - 1];

  for (int i = 0; i < s.size(); ++i) {
    int right_east = whole_east - east[i];
    // int right_west = whole_west - west[i];

    // int left_east;
    int left_west;
    if (s[i] == 'E') {
      // left_east = east[i] - 1;
      left_west = west[i] - 0;
    }
    else {
      // left_east = east[i] - 0;
      left_west = west[i] - 1;
    }

    int tmp = right_east + left_west;
    ans = min(ans, tmp);
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 2948
/*input
8
8 2 7 3 4 5 6 1
*/

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

int main() {
    int n;
    cin >> n;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    rep(i, n) {
        int x;
        cin >> x;
        que.push(pii(x, i+1));
    }
    rep(i, n) {
        pii p = que.top(); que.pop();
        cout << p.second << endl;
    }
}

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

using namespace std;
#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__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define ld long double
 	#define lb lower_bound 
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
	#define all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
	
	 const int N =3e5+5;
	 const int lg=20;
	
	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};  
	 
	 
	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;	
	   }   
	   
mi mp;	   


void solve() {
	  
	  int n;
	  cin>>n;
	  vi a(n,0),b(n,0);
	  rep(i,0,n) {
		    cin>>a[i]>>b[i];
		  }
		  
		  sort(all(a));
		  sort(all(b));
		  
		  int x=0,y=0;
		  
		  if(n%2==1) {
			    x=a[n/2];
			    y=b[n/2];
			  }
		  else {
			     x=a[n/2-1]+a[n/2];
			     y=b[n/2-1]+b[n/2];
			  }	  
			  
			  cout<<y-x+1<<endl;		    
			  
		  } 
 
int32_t main() {
	cool;
	int t=1;	
	   //~ cin>>t;
	while(t--)
	   solve();		   
	   
	   return 0;	   
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n;
	while (cin >> n, n) {
		vector<int>v(n); rep(i, 0, n)cin >> v[i];
		int k; cin >> k;
		int ans(0);
		int l = 0, r = n - 1;
		while (l <= r) {
			int mid = (l + r) / 2;
			ans++;
			if (v[mid] == k)break;
			else if (v[mid] < k) l = mid + 1;
			else r = mid - 1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int flag, i, N;
    long long P, T, s[200010];
    scanf("%d%lld", &N, &T);
    for (i=0;i<N;i++) scanf("%lld", &s[i]);

    P = 0LL; flag = 0;
    for (i=0;i<N;i++) {
        if (i<N-1) {
            if (s[i] + T > s[i+1]) {
                P += s[i+1] - s[i];
                flag = 1;
            } else {
                P += T;
                flag = 0;
            }
        } else {
            P += T;
        }
    }
    printf("%lld\n", P);
    return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

int H, W, D;
map<ll, pair<int, int> > data;

int main(){
    ios::sync_with_stdio(false);
    cin >> H >> W >> D;
    REP(i, H) REP(j, W) {
        int t;
        cin >> t;
        data[t]=(make_pair(i, j));
    }
    // 全ての経路を計算する
    map<ll, vector<ll> > data2;
    FOR(i, 1, H*W+1) {
        if(i / (1+D) == 1 ) break;
        for(ll j = i + D; j < W*H+1; j+=D) {
            p a = data[j];
            p b = data[j-D];
            data2[i].pb(abs(a.first - b.first) +abs(a.second - b.second));
        }
    }
    // 累積和
    map<ll, vector<ll> > data3;
    FOR(i, 1, H*W+1) {
        if(i / (1+D) == 1 ) break;
        data3[i].resize(data2[i].size()+1,0);
        REP(j,data2[i].size()) {
            data3[i][j+1] = data2[i][j] + data3[i][j];
        }
    }
    int Q;
    cin >> Q;
    REP(i, Q) {
        int L, R;
        cin >> L >> R;
        int st = L % D;
        st = st == 0 ? D : st;
        int num = (R-L)/D;
        int st2 = (L - st) / D;
        cout << data3[st][st2+num] - data3[st][st2] << endl;
    }
    
    return 0;
}


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

using namespace std;
const int mod = 1000000007;

int main(void)
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> dp(H+1, vector<int>(W, 0));
	dp[0][0] = 1;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			for (int k = 0; k < (1 << (W - 1)); k++){
				//kが正しい形か判断する
				bool flag = false;
				for (int l = 0; l < W - 2; l++){
					if (((k >> l)) & 1 && ((k >> (l + 1)) & 1)){
						flag = true;
					}
				}
				if (flag) continue;

				//右に横棒をはやす
				//dp[h+1][w+1] += dp[h][w]
				if (j != W - 1 && ((k >> j) & 1)){
					dp[i + 1][j + 1] += dp[i][j];
					dp[i + 1][j + 1] %= mod;
				}
				//左に横棒をはやす
				//dp[h+1][w-1] += dp[h][w]
				else if (j != 0 && ((k >> (j - 1)) & 1)){
					dp[i + 1][j - 1] += dp[i][j];
					dp[i + 1][j - 1] %= mod;
				}

				//そのまま下へ行く
				//dp[h+1][w] += dp[h][w]
				else{
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j] %= mod;
				}
			}
		}
	}

	cout << dp[H][K - 1] << endl;
}

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

int main() {
    int h, w, m; cin >> h >> w >> m;

    vector<int> row[h+1];
    vector<int> col[w+1];
    int colc[w+1];
    int rowc[h+1];
    memset(colc, 0, sizeof colc);
    memset(rowc, 0, sizeof rowc);
    while(m--) {
        int a, b; cin >> a >> b;
        row[a].push_back(b);
        col[b].push_back(a);
        rowc[a]++;
        colc[b]++;
    }
    int ri = 0;
    int mx = 0;
    for (int i=1; i<=h; i++) {
        if (row[i].size() > mx) {
            mx = row[i].size();
            ri = i;
        }
    }

    for (int j: row[ri]) colc[j]--;
    int maxc = 0;
    for (int i=1; i<=w; i++) maxc = max(maxc, colc[i]);
    int ans1 = maxc + mx;
    

    int rc = 0;
    mx = 0;
    for (int i=1; i<=w; i++) {
      if (col[i].size() > mx) {
        mx = col[i].size();
        rc = i;
      }
    }
    for (int j: col[rc]) rowc[j]--;
    int maxr = 0;
    for (int i=1; i<=h; i++) maxr = max(maxr, rowc[i]);
    ans1 = max(ans1, mx + maxr);
    cout << ans1 << endl;

}


Measured memory_bytes: 38776
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}

int main()
{
    arena
    ll n,m;
    cin>>n>>m;
    
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    
    ll x=0;
    for(ll i=0;i<n;i++)
    {
        if(i==0)
        {
            ll temp=arr[i];
            while(temp%2==0)
            {
                temp=temp/2;
                x++;
            }
            continue;
        }
        
        ll temp1=arr[i];
        ll cnt=0;
        while(temp1%2==0)
        {
            temp1=temp1/2;
            cnt++;
        }
        if(cnt!=x)
        {
            cout<<"0";
            return 0;
        }
    }
    
    for(ll i=0;i<n;i++)
    {
        arr[i]=arr[i]/2;
    }
    
    ll ans=arr[0];
    for(ll i=1;i<n;i++)
    {
        ans=lcm(ans,arr[i]);
    }
    
    ll p=m/ans;
    if(p%2==0)
    cout<<p/2;
    else
    cout<<p/2+1;
}

Measured memory_bytes: 1024