akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using Vl = vector<ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if(a > b || (n == 1 && a != b)){
        cout << 0 << endl;
        return 0;
    }
    cout << b * (n - 1) + a - (b + a * (n - 1)) + 1 << endl;
}



Measured memory_bytes: 3608
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

int n, a, b, c, d;
string s;

bool rusza()
{
  dbg(a);
  if(a + 1 < SZ(s) && s[a + 1] == '.' && a + 1 != b)
  {
    a++;
    return 1;
  }
  else
  {
    if(a + 2 < SZ(s) && s[a + 2] == '.' && a + 2 != b && a + 2 <= c)
    {
      a += 2;
      return 1;
    }
  }
  return 0;
}

bool ruszb()
{
  dbg(b);
  if(b + 1 < SZ(s) && s[b + 1] == '.' && b + 1 != a)
  {
    b++;
    return 1;
  }
  else
  {
    if(b + 2 < SZ(s) && s[b + 2] == '.' && b + 2 != a && b + 2 <= d)
    {
      b += 2;
      return 1;
    }
  }
  return 0;
}

void odp(bool f)
{
  cout<<(f == 0 ? "No" : "Yes");
  exit(0);
}

int main()
{
	_upgrade
  cin>>n>>a>>b>>c>>d>>s;
  s = "#" + s;
  if(c < d)
  {
    while(b != d && ruszb());
    while(a != c && rusza());
    odp(a == c && b == d);
  }
  else
  {
    while(a != c)
    {
      while(a != c && rusza());
      if(a != c)
        if(!ruszb())
          break;
    }
    while(b != d && ruszb());
    odp(a == c && b == d);
  }
	return 0;
}


Measured memory_bytes: 720
def warshall_floid(d):
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

n,m,l = map(int,input().split())
d = [[10**13]*(n+1) for i in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    d[a][b] = c
    d[b][a] = c
for i in range(1,n+1):
    d[i][i] = 0
d = warshall_floid(d)
for i in range(1,n+1):
    for j in range(1,n+1):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**13
d = warshall_floid(d)
q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if d[s][t] >= 10**13:
        print(-1)
    else:
        print(d[s][t]-1)


Measured memory_bytes: 58524
#include <cstdio>

using namespace std;

int main(){
	
	int yx[14][14]={0};
	int x,y,s;
	int count=0;
	int max=0;
	
	while (scanf("%d,%d,%d",&x,&y,&s)!=EOF) {
		x+=2;
		y+=2;
		if (s==1) {
			for (int i=0; i<3; i++) {
				yx[y+i-1][x]++;
				yx[y][x+i-1]++;
			}
			yx[y][x]--;
		}
		else if(s==2){
			for (int i=0; i<3; i++) {
				for(int j=0;j<3;j++){
					yx[y+i-1][x+j-1]++;
				}
			}
		}
		else {
			for (int i=0; i<3; i++) {
				for(int j=0;j<3;j++){
					yx[y+i-1][x+j-1]++;
				}
			}
			yx[y][x-2]++;
			yx[y][x+2]++;
			yx[y-2][x]++;
			yx[y+2][x]++;
			
		}
	}
	
	for (int i=2; i<12; i++) {
		for (int j=2; j<12; j++) {
			if(yx[i][j]==0)count++;
			if (yx[i][j]>max) {
				max=yx[i][j];
			}
		}
	}
	printf("%d\n%d\n",count,max);
	
	return 0;
}
 

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<P> a(n);
    rep(i, n) cin >> a[i].second >> a[i].first;
    sort(whole(a));
    string ans = "Yes";
    ll now = 0;
    rep(i, n) {
        now += a[i].second;
        if (a[i].first<now) {
            ans = "No";
            break;
        }
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int k, n; // k perimeter, n house
  cin >> k >> n; 
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
   cin >> A[i]; 
  }
  // the distance that needs to be traveled is the perimeter minus the largest distance between any 2 houses
  int largest_dist = -1;
  for (int i = 0; i < n - 1; ++i) {
  	largest_dist = max(largest_dist, A[i+1] - A[i]);
  }
  largest_dist = max(largest_dist, k + A[0] - A[n - 1]);
  cout << k - largest_dist << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>

using namespace std;

typedef struct {
  string name;
  int time;
} Process;

int main() {
  int n, q;
  queue<Process> que;
  
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    string name;
    int time;

    cin >> name >> time;

    Process p = {name, time};
    que.push(p);
  }

  int sum = 0;
  while (!que.empty()) {
    Process pro = que.front();
    que.pop();
    
    if (pro.time <= q) {
      sum += pro.time;
      cout << pro.name << " " << sum << endl;
    } else {
      sum += q;
      pro.time -= q;
      que.push(pro);
    }
  }
  
  return 0;
}

Measured memory_bytes: 4404
object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt
    var p = readLine().split(' ').map(_.toInt)
    var check = ""

    if(SortCheck(p)) check = "fin"
    if(check != "fin") {
      var f = -1
      var e = -1
      for(i <- 0 until p.size - 1) {
        if(p(i) > p(i + 1) && f == -1) f = i
      }
      for(i <- f until p.size - 1) {
        if(p(i) > p(i + 1)) e = i + 1
      }
      p = change(p,f,e)
    }
    if(SortCheck(p)) check = "fin"

    if(check == "fin") println("YES")
    else println("NO")
  }

  def SortCheck(p:Array[Int]) ={
    var flag = true
    for(i <- 0 until p.size - 1) {
      if(p(i) > p(i + 1)) flag = false
    }
    flag
  }

  def change(p:Array[Int],f:Int,e:Int) ={
    val temp = p(f)
    p(f) = p(e)
    p(e) = temp
    p
  }
}


Measured memory_bytes: 25540
#include<stdio.h>
int main(){
    int x,y,a,b,n;
    scanf("%d%d",&x,&y);
    if(x>=y){
        a=x;
        b=y;
    }
    else{
        a=y;
        b=x;
    }
    while(b!=0){
        n=b;
        b=a%b;
        a=n;
    }
    printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 2140
#include<stdio.h>
int main(void){
int x,y,z,i,all,cou=0,cou2=0;
while(scanf("%d,%d,%d",&x,&y,&z)!=EOF){
    if(z*z==x*x+y*y)cou++;
    if(x==y)cou2++;
}
printf("%d\n%d\n",cou,cou2);
return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<double> a(N);
    double average = 0;
    for (int i = 0; i < N;i++)
    {

        cin >> a[i];
        average += a[i];
    }

    average /= N;
    double min = 1e9;
    int index;
    for (int i = 0; i< N;i++)
    {
        a[i] = abs(a[i] - average);

        if (min > a[i])
        {
            min = a[i];
            index = i;
        }
    }
    cout << index;
    return 0;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut min = n - 1;
    let mut i = 2;
    while i * i <= n {
        if n % i == 0 {
            min = std::cmp::min(min, i + n / i - 2);
        }
        i += 1;
    }
    println!("{}", min);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define db long double
#define up upper_bound
#define lb lower_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define int long long
#define mod 1000000007
#define MAX 100005
using namespace std;
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
 
    ll a,b;
    cin >> a >> b;
    cout << a*b / (__gcd(a,b));
    
    return 0;
 
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m, s;
	cin >> n >> m >> s;

	ll k = 2525;
	s = min(k,s);

	vl u(m), v(m), a(m), b(m);
	vvl adj(n);
	FOR(i,0,m) {
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		u[i]--, v[i]--;
		adj[u[i]].pb(i);
		adj[v[i]].pb(i);
	}

	
	vl c(n), d(n);
	FOR(i,0,n) cin >> c[i] >> d[i];
	
	vvl dist(n, vl(k+1, oo));
	set<pair<ll,pll>> q;

	dist[0][s] = 0;
	q.insert({0, {0,s}});

	while (sz(q)) {
		ll i, j;
		tie(i,j) = begin(q)->yy;
		q.erase(begin(q));

		auto aug = [&](ll ni, ll nj, ll nd) {
			if (nd >= dist[ni][nj]) return;
			q.erase({dist[ni][nj], {ni,nj}});
			dist[ni][nj] = nd;
			q.insert({dist[ni][nj], {ni,nj}});
		};

		aug(i, min(k, j+c[i]), dist[i][j] + d[i]);
		
		for (ll t: adj[i]) {
			if (a[t] > j) continue;
			ll ni = i ^ u[t] ^ v[t];
			aug(ni, j-a[t], dist[i][j] + b[t]);
		}
	}
	
	FOR(i,1,n) cout << *min_element(all(dist[i])) << endl;
}



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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct UnionFind {
private:
    vector<int> par,sizes;
public:
    UnionFind (int n) {
        par.resize(n);
        sizes = vector<int>(n,1);
        for (int i = 0;i < n;++i) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x,y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x,int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sizes[find(x)];
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0;i < m;++i) {
        int x,y,z;
        cin >> x >> y >> z;
        uf.unite(x-1,y-1);
    }
    unordered_set<int> st;
    for (int i = 0;i < n;++i) st.insert(uf.find(i));
    cout << st.size() << endl;
    return 0;
}

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

#define int long long
#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

const int MOD = 1000000007;

const int N = 200005;

int fac[N], ifac[N];

int power(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) res = 1LL * res * x % MOD;
        y >>= 1;
        x = 1LL * x * x % MOD;
    }
    return res;
}

int C(int k, int n) {
    if (k < 0) return 0;
    if (k > n) return 0;
    return (fac[n] * ifac[k] % MOD * ifac[n - k] % MOD);
}

main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    k = min(k, n);
    fac[0] = ifac[0] = 1;
    for (int i = 1; i <= n; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        ifac[i] = power(fac[i], MOD - 2);
    }
    int ans = 0;
    for (int i = 0; i <= k; i++) {
        ans += C(i, n) * C(n - i - 1, n - 1) % MOD;
        ans %= MOD; 
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

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

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n , -1), rank(n, 1) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 1); }

    int find(int x) {
        if (par[x] == -1) return x;
        else return par[x] = find(par[x]);
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    bool merge(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        rank[x] += rank[y];
        par[y] = x;
        return true;
    }

    vector<int> roots(){
        vector<int> d;
        rep(i,par.size()){
            if(par[i]<0) d.emplace_back(i);
        }
        return d;
    }

    int size(int x){
        return rank[find(x)];
    }

    int count_group(){
        return roots().size();
    }
};

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<vector<int>> g(n);
    vector<int> s(n,0);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a,b);
        s[a]++;
        s[b]++;
    }
    rep(i,k){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    rep(i,n){
        s[i] = uf.size(i) - s[i];
        rep(j,g[i].size()){
            if(uf.is_same(g[i][j],i)){
                s[i]--;
            }
        }
    }
    rep(i,n){
        if(i==n-1){
            cout << s[i]-1 << endl;
            return 0;
        }
        cout << s[i]-1 << " ";
    }
}

Measured memory_bytes: 7168
#include<stdio.h>

#define MAX 101
#define WHITE 0
#define BLACK 1
#define INF 10000001
#define NIL -1

int G[MAX][MAX],n,d[MAX],pi[MAX],color[MAX];

void Dijkstra(int r){
  int i,j;
  for(i=0;i<n;i++){
    d[i]=INF;
    pi[i]=NIL;
  }
  d[r]=0;
  while(1){
	int u,mincost = INF;
	for(i=0;i<n;i++){
  	if(color[i]!=BLACK && d[i]<mincost){
    mincost = d[i];
    u = i;
  	}
	}

	if(mincost==INF)break;
	color[u]=BLACK;

	for(i=0;i<n;i++){
  	if(color[i]!=BLACK && G[u][i]+d[u]<d[i] && G[u][i]!=-1){
    pi[i] = u;
    d[i] = G[u][i]+d[u];
  	}
	}
  }
}

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=NIL;
    }
  }
  for(i=0;i<n;i++){
    int u,k;
    scanf("%d %d",&u,&k);
	   for(j=0;j<k;j++){
       int c;
       scanf("%d",&c);
  	   scanf("%d",&G[u][c]);
  	}
  }
  Dijkstra(0);
  for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);
  return 0;
}



Measured memory_bytes: 2048
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

void solve() {
  int N;
  cin >> N;

  vector<int> P(N);
  for (int &p : P) {
    cin >> p;
  }

  int ans = 0;
  for (int i = 1; i < P.size() - 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;
}

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


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

int main(){
    char s1[10], s2[10];
    int taro=0,hanako=0,x;
    scanf("%d",&x);
    for(int i=0;i<x;i++){
        scanf("%s %s", s1, s2);
        if ( strcmp(s1, s2) == 0 ){
            taro +=1;
            hanako +=1;
        }
        else if ( strcmp(s1, s2) > 0 ) taro+=3;
        else if ( strcmp(s1, s2) < 0 ) hanako +=3;
    }
    printf("%d %d\n",taro,hanako);
    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define in freopen("in.txt","r",stdin)
//#define out freopen("out.txt","w",stdout) 
ll n,j,k,t,l,r;
//ll c,d;
char A,B,C,X,Y,Z;
ll ans,MAX,MIN=40,sum;
ll ax[200050],bx[200050];
//ll dp1[1000][1000],dp2[1000][1000];
char str[200050];

int main()
{
    ll i,s;
    double a,b,c;
	double h,m,x;
    t=1;
    //scanf("%lld",&t);
    while(t--)
    {
    	cin>>a>>b>>h>>m;
    	double x=2*3.14159265358979323846*(h/12.0+m/60.0/12.0-m/60.0);
    	x=fabs(x);
    	c=a*a+b*b-2*a*b*cos(x);
    	c=sqrt(c);
    	printf("%.20f",c);
	}
	return 0;
}

Measured memory_bytes: 4216
#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

use Data::Dumper;

my $N = <>;
my @rests;
my $num = 1;
while (<>) {
    my ($city, $point) = split " ";
    push @rests, +{ city => $city, point => $point, num => $num++ };
}

my @ans = sort { $a->{city} cmp $b->{city} || $b->{point} <=> $a->{point} } @rests;

print join "\n", map {$_->{num}} @ans; 


Measured memory_bytes: 1920
import java.util.*;
import java.lang.*;

class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        boolean T = true;
        for(int i = 0 ; i < S.length()-1 ; i++){
            if(S.substring(i, i+1).equals(S.substring(i+1, i+2))){
                System.out.println("Bad");
                T = false;
                break;
            }
            
        }
        if(T){
            System.out.println("Good");
        }

        sc.close();

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> dp(k + 1);
	dp[0] = 0;
	for(int i = 1; i <= k; i++){
		bool win = false;
		rep(j,n){
			if(i - a.at(j) >= 0 && dp[i - a.at(j)] == 0) win = true;
		}
		if(win) dp[i] = 1;
	}
	if(dp[k]) cout << "First" << endl;
	else cout << "Second" << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define io ios_base::sync_with_stdio(false); cin.tie(0);

#define fs first
#define sc second
#define pb push_back

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef long double ld;

const ll LINF = 1e18;
const int INF = 1e9;
const ld EPS = 1e-9;
const int MOD = 1e9+7;

/// Scanf para ler char array separado por espacos -> scanf(" %[^\n]", texto);
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5+5;
int v[N];

int main(){

	int n, k;
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++){
		scanf("%d", &v[i]);
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++){ 
		for(int j = i; j <= i+k; j++){
			if(j < n) dp[j] = min(dp[j], dp[i] + abs(v[i]-v[j]));
		}
	}
	printf("%d", dp[n-1]);
	return 0;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N,K,C;
  cin>>N>>K>>C;
  string S;
  cin>>S;
  vector<ll> v;
  for(ll i = 0LL; i < N; i++){
    if(S[i]=='o') v.push_back(i);
  }
  ll t=v.size();
  vector<ll> work(K);
  work[0]=0;
  for(ll i = 1LL; i < K; i++){
    work[i]=(ll)(upper_bound(v.begin(),v.end(),v[work[i-1]]+C)-v.begin());
  }
  vector<ll> ans;
  for(ll i = K-1LL; i >=0; i--){
    if(i==K-1) {
      if(work[i]==t-1LL) ans.push_back(v[work[i]]);
      work[i]=t-1LL;
    }
    else{
      auto ite = lower_bound(v.begin(),v.end(),v[work[i+1]]-C);
      if((ll)(ite-v.begin()-1)==work[i]) ans.push_back(v[work[i]]);
      work[i]=(ll)(ite-v.begin()-1);
    }
  }
  for(ll i = (ll)ans.size()-1; i >=0;i--){
    cout<<ans[i]+1<<endl;
  }
}

Measured memory_bytes: 9692
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
const int N=1005;
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
struct mat{
    ll a[2][2];
    mat(){memset(a,0,sizeof a);}
}e;
mat operator *(mat a,mat b){
    mat c;
    for(int i=0;i<2;i++)
        for(int j=0;j<2;j++)
            for(int k=0;k<2;k++)
                c.a[i][j]=(c.a[i][j]+(1ll*a.a[i][k]*b.a[k][j])%mod)%mod;
    return c;
}
mat operator ^(mat a,ll y){
    mat c=e;
    while(y){
        if(y&1)
            c=c*a;
        a=a*a;
        y>>=1;
    }
    return c;
}
ll ksm(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res=(1ll*res*x)%mod;
        x=(1ll*x*x)%mod;
        y>>=1;
    }
    return res;
}
char s[N][N];
int n,m;
ll k;
int main()
{
    scanf("%d%d%lld",&n,&m,&k);
    if(k<=1){
        puts("1");
        return 0;
    }
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    int lr=0,ud=0;
    for(int i=1;i<=n;i++)
        if(s[i][1]=='#'&&s[i][m]=='#')
            lr++;
    for(int j=1;j<=m;j++)
        if(s[1][j]=='#'&&s[n][j]=='#')
            ud++;
    int v=0,ev=0,eh=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            v+=s[i][j]=='#';
            ev+=s[i][j]=='#'&&s[i+1][j]=='#';
            eh+=s[i][j]=='#'&&s[i][j+1]=='#';
        }
    if(lr>0&&ud>0){
        puts("1");
        return 0;
    }
    if(lr==0&&ud==0){
        printf("%lld\n",ksm(v,k-1));
        return 0;
    }
    if(lr>0){
        swap(ud,lr);
        swap(ev,eh);
    }
    mat ans,x;
    for(int i=0;i<2;i++)
            e.a[i][i]=1;
    ans.a[1][0]=1;
    x.a[0][0]=ud,x.a[0][1]=ev;
    x.a[1][0]=0,x.a[1][1]=v;
    x=x^(k-1);
    ans=x*ans;
    printf("%lld\n",(ans.a[1][0]-ans.a[0][0]+mod)%mod);
}


Measured memory_bytes: 1152
#include<stdio.h>
 
int main(void){
    int D;
    scanf("%d",&D);
    if(D == 25)
        printf("Christmas");
    if(D == 24)
        printf("Christmas Eve");
    if(D ==23)
        printf("Christmas Eve Eve");
    if(D == 22)
        printf("Christmas Eve Eve Eve");
            
 
    
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
    int x, y;
    int kame, turu;
    scanf("%d%d", &x, &y);
    for (turu = 0; turu < x+1; turu++){
        kame = x - turu;
        if (y == turu*2 + kame*4){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

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

using namespace std;

int N,M;
char s[1010][1010];
typedef pair<int,int> pii;
int d[1010][1010];

queue<pii>q;
int main() {
	scanf("%d%d",&N,&M);
	for (int i=1;i<=N;i++) {
		scanf("%s",s[i] + 1);
	}
	for (int i=1;i<=N;i++) {
		for (int j=1;j<=M;j++) {
			d[i][j] = -1;
			if (s[i][j] == '#') {
				d[i][j] = 0;
				q.push(pii(i,j));
			}
		}
	}
	int ans = 0;
	int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
	while(!q.empty()) {
		auto now = q.front();
		q.pop();
		int x = now.first, y = now.second;
		ans = max(ans,d[x][y]);
		for (int i=0;i<4;i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx < 1 || ny < 1 || nx > N || ny > M || d[nx][ny] != -1) {
				continue;
			}
			d[nx][ny] = d[x][y] + 1;
			q.push(pii(nx,ny));
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 13456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;
typedef pair<int, int> p;

int main()
{
    rep (i, 3) {
        rep (j, 3) {
            char c;
            cin >> c;
            if (i == j)
                cout << c;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


int n;
int p[500 * 500];
int d[502][502];
int in[502][502];



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

	cin >> n;
	rep(i, n * n)cin >> p[i];
	for (int y = 1; y <= n;y++) {
		for (int x = 1; x <= n;x++) {
			d[y][x] = min({ y,x,n - y + 1, n - x + 1 });
			in[y][x] = 1;
		}
	}

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

	int ans = 0;
	rep(i, n*n) {
		int y = (p[i] - 1) / n + 1;
		int x = (p[i] - 1) % n + 1;

		ans += d[y][x] - 1;
		in[y][x] = 0;

		d[y][x]--;
		queue<pair<int, int>> q;
		q.emplace(y, x);
		while (!q.empty()) {
			auto p = q.front();
			q.pop();
			y = p.first;
			x = p.second;

			rep(dir, 4) {
				int ny = y + dy[dir];
				int nx = x + dx[dir];
				if (d[y][x] + in[ny][nx] < d[ny][nx]) {
					d[ny][nx] = d[y][x] + in[ny][nx];
					q.emplace(ny, nx);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s / 100;
  s2 = (s - s1 * 100) / 10;
  s3 = (s - s1 * 100 - s2 * 10);
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include <algorithm>
#include <iostream>
#include <queue>
#include <functional>
#include <numeric>
#include <math.h>

using namespace std;

#define PRINT(A) {for (int i = 0; i < A.size(); i++) { cout << A[i] << " ";} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;


int main() {
    double N, D;
    cin >> N >> D;
    VVI points;
    int ans = 0;
    REP(i, N) {
        double x, y;
        cin >> x >> y;
        if (sqrt(pow(x,2) + pow(y,2)) <= D) {
            ans += 1; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


n=int(input())
a, b, c = [], [], []
for _ in range(n):
    x,y,z=get_ints()
    ##li=[[-1 for i in range(4)]for j in range(n)]
    a.append(x)
    b.append(y)
    c.append(z)
li=[[-1 for i in range(4)]for j in range(n)]
for i in range(n):
   for j in range(4):
        if i==0:
            if j==0:
                li[i][j]=a[i]
            if j==1:
                li[i][j]=b[i]
            if j==2:
                li[i][j]=c[i]
            if j==3:
                li[i][j] = 0
            continue
        if j==0:
            li[i][j] = max(a[i] + li[i-1][1] ,a[i] + li[i - 1][2])
        if j==1:
            li[i][j] = max(b[i] + li[i - 1][0], b[i] +li[i - 1][2])
        if j==2:
            li[i][j] = max(c[i] + li[i - 1][1], c[i] + li[i - 1][0])
        if j==3:
            li[i][3] = (max(li[i - 1][2],li[i - 1][1], li[i - 1][0]))
print(max(li[n-1]))



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

using namespace std;

int main(){
    int n, ans = 1, tmp, curmin = 0;
    cin >> n;
    cin >> tmp;
    curmin = min(tmp, tmp);
    for(int i = 0; i < n - 1; ++i){
        cin >> tmp;
        if(tmp < curmin)ans++;
        curmin = min(tmp, curmin);
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<lint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(ALL(a));
  lint ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (a[i] == a[j] or a[j] == a[k]) continue;
        if (a[i] + a[j] > a[k]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

k = int(readline())
roops = k//50
remains = k%50
ans = [49+roops]*50


for i in range(50-remains):
    ans[i] -= remains
for i in range(50-remains,50):
    ans[i] += 50-remains
print(50)
print(*ans)

Measured memory_bytes: 61872
#include <iostream>
#include <algorithm>

inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}

int main(){
    int n, c, k; fastin(n); fastin(c); fastin(k);
    int t[n];
    for (int i = 0; i < n; ++i) fastin(t[i]);

    std::sort(t, t + n);

    int ans = 0;
    int beg = 0;
    while (beg < n){
        int end = beg;
        while (end - beg + 1 < c && t[end + 1] - t[beg] <= k){
            ++end;
            if (end == n - 1) break;
        }
        ++ans; beg = end + 1;
        if (beg == n - 1){
            ++ans; break;
        }
    }
    fastout(ans);
    
    return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    bool firstTurn = true;
    
    while (A > 0 && C > 0) {
        if (firstTurn) {
            C -= B;
        } else {
            A -= D;
        }
        firstTurn = !firstTurn;
    }
    
    cout << (A <= 0 ? "No" : "Yes");

    return 0;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <string>

using namespace std;

int main(void){
    int A,B;

    scanf("%d%d", &A, &B);

    int X1;
    if (A > B) {
        X1 = A;
        A--;
    }
    else {
        X1 = B;
        B--;
    }

    int X2;
    if (A > B) {
        X2 = A;
    }
    else {
        X2 = B;
    }

    printf("%d\n", X1 + X2);
    fflush(stdout);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
char x, y;
/**********************************************/

int main(){
    cin >> x >> y;

    if(x - 'A' < y - 'A'){
        cout << "<" << endl;
    }else if(x - 'A' > y - 'A'){
        cout << ">" << endl;
    }else {
        cout << "=" << endl;
    }
}


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    if (H > W) swap(H, W);

    cout << ((N + W - 1) / W) << endl;

    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


vector<ll> a(200005);

void solve() {
    ll N, K; cin >> N >> K;
    rep(i, 200005) a[i] = INF;
    unordered_map<int, int> m;
    rep(i, N){
        int x; cin >> x;
        m[x]++;
    }
    int cnt = 0;
    for(auto ma: m){
        cnt++;
        a[ma.first] = ma.second;
    }
    sort(all(a));
    ll res = 0;
    rep(i, cnt-K){
        res += a[i];
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 14152
import java.io.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int A, B;
        A = Integer.parseInt (arr[0]);
        B = Integer.parseInt (arr[1]);
        System.out.println (A * B);
    }
}

Measured memory_bytes: 32564
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)
using namespace std;

int main()
{
	LL n, a, b; scanf("%lld%lld%lld", &n, &a, &b);
    printf("%lld\n", min(n * a, b));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


// vector<ll> a(20,0);


int main(){
	ll n;
	char a[10]={'0','1','2','3','5','7','8','9'};
	while(cin>>n,n){
		string tmp2;
		string tmp1;
		stringstream ss1;
		ss1<<oct<<n;
		ss1>>tmp1;
		// cout<<tmp1<<endl;
		// const char tmp3[]=tmp1;
		// n=strtoul(tmp3,&tmp2,8);
		// string tmp;
		// stringstream ss;
		// ss>>tmp;
		rep(i,tmp1.size()){
			tmp1[i]=a[tmp1[i]-'0'];
		}
		cout<<tmp1<<endl;
	}

}

Measured memory_bytes: 1216
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

#include <bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll n, d, ans;
vvll x;

bool is_perfect_square(ll x) {
    ll y = round(sqrt((double) x));
    return y * y == x;
}

void func() {
    cin >> n >> d;
    ans = 0;
    x.resize(n, vll(d));
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < d; j++) {
            cin >> x[i][j];
        }
        for (ll i2 = 0; i2 < i; i2++) {
            ll dis = 0;
            for (ll j = 0; j < d; j++) {
                dis += (x[i2][j] - x[i][j]) * (x[i2][j] - x[i][j]);
            }
            if (is_perfect_square(dis)) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 256
N = int(input(""))
L = map(int, input("").split(" "))
L = sorted(L)

n = 0

for i in range(0, len(L)):
    for j in range(i, len(L)):
        for k in range(j, len(L)):
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    n += 1
print(n)

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

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

    int f[4][3][10];
    std::fill(f[0][0], f[4][0], 0);

    int a, b, c, d;
    for(int i = 0; i < n; i++){
        cin >> a >> b >> c >> d;
        f[a-1][b-1][c-1] += d;
    }

    for(int x = 0; x < 4; x++){
        for(int y = 0; y < 3; y++){
            for(int z = 0; z < 10; z++){
                cout << " " << f[x][y][z];
            }
            cout << endl;
        }
        if(x != 3)
            cout << "####################" << endl;
    }

    return 0;
}


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

int main() {
  int n,t,a;
	cin>>n>>t;
	int k=0;
	for(int i=0;i<t;i++){
		cin>>a;
		k=max(k,a);
	}
	if(n%2)cout<<max(0,(k-(n+1)/2)*2)<<endl;
	else cout<<max(0,(k-n/2)*2-1)<<endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll* h = NULL;
    h = (ll*)malloc(100000005*sizeof(ll));
    for(ll i=0; i<n; i++) {
        cin>>h[i];
    }
    ll step=0;
    ll maxstep=0;
    ll stair=1;

    for(ll i=1; i<n; i++){     
        if(h[i-1]>=h[i]){
            stair++;
            step++;
//            dbg(step);
        }else{
            stair++;
            if(step>maxstep){
                maxstep=step;
 //               dbg(maxstep);
            }
            step=0;
        }
    }
    if(step>maxstep){
        maxstep=step;
    }  

    cout<<maxstep<<endl;
    return  0;
}


Measured memory_bytes: 3072