akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

vector<int> graph[100001];
bool reached[100001];

void dfs(int x){
	reached[x] = true;
	for (auto y : graph[x]){
		if (!reached[y]){
			dfs(y);
		}
	}
	return;
}

int main(){
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++){
		int x, y, z;
		cin >> x >> y >> z;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}

	int ans = 0;
	for (int i = 1; i <= n; i++){
		if (!reached[i]){
			dfs(i);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    n=n*n*n;
    cout<<n<<'\n';    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  string s;
  cin >> s;
  ll r = 0;
  rep(i, s.size()) {
    r += s[i] - '0';
  }
  cout << (r % 9 == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 char b[4]={'3','5','7'};
	map<int,int> M;
    queue<string> q;
    q.push("357");
    q.push("375");
    q.push("537");
    q.push("573");
    q.push("735");
    q.push("753");
    int w=3,count=6,ans=6,nn=0,n;
    stringstream ss;
    cin>>n;
    if(n>=3357)
    {
    	 while(w>0)
    	 {
    	 	  int flag=0,x;
    	 	  for(int j=1;j<=count;j++)
    	 	  {
    	 	  	 string str =q.front(),str1;
    	 	  	 q.pop();
    	 	  	 for(int i=0;i<3;i++)
    	 	  	 {   
    	 	  	      for(int k=0;k<=w;k++)
    	 	  	 	 {   str1=str;
						 str1.insert(str1.begin()+k,b[i]);
    	 	  	 	 ss<<str1;
    	 	  	 	  ss>>x;
    	 	  	 	  ss.clear();
    	 	  	 	  if(x<=n)
    	 	  	 	  {
    	 	  	 	  	 if(M[x]==0)
    	 	  	 	  	 {
    	 	  	 	  	 	 q.push(str1);
    	 	  	 	  	 	 ans++;
    	 	  	 	  	 	 nn++;
    	 	  	 	  	 	 M[x]=1;
							   }
						  }
						  else
						  flag=1;
						 }
    	 	  	  
    	 	  	 	 
					}	
			   }
				count=nn;
				nn=0;
				if(flag)
				break;
				else
				w++;
		 }
	}
  else if(n>=753) ans=6;
    else if(n>=735) ans=5;
    else if(n>=573) ans=4;
    else if(n>=537) ans=3;
    else if(n>=375) ans=2;
    else if(n>=357) ans=1;
    else ans=0;
    printf("%d\n",ans);
}

Measured memory_bytes: 12544
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#define fora(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T> void UNIQUE(vector<T> &a){ SORT(a);a.erase(unique(ALL(a)),a.end());}
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    ll mae=1, ato=2+M;
    repr(i,M,1){
        if((M-i)%2==0){
            cout<< mae SP mae+i <<"\n";
            ++mae;
        }
        else{
            cout<< ato SP ato+i <<"\n";
            ++ato;
        }
    }
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; rep(QQ,Qkai) Main();
    Main();
}
//-----------------------------------------

Measured memory_bytes: 3624
if __name__ == "__main__":
    N, M = map(int, input().split())
    T = []
    for i in range(M):
        p, y = map(int, input().split())
        T.append((p, y, i))
    T.sort()
    ID = []
    cp = -1
    count = -1
    for p, y, i in T:
        if p != cp:
            cp = p
            count = 1
        ID.append((i, "0"*(6-len(str(cp)))+str(cp)+"0"*(6-len(str(count)))+str(count)))
        count += 1
    ID.sort()
    for i , id in ID:
        print(id)


Measured memory_bytes: 35628
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string a,b,c,A,B,C;
	cin>>a>>b>>c;
	A=a.substr(0,1);
	B=b.substr(0,1);
	C=c.substr(0,1);
	transform(A.begin(), A.end(), A.begin(), ::toupper);
	transform(B.begin(), B.end(), B.begin(), ::toupper);
	transform(C.begin(), C.end(), C.begin(), ::toupper);
	cout<<A+B+C<<endl;
	return 0;
}


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

int main()
{
    char s[1001];
    scanf("%s",s);
    char char_array[1001],str2[1001];
    char str[1001];
    strcpy(char_array,s);
    int t,i,a,b,k=0,l=0;
    char temp,p[1001];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%s",str);
        if(strcmp(str,"replace")==0)
        {
            scanf("%d%d",&a,&b);
            scanf("%s",str2);
            for(i=a; i<=b; i++)
            {
                temp=char_array[i];
                char_array[i]=str2[k];
                str2[k]=temp;
                k++;
            }
            k=0;
        }
        else if(strcmp(str,"reverse")==0)
        {
            scanf("%d%d",&a,&b);
            while(a<b)
            {
                temp=char_array[a];
                char_array[a]=char_array[b];
                char_array[b]=temp;
                a++;
                b--;
            }
        }
        else if(strcmp(str,"print")==0)
        {
            scanf("%d%d",&a,&b);
            for(i=a; i<=b; i++)
            {
                p[l]=char_array[i];
                l++;
            }
            p[l]='\0';
            printf("%s\n",p);
            l=0;
        }
    }
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  	string s;
	int i,ans;
  
  cin >> s;
  ans=0;
  for (i=0;i<3;++i)
  {
    if (s[i]=='1')
      ++ans;
  }
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.chomp.split(" ").map(&:to_i)

dp = Array.new(n, Float::INFINITY)
dp[0] = 0
dp[1] = (h[1] - h[0]).abs

for i in 2.. n - 1
    step1 = dp[i - 1] + (h[i] - h[i - 1]).abs
    step2 = dp[i - 2] + (h[i] - h[i - 2]).abs
    
    if step1 < step2
        dp[i] = step1
    else
        dp[i] = step2
    end
end

puts dp[n - 1]

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,k;
cin >> n >> k;
string ans = "Yes";
if(n*k%2==0) {
  ans = "No";
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

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

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i != (n / i) && i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}

bool IsPrime(ll num) {
  if(num == 1)
    return true;
  else if(num == 2)
    return true;
  else if(num % 2 == 0)
    return false;

  ld sqrtNum = sqrt(num);
  for(ll i = 3; i <= sqrtNum; i += 2) {
    if(num % i == 0) return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  if(a < b) swap(a, b);
  ll gcd = GCD(a, b);
  // cout << gcd << '\n';
  vector<ll> s = enum_div(gcd);
  // REP(i, (int)s.size()) cout << s[i] << " ";
  // cout << '\n';
  ll cnt = 0;
  for(ll x : s) {
    if(IsPrime(x)) cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();
        }
        Arrays.sort(p);
        int ans = 0;
        for (int i = 0 ; i < k ; i++) {
            ans += p[i];
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 38828
#include<bits/stdc++.h>
#define ll long long
#define N 310
#define mo 998244353
using namespace std;
string s;
ll jie[N],nj[N],dp[N][N][N],f[N][2],ans,n;
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
ll C(ll x,ll y){if (x==-1&&y==0)return 1;if (x<y)return 0;return (jie[x]*nj[y]%mo)*nj[x-y]%mo;}
int main(){
	cin>>s;n=s.length();
	jie[0]=1;for (int i=1;i<=n;i++)jie[i]=jie[i-1]*i%mo;
	nj[n]=po(jie[n],mo-2);for (int i=n-1;i>=0;i--)nj[i]=nj[i+1]*(i+1)%mo;
	dp[0][0][0]=1;
	for (int i=0;i<=n;i++){
		for (int j=0;j<=i;j++){
			for (int k=0;j+k<=i;k++){
				if (dp[i][j][k]){
					dp[i+1][j][k]=1;
					if (s[i]=='0'||s[i+1]=='0')dp[i+2][j+1][k]=1;
					if (s[i]=='1'||s[i+1]=='1')dp[i+2][j][k+1]=1;
					if (s[i]=='0'&&k)dp[i+1][j+1][k-1]=1;
					if (s[i]=='1'&&j)dp[i+1][j-1][k+1]=1;
				}
			}
		}
	}
	for (int i=n;i>=1;i--){f[i][0]=f[i+1][0];f[i][1]=f[i+1][1];f[i][s[i-1]-'0']++;}
	for (int i=0;i<=n;i++){
		for (int j=0;j<=i;j++){
			for (int k=0;k+j<=i;k++){
				if (dp[i][j][k]){
					ans=(ans+C(f[i][0]+k-1,k)*C(f[i][1]+j-1,j))%mo;
				}
			}
		}
	}
	cout<<(ans+mo-1)%mo<<endl;
	return 0;
}

Measured memory_bytes: 59540
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
    int n;cin>>n;
    vector<P>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(all(a),greater<P>());
    a[n].first=0;
    ll ans[100010]={};
    ll mi=INF;
    for(int i=1;i<=n;i++){
        mi=min(mi,a[i-1].second);
        ans[mi]+=i*(a[i-1].first-a[i].first);
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3456
h,w=map(int,input().split())
snuke=[]
for i in range(h):
  snuke.append(list(map(str,input().split())))
for i in range(h):
  for j in range(w):
    if snuke[i][j]=="snuke":
      print(chr(97+j).upper()+str(i+1))

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

using namespace std;
typedef long long ll;
typedef double ld;
const int MAXN = 65;
const double EPS = 1e-7;

struct pt
{
    double x, y;

    pt()
    {
        x = 0;
        y = 0;
    }

    pt (double __x, double __y)
    {
        x = __x;
        y = __y;
    }

    pt add (pt p)
    {
        return pt(x + p.x, y + p.y);
    }

    pt sub (pt p)
    {
        return pt(x - p.x, y - p.y);
    }

    double dist()
    {
        return sqrt (x * x + y * y);
    }

    pt norm()
    {
        double d = sqrt (x * x + y * y);
        return pt(x / d, y / d);
    }

    pt mult (double d)
    {
        return pt(x * d, y * d);
    }

    pt rot()
    {
        return pt(-y, x);
    }
};

int N, K;
double c[MAXN];
pt p[MAXN];
double r[MAXN];

bool okay (pt goal)
{
    int ans = 0;
    for (int i = 0; i < N; i++)
        if (goal.sub(p[i]).dist() < r[i] + EPS)
            ans++;
    return ans >= K;
}

bool works (ld t)
{
    for (int i = 0; i < N; i++)
        r[i] = t / c[i];

    for (int i = 0; i < N; i++)
        if (okay (p[i]))
            return true;

    for (int i = 0; i < N; i++)
        for (int j = i + 1; j < N; j++)
        {
            double dv = p[i].sub(p[j]).dist();
            if (dv - EPS < abs (r[i] - r[j])) continue;
            if (dv + EPS > r[i] + r[j]) continue;

            double nv = r[i] * r[i] - r[j] * r[j];
            double pv = nv / dv;
            double av = (dv + pv) / 2;

            pt dir = p[j].sub(p[i]).norm();
            pt pg = p[i].add(dir.mult(av));

            double ov = sqrt (r[i] * r[i] - av * av);
            pt pdone1 = pg.add(dir.rot().mult(ov));
            pt pdone2 = pg.add(dir.rot().mult(-ov));
            if (okay (pdone1) || okay (pdone2))
                return true;
        }
    return false;
}

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

    cin >> N >> K;
    for (int i = 0; i < N; i++)
        cin >> p[i].x >> p[i].y >> c[i];

    if (K == 1)
    {
        cout << "0.0\n";
        return 0;
    }

    ld lo = 0., hi = 1e6;
    for (int i = 0; i < 50; i++)
    {
        ld mid = (lo + hi) / 2;
        if (works (mid))
            hi = mid;
        else
            lo = mid;
    }

    cout << fixed << setprecision(8);
    cout << lo << "\n";
}

Measured memory_bytes: 256
from bisect import bisect_left
from random import randint
D = int(input())
Cs = list(map(int, input().split()))
Sss = []
for _ in range(D):
    Ss = list(map(int, input().split()))
    Sss.append(Ss)

def change(d, afterIdx):
    global score
    i = d - 1
    beforeIdx = Ts[i] - 1
    afterIdx -= 1
    if beforeIdx == afterIdx:
        return

    newScore = score

    before = lasts[beforeIdx]
    # dが何番目にあるか
    k1 = bisect_left(before, d)
    w = before[k1+1] - d
    h = d - before[k1-1]
    newScore -= Sss[i][beforeIdx]
    newScore -= w * h * Cs[beforeIdx]

    after = lasts[afterIdx]
    # dが何番目にあるか
    k2 = bisect_left(after, d)
    w = after[k2] - d
    h = d - after[k2-1]
    newScore += Sss[i][afterIdx]
    newScore += w * h * Cs[afterIdx]

    if newScore > score:
        lasts[beforeIdx].pop(k1)
        lasts[afterIdx].insert(k2, d)
        Ts[i] = afterIdx + 1
        score = newScore

Ts = []
for _ in range(D):
    Ts.append(randint(1, 26))

score = 0
lasts = [[0] for _ in range(26)]
for i, t in enumerate(Ts):
    d = i + 1
    t -= 1
    score += Sss[i][t]
    lasts[t].append(d)
    for j in range(26):
        score -= (d - lasts[j][-1]) * Cs[j]

for i in range(26):
    lasts[i].append(D+1)


for i in range(300000):
    change(randint(1, D), randint(1, 26))

for t in Ts:
    print(t)


Measured memory_bytes: 84152
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define pos position<int>
#define at_(p) at(p.x).at(p.y)

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;


const long long P=1000000007;

int main(){
  int s,w;
  cin>>s>>w;
  if(w>=s){
    cout<<"unsafe";
  }else{
    cout<<"safe";
  }

}



/* きょむ〜 */


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

int main()
{
	int N;
	scanf("%d", &N);
	int sum{}, count{1};
	while (sum <= N)
	{
		sum += count;
		count++;
	}
	count--;
	std::vector<int> ans;
	for (int i{1}; i <= count; i++)
		if (i != sum - N)
			printf("%d\n", i);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N;

    scanf("%d", &N);

    switch (N%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            printf("hon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            printf("pon");
            break;
        case 3:
            printf("bon");
            break;
        default:
            break;
            
    }
}

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

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

    int n, a, b;
    cin >> n >> a >> b;
    int x = 0, y = 0;
    rep(i,n){
        int p;
        cin >> p;
        if(p<=a)
            x++;
        else if(b<p)
            y++;
    }
    cout << min({x, y, n - x - y}) << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
sc = []
for i in range(M):
    s, c = map(int, input().split())
    sc.append((s, str(c)))
for i in range(0, 1000):
    i = list(str(i))
    if len(i) != N:
        continue
    for s, c in sc:
        if i[s - 1] != c:
            break
    else:
        print(''.join(i))
        exit()
print(-1)


Measured memory_bytes: 3064
A, B, K = map(int, input().split())
f = 0
for i in range(K):
  if f == 0:
    A, B = A // 2, B + A // 2
  else:
    A, B = A + B // 2, B // 2
  f ^= 1
print(str(A) + " " + str(B))

Measured memory_bytes: 61816
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL a;
    LL b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;

    return 0;
}


Measured memory_bytes: 3624
n = gets.to_i
t, a = gets.split(" ").map(&:to_i)
h = gets.split(" ").map(&:to_i)

arr = h.map do |i|
  t - (i * 0.006)
end
m = arr.min_by { |i| (a - i).abs }
p arr.index(m) + 1


Measured memory_bytes: 1788
import java.util.Scanner;

class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		//String string = scanner.next();
		int N = scanner.nextInt();
		
		for(int i = N;i < 1000;i++){
			if(i == 111 ||i == 222 || i == 333 ||i == 444 ||i == 555 ||i == 666 ||i == 777 ||i == 888 ||i == 999){
				System.out.println(i);
				return;
			}
		}
	}
}



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

#define N 200000

using namespace std;

map <int ,int > record;

int main(void){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int data;
		scanf("%d",&data);
		map<int ,int >::iterator itr = record.find(data);
		if(itr!=record.end()){
			itr->second++;
		}else{
			record.insert(make_pair(data,1));
		}
	}
	int size = record.size();
	if(size<=k){
		printf("0\n");
		return 0;
	}else{
		int rang = size-k;
		priority_queue <int ,vector<int >,greater<int > > minus;
		for(map<int ,int >::iterator i=record.begin();i!=record.end();i++){
			minus.push(i->second);
		}
		int ans=0;
		while(rang--){
			ans+=minus.top();
			minus.pop();
		}
		printf("%d\n",ans);
		return 0;
	}
} 

Measured memory_bytes: 10748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication30
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int r = int.Parse(Console.ReadLine());
                if (r == 0)
                    break;
                int c, d, a;
                a = c = d = 0;
                a = 1000 - r;
                c += a / 500;
                d = a % 500;
                c += d / 100;
                d = d % 100;
                c += d / 50;
                d = d % 50;
                c += d / 10;
                d = d % 10;
                c += d / 5;
                d = d % 5;
                c += d / 1;
                Console.WriteLine(c);
            }
        }
    }
}

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

int main() 
{
    int n, k;
    cin >> n >> k;
    k--;

    string s;
    cin >> s;

    string ans = "";
    rep(i,n) {
        char ch = s[i];
        if (i != k) ans += ch;
        else {
            if (ch == 'A') ans += 'a';
            if (ch == 'B') ans += 'b';
            if (ch == 'C') ans += 'c';
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
int main(void)
{
  int n,a,b,c;
  scanf("%d",&n);
  a=n/100;
  b=(n-a*100)/10;
  c=n-a*100-b*10;
  if(a==7||b==7||c==7)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 1724
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int []a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		scan.close();
		for(int i = n - 1; i >= 0; i--) {
			if(i == 0) {
				System.out.println(a[i]);
			}else {
				System.out.print(a[i] + " ");
			}
		}
	}
}


Measured memory_bytes: 26252
#include <iostream>
using namespace std;
int main(){

  int n,s1=1145141919,s2,result=-1145141919;

  cin>>n>>s2;
  for(int i=1;i<n;i++){
    s1=min(s1,s2);
    cin>>s2;
    result=max(result,s2-s1);
  }
   
  cout<<result<<endl;

  return 0; 

}



Measured memory_bytes: 3108
use std::io::stdin;


fn read_ints() -> Vec<i32> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|token |token.parse().unwrap()).collect()
}

fn main() {
    let values = read_ints();
    let max_value = values.iter().max_by_key(|&x | x).unwrap();
    let min_value = values.iter().min_by_key(|&x | x).unwrap();
    let answer = max_value -min_value;
    println!("{}", answer);
}

Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  int x, y;
  vector<pair<int,int>> v(n);
  for(int i=0; i<n; i++) {
    cin >> x >> y;
    v[i] = make_pair(x, y);
  }
  
  vector<pair<int,int>> w(m);
  for(int i=0; i<m; i++) {
    cin >> x >> y;
    w[i] = make_pair(x, y);
  }
  
  int xn, xm, yn, ym, dis, ans;
  int i = 1;
  int min = 1000000000;
  for(auto s : v) {
    tie(xn, yn) = s;
    for(auto t : w) {
      tie(xm, ym) = t;
      dis = abs(xn-xm)+abs(yn-ym);
      if(min>dis) {
        min = dis;
        ans = i;
      }
      i++;
    }
    cout << ans << endl;
    min = 1000000000;
    i = 1;
  }
  return 0;
}

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

int main(){
    int n, c=0;
    cin >> n;

    vector <int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int k=a[0];
    for(int i =1; i < n; i++){
        if(k<=a[i]){
          c++;
          k=a[i];
        }
    }
    printf("%d\n",c+1);
    return 0;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2,v=0; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n*2);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	bool f = false;
	REP(i, s.size())REP(j, i + 1)
	{
		string t = s.substr(0, j) + s.substr(i);
		if (t == "keyence") f = true;
	}
	cout << (f ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

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

const double pi = M_PI;
const Int MOD = 1000000007;

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

    bool is_kaibun = true;
    int ss = s.size();
    string S = s;
    reverse(S.begin(), S.end());
    for (int i = 0; i < ss; i++) {
        if (s[i] != S[i]) {
            is_kaibun = false;
            break;
        }
    }

    bool right = true, left = true;
    string r, l, R, L;
    for (int i = 0; i < ss / 2; i++) {
        r.push_back(s[i]);
    }
    for (int i = ss / 2 + 1; i < ss; i++) {
        l.push_back(s[i]);
    }

    R = r;
    reverse(R.begin(), R.end());
    L = l;
    reverse(L.begin(), L.end());

    for (int i = 0; i < ss / 2; i++) {
        if (r[i] != R[i]) {
            right = false;
            break;
        }
    }
    for (int i = 0; i < ss / 2; i++) {
        if (l[i] != L[i]) {
            left = false;
            break;
        }
    }

    if (is_kaibun && right && left) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, k, i;
    cin>>n>>k;
    double ans = 0;
    int tmp;
    double tmp2=1.0;
    for(i=1; i<=n; i++){
        tmp = i;
        tmp2 = 1/(double)n;
        while(1){
            if(tmp>=k){
                break;
            }
            tmp2 *= 0.5;
            tmp *= 2;
        }
        ans += tmp2;
    }
    printf("%.9f\n",ans);
    return 0;
}

Measured memory_bytes: 256
Scanf.(Array.(scanf" %d"@@fun n->
	let a=init n (fun i->scanf" %d"@@fun v->(v,i))
	in sort compare a;
	let (l,_),(r,_)=a.(n/2-1),a.(n/2) in
	let a=map (fun (v,i) -> i,if v<=l then r else l) a
	in sort compare a;
	iter (fun (_,v)->print_int v;print_newline()) a))

Measured memory_bytes: 18432
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
void solve(){
    ll k=0;
    cin>>k;
    ll s=0;
    for(ll i=1;i<=k;++i){
        for(ll j=1;j<=k;++j){
            for(ll l=1;l<=k;++l){
                s+=__gcd(l,__gcd(i,j));
            }
        }
    }
    cout<<s;
}
int main()
{
    fastio;
//    ll t=0;
//    cin>>t;
//    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    int len = S.size();

    vector<int> counter(3);
    for(int i = 0; i < len; i++){
        if(S[i] == 'a'){
            counter[0]++;
        } else if(S[i] == 'b'){
            counter[1]++;
        } else {
            counter[2]++;
        }
    }

    int diff1 = abs(counter[0] - counter[1]);
    int diff2 = abs(counter[1] - counter[2]);
    int diff3 = abs(counter[2] - counter[0]);

    if(diff1 <= 1 && diff2 <= 1 && diff3 <= 1){
        cout << "YES" << endl;
    } else{
        cout << "NO"<< endl;
    }

    return 0;
}


Measured memory_bytes: 3756
K = int(input())
if K==7 or K==1:
  print(1)
else:
  count = 1
  x = 7%K
  for i in range(K):
    x = (x*10+7)%K
    count += 1
    if x==0:
      print(count)
      break
  if x!=0:
    print(-1)

Measured memory_bytes: 9092
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		String[] d = new String[N];

		for (int i = 0; i < N; i++) {
			String s = sc.next();
			int p = sc.nextInt();
			d[i] = s + (200-p);
		}

		String[] ans = new String[N];
		for (int i = 0; i < N; i++)
			ans[i] = d[i];

		Arrays.sort(ans);

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (ans[i] == d[j])
					System.out.println(j + 1);
			}
		}

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    while (1)
    {
        cin >> n;
        if (n == 0)
            break;
        vector<string> f(n);
        rep(i, n) cin >> f[i];
        int ans = 0;
        bool last = true, left = true, right = true;
        rep(i, n)
        {
            if (f[i] == "lu")
                left = false;
            if (f[i] == "ru")
                right = false;
            if (f[i] == "ld")
                left = true;
            if (f[i] == "rd")
                right = true;
            if (right && left)
            {
                if (!last)
                    ans++;
                last = true;
            }
            if (!right && !left)
            {
                if (last)
                    ans++;
                last = false;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3240
program sample
	implicit none
    integer(8) :: x,y,z,a,b,c,d
    
    read(*,*) x,y,z
    
    if (mod(x,2)/=0 .and. mod(y,2)/=0 .and. mod(z,2) /=0) then
    	if (x<=y) then
        	if (y>z) then
            	a=y
                b=z
                y=b
                z=a
            end if
            write(*,*) x*y
        else
        	a=x
            b=y
            x=b
            y=a
            if (y>z) then
            	c=y
                d=z
                y=d
                z=c
            end if
           	write(*,*) x*y
        end if
    else
    	write(*,*) 0
    end if
    
    stop
end program sample

Measured memory_bytes: 256
if __name__ == '__main__':
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    l =abs(a - b)
    s=abs(v - w)

    if w >= v or l / s > t:
        print("NO")
    else:
        print("YES")


Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
using namespace std;
int n, r, t, a[1000], u[1000], sum;
int main() {
	cin >> n >> r >> t; for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 1; i <= t; i++) {
		for (int j = 0; j < n; j++) {
			int pos = (i*a[j]) % r;
			if (u[pos] == 0) { u[pos] = 1; sum++; }
			u[pos]--;
		}
		if (i == 1)continue;
		for (int j = 0; j < n; j++) u[(i*a[j]) % r]++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    string ans;
    REP(i,s.size()){
        if(s[i]=='0'){
            ans.push_back('0');
        }
        else if(s[i]=='1'){
            ans.push_back('1');
        }
        else if(ans.size()) ans.pop_back();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        if (B.substring(0,1).equals(A.substring(A.length()-1))) {
          if  (C.substring(0,1).equals(B.substring(B.length()-1))) {   
            System.out.println("YES");
          } else {
            System.out.println("NO");
          }
        } else {
          System.out.println("NO");
        }     
  }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
	#pragma GCC target("avx,avx2,fma")
	#pragma GCC optimization ("unroll-loops")
	
    #include<bits/stdc++.h>
    using namespace std;
	
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    #define ff first
    #define ss second
    #define null NULL
    #define MAX 1000000000  // 1x10^9
    #define all(c) (c).begin(),(c).end()
    #define eb emplace_back
    #define pb push_back
    #define pf push_front
    #define lb lower_bound   //used for sortted 
    #define ub upper_bound 
    #define m_p make_pair      
    #define mod 1000000007
    #define For(i,n) for(int i=(0);i<(n);++i)
    #define FOR(i,a,b) for(int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
    #define in(s3) inserter((s3), (s3).begin())  //	set_union(all(s1),all(s2),in(s3));
    typedef vector<ll> vl;
    typedef vector< vl > vvl;
    typedef pair< ll,ll> pll;
    typedef map< ll,ll> mll;
    
    //  A-65 Z-90 a-97 z-122   A-a = 32   Z-A = z-a = 35
    //	v.push_back(make_pair(min(2 * k[i], l[i]) - min(k[i], l[i]), i));      //int pos = v[i].second;
    //	floor(log10(no) + 1);                   //	to_string(no).length();             ----- length of a number
	//  llabs - long long of abs
	//  labs -long of abs
	//  sqrtf - sq root of float
	//  sqrtl - sq of long double    ( cout << fixed << setprecision(12) << sqrtl(val2) << endl; )
	//  it = find (all(vec), e);     if(it != vec.end());       it - vec.begin();
   	//	size_t found = str.find(str1);    if(found != string::npos); 	 cout<<found;
    	 
	/*	
		1. ^ is XOR and is used to to check odd occurance of number as a number XORed with itself results in zero so all even	occurrances result in zero.
		2.   & is used to check even or odd. (x & 1) ? printf("Odd") : printf("Even"); 
		3.   left shift(<<) - *         right shift(>>) - /
	*/
	
	string to_string(char& x) {      
		string s(1,x);
		return s;    
	} 
	struct obj {
		ull val1;
		ull val2;
		ull pos;
	};
	bool cmp(const pair<int,int>&a,const pair<int,int>&b) {
		if(a.first==b.first)
		return a.second<b.second;
		return a.first<b.first;
	}

	int main() {
		string s;
		int n=3;
		int count=0;
		cin>>s;
		for(int i=0;i<3;i++)
		{
			if(s[i]=='R' && count==0)
			count=1;
			if(s[i]=='R' && s[i-1]=='R')
			count++;
		}
		cout<<count;
		return 0;
	}






Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int a[1000005] = { 0 };
int b[1000005] = { 0 };
int main() {
	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i] + i * 10;
	}
	int m = b[0];
	for (int i = 1; i < n; i++) {
		if (10*i > m) {
			cout << "no" << endl;
			return 0;
		}
		else {
			m = max(m, b[i]);
		}
	}
	for (int i = 0; i < n; i++) {
		b[i] = a[n - 1 - i] + i * 10;
	}
	m = b[0];
	for (int i = 1; i < n; i++) {
		if (10 * i > m) {
			cout << "no" << endl;
			return 0;
		}
		else {
			m = max(m, b[i]);
		}
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 5460
def calc(ls, k):
    cnt = 0
    while ls[0] > 0:
        ls.sort(reverse=True)
        for i in range(k):
            ls[i] -= 1
            if ls[i] < 0:
                return cnt
        ls.sort(reverse=True)
        #print(ls)
        cnt += 1
    return cnt

n, k = map(int, input().split())
ls = [0 for i in range(26)]
for i in range(n):
    word = input()
    inx = ord(word[0]) - ord('A')
    ls[inx] += 1
ls.sort(reverse=True)
ans = calc(ls, k)
print(ans)

Measured memory_bytes: 3064
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

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

  cout << (n == 1 ? 0 : 1);
  return 0;
}


Measured memory_bytes: 3628
# 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 <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = 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<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, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v;
map<string, vector<LL>>ma;
//set<LL>st;
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;
}
int main() {
	cin >> n;
	set<LL>st[2];
	rep(i, n) {
		LL x;
		cin >> x;
		st[0].insert(x);
	}
	cin >> m;
	rep(i, m) {
		LL x;
		cin >> x;
		st[1].insert(x);
	}
	set_union(st[0].begin(),st[0].end(), st[1].begin(), st[1].end(), inserter(st[0], st[0].begin()));
	for (auto& i: st[0]) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 35960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  int A,B;
  cin>>A>>B;
  int ans =0;
  for(int a=0;a<10;a++){
    for(int b=0;b<10;b++){
      for(int c=0;c<10;c++){
        int x = 10001*a+1010*b+100*c;
        if(A<=x&&x<=B)
          ans++;
      }
    }
  }
  
	cout<<ans<<endl;


}


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

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back

const int N = 300+1;
int n;
ll d[N][N];

int main()
{
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      scanf("%lld", &d[i][j]);
  //check
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
	if (k != i && k != j && d[i][k]+d[k][j] < d[i][j])
	  {
	    puts("-1");
	    return 0;
	  }
  //cal
  ll ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i+1; j <= n; ++j)
      {
	ans += d[i][j];
	for (int k = 1; k <= n; ++k)
	  if (i != k && j != k && d[i][k]+d[k][j] == d[i][j])
	    {
	      ans -= d[i][j];
	      break;
	    }
      }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 1e6 + 5;

int main() {
	run();
	int n, m;
	cin >> n >> m;
	vector<ii> v(n);
	lp(i,n){
		cin>>v[i].first>>v[i].second;
	}
	sort(all(v));
	int j = 0;
	priority_queue<long long> pq;
	long long ans = 0;
	for (int i = 1; i <= m; i++) {
		for (; j < n && v[j].first == i; j++) {
			pq.push(v[j].second);
		}
		if (pq.size()) {
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
 
  
  sort(A.begin(), A.end());

  
  bool b=true;
  
 
  for(int i=0; i<N-1; i++){
    if(A.at(i)==A.at(i+1)){
      b=false;
      break;
    }
  }
  if(b){
  cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }

  

}





Measured memory_bytes: 1024
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <cstdio>
    #include <bits/stdc++.h>
    #include <unordered_map>
    #include <unordered_set>
    #include <queue>
     
    using namespace std;
    typedef long long ll;
     
     
    bool debug = false;
     
     
    // vector<ll> graph[100005];
    ll good[100005];
    ll H[100005];
     
    int main()
    {
    	std::ios::sync_with_stdio(false);
     
    	
        ll n,m;
        cin >> n >> m;

        for (int i = 1; i <= n; i++)
        {
            cin >> H[i];
            good[i] = 1;
        }

        for (int i = 0; i < m; i++)
        {
            ll a,b;

            cin >> a >> b;

            if (H[a] > H[b])
            {
                good[b] = 0;
            }
            else if (H[a] < H[b])
            {
                good[a] = 0;
            }
            else // ==
            {
                good[a] = 0;
                good[b] = 0;
            }
        }

        ll res = 0;
        for (int i = 1; i <= n; i++)
            if (good[i])
                res++;


        cout << res << endl;
    	

    	return 0;
    }

Measured memory_bytes: 5204