akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
int x[100100], y[100100];
set<pii> g[100100];

int par[100100], sz[100100];

inline int find(int k) { return k==par[k] ? k : par[k]=find(par[k]); }
inline bool join(int a, int b) {
  a=find(a), b=find(b);
  if(a==b) return 0;
  if(sz[a]>sz[b]) swap(a,b);
  par[a]=b, sz[b]+=sz[a];
  return 1;
}

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

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

  vector<pii> xp(N), yp(N);
  for(int i=0;i<N;i++) xp[i]={x[i],i}, yp[i]={y[i],i}, sz[i]=1,par[i]=i;
  sort(xp.begin(),xp.end());
  sort(yp.begin(),yp.end());

  min_queue<pair<int,pii>> q;
  for(int i=0;i<N-1;i++) {
    q.push({xp[i+1].fst-xp[i].fst, {xp[i].snd, xp[i+1].snd}});
  }
  for(int i=0;i<N-1;i++) {
    q.push({yp[i+1].fst-yp[i].fst, {yp[i].snd, yp[i+1].snd}});
  }
 
  ll res=0;
  while(!q.empty()) {
    auto pr=q.top();q.pop();
    int wt=pr.fst,a=pr.snd.fst,b=pr.snd.snd;
    if (!join(a,b)) continue;
    res += wt;
  }

  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 12788
N , M = (map(int , input().split()))
A = list(map(int , input().split()))
a_lis = []
for i in range(len(A)-1):
    a_lis.append(A[i+1]-A[i])
a_lis.append((N+A[0]) - A[-1])
print(N - max(a_lis))

Measured memory_bytes: 25840
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int a[3],m[3],t[3];

ll gcd(ll a,ll b){
	if(!b)return a;
	return gcd(b,a%b);
}

int main(){
	while(cin>>a[0]>>m[0]>>a[1]>>m[1]>>a[2]>>m[2]&&a[0]){
		rep(i,3){
			int p=1,c=0;
			while(1){
				p=(a[i]*p)%m[i];
				c++;
				if(p==1)break;
			}
			t[i]=c;
		}
		ll T=t[0]*t[1]/gcd((ll)t[0],(ll)t[1]);
		cout<<T*t[2]/gcd((ll)T,(ll)t[2])<<endl;
	}
}

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

int main(){
    int W,H,x,y,r;

    cin>> W>> H >> x>>y>>r;
    
    if (x+r <= W && x-r >= 0 && y+r <= H && y-r>=0) {
    cout << "Yes" << endl;
    }
    else {
    cout << "No" << endl;
    }

    return 0;
}


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

int main(){
    int a, b;

    while(cin >> a >> b, a != 0){
        for(int y = 0; y < a; y++){
            for(int x = 0; x < b; x++){
                if(y%2==0){
                    if(x%2 == 0)
                        cout << '#';
                    else
                        cout << '.';
                }else{
                    if(x%2 == 0)
                        cout << '.';
                    else
                        cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll h, w;
    cin >> h >> w;
    vll a(h), b(h);
    rep(i, h) cin >> a[i] >> b[i];
    set<pll> s;
    rep(i, w) s.emplace(i+1, i+1);  // (now, start)
    multiset<ll> ms;
    rep(i, w) ms.insert(0); // (now - start)
    rep(i, h) {
        auto it = s.lower_bound(pll(a[i], 0));
        ll stmax = -1;
        while(it != s.end() && it->first <= b[i]) {
            chmax(stmax, it->second);
            ms.erase(ms.find(it->first - it->second));
            s.erase(it++);
        }
        if(stmax != -1 && b[i] < w) {
            s.emplace(b[i]+1, stmax);
            ms.insert(b[i]+1 - stmax);
        }
        ll ans = -1;
        if(!ms.empty()) ans = *ms.begin() + i+1;
        cout << ans << endl;
    }
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 28268
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
    string s,t,u,x,p,tem;
    int a,b,c,d,n=0,i;
    cin >> s >> n;
    u = s;
    for(i = 0;i < n;i++){
        cin >> t >> a >> b;
        if(t == "print"){
            x = u.substr(a,b-a+1);
            cout << x << endl;
        }
        else if(t == "reverse"){
            x = u.substr(a,b-a+1);
            tem = "\0";
            for(int j = x.size()-1;j >= 0;j--){
                tem += x[j];
            }
            u = u.replace(a,x.size(),tem);
        }
        else if(t == "replace"){
            cin >> p;
            u = u.replace(a,b-a+1,p);
        }
    }


    return 0;
}


Measured memory_bytes: 3228
#include <stdio.h>

int n,A[100][100];

int p();

int main(){
  int i,j,a;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a);
      A[i][j]=(a==-1)?(1<<21):a;
    }
  }

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

  return 0;
}

int p(){
  int u,mv,d[100],p[100],c[100],ans,i,v;

  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    c[i]=0;
  }

  d[0]=0;

  while(1){
    mv=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mv>d[i]&&c[i]!=2){
	u=i;
	mv=d[i];
      }
    }
    if(u==-1){
      break;
    }
    c[u]=2;
    for(v=0;v<n;v++){
      if(c[v]!=2&&A[u][v]!=(1<<21)){
	if(d[v]>A[u][v]){
	  d[v]=A[u][v];
	  p[v]=u;
	  c[v]=1;
	}
      }
    }
  }

  for(i=0;i<n;i++){
    if(p[i]!=-1){
      ans+=A[i][p[i]];
    }
  }

  return ans;
}


Measured memory_bytes: 2084
// 解説前
#include <algorithm>
#include <iostream>
#include <vector>

// N<=15なので、2^N<4*10^4になる
// => すべてのパターンをチェックできそう

// N<=15なので、N*2^N<6*10^5になる
// => すべてのパターンにおいて、そのときの正直者の証言が正しいことを確認すればいい
int solve_C() {
  // 人数を読み取る
  size_t N = 0;
  std::cin >> N;

  // 証言を読み取る
  std::vector<uint16_t> ones(N);  // iの証言による正直者の人のビットセット
  std::vector<uint16_t> zeros(N);  // iの証言による不親切な人のビットセット
  for (size_t i = 0; i < N; ++i) {
    size_t A;
    std::cin >> A;
    for (size_t j = 0; j < A; ++j) {
      int x, y;
      std::cin >> x >> y;
      if (y == 1) {
        ones[i] |= size_t(1) << (x - 1);
      } else if (y == 0) {
        zeros[i] |= size_t(1) << (x - 1);
      }
    }
  }

  // 正直者の最大人数を計算する
  // stateは正直者である人のビットセット
  size_t result = 0;
  for (uint16_t state = 1; state < (1 << N); ++state) {
    [&] {
      // 各人の証言が正しいことを確認する
      size_t count = 0;
      for (size_t i = 0; i < N; ++i) {
        // iが正直者であれば、その発言が現在の状態と矛盾するかを調べる
        if (state & (1 << i)) {
          const uint16_t one = ones[i];
          const uint16_t zero = zeros[i];
          if ((state & one) != one || (~state & zero) != zero) {
            // 矛盾したので、この状態での人数は数えない
            return;
          }

          // 正直者の人数を数える
          count++;
        }
      }

      // 正直者の最大人数を計算する
      result = std::max(result, count);
    }();
  }

  // 結果発表
  std::cout << result;

  return 0;
}

int main() {
  return solve_C();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

int cnt[200010];

int main(){
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a - 1]++;
    }

    sort(cnt, cnt + n);

    for (int i = 0; i < n - k; i++){
        ans += cnt[i];
    }

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

Measured memory_bytes: 1024
/*input
6
11 21 35 22 7 36 27 34 8 20 15 13 16 1 24 3 2 17 26 9 18 32 31 23 19 14 4 25 10 29 28 33 12 6 5 30
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

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


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

ll n;
ll a[501][501],vis[501][501];
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

void func(ll k,ll r,ll c){
	if(r<0||r>n-1||c<0||c>n-1)return ;
	if(a[r][c]<=k+vis[r][c])return ;
	ll j;
	a[r][c]=k+vis[r][c];
	rep(j,0,4){
		func(a[r][c],r+dx[j],c+dy[j]);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j,p;
	cin>>n;
	rep(i,0,n){
		rep(j,0,n){
			a[i][j]=min({i,j,n-i-1,n-j-1});
			vis[i][j]=1;
		}
	}
	ll ans=0;
	rep(i,0,n*n){
		cin>>p,--p;
		ll r=p/n,c=p%n;
		ans+=a[r][c];
		vis[r][c]=0;
		a[r][c]--;
		rep(j,0,4)func(a[r][c],r+dx[j],c+dy[j]);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 22932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    ll allxor = 0;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
        allxor = allxor ^ a.at(i);
    }
    REP(i, n){
        cout << (allxor ^ a.at(i));
        if(i + 1 < n){
            cout << ' ';
        }
    }
    cout << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  bool le,ri,c;
  string s;
  cout << 0<<endl;
  cout << flush;
  cin>>s;
  if(s=="Vacant")return 0;
  map<string,bool> mp;
  mp["Female"]=0;
  mp["Male"]=1;
  ri=mp[s];
  cout<<n-1<<endl;
  cout << flush;
  cin>>s;
  if(s=="Vacant")return 0;
  le=mp[s];
  int mi=0,ma=n-1,mid=(ma+mi)/2;
  while(1){
    cout<<mid<<endl;
    cout << flush;
    cin>>s;
    if(s=="Vacant")break;
    c=mp[s];
    if((ma-mid)%2){
        if(le==c){
            ri=c;
            mi=mid;
        }
    }else{
        if(le!=c){
            ri=c;
            mi=mid;
        }
    }
    if((mid-mi)%2){
        if(ri==c){
            le=c;
            ma=mid;
        }
    }else{
        if(ri!=c){
            le=c;
            ma=mid;
        }
    }
    mid=(ma+mi)/2;
  }
  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
const int MOD=998244353;
int main(){
  int N,S,ans=0,dp[3001][3001];
  cin>>N>>S;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  dp[0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=S;j++){
      if(dp[i-1][j]>0){dp[i][j]=dp[i-1][j];}
      if(j-A.at(i-1)>=0 && dp[i-1][j-A.at(i-1)]>0){dp[i][j]+=dp[i-1][j-A.at(i-1)];}
      dp[i][j]%=MOD;
    }
    dp[i][0]++;
    ans+=dp[i][S];
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 38816
def main():
    N = int(input())
    S = input()
    K = int(input())
    unchange = S[K-1]
    for i in range(N):
        if S[i] == unchange:
            pass
        else:
            S = S.replace(S[i], '*')
    print(S)


if __name__ == '__main__':
    main()


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = new int[N];
            for (int i = 0; i < N; i++) A[i] = ReadInt();
            Array.Sort(A);
            var mull = new int[N];
            var mulh = new int[N];
            mull[0] = -1;
            for (int i = 1; i < N - 1; i++)
            {
                if (i % 2 == 0) mull[i] = -2;
                else mull[i] = 2;
            }
            if (N % 2 == 0) mull[N - 1] = 1;
            else mull[N - 1] = -1;
            Array.Sort(mull);
            mulh[0] = 1;
            for (int i = 1; i < N - 1; i++)
            {
                if (i % 2 == 0) mulh[i] = 2;
                else mulh[i] = -2;
            }
            if (N % 2 == 0) mulh[N - 1] = -1;
            else mulh[N - 1] = 1;
            Array.Sort(mulh);
            var ansl = 0L;
            var ansh = 0L;
            for (int i = 0; i < N; i++)
            {
                ansl += A[i] * mull[i];
                ansh += A[i] * mulh[i];
            }

            Console.WriteLine(ansl > ansh ? ansl : ansh);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main(){
  int n,i,j,kotae;
  double wa=0,k;
  cin>>n;
  k=n*1.0;
  int x[n],y[n];
  for(i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      wa+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  printf("%.10lf",wa*2.0/k);

}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long n,m,ans;
  cin >> n >> m;
  ans=(n-2)*(m-2);
  if (n==1) ans=m-2;
  if (m==1) ans=n-2;
  if (n==1 && m==1) ans=1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# AGC026A - Colorful Slimes 2
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    ans, flg = 0, False
    for i, j in zip(A, A[1:]):
        if flg:
            flg = False
        else:
            if i == j:
                ans += 1
                flg = True
    print(ans)


if __name__ == "__main__":
    main()

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

int main(void) {

	int n, k;
	char s[51];

	scanf("%d %d\n%s", &n, &k,s);
	s[k - 1] = s[k-1] + 32;
	printf("%s", s);

	return 0;
}

Measured memory_bytes: 128
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cctype>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int x, a, b;
  cin >> x >> a >> b;

  if(abs(x-a) < abs(x-b)) cout << 'A' << endl;
  else cout << 'B' << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

#define MIN(a,b) ((a)<(b)?(a):(b))
#define POS(i, j) ((i) * (n + 1) + (j))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  if (n > 3000) exit (1);
  i64 *a = ALLOC (n + 1, i64);
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi64, a + i);
  }
  for (i32 i = n - 1; i >= 0; --i) {
    a[i] += a[i + 1];
  }
  i64 *dp = ALLOC ((n + 1) * (n + 1), i64);
  i32 *p = ALLOC ((n + 1) * (n + 1), i32);
  for (i32 l = 0; l <= n - 2; ++l) {
    i32 r = l + 2;
    dp[POS(l, r)] = a[l] - a[r];
    p[POS(l, r)] = l + 1;
  }
  for (i32 len = 3; len <= n; ++len) {
    for (i32 l = 0; l <= n - len; ++l) {
      i32 r = l + len;
      i32 k = p[POS(l, r - 1)];
      i64 min = dp[POS(l, k)] + dp[POS(k, r)];
      for (i32 i = p[POS(l, r - 1)]; i <= p[POS(l + 1, r)]; ++i) {
        if (min <= dp[POS(l, i)] + dp[POS(i, r)]) continue;
        k = i;
        min = dp[POS(l, i)] + dp[POS(i, r)];
      }
      dp[POS(l, r)] = min + a[l] - a[r];
      p[POS(l, r)] = k;
    }
  }
  printf ("%" PRIi64 "\n", dp[POS(0, n)]);
}

int main (void) {
  run();
  return 0;
}


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

int main(){
  double ax,ay,ar;
  double bx,by,br;
  
  cin>>ax>>ay>>ar;
  cin>>bx>>by>>br;

  double dist = sqrt( (ax-bx)*(ax-bx) + (ay-by)*(ay-by) );

  if( ar+br < dist ){
    cout<<4<<endl;
  }else if( ar+br == dist ){
    cout<<3<<endl;
  }else if( abs(ar-br) < dist ){
    cout<<2<<endl;
  }else if( abs(ar-br) == dist ){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  a*=100,b*=100;
  int s = 0;
  int w = 0;
  double r = 0;
  int answ,anss;
  for(int i = 0; a*i <= f; i++){
    for(int j = 0; a*i + b*j <=f; j++){
      if(i==0&&j==0)continue;
      w = a*i + b*j;
      for(int k = 0; c*k + w <=f; k++){
        for(int l = 0; c*k + d*l + w <=f; l++){
          s = c*k + d*l;
          if(s<=e*w/100 && r<s*100.0/(s+w)){
            anss = s;
            answ = w;
            r = s*100.0/(s+w);
            //cout<<"r="<<r<<endl;
            //cout<<anss+answ<<" "<<answ<<endl;
          }
        }
      }
    }
  }
  if(anss==0)answ=a;
  cout<<answ+anss<<" "<<anss<<endl;
  return 0;
}







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

using namespace std;

int ans[55];

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for (int i=0; i<m; i++)
        {
            int a,b;
            cin>>a>>b;
            ans[a]++;
            ans[b]++;
        }
        for (int i=1; i<=n; i++)
        {
            cout<<ans[i]<<endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 256
#include<string.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#define lli long long int
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define fo(i,n) for(int i=0;i<(n);i++)
using namespace std;


void solve(){
    double d , t , sp;
    cin>>d>>t>>sp;
    double ta = (d/sp);
    if(ta <= t){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }


}

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

    return 0;
}

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    string A;
    cin>>A;
    int ans=0;
    REP(i,1,A.length()){
        if(A[i]!=A[i-1]){
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 512
N=int(input())
sister=[]
for i in range (N):
    A=int(input())
    sister.append(A)
sister
import collections
c=collections.Counter(sister)
sister_unique=list(set(sister))
count=0
for j in range (len(sister_unique)):
    if c[sister_unique[j]]%2!=0:
        count+=1
print (count)


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

int N;
LL A[100000];
LL X;
LL ans=0;

int main(){
 scanf("%d%lld",&N,&X);
 rep(i,N) scanf("%lld",&A[i]);

 if(A[0]>X){ ans+=A[0]-X; A[0]=X; }
 rep(i,N-1){
  if(A[i+1]+A[i]>X){
   ans += A[i]+A[i+1]-X;
   A[i+1] = X-A[i];
  }
 }

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

 return 0;
}




Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
vector<int> g[1005];
bool vis[1005];
int dp[1005], f[1005];
int main(){
    int n, m, a, b;
    scanf("%d%d", &n, &m);   
    for(int i=1;i<=m;i++){
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
    }

    int ans = 1e9, v = 0;
    for(int u=1;u<=n;u++){
        memset(dp, -1, sizeof(dp));
        int x = u;
        queue<int> q;
        q.push(u);
        while(!q.empty()){
            int u = q.front();
            q.pop();
            for(int i=0;i<g[u].size();i++){
                int v = g[u][i];
                if(dp[v] == -1){
                    if(u == x) dp[v] = 1;
                    else dp[v] = dp[u] + 1;
                    q.push(v);
                }
            }
        }
        if(dp[u] == -1) continue;
        if(dp[u] < ans){
            ans = dp[u];
            v = u;
        }
    }
    if(ans == 1e9) printf("-1\n");
    else{
        printf("%d\n", ans);

        memset(dp, -1, sizeof(dp));
        queue<int> q;
        q.push(v);

        while(!q.empty()){
            int uu = q.front();
            q.pop();
            for(int i=0;i<g[uu].size();i++){
                int vv = g[uu][i];

                f[vv] = uu;
                if(vv == v){
                    while(uu != v){
                        printf("%d\n", uu);
                        uu = f[uu];
                    }
                    printf("%d\n", v);
                    return 0;
                }

                if(dp[vv] == -1){
                    q.push(vv);
                    dp[vv] = 1;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};
//template<class T>vector<T> var_vec(size_t a){return vector<T>(a);}
//template<class T, class... Ts>auto var_vec(size_t a, Ts... ts){return vector<decltype(var_vec<T>(ts...))>(a, var_vec<T>(ts...));}

//}

int n;
int a[111111];
int tans[111111];

main(){
	rep(i,111111)a[i]=-1;
	cin>>n;
	rep(i,n)cin>>a[i];
	a[n]=a[0];
	vint v;v.pb(0);
	rep(i,n-1){
		v.pb(a[i]*2-v[i]);
	}
	v.pb(0);
	rep(i,v.size()-1){
		tans[i]=(v[i]+v[i+1])/2;
	}
	//rep(i,v.size())dump(tans[i]);
	rep(i,n){
		v[i]+=(i&1?-1:1)*(a[n-1]-tans[n-1]);
	}
	rep(i,n)dump(v[i]);
}




Measured memory_bytes: 3828
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    for x in range(W):
        d[A[y][x]] = (y, x)

t = [[0] * (H * W // D + 1) for _ in range(D)]
for i in range(D):
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        t[i][j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(H * W // D):
        t[i][j + 1] += t[i][j]

Q = int(input())
result = []
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    result.append(t[i][(R - i) // D] - t[i][(L - i) // D])
print('\n'.join(str(i) for i in result))


Measured memory_bytes: 35428
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0257>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int b1,b2,b3; cin >> b1 >> b2 >> b3;
    int state = 4*b1 + 2*b2 + b3;
    if(state == 4 || state == 0 || state == 2) cout << "Close" << endl;
    else cout << "Open" << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n;
    cin >> n;

    int k;
    cin >> k;

    vector<int> b(k);
    rep(i, k)cin >> b[i];

    for (int i = 0; i < (1 << k); i++) {
        unsigned long long ans = 0;
        for (int j = 0; j < k; j++) {
            if (((i >> j) & 1) == 0) {
                continue;
            }
            unsigned long long mask = 1ull << b[j];
            ans |= mask;
        }

        printf("%lld:", ans);

        rep(j, k) {
            if (((i >> j) & 1) == 0) {
                continue;
            }
            printf(" %d", b[j]);
        }

        cout << endl;

    }


}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
const ll INF = 1e13;
const ll N = 200001;
const ll mod=998244353;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
void solve()
{
  ll n,k;
  cin>>n>>k;
  vl h(n+1), dp(n+1,INT_MAX);
  loop(i,1,n+1) cin>>h[i];
  dp[1]=0;
  dp[2] = abs(h[2]-h[1]);
  loop(i,3,n+1)
  {
  	revloop(j,i-1,max(i-k,(ll)1)) dp[i]=min(dp[i], dp[j]+ abs(h[i]-h[j]) );
  }
  cout<<dp[n]<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> sum(n);
  for (int i = 0; i < n; i++) {
    int w;
    cin >> w;
    if (i == 0) {
      sum[i] = w;
    } else {
      sum[i] = sum[i - 1] + w;
    }
  }
  int ans = (int)100000;
  for (int i = 0; i < n - 1; i++) {
    ans = min(ans, abs(2 * sum[i] - sum[n - 1]));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
long long a[3002][3002][2]={0};



int main(){
    
        string s1,s2;
        cin>>s1>>s2;
        long long l1=s1.length(),l2=s2.length();
        for(long i=1;i<=l1;i++){
            for(int j=1;j<=l2;j++){
                if(s1[i-1]==s2[j-1]){
                    a[i][j][0]=a[i-1][j-1][0]+1;
                    a[i][j][1]=3;
                }
                else if(a[i][j-1][0]>=a[i-1][j][0]){
                    a[i][j][0]=a[i][j-1][0];
                    a[i][j][1]=1;
                }
                else {
                    a[i][j][0]=a[i-1][j][0];
                    a[i][j][1]=2;
                }
            }
        }
         /*for(int i=0;i<=l1;i++){
            for(int j=0;j<=l2;j++){
                cout<<a[i][j][1]<<" ";
            }cout<<endl;
        }*/
        long i=l1,j=l2,n=a[l1][l2][0];
        string str="";    
         while(i>=0 && j>=0 && n!=0){
            if(a[i][j][1]==3){//cout<<s1[i-1]<<endl;
                str+=s1[i-1];
                i--;j--;n--;
            }
            else if(a[i][j][1]==2){
                i--;
            }
            else if(a[i][j][1]==1){
                j--;
            }
            
         
         }    
        reverse(str.begin(),str.end());
        cout<<str<<endl;
    
    
    
    
}


Measured memory_bytes: 141056
#include <stdio.h>

int insertionSort(int [1000], int N);

int main(void){
  int i, j, k, v, N;
  int A[1000];
  scanf("%d", &N);
  for (i=0; i<N; ++i)scanf("%d", &A[i]);
  insertionSort(A, N);
  return 0;
}

int insertionSort(int A[1000], int N){
  int i, j, v, k;
  for (k=0; k<N-1; ++k)printf("%d ", A[k]);
  printf("%d", A[N-1]);
  printf("\n");
  for (i=1; i<=N-1; ++i){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for (k=0; k<N-1; ++k)printf("%d ", A[k]);
    printf("%d", A[N-1]);
    printf("\n");
     
  }
}



Measured memory_bytes: 2124
#include <iostream>
#define MAXN 1001
using namespace std;

int effect[MAXN];
int dice[MAXN];
int position,j,n,m;
int main(){
	while(1){
		cin >> n >> m;
		if(n==0&&m==0)break;
		for(int i=1;i<=n;i++){
			cin >>effect[i];
		}
		for(int i=1;i<=m;i++){
			cin >>dice[i];
		}
		position=1;
		for(j=1;j<=m;j++){
			position+=dice[j];
			if(position>=n)break;
			position+=effect[position];
			if(position>=n)break;
		}
		cout << j<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
#define pb push_back
#define solid const auto &
#define enter cout<<endl
#define pii pair<int,int>
using namespace std;
typedef long long ll;
template<class T>il void rd(T &x){
    char ch;x=0;bool fl=false;while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
    for(x=numb;isdigit(ch=getchar());x=x*10+numb);(fl==true)&&(x=-x);}
template<class T>il void output(T x){if(x/10)output(x/10);putchar(x%10+'0');}
template<class T>il void ot(T x){if(x<0) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}
namespace Modulo{
const int mod=1e9+7;
int ad(int x,int y){return (x+y)>=mod?x+y-mod:x+y;}
void inc(int &x,int y){x=ad(x,y);}
int mul(int x,int y){return (ll)x*y%mod;}
void inc2(int &x,int y){x=mul(x,y);}
int qm(int x,int y=mod-2){int ret=1;while(y){if(y&1) ret=mul(x,ret);x=mul(x,x);y>>=1;}return ret;}
}
using namespace Modulo;
namespace Miracle{
const int N=2003;
int A,B;
int f[N][N];
int C[N][N];
int main(){
    rd(A);rd(B);
    C[0][0]=1;
    int lim=max(A,B)+1;
    for(reg i=1;i<=lim;++i){
        C[i][0]=1;
        for(reg j=1;j<=i;++j){
            C[i][j]=ad(C[i-1][j],C[i-1][j-1]);
        }
    }
    for(reg i=1;i<=lim;++i){
        for(reg s=1;s<=lim;++s){
            f[i][s]=ad(f[i][s-1],C[i-1][s-1]);
        }
        for(reg s=1;s<=lim;++s) f[i][s]=ad(f[i][s],f[i][s-1]);
    }
    int ans=0;
    for(reg t=1;t<=A+1;++t){
        for(reg i=0;i<=t-1;++i){
            if(i!=0) ans=ad(ans,mul(C[B-1][i],f[i][t-i]));
            else ans=ad(ans,1);
        }
    }
    ot(ans);
    return 0;
}

}
signed main(){
    Miracle::main();
    return 0;
}

/*
   Author: *Miracle*
*/

Measured memory_bytes: 30720
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int N; cin >> N;
    vector<string> S;
    ll ans = 1;
    string tmp;

    for (int i = 0; i < N; i++){
      string s; cin >> s;
      S.push_back(s);
    }
    
    if(N == 1) {
      cout << ans << endl;
      return 0;
    }

    sort(S.begin(), S.end());
    
    for (int i = 0; i < N-1; i++)
    {
      tmp = S[i];
      if(tmp.compare(S[i+1]) != 0){
        ans++;
      }
    }

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

Measured memory_bytes: 11660
n, a, b = map(int, input().split())
MOD = 10**9+7
ans = pow(2, n, MOD)-1
X = Y = 1
for i in range(1, b+1):
    Y = Y*i % MOD
    X = X*(n-i+1) % MOD
    if i == a or i == b:
        ans -= X*pow(Y, MOD-2, MOD)

print(ans % MOD)

Measured memory_bytes: 3060
n,m = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(m)]
imos= [0]*(n+2)

for l,r in LR:
    imos[l] += 1
    imos[r+1] -= 1

for j in range(1,n+1):
    imos[j] += imos[j-1]
    
print(imos[:-1].count(m))

Measured memory_bytes: 32060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A,B,a,ans=1;
int main()
{
    go;
    cin>>A>>B;
    if(B==1)
    {
        cout<<0;
        return 0;
    }
    a=A-1;
    while(A<B)
    {
        ans++;
        A+=a;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#define ll long long
using namespace std;

bool done[111111];


int main() {
    int K;
    cin>>K;
    
    for(int i=0;i<=K-1;i++)
        done[i]=false;
    
    set<pair<int,int> > sum_rem;
    for(int d=1;d<=9;d++)
        sum_rem.insert({d,d%K});
    
    int ans = -1;
    while(!sum_rem.empty()) {
        set<pair<int,int>>::iterator it = sum_rem.begin();
        
        int summ = it->first;
        int rem = it->second;
        sum_rem.erase(it);

        done[rem]=true;
        
        if (rem == 0) {
            ans = summ;
            break;
        }
        
        for(int d=0;d<=9;d++) {
            int nrem = (rem*10+d)%K;
            if (done[nrem])
                continue;
            sum_rem.insert({summ+d,(rem*10+d)%K});
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 20480
/**
 *      ABC 94 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/29
**/

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

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

    int N, M, X; cin >> N >> M >> X;
    vector<int> v;
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        v.push_back(a);
    }

    int small = 0; int large = 0;

    for (int i = 0; i < M; ++i) {
        if (v[i] <= X){
            ++small;
        }
        else {
            ++large;
        }        
    }

    cout << min(small, large) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  cout << n/3 << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
a=[0]*200001
cnt=0
for i in range(N):
    if a[A[i]]==0:
        cnt+=1
    a[A[i]]+=1
a.sort(reverse=True)
sum=0
for i in range(cnt-K):
    sum+=a[cnt-i-1]

print(sum)

Measured memory_bytes: 100088
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

class RMQ{
	int n,seg,init;
	vector<int> dat;
public:
	RMQ(int siz,int def) : n(siz),init(def),seg(1){
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = 0;i < seg * 2 - 1;i++) dat[i] = init;
	}
	void update(int i,int x){
		i += seg - 1;
		dat[i] = x;
		while(i){
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]); //do
		}
	}
	int get(int a = 0,int b = -1,int k = 0,int l = 0,int r = -1){
		if(b == -1) b = seg;
		if(r == -1) r = seg;
		if(b <= l || r <= a) return init;
		if(a <= l && r <= b) return dat[k];
		return min(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r)); //do
	}
};

signed main(){
	int n,m;
	string s;
	cin >> n >> m >> s;
	RMQ rmq(n + 1,INF);
	rmq.update(n,0);
	for(int i = n - 1;i >= 0;i--){
		if(s[i] == '0') rmq.update(i,rmq.get(i + 1,min(n + 1,i + m + 1)) + 1);
	}
	int pos = 0;
	vector<int> ans;
	while(pos != n){
		bool canMove = false;
		for(int i = 1;i <= m;i++){
			if(rmq.get(pos + i,pos + i + 1) == rmq.get(pos,pos + 1) - 1){
				pos += i;
				ans.push_back(i);
				canMove = true;
				break;
			}
		}
		if(!canMove){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i = 0;i < ans.size();i++) cout << (i ? " " : "") << ans[i];
	cout << endl;
}


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

int n;
ll memo[10][10];

ll solve(int head, int end){
  ll ret = 0;
  for(int i = 1; i <= n; i++){
    int e = i % 10;
    int h = i;
    while(h > 9) h /= 10;
    if(h == head && e == end){
      ret++;
    }
  }
  return ret;
}

int main(){
  cin >> n;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      memo[i][j] = solve(i, j);
    }
  }
  ll res = 0;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      res += memo[i][j] * memo[j][i];
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 30.09.2017 15:59:34       
**/
#include <bits/stdc++.h>

using namespace std;

inline void add(int &a, int b, int md) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b, int md) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b, int md) {
#if !defined(_WIN32) || defined(_WIN64)
  return (long long) a * b % md;
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b, int md) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a, md);
    }
    a = mul(a, a, md);
    b >>= 1;
  }
  return res;
}

inline int inv(int a, int md) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

template<typename T>
T extgcd(T a, T b, T &x, T &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}

template<typename T>
bool diophantine(T a, T b, T c, T &x, T &y, T &g) {
  if (a == 0 && b == 0) {
    if (c == 0) {
      x = y = g = 0;
      return true;
    }
    return false;
  }
  if (a == 0) {
    if (c % b == 0) {
      x = 0;
      y = c / b;
      g = abs(b);
      return true;
    }
    return false;
  }
  if (b == 0) {
    if (c % a == 0) {
      x = c / a;
      y = 0;
      g = abs(a);
      return true;
    }
    return false;
  }
  g = extgcd(a, b, x, y);
  if (c % g != 0) {
    return false;
  }
  T dx = c / a;
  c -= dx * a;
  T dy = c / b;
  c -= dy * b;
  x = dx + (T) ((__int128) x * (c / g) % b);
  y = dy + (T) ((__int128) y * (c / g) % a);
  g = abs(g);
  return true;
  // |x|, |y| <= max(|a|, |b|, |c|) [tested]
}

int get_phi(int m) {
  int phi = m;
  int tmp = m;
  for (int i = 2; i * i <= tmp; i++) {
    if (tmp % i == 0) {
      phi /= i;
      phi *= (i - 1);
      while (tmp % i == 0) {
        tmp /= i;
      }
    }
  }
  if (tmp > 1) {
    phi /= tmp;
    phi *= tmp - 1;
  }
  return phi;
}

long long solve(int a, int m) {
  if (m == 1) {
    return 30;
  }
  int phi = get_phi(m);
  int g = __gcd(m, phi);
  long long k = solve(a, g);
  int value = power(a, k, m);
  k %= phi;
  // res = value (mod m)
  // res = k (mod phi)
  // res = m * x + value = phi * y + k
  int x, y;
  assert(diophantine(m, -phi, (int) (k - value), x, y, g));
  long long res = (long long) m * x + value;
  while (res < 30) {
    res += (long long) m / g * phi;
  }
  return res;
}

int main() {
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int a, m;
    scanf("%d %d", &a, &m);
    long long k = solve(a, m);
    cout << k << endl;
    assert(power(a, k, m) == k % m);
  }
  return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
A = [int(x) for x in input().split()]

for a in A:
    if a % 2 == 0:
        if not (a/2 % 3 == 0 or a/2 % 5 == 0):
            print('DENIED')
            sys.exit(0)
print('APPROVED')
            

Measured memory_bytes: 3060
import sys
from collections import namedtuple
from heapq import heappush, heappop

INF = sys.maxsize

P = namedtuple('P', 'cost v')
Edage = namedtuple('Edge', 'to cost')

n, m, s, t = map(int, input().split())

s, t = s - 1, t - 1

# 円とスヌークそれぞれグラフを構成する
Yen = [[] for _ in range(n)]
Snuuk = [[] for _ in range(n)]

for _ in range(m):
  u, v, a, b = map(int, input().split())
  
  u, v = u - 1, v - 1
  
  Yen[u].append(Edage(v, a))
  Yen[v].append(Edage(u, a))
  Snuuk[u].append(Edage(v, b))
  Snuuk[v].append(Edage(u, b))

  
def min_costs(graph, start):
  costs = [INF] * n
  costs[start] = 0
  
  q = [P(0, start)]
  
  while q:
    cost, v = heappop(q)
    if cost > costs[v]:
      continue
    for to, cost in graph[v]:
      if costs[to] > costs[v] + cost:
        costs[to] = costs[v] + cost
        heappush(q, P(costs[to], to))        
        
  return costs

min_costs_in_yen = min_costs(Yen, s)
min_costs_in_snuuk = min_costs(Snuuk, t)

total_costs = [
  min_costs_in_yen[i] + min_costs_in_snuuk[i] 
  for i in range(n)
]

# 両替所が閉鎖されていく
for i in range(n - 1, 0, -1):
  total_costs[i - 1] = min(total_costs[i - 1], total_costs[i])
                      
    
for i in range(n):
  print(10 ** 15 - total_costs[i])
  
  

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

using namespace std;

int main() 
{
	
	string s1,s2;
	int count=0;
	cin >> s1 >> s2 ;
	for(int i=0;i<s1.length();i++)
	{
	    if(s1[i]!=s2[i])
	    {
	        count++;
	    }
	}
	cout << count << endl;
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3876
def main():
    n = int(input())
    p = list(map(int, input().split()))
    p_ascend = [i for i in range(1, n + 1)]
    cnt = 0

    for i in range(n):
        if p[i] != p_ascend[i]:
            cnt += 1

    if cnt == 0 or cnt == 2:
        ans = "YES"
    else:
        ans = "NO"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61788
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<queue>
#include<iomanip>
#include<bitset>
#include<math.h>
#include<stack>
#include<set>
using namespace std;
#define int long long
int mod = 1e9 + 7;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	int a, b, n;
	cin >> a >> b >> n;
	cout << (a * min(n, b-1)) / b - a * (min(n, b-1) / b);
}
	

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int seconds = sc.nextInt();
		int hour_sec = 60 * 60;
		int minute_sec = 60;
		int h = seconds / hour_sec;
		int m = (seconds % hour_sec) / minute_sec;
		int s = seconds % hour_sec % minute_sec;
		System.out.println(String.valueOf(h) + ":" + String.valueOf(m) + ":" + String.valueOf(s));
		sc.close();
	}
}

Measured memory_bytes: 17324