akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

const int N = 20000010;
const int moder = (int) 1e9 + 7;

int fac[N], inv[N], invf[N];

void init(){
    fac[0] = invf[0] = 1;
    for (int i = 1; i < N; ++ i){
        fac[i] = 1ll * fac[i - 1] * i % moder;
        inv[i] = i == 1 ? 1 : moder - 1ll * (moder / i) * inv[moder % i] % moder;
        invf[i] = 1ll * invf[i - 1] * inv[i] % moder;
    }
}

int perm(int n, int m){
    return 1ll * fac[n] * invf[n - m] % moder;
}

int comb(int n, int m){
    return 1ll * fac[n] * invf[m] % moder * invf[n - m] % moder;
}

int main(){
    init();
    int h, w, k;
    scanf("%d%d%d", &h, &w, &k);
    int ans = 0;
    for (int i = 0; i <= h; ++ i){
        int y = k - i;
        if (y < 0 || y > w) continue;
        ans = (ans + 1ll * perm(h, i) * perm(w, y) % moder * ((2ll * i * y + 3 * i + 3 * y + 6) % moder) % moder * fac[i + y + 1] % moder * inv[6] % moder * invf[i] % moder * invf[y]) % moder;
        ans = (ans - 1ll * perm(h, i) * perm(w, y) % moder * comb(i + y, i)) % moder;
    }
    ans += ans < 0 ? moder : 0;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 234624
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int AWA[100001];
bool AC[100001];

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

    int cnt_AC = 0;
    int real_WA = 0;

    for (int i = 0; i < m; i++)
    {
        int p;
        string str;
        cin >> p >> str;

        if (!AC[p])
        {
            if (str == "WA")
                AWA[p]++;
            else if (str == "AC")
            {
                AC[p] = true;
                cnt_AC++;
                real_WA += AWA[p];
            }
        }
    }

    cout << cnt_AC << " " << real_WA;
}

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

using namespace std;

#define WA(x) #x << " = " << x << '\n'
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define FORT(i, a, b) for(int i = a; i < (int) b; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

	int n, r; cin >> n >> r;
	if(n >= 10) cout << r << '\n';
	else cout << r + 100*(10-n) << '\n';

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	var ans int64
	if a+b > c*2 {
		if x > y {
			ans = int64(c * y * 2)
			if a < c*2 {
				ans += int64(a * (x - y))
			} else {
				ans += int64(c * 2 * (x - y))
			}
		} else {
			ans = int64(c * x * 2)
			if b < c*2 {
				ans += int64(b * (y - x))
			} else {
				ans += int64(c * 2 * (y - x))
			}
		}
	} else {
		ans = int64(a*x + b*y)
	}

	fmt.Println(ans)
}


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

int main() {
 int S;
 cin >> S;
 int a,b;
 a=S/100;
 b=S%100;
 if((a>12 || a==0) && (b>12 || b==0)){
    cout << "NA";
 }
  else if(a<13 && (b>12 || b==0)){
    cout << "MMYY";
 }
 else if((a>12 || a==0) && b<13){
    cout << "YYMM";
 }
  else{
    cout << "AMBIGUOUS";
 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define frab(i, a, b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
const int N = 1e3 + 10;

ll a[N][N];

vector <ll> primes;

bool prime(int x) {
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0)
            return false;
    return true;
}

ll f(int i, int j, int n) {
    ll cur = 1;
    if (i)
        cur *= (a[i - 1][j]) / __gcd(cur, a[i - 1][j]);
    if (i + 1 < n)
        cur *= (a[i + 1][j]) / __gcd(cur, a[i + 1][j]);
    if (j)
        cur *= (a[i][j - 1]) / __gcd(cur, a[i][j - 1]);
    if (j + 1 < n)
        cur *= (a[i][j + 1]) / __gcd(cur, a[i][j + 1]);
    return cur + 1;
}

void check(int n) {
    set <ll> s;
    fr(i, n)
        fr(j, n) {
            s.insert(a[i][j]);
            assert(a[i][j] > 0 && a[i][j] < 1e15);
        }
    assert(s.size() == n * n);
    fr(i, n)
        fr(j, n) {
            if (i + 1 < n)
                assert(max(a[i][j], a[i + 1][j]) % min(a[i][j], a[i + 1][j]) == 1);
            if (j + 1 < n)
                assert(max(a[i][j], a[i][j + 1]) % min(a[i][j], a[i][j + 1]) == 1);
        }
    return;
}

int main() {
    //freopen("a.in", "r", stdin);
    int n;
    scanf("%d", &n);
    int i = 2;
    while (primes.size() < 4 * n + 10)
        if (prime(i++))
            primes.pb(i - 1);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if ((i + j) % 2 == 0) {
                a[i][j] = primes[(i + j) / 2] * primes[(i - j) / 2 + n / 2 + n];
            }
    fr(i, n)
        fr(j, n)
            if ((i + j) % 2)
                a[i][j] = f(i, j, n);
    if (n == 2)
        a[0][1] = (a[0][1] - 1) * 2 + 1;
    fr(i, n)
        fr(j, n)
            cout << a[i][j] << (j == n - 1 ? "\n" : " ");
    check(n);
}


Measured memory_bytes: 18944
import networkx as nx

def main():
  N,M=map(int,input().split())
  S = [list(input()) for _ in range(N)]

  if N == M == 1:
    print(0)
    print(S[0][0])
    exit()

  index = lambda i,j: i*M+j

  G=nx.Graph()
  dx,dy=(1,0),(0,1)
  E = []
  n1,n2 = [],[]
  for i in range(N):
    for j in range(M):
      if S[i][j]=='#':continue
      if (i+j)%2: n1.append(index(i,j))
      else: n2.append(index(i,j))
      for k in range(2):
        v1,v2 = index(i,j),index(i+dx[k],j+dy[k])
        if not (0<=i+dx[k]<N and 0<=j+dy[k]<M): continue
        if S[i+dx[k]][j+dy[k]] == '#': continue
        if (i+j) % 2: E.append((v2,v1))
        else: E.append((v1,v2))
     
  G.add_nodes_from(n1, bipartite=0)
  G.add_nodes_from(n2, bipartite=1)
  G.add_edges_from(E)
  match = nx.bipartite.maximum_matching(G, top_nodes=n1)
  match = {v:match[v] for v in match.keys() if v < match[v]}
 
  for v in match.keys():
    i1,j1 = divmod(v,M)
    i2,j2 = divmod(match[v],M)
    if i1 > i2 or j1 > j2:
      (i1,j1),(i2,j2) = (i2,j2),(i1,j1)
    if i1 < i2:
      S[i1][j1] = 'v'
      S[i2][j2] = '^'
    else:
      S[i1][j1] = '>'
      S[i2][j2] = '<'

  print(len(match))
  for i in range(N):
    print(''.join(S[i]))
    
if __name__ == "__main__":
  main()

Measured memory_bytes: 68108
/* Simplicity and Goodness */

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

using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{   
    string s;
    cin >> s;

    int sum = 0;

    for(auto c : s) {
        int d = c - '0';
        sum += d;
        sum %= 9;
    }

    puts(sum == 0 ? "Yes" : "No");
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;
 
#define DtR(degrees) ((degrees)*(M_PI/180.0f))
 
void moveXY( double& x, double& y, double mx, double my, double si, double co )
{
    double xy[3][1] = { {x},
                        {y},
                        {1}, };
    double r[3][3] = { { co, -si, 0 },
                    { si, co, 0 },
                    { 0, 0, 1 } };
    double m[3][3] = { { 1, 0, mx },
                    { 0, 1, my },
                    { 0, 0, 1 } };    
    int i,j,k;
    double a[3][3] = { {0} };
    for( i=0; i<3; i++ ) {
        for( j=0; j<3; j++ ) {
            for( k=0; k<3; k++ ) {
                a[i][j] += m[i][k]*r[k][j];
            }
        }
    }
 
    double b[3][1] = { {0} };          
    for( i=0; i<3; i++ ) {
        for( j=0; j<3; j++ ) {
            b[i][0] += a[i][j]*xy[j][0];
        }
    }
 
    x = b[0][0];
    y = b[1][0];
    return;
}
 
void kochCurve( int n, double px, double py, double px2, double py2 )
{
 
    double sx, sy;
    double ux, uy;
    double tx, ty;
    double d = sqrt( pow( px2-px, 2 ) + pow( py2-py, 2 ) );
     
    sx = d/3;
    ux = d/2;
    tx = sx*2;
    sy = ty = 0;
    uy = sin( DtR(60) )*sx;
     
    double si=0;
    double co=0;
	py = py*100000;
	py = (double)(int)py;
	py = py/100000;
	py2 = py2*100000;
	py2 = (double)(int)py2;
	py2 = py2/100000;
    if( px < px2 ) {
        if( py == py2 ) {
            si = sin( DtR(0) );
            co = cos( DtR(0) );            
        } else if( py < py2 ) {
            si = sin( DtR(60) );
            co = cos( DtR(60) );            
        } else if( py2 < py ) {
            si = sin( DtR(-60) );
            co = cos( DtR(-60) );
        }
    } else if( px2 < px ) {
        if( py == py2 ) {
            si = sin( DtR(-180) );
            co = cos( DtR(-180) );                 
        } else if( py2 < py ) {
            si = sin( DtR(-120) );
            co = cos( DtR(-120) );
        } else if( py < py2 ) {
            si = sin( DtR(-240) );
            co = cos( DtR(-240) );            
        }
    }
 
	moveXY( sx, sy, px, py, si, co );
	if( 1 < n ) {
		kochCurve( n-1, px, py, sx, sy );
	}
	cout<<sx<<" "<<sy<<endl; 
	
	moveXY( ux, uy, px, py, si, co );
	if( 1 < n ) {
		kochCurve( n-1, sx, sy, ux, uy );
	}
	cout<<ux<<" "<<uy<<endl;
	
	moveXY( tx, ty, px, py, si, co );
	if( 1 < n ) {
		kochCurve( n-1, ux, uy, tx, ty );
	}
	cout<<tx<<" "<<ty<<endl;
	
	if( 1 < n ) {
		kochCurve( n-1, tx, ty, px2, py2 );
	}
 
    return;
}
 
int main()
{
	cout.setf( ios::fixed );	
	int n;
	cin>>n;
	
	cout<<0.0<<" "<<0.0<<endl;	
	if( 1 <= n ) {
		kochCurve( n, 0, 0, 100.0, 0.0 );
	}
	cout<<100.0<<" "<<0.0<<endl;	
 
    return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
signed main() {
	int c, b, a; cin >> c >> b >> a;
	int k; cin >> k;
	if (b > c) {
		int count = 0;
		while (a <= b)a *= 2, count++;
		if (count > k)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	else {
		int count = 0;
		while (b<= c)b *= 2, count++;
		if (count > k)cout << "No" << endl;
		else {
			if (a > b)cout << "Yes" << endl;
			else {
				while (a <= b)a *= 2, count++;
				if (count > k)cout << "No" << endl;
				else cout << "Yes" << endl;
			}
		}
	}
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int answer = solutionA(n, a, b);
        System.out.println(answer);
    }

    public static int solutionA (int n, int a, int b) {
        if ((n * a) < b) {
            return (n * a);
        } else {
            return b;
        }
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    int N; cin >> N;
    vector<long long> v1(N);
    vector<long long> v2(N);
    for(int i=0;i<N;i++) cin >> v2[i];
    v1 = v2;
    sort(v2.begin(),v2.end());
    long long a = v2[N/2];
    long long b = v2[N/2-1];
    for(int i=0;i<N;i++){
        if(v1[i] < a) cout << a << endl;
        else cout << b << endl;
    }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n; cin >> n;
    vector<vector<int>> g(n);
    vector<pair<int, int>> vp;
    
    for (int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        
        vp.push_back({a, b});
    }
    
    std::queue<int> q;
    vector<int> used(n, 0);
    vector<int> parent(n, 0);
    
    int max_color = 0;
    map<pair<int, int>, int> ans;
    q.emplace(0);
    used[0] = 1;
    while(!q.empty()){
        int v = q.front(); q.pop();
        int cn = 0;
        for (auto nv: g[v]){
            if(used[nv] != 0) continue;
            cn++;
            used[nv] = 1;
            if (cn == parent[v]) cn++;
            
            pair<int, int> p = {v, nv};
            ans[p] = cn;
            parent[nv] = cn;
            q.push(nv);
        }
        max_color = max(max_color, cn);
    }
    
    cout << max_color << endl;
    for (int i=0; i<n-1; i++){
        cout << ans[vp[i]] << endl;
    }
    
}


Measured memory_bytes: 16668
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define FOR(i,n,a) for(int i = a;i<n;i++)
#define rep(i,n) FOR(i,n,0)
#define UNFOR(i,n,a) for(int i = a;i>n;i--)
#define unrep(i,n) UNFOR(i,0.n)
typedef long long ll;
using namespace std;
int x, n;
string s;
int main() {
	cin >> n >> s;
	int ans = 1000000;
	int hantai = 0;
	FOR(i, n, 0) {
		if (s[i] == 'E')hantai++;
	}
	FOR(i, n,0) {
		if(s[i]=='E')hantai--;
		ans = min(ans, hantai);
		if (s[i] == 'W')hantai++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, M;
  cin >> N >> M;

  int road[N];
  for(int i = 0; i < N; i++){
    road[i] = 0;
  }
 
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;

    road[a - 1] += 1;
    road[b - 1] += 1;
  }

  for(int i = 0; i < N; i++){
    cout << road[i] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int gcd(int a, int b) {
  if(a<b) swap(a,b);
  int c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
  
int main() {
  int N,X;
  cin >> N >> X;
  vi x(N);
  rep(i,N) {
    cin >> x[i];
  }
  x.push_back(X);
  sort(rng(x));
  vi spaces;
  srep(i,1,N+1) {
    spaces.push_back(x[i] - x[i-1]);
  }
  int ans = spaces[0];
  rep(i,sz(spaces)) {
    ans = gcd(ans,spaces[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>
#define EPS 0.0000001
int main(void){
    double x,y,r,s,t,u,a,b,p,c,d,q;
        while(1){
        if(scanf("%lf",&a)==EOF)break;
        scanf("%lf%lf%lf%lf%lf",&b,&p,&c,&d,&q);
        r=p*d-b*q;
        s=a*d-b*c;
        x=r/s;
        t=a*q-p*c;
        u=a*d-b*c;
        y=t/u;
        if(-EPS<x && x<=0) x = 0;
        if(-EPS<y && y<=0) y = 0;
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	
	if(n>=400&&n<=599) cout<<8;
	else if(n>=600&&n<=799) cout<<7;
	else if(n>=800&&n<=999) cout<<6;
	else if(n>=1000&&n<=1199) cout<<5;
	else if(n>=1200&&n<=1399) cout<<4;
	else if(n>=1400&&n<=1599) cout<<3;
	else if(n>=1600&&n<=1799) cout<<2;
	else if(n>=1800&&n<=1999) cout<<1;
	
	return 0;
}

Measured memory_bytes: 3628
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define mod        1000000007 
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll fact(ll n){ if(n==0){return 1;}return (n*fact(n-1))%mod;}
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2);}
ll gcd(ll a,ll b){if(b==0){return a;}gcd(b,a%b);}
ll a[2000000];
void sieve(){ll i,j;fli(i,2,1000001){if(a[i]==0){for(j=i*i;j<1000001;j+=i){a[j]=1;}}}}
vector<ll>v1;
bool compar(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second);
} 
ll ans=0;
ll arr[1000000];
vector<ll>root;
map<string,ll>m1;
map<pair<string,ll>,ll>m2;

void comp()
{
	ll i,j,k,n,m;
	string s,t;
	cin>>s>>t;
	ll ans=0;
	fl(i,s.length())
	{
		if(s[i]==t[i])
		{
			ans++;
		}
	}
	cout<<ans<<"\n";
} 
int main()
{
	speedup;
	ll i=0,t;
	ll n;
	//cin>>t;
	t=1;
	while(t--)
	{
	 comp();
	}
}

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




























int main () {
    long long N;
    cin >> N;
    vector<long long> vect;
    while (N > 0) {
        vect.push_back(N % 26);
        if (N % 26 == 0) N -= 26;
        N /= 26;
    }

    reverse (vect.begin(), vect.end());

    for (long long i: vect) {
        if (i == 1) {
            cout << "a";
        }
        if (i == 2) {
            cout << "b";
        }
        if (i == 3) {
            cout << "c";
        }
        if (i == 4) {
            cout << "d";
        }
        if (i == 5) {
            cout << "e";
        }
        if (i == 6) {
            cout << "f";
        }
        if (i == 7) {
            cout << "g";
        }
        if (i == 8) {
            cout << "h";
        }
        if (i == 9) {
            cout << "i";
        }
        if (i == 10) {cout << "j";}
        if (i == 11) {cout << "k";}
        if (i == 12) {cout << "l";}
        if (i == 13) cout << "m";
        if (i == 14) cout << "n";
        if (i == 15) cout << "o";
        if (i == 16) cout << "p";
        if (i == 17) cout << "q";
        if (i == 18) cout << "r";
        if (i == 19) cout << "s";
        if (i == 20) cout << "t";
        if (i == 21) cout << "u";
        if (i == 22) cout << "v";
        if (i == 23) cout << "w";
        if (i == 24) cout << "x";
        if (i == 25) cout << "y";
        if (i == 0) cout << "z";
    }

    cout << endl;
}

Measured memory_bytes: 3628
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
      	01 C PIC 9(15).
      	01 E PIC 9(15).
      	01 D PIC 9(15).
      	01 X PIC 9(15).
      	01 Y PIC 9(15).
      	01 W PIC 9(15).
      	01 F PIC ZZZZZZZZZ9.
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
      	01 temp3 PIC 9(15).
        01 N PIC 9(15).
        PROCEDURE DIVISION.
      	MAIN.
      		ACCEPT INP.
			PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		ADD 1 TO temp2.
      		PERFORM VARYING temp3 FROM temp2 BY 1
            UNTIL INP(temp3:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp3 - temp2.
        	MOVE INP(temp2:N) TO C.
      		COMPUTE C =  C / A.
      		COMPUTE C = C * B.
      		MOVE C to F.
      		DISPLAY F.
		STOP RUN.

Measured memory_bytes: 384
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) { }
    bool unionSet(ll x, ll y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) {
        return root(x) == root(y);
    }
    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(ll x) {
        return -data[root(x)];
    }
};

ll gcd(ll a, ll b)
{
    for (;;)
    {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

ll lcm(ll a, ll b)
{
    ll temp = gcd(a, b);
    
    return temp ? (a / temp * b) : 0;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> lower(n);
    vector<ll> upper(n);
    vector<bool> f(n);
    for(int i = 0;i < n;i++)
    {
        f[i] = false;
    }
    ll p = -1;
    for(int i = 0;i < n;i++)
    {
        ll t;
        cin >> t;
        if(p < t)
        {
            f[i] = true;
            lower[i] = t;
            upper[i] = t;
        }
        else
        {
            lower[i] = 1;
            upper[i] = t;
        }
        p = t;
    }
    vector<ll> right(n);
    for(int i = 0;i < n;i++)
    {
        ll a;
        cin >> a;
        right[i] = a;
    }
    p = -1;
    for(int i = n-1;i >= 0;i--)
    {
        ll a = right[i];
        if(p < a)
        {
            if(lower[i] <= a && upper[i] >= a)
            {
                f[i] = true;
                lower[i] = a;
                upper[i] = a;
            }
            else
            {
                cout << 0 << endl;
                return 0;
            }
        }
        else
        {
            if(lower[i] > a)
            {
                cout << 0 << endl;
                return 0;
            }
            lower[i] = max(lower[i], (ll)1);
            upper[i] = min(upper[i], a);
        }
        p = a;
    }
    ll sum = 1;
    for(int i = 0;i < n;i++)
    {
        ll e = (upper[i] - lower[i] + 1);
        //cout << e << endl;
        sum *= e;
        sum %= 1000000007;
    }
    cout << sum << endl;
    return 0;
}

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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pd pair<double, int>
#define pib pair<pi, bool>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 200001
#define MAXL 1000001
#define mod 1000000007

signed main()
{
  string s;
  cin >> s;
  (s == "ARC") ? cout << "ABC\n" : cout << "ARC\n";
  return 0;
}

Measured memory_bytes: 3632
import collections,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = sorted(LI())
deque = collections.deque()
for x in a:
    deque.append(x)
ans = 0
for _ in range(N):
    deque.popleft()
    deque.pop()
    ans += deque.pop()
print(ans)


Measured memory_bytes: 37468
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

inline void YESNO(bool ans){cout<<(ans?"YES":"NO")<<endl;}
inline void YesNo(bool ans){cout<<(ans?"Yes":"No")<<endl;}
inline void yesno(bool ans){cout<<(ans?"yes":"no")<<endl;}

struct Edge{
	int to,cost;
};

bool ans=true;
int n,m;
vector<vector<Edge> > edge;
vector<bool> seen;
vi d;

void dfs(int v,int val){
	seen[v]=true;
	d[v]=val;
	
	REP(i,edge[v].size()){
		int to=edge[v][i].to;
		int cost=edge[v][i].cost;
		
		if(seen[to]){
			if(d[to]==val+cost){}
			else{
				ans=false;
				return;
			}
		}else dfs(to,val+cost);
	}
}

//解説参考.
int main(){
	cin>>n>>m;
	
	edge.resize(n);
	REP(i,m){
		int l,r,d;
		cin>>l>>r>>d;
		l--, r--;
		
		edge[l].push_back({r,d});
		edge[r].push_back({l,-d});
	}
	
	seen.assign(n,false);
	d.assign(n,2*INF);
	REP(i,n){
		if(ans and (not seen[i])) dfs(i,0);
	}
	
	YesNo(ans);
}

Measured memory_bytes: 14952
D = int(input())
c = list(map(int,input().split()))
s = list(list(map(int,input().split())) for i in range(D))
t = []
score = 0
last = [0]*26
#v = [0]*D

def calc(d):
    """
    貪欲法でd日目のスコアが最も高くなるコンテストを出力
    """
    score = 0
    t = 0
    for i in range(26):
        temp = 0
        temp += s[d][i]
        for j in range(26):
            temp -= c[j]*(d+1-last[j])
        if score > temp:
            pass
        else:
            score = temp
            contest = i
    return i

for d in range(D):
    i = calc(d)
    t.append(i)
    last[i] = d+1
for i in range(D):
    print(t[i])

Measured memory_bytes: 9396
main :: IO ()
main = do
    [sx, sy, tx, ty] <- map read . words <$> getLine :: IO [Int]
    let up    = if sy < ty then "U" else "D"
    let down  = if sy < ty then "D" else "U"
    let right = if sy < ty then "R" else "L"
    let left  = if sy < ty then "L" else "R"

    putStrLn $ case (sy /= ty, sx /= tx) of
        (True, True) ->  gen ty sy up ++ gen tx sx right ++ gen ty sy down ++ gen tx sx left
            ++ left ++ gen ty sy up ++ up ++ gen tx sx right ++ right ++ down
            ++ right ++ gen ty sy down ++ down ++ gen tx sx left ++ left ++ up
        (True, False) -> gen ty sy up ++ right ++ gen ty sy down ++ left
            ++ left ++ gen ty sy up ++ right
            ++ up ++ right ++ right ++ gen ty sy down ++ down ++ down ++ left ++ left ++ up
        (False, True) -> gen tx sx right ++ down ++ gen tx sx left ++ up
            ++ up ++ gen tx sx right ++ down
            ++ right ++ down ++ down ++ gen tx sx left ++ left ++ left ++ up ++ up ++ right

gen :: Int -> Int -> String -> String
gen n m c = concat $ replicate (abs $ n-m) c


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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}


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

    int n;
    cin >> n;
    n %= 10;
    if(n == 3) {
        cout << "bon\n";
    } else if(n == 0 || n==1||n==6||n==8) {
        cout << "pon\n";
    } else {
        cout << "hon";
    }
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long k = in.nextLong();
			long base = 1;

			Set<Long> set = new TreeSet<>();
			for (int i = 0; i <= 15; i++) {
				for (int j = 1; j < 150; j++) {
					set.add((j+1) * base - 1);
				}
				base *= 10;
			}

			List<Long> list = new ArrayList<>();
			for (Long l : set) {
				list.add(l);
			}
			Collections.sort(list);

			for (int i = 0; i < list.size(); i++) {
				for (int j = i+1; j < list.size(); j++) {
					if (g(list.get(i)) > g(list.get(j))) {
						list.remove(i--);
						break;
					}
				}
			}

			for (int i = 0; i < k; i++) {
				out.println(list.get(i));
			}
		}

		long f(long n) {
			long ret = 0;
			while (n > 0) {
				ret += n % 10;
				n /= 10;
			}
			return ret;
		}

		double g(long n) {
			return (double)n / f(n);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21840
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const string MINUSINF = "-";

void chmax(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

long long match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; ++i) cin >> A[i];

    // 初期化
    for (int i = 0; i < 11000; ++i) dp[i] = MINUSINF;

    // 初期条件
    dp[0] = "";

    // DP ループ
    for (int i = 0; i <= N; ++i) {
        if (dp[i] == MINUSINF) continue;
        for (auto a : A)  chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 43776
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

bool input(int a[]){
	int i, inp;
	scanf("%d",&inp);
	if(inp == 0)
		return false;
	for(i = 3;i >= 0;i--){
		a[i] = inp % 10;
		inp /= 10;
	}
	return true;
}
int main(void){
	int a[4], b[4], i, count;
	const int suc[4] = {6,1,7,4};
	while(input(a)){
		count = 0;
		while(1){
			for(i = 0;i < 4;i++)
				if(suc[i] != a[i]) break;
			if(i == 4){
				printf("%d\n",count);
				break;
			}
			for(i = 1;i < 4;i++)
				if(a[0] != a[i]) break;
			if(i == 4){
				printf("NA\n");
				break;
			}
			for(i = 0;i < 4;i++)
				b[i] = a[i];
			sort(a,a + 4,greater<int>());
			sort(b,b + 4);
			for(i = 3;i >= 0;i--){
				a[i] -= b[i];
				if(a[i] < 0){
					a[i - 1]--;
					a[i] += 10;
				}
			}
			count++;
		}
	}
	return 0;
} 

Measured memory_bytes: 1052
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (
            Scanner sc = new Scanner(System.in);
        ) {
            int r = sc.nextInt();
            int g = sc.nextInt();
            int b = sc.nextInt();
            int num = r * 100 + g * 10 + b;
            String result = (num % 4 == 0) ? "YES" : "NO";
            System.out.println(result);

        }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  ll n; cin >> n;
  if(n % 2){
    cout << 0 << endl;
    return 0;
  }
  n /= 2;
  ll cnt = 0;
  ll div = 5;
  while(div <= n){
    cnt += n / div;
    div *= 5;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> memo(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    memo[a[i]]++;
  }

  int notzero = n - count(memo.begin() + 1, memo.end(), 0);

  // cout << notzero << endl;
  if (notzero <= k) {
    cout << 0 << endl;
    return 0;
  }

  sort(memo.begin(), memo.end());

  int i = 0;
  int ans = 0;
  while (1) {
    // cout << i << " " << memo[i] << endl;
    if (memo[i] != 0) {
      ans += memo[i];
      notzero--;
    }
    i++;
    if (notzero == k) {
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4820
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define MAX_N 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1
typedef pair<ull, ull> P;

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

void print(vector<ll> &v) {
    rep(i, v.size()) {
        if(i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

int main() {
    ull N, M, A, B;
    cin >> N >> M;
    vector<P> vec;
    rep(i, N) {
        cin >> A >> B;
        vec.push_back(P(A, B));
    }
    sort(vec.begin(), vec.end());

    ull cnt = M, sum = 0;
    for(auto v : vec) {
        if(v.second >= cnt) {
            sum += v.first * cnt;
            break;
        } else {
            sum += v.first * v.second;
            cnt -= v.second;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 2420
import java.util.Scanner;

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

        if (b - a <= 0) {
            System.out.println("delicious");
        } else if (b - a <= x) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep (i, n) cin >> p[i];

  int wrongCount = 0;
  rep(i, n) {
    if (p[i] != (i + 1)) {
      wrongCount++;
    }
  }
  string result = (wrongCount == 0 || wrongCount == 2) ? "YES" : "NO";
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin>>n;
    lli c=0;
    rep(i,9){
        if(n%(9-i)==0){ 
            n/=(9-i);
            c++;
            if (c==1) {
                if (n%(9-i)==0) {
                    n/=(9-i);
                    c++;
                }
            }
            if (c==2) {
                break;
            }
        }
    }

    Yes(n==1);
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200000
int n,k,arr[MAXN+5],temp,res;
priority_queue<int> pq;
int main(){
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &temp);
        arr[temp]++;
    }
    for(int i = 0; i <= MAXN; i++){
        if(arr[i]>0)pq.push(arr[i]);
    }
    while(k and !pq.empty()){
        pq.pop();
        k--;
    }
    while(!pq.empty()){
        res += pq.top();
        pq.pop();
    }
    printf("%d\n", res);
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] l = new int[m];
        int[] r = new int[m];
        for (int i = 0; i < m; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        int L = 0;
        int R = n;
        for (int i = 0; i < m; i++) {
            L = Math.max(L, l[i]);
            R = Math.min(R, r[i]);
        }
        if (L <= R) {
            System.out.println(R - L + 1);
        } else {
            System.out.println(0);
        }

    }

}

Measured memory_bytes: 64748
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A;
  int B;
  rd(A);
  rd(B);
  if(A<=9&&B<=9){
    wt_L(A*B);
    wt_L('\n');
  }
  else{
    wt_L(-1);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191027-1

// --- original code ---
// {
//   int A, B;
//   rd(A,B);
//   wt( if[A<=9&&B<=9, A*B, -1] );
// }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <cassert>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, c; cin >> a >> b >> c;
    cout << max(0, c - a + b) << '\n';
    return 0;
}


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

using namespace std;

const int N=1e5+5;

int n,q,statop;

ll sta[N],qu[N],f[N],c[N];

void solve(ll u,ll v){
	if(!u){
		return;
	}
	int pos=upper_bound(sta+1,sta+statop+1,u)-sta-1;
	if(!pos){
		c[1]+=v;c[u+1]-=v;
	}
	else{
		f[pos]+=u/sta[pos]*v;
		solve(u%sta[pos],v);
	}
}

int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=q;i++){
		scanf("%lld",&qu[i]);
	}
	sta[++statop]=n;
	for(int i=1;i<=q;i++){
		while(qu[i]<=sta[statop]){
			--statop;
		}
		sta[++statop]=qu[i];
	}
	f[statop]=1;
	for(int i=statop;i>1;i--){
		f[i-1]+=sta[i]/sta[i-1]*f[i];
		solve(sta[i]%sta[i-1],f[i]);
	}
	c[1]+=f[1];c[sta[1]+1]-=f[1];
	for(int i=1;i<=n;i++){
		c[i]+=c[i-1];
		printf("%lld\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 4864
a = int(input())
b= int(input())
c = int(input())
x = int(input())

pattern = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x-500*i-100*j-50*k==0:
                pattern+=1

print(pattern)
            

Measured memory_bytes: 8984
def submit():
  from collections import deque
  import sys
  input = sys.stdin.readline
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([0])
  while z:
    zp = z.popleft()
    j = zp//10**6
    b = zp%(10**6)
    for yj in y[j]:
      if yj != b:
        z.append(yj*10**6+j)
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Measured memory_bytes: 92236
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


ll getGCD(ll A, ll B) {
  if(A > B) return getGCD(B, A);
  ll r;
  while((r=B % A)) {
    B = A;
    A = r;
  }
  return A;
}

int main(void) {
  ll A, B;
  cin >> A >> B;
  ll gcd = getGCD(A, B);

  int ans = 1;// 1no bun
  for(ll i = 2; i * i <= gcd; ++i) {
    if(gcd % i == 0) {
      ++ans;
      while(gcd % i == 0) gcd /= i;//i wo soinsuu ni motu nowo nozoku
    }
  }

  if(gcd != 1) ++ans;//1ja nakattara sorega saigo no sosuu nanode +1

  cout << ans << endl;

  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll A, V, B, K, T;
  cin >> A >> V >> B >> K >> T;
  ll dist = A - B;
  if (dist < 0)
    dist *= -1;
  else if (dist == 0) {
    cout << "YES" << endl;
    return 0;
  }
  if (V - K <= 0 && dist > 0) {
    cout << "NO" << endl;
    return 0;
  }
  ll time = (dist + (V - K - 1)) / (V - K);
  if (time <= T)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int counter=0;
  for(int ema=min(A,B);ema>0;ema--){
    if((A%ema==0)&&(B%ema==0)){
      counter ++;
    }
    if(counter == K){
      cout << ema << endl;
      break;
    }
  }
}

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

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int N;
int a,b,c,d;
char ope[2] = {'+','-'};


int main(){
	cin >> N;
  a = N/1000;
  N -=a*1000;
  b = N/100;
  N -= b*100;
  c = N/10;
  d = N%10;
  REP(i,2){
    REP(j,2){
      REP(k,2){
        if(a + (1-i*2)*b + (1-j*2)*c + (1-k*2)*d ==7){
          cout << a << ope[i] << b << ope[j] << c << ope[k] << d << "=7"<<endl;
          return 0;
        }
      }
    }
  }

	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [[i for i in input()] for _ in range(n)]
dic = {}
for si in s[0]:
    if si not in dic.keys():
        dic[si] = [0 for _ in range(n)]
    dic[si][0] += 1
for i in range(1, n):
    for si in s[i]:
        if si not in dic.keys(): continue
        else:
            dic[si][i] += 1
dic = sorted(dic.items(), key=lambda x:x[0])
ans = ""
for k, v in dic:
    mi = min(v)
    if mi == 0: continue
    else:
        ans += k*mi
print(ans)

Measured memory_bytes: 3064