akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int num = 500000, NIL = -1;
vector<int> ans;
class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y) : id(id), x(x), y(y) {}
	bool operator < (Point p) {
		return id < p.id;
	}
};
Point P[num];
class Node {
public:
	int l, r, p, location;
};
Node t[num];
inline bool sortx(Point p1, Point p2) { return p1.x < p2.x; }
inline bool sorty(Point p1, Point p2) { return p1.y < p2.y; }
int np = 0;
inline int maket(int l, int r, int de) {
	if (l == r)return NIL;
	int T = np++;
	int mid = (l + r) / 2;
	if (de % 2 == 0) sort(P + l, P + r, sortx);
	else sort(P + l, P + r, sorty);
	t[T].location = mid;
	t[T].l = maket(l, mid, de + 1);
	t[T].r = maket(mid + 1, r, de + 1);
	return T;
}
inline void search(int i, int sx, int tx, int sy, int ty, int de, vector<int> &v) {
	if (sx <= P[t[i].location].x && tx >= P[t[i].location].x && sy <= P[t[i].location].y && ty >= P[t[i].location].y) v.push_back(P[t[i].location].id);
	if (de % 2 == 0) {
		if (t[i].l != NIL && P[t[i].location].x >= sx)  search(t[i].l, sx, tx, sy, ty, de + 1, v);
		if (t[i].r != NIL && P[t[i].location].x <= tx)search(t[i].r, sx, tx, sy, ty, de + 1, v);
	}
	else {
		if (t[i].l != NIL && P[t[i].location].y >= sy)  search(t[i].l, sx, tx, sy, ty, de + 1, v);
		if (t[i].r != NIL && P[t[i].location].y <= ty)   search(t[i].r, sx, tx, sy, ty, de + 1, v);
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		P[i] = Point(i, x, y);
		t[i].l = t[i].r = t[i].p = NIL;
	}
	int q;
	cin >> q;
	int root = maket(0, n, 0);
	for (int i = 0; i < q; i++) {
		int sx, sy, tx, ty;
		scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
		search(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < ans.size(); j++) printf("%d\n", ans[j]);
cout << endl;
		ans.clear();
	}

	return 0;
}

Measured memory_bytes: 16484
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {

  string in;
  cin >> in;

  long long int a;
  cin >> a;

  long long int k = 0;
  char c = '+';
  long long int n = 1;
  long long int ans_0 = 0;
  long long int ans_1 = 0;

  for ( long long int i = 0; i < in.size(); i++ ) {

    if ( in[i] == '+' ) {

      if ( c == '+' ) {
	ans_0 += k;
      }else {
	ans_0 *= k;
      }
      c = '+';
      n *= k;
      ans_1 += n;
      k = 0;
      n = 1;

    }else if ( in[i] == '*' ) {

      if ( c == '+' ) {
	ans_0 += k;
      }else {
	ans_0 *= k;
      }
      c = '*';
      n *= k;
      k = 0;

    }else {

      k = k * 10 + in[i] - '0';

    }

  }

  if ( c == '+' ) {
    ans_0 += k;
  }else {
    ans_0 *= k;
  }
  n *= k;
  ans_1 += n;

  string s = "ILMU";

  k = 0;

  if ( a == ans_0 ) k++;
  if ( a == ans_1 ) k += 2;

  cout << s[k] << endl;

  return 0;

}

Measured memory_bytes: 1204
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


n = I()
s = S()

ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    t_index = 0
    for s_index in range(n):
        if s[s_index] == t[t_index]:
            t_index += 1
            if t_index == 3:
                break
    if t_index == 3:
        ans += 1
print(ans)


Measured memory_bytes: 41068
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int H,W,K;
    cin>>H>>W>>K;
    vector<vi> c(H,vi(W,0));
    for(int i=0;i<H;i++){
        string S;cin>>S;
        for(int j=0;j<W;j++){
            if(S[j]=='#'){
                c[i][j]=1;
            }
        }
    }
    int Hp=1<<H;
    int Wp=1<<W;
    vector<vi> M(H,vi(W,0));
    //cout<<Hp<<" "<<Wp<<endl;
    int ans=0;
    for(int i=0;i<Hp;i++){
        for(int j=0;j<Wp;j++){
            int count=0;
            for(int h=0;h<H;h++){
                for(int w=0;w<W;w++){
                    M[h][w]=c[h][w];
                    if((i>>h)&1){
                        M[h][w]=0;
                    }
                    if((j>>w)&1){
                        M[h][w]=0;
                    }
                    if(M[h][w]==1)count++;
                }
            }
            if(count==K)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>
 
using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
 
const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
struct people { ll v, k, year; };
struct Combination{
  int mod;
  vector< int64_t > mfact, rfact;
 
  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod){
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }
 
  int64_t fact(int k) const{
    return (mfact[k]);
  }
 
  int64_t pow(int64_t x, int64_t n) const{
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }
 
  int64_t inv(int64_t x)const {
    return (pow(x, mod - 2));
  }
 
  int64_t P(int n, int r) const{
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }
 
  int64_t C(int p, int q) const{
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }
 
  int64_t H(int n, int r) const{
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};
 
int main() {
	ll n, a[101100], cou[101100], itl, itr;
        Combination comb(100100,MOD);
	cin >> n;
	for (int i = 1;i <= n + 1;i++) {
		cin >> a[i];
		if (cou[a[i]] == 0)cou[a[i]]++;
		else itr = i;
	}
	for (int i = 1;i <= n+1;i++) {
		if (a[i] == a[itr]) {
			itl = i;
			break;
		}
	}
	for (int i = 1;i <= n + 1;i++) {
		cout << (MOD + comb.C(n + 1, i) - comb.C(itl + n - itr, i - 1)) % MOD << endl;
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll n=s.size();
    vector<ll>num(n,0);
    for(ll i=0;i<n-1;i++){
        if(s[i]=='R'&&s[i+1]=='L'){
            for(ll j=i;j>=0&&s[j]=='R';j--){
                num[i+((i-j)%2==1)]++;
            }
            for(ll j=i+1;j<n&&s[j]=='L';j++){
                num[i+((j-i)%2==1)]++;
            }
        }
    }
    for(ll i=0;i<n;i++){
        cout << num[i] << " ";
    }
}

Measured memory_bytes: 4288
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int a[N], dp[N];

signed main(){
    IOS;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; i++)
        dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
// AOJ 1378: Secret of Chocolate Poles
// 2017.12.20 bal4u@uu

#include <stdio.h>

long long dp[101];

int main()
{
	int l, k, s;
	long long ans;

	scanf("%d%d", &l, &k);
	dp[1] = 1;
	if (k <= l) dp[k] = 1;
	for (s = 1; s < l; s++) {
		if (dp[s] > 0) {
			if (s+2   <= l) dp[s+2]   += dp[s];
			if (s+k+1 <= l) dp[s+k+1] += dp[s];
		}
	}

	ans = 0;
	for (s = 1; s <= l; s++) ans += dp[s];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  long long int X,a,b,c,ans;
  cin >> X;
  a = X % 500;
  b = X / 500;
  c = a / 5;
  ans = 0;
  ans += c*5;
  ans += b*1000;
  cout << ans << endl;
}

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

const int INF = 1e9;

void solve() {
    int n;
    scanf("%d", &n);
    int max_sum = -INF, min_sum = INF;
    int max_diff = -INF, min_diff = INF;

    for (int i = 1; i <= n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        max_sum = max(max_sum, x+y);
        min_sum = min(min_sum, x+y);

        max_diff = max(max_diff, x-y);
        min_diff = min(min_diff, x-y);
    }
    printf("%d\n", max(max_sum-min_sum, max_diff-min_diff));
}

int main(){

    solve();
    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int i;
  vector<char> v(6);
  for(i=0;i<6;i++) cin >> v[i];
  if(v[0]==v[5]&&v[1]==v[4]&&v[2]==v[3]) cout << "YES" << "\n";
  else cout << "NO" << "\n";
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){

    int h,w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0)break;
        for(int i = 0; i < w; i++){
            cout << '#';
        }
        cout << endl;
        for(int i = 2; i < h; i++){
            cout << '#';
            for(int j = 2; j < w; j++){
                cout << '.';
            }
            cout << '#' << endl;
        }
        for(int i = 0; i < w; i++){
            cout << '#';
        }
        cout << endl << endl;

    }

}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,M,sum_A=0,count=0;
  cin >> N >> M;
  long long A[N];
  for(long long i=0;i<N;i++){
    cin >> A[i];
    sum_A += A[i];
  }
  
  for(long long i=0;i<N;i++){
    if(sum_A <= A[i]*4*M){
      count++;
    }
  }
  
  if(count >= M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
a, b = raw_input().split(" ")
a = int(a)
l = int(b) - a
if a > 0:
    print "Positive"
elif a == 0 or b == 0 or a + l > 0:
    print "Zero"
else:
    if l % 2 != 0:
        print "Positive"
    else:
        print "Negative"

Measured memory_bytes: 2568
n,m=map(int,input().split())
lists=list(map(int,input().split()))
uselist=[]
for some in lists:
    some=some//2
    uselist.append(some)

import fractions
import math
ans = uselist[0]
for i in range(1, n):
    ans = ans* uselist[i] // fractions.gcd(ans, uselist[i])

flags=True
for some in uselist:
    a=ans//some
    if a%2==0:
        flags=False
        break
if flags:
    p=math.floor(m/ans)
    if p%2==0:
      print(p//2)
    elif p%2!=0:
      print(p//2+1)
    
else:
    print(0)


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

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


Measured memory_bytes: 3096
#include <string>
#include<queue>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main()
{
	int N;
	scanf("%d", &N);
	int cnt[3] = {}, a;
	for(int i = 0; i < N; i++){
		scanf("%d", &a);
		if( a%2 == 1 ) cnt[0]++;
		else if( a%4 == 2 ) cnt[1]++;
		else cnt[2]++;
	}
	if( cnt[2] >= cnt[0] ) printf("Yes\n");
	else if( cnt[2] == cnt[0] - 1 && cnt[1] == 0 ) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, b) for ( int i = a; i < b; i++ )
#define rep(i, n) REP(i, 0, n)
#define INFTY (1<<21)

int m, n, k, d, C[7], G[110][110], N, D[110][64];

int getID(string str){
    if ( str == "H" ) return 0;
    if ( str == "D" ) return N - 1;
    string num = str.substr(1, str.size()-1);
    if ( str[0] == 'C' ) return atoi(num.c_str());
    return atoi(num.c_str()) + m;
}

bool isC(int x){ return 1 <= x && x <= m; }

int bellman(){
    rep(i, N) rep(j, (1<<m)) D[i][j] = INFTY;
    D[0][0] = 0;
    rep(o, N*(1<<m)){
	bool change = false;
	rep(u, N) rep(v, N){
	    if ( u == v || G[u][v] == INFTY ) continue;
	    rep(b, (1<<m)){
		if (isC(v) && (b&(1<<(v-1))) != 0 ) continue; 
		if ( isC(v) ) {
		    if ( D[u][b] + G[u][v] - C[v] < D[v][b|(1<<(v-1))] ) {
			D[v][b|(1<<(v-1))] = D[u][b] + G[u][v] - C[v];
			change = true;
		    }
		} else {
		    if ( D[u][b] + G[u][v] < D[v][b] ){
			D[v][b] = D[u][b] + G[u][v];
			change = true;
		    }
		}
	    }
	}
	if ( !change ) break;
    }

    int minv = INFTY;
    rep(i, (1<<m)) minv = min(minv, D[N-1][i]);
    return minv;
}

int main(){
    string source, target;
    int cost;
    while(cin >> m >> n >> k >> d && m ){
	N = 2 + n + m;
	REP(i, 1, m+1) cin >> C[i];
	rep(i, N) rep(j, N) G[i][j] = INFTY;
	rep(i, d){
	    cin >> source >> target >> cost;
	    int s = getID(source);
	    int t = getID(target);
	    G[t][s] = G[s][t] = min(G[s][t], cost * k);
	}
	cout << bellman() << endl;
    }
    return 0;
}

Measured memory_bytes: 1008
n,d = gets.split(" ").map(&:to_i)
points = []
n.times{ points << gets.split.map(&:to_i) }
count = 0
points.combination(2) do |y,z|
    dist = 0
        (0...d).each do |e|
        dist += (y[e] - z[e]) ** 2
    end
    dist = Math.sqrt(dist)
    count += 1 if dist - dist.to_i == 0
end
print count

Measured memory_bytes: 1788
import itertools

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

seq = itertools.permutations(range(1,N+1))
listseq = list(seq)
tupleA = tuple(A)
tupleB = tuple(B)

indexA = listseq.index(tupleA) + 1
indexB = listseq.index(tupleB) + 1

ans = abs(indexA - indexB)

print(ans)


Measured memory_bytes: 44656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
//d
queue<int> qA, qB;

void dfs(int i, int j, vector<bool> &check, vector<vector<int>> &data, vector<int> &ans){
  
  if(check[i-1]) return;
  else check[i-1] = true;
  ans[i-1]=j;
  rep(k, data[i-1].size()){
    qA.push(data[i-1][k]);
    qB.push(i);
  }
  return;
  
}

void search(int N, vector<vector<int>> &data, vector<int> &ans){
  
  vector<bool> check(N);
  qA.push(1);
  qB.push(-1);
  while(qA.size()!=0){
    dfs(qA.front(), qB.front(), check, data, ans);
    qA.pop();
    qB.pop();
  }
  return;
  
}

int main(){
  
  cout << "Yes" << endl;
  int N, M;
  cin >> N >> M;
  vector<vector<int>> data(N, vector<int> (0));
  vector<int> ans(N);
  rep(i, M){
    int a, b; cin >> a >> b;
    data[a-1].push_back(b);
    data[b-1].push_back(a);
  }
  
  search(N, data, ans);
  
  rep(i, N) if(i!=0) cout << ans[i] << endl;
  
}

Measured memory_bytes: 12220
#include <stdio.h>
int main(){
    char ch;
    char a[1000]={0};
    int flag=0;
    while((ch=getchar())!='\n'){
        a[ch-'0']++;
        if(a[ch-'0']>1&&flag==0) {
            printf("no\n");
            flag=1;}
    }
    if(flag==0) printf("yes\n");
    return 0;
}

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

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

ll mod = 1e9 + 7;



int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    int now;
    rp(i, 0, n) {
        scanf("%d", &now);
        ans += now - 1;
    }
    printf("%d", ans);
    return 0;

} 

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public void kami() {
                Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x,j = 0;
		
		for(int i = a; i <= b; i++){
			x = c % i;
			if(x == 0){
				j++;
			}
			
		}
		System.out.println(j);

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

}

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

int main(){
  while(1){
    string s;
    cin>>s;
    if(s=="-"){
      break;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      int h;
      cin>>h;
      s=s.substr(h)+s.substr(0,h);
    }
    cout<<s<<endl;
  }
  return 0;
}



Measured memory_bytes: 3164
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
//template
typedef double db;
const db eps=1e-10;
const db pi=acosl(-1.0);
int sign(db x){if(x<-eps)return -1;if(x>eps)return 1;return 0;}
int cmp(db x,db y){return sign(x-y);}
bool inmid(db x,db l,db r){return cmp(x,l)*cmp(x,r)<=0;}
struct po{
	db x,y;
	po(db _x=0,db _y=0):x(_x),y(_y){}
	void read(){scanf("%lf%lf",&x,&y);}
};
po operator +(const po &a,const po &b){return po(a.x+b.x,a.y+b.y);}
po operator -(const po &a,const po &b){return po(a.x-b.x,a.y-b.y);}
po operator *(const po &a,const db &b){return po(a.x*b,a.y*b);}
po operator /(const po &a,const db &b){return po(a.x/b,a.y/b);}
db operator *(const po &a,const po &b){return a.x*b.x+a.y*b.y;}
db operator ^(const po &a,const po &b){return a.x*b.y-a.y*b.x;}
db mo2(po a){return a*a;}
db mo(po a){return sqrt(a*a);}
po proj(po x,po y){//proj x to y
	return y*((x*y)/mo2(y));
}
po refl(po x,po y){//refl x from y
	return proj(x,y)*2-x;
}
bool onseg(po x,po l,po r){
	return (sign((x-l)^(r-l))==0)&&inmid(x.x,l.x,r.x)&&inmid(x.y,l.y,r.y);
}
//template
int main(){
	int t;scanf("%d",&t);
	while(t--){
		po a,b,c,d;
		a.read();b.read();c.read();d.read();
		b=b-a;
		d=d-c;

		if(sign(b*d)==0)puts("1");
		else if(sign(b^d)==0)puts("2");
		else puts("0");
	}
	return 0;
}






Measured memory_bytes: 3252
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
		int n,k,i;
		cin>>n>>k;
		vi a(n);
		repf(i,0,n) cin>>a[i];
		sort(a);
		int ans=0;
		repf(i,0,k) ans+=a[i];
		cout<<ans;
    }
    return 0;
} 


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	if (n / 100 == 7 || n % 100 / 10 == 7 || n % 10 == 7) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

// headers {{{
using namespace std;
// using namespace rel_ops;
 
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> inline bool bit(T a, int b) {return (a>>b)&1;}
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(long long n) { return __builtin_popcountll(n); }
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define eb(args...) emplace_back(args)
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#define sz(g) int(g.size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
#ifdef LOCAL
#define dout cerr 
void out() { dout << endl; }
template<typename A, typename... B> void out(A a, B... b) { dout << ' ' << a; out(b...); }
#define dbg(args...) dout << __LINE__ << ":(" << #args << ") -> ", out(args)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
constexpr bool local = true;
#else
#define dbg(...)
#define dout if(true);else cerr
#define out(...)
#define show(...)
constexpr bool local = false;
#endif
// }}}

int N, Q;
int64 a[200005];
void solve() {
    cin >> N;
    int64 sum = 0;
    rep(i, N) {
        int x; cin >>x;
        a[x]++;
        sum += x;
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
        int b, c;
        cin >> b >> c;
        sum -= b * a[b];
        sum -= c * a[c];
        a[c] += a[b];
        a[b] = 0;
        sum += c * a[c];
        cout << sum << '\n';
    }

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    solve();
    return 0;
}



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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, a, b, x);
  wt(a <= x && x <= a + b ? "YES" : "NO");
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int H, W; cin >> H >> W;
    string ans = "";

    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            string s; cin >> s;
            if(s == "snuke"){
                char c = 'A';
                for(int k=0; k<j-1; k++) c += 1;
                ans += c;
                ans += to_string(i);
            }
        }
    }

    cout << ans << endl;
} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N, K = map(int, input().split())
A = list(map(int, input().split()))

log = []
check = [False]*N

def func(x, iter):
    x = A[x-1]

    if iter+1 == K:
        return x
    if check[x-1]:
        ix = log.index(x)
        loop = log[ix:]
        tmp = (K-iter-1)%len(loop)
        return loop[tmp]
    else:
        log.append(x)
        check[x-1] = True
        iter += 1
        return func(x, iter)

print(func(1, 0))

Measured memory_bytes: 160116
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int p, q, r, max1, max2;
	cin >> p >> q >> r;
	max2 = (p > q)? p : q;
	max1 = (max2 > r)? max2 : r;
	cout<< (p + q + r - max1) <<endl;
	return 0;
}

Measured memory_bytes: 256
w = gets.to_i
n = gets.to_i
a = (1..w).to_a

for i in 1..n
  x, y = gets.split(",").map{|val| val.to_i}
  x -= 1
  y -= 1
  a[x], a[y] = a[y], a[x]
end

puts a

Measured memory_bytes: 2380
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	int x, y;
	int a[7] = {1, 3, 5, 7, 8, 10, 12};
	int b[4] = {4, 6, 9, 11};
	
	cin >> x >> y;

	if (x == 2 || y == 2) {
		cout << "No" << endl;
		return (0);
	} else {
		int judge = 0;
		for (int i = 0; i <= 6; i++) {
			if (x == a[i]) {
				judge = 1;
			}
		}
		if (judge) {
			for (int i = 0; i <= 6; i++) {
				if (y == a[i]) {
					cout << "Yes" << endl;
					return (0);
				}
			}
		} else {
			for (int i = 0; i <= 3; i++) {
				if (y == b[i]) {
					cout << "Yes" << endl;
					return (0);
				}
			}
		}
	}
	cout << "No" << endl;

	return (0);
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    v<int> a(q), b(q), c(q), d(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    v<int> comb(n+m-1, 1);
    rep(i,m-1) comb[i] = 0;
    int ans = 0;
    do {
        int cnt = 0;
        int score = 0;
        v<int> A;
        
        rep(i,(int)comb.size() + 1) {
            if (comb[i] == 0) cnt++;
            else A.push_back(cnt + 1);
        }

        rep(i,q) {
            if (A[b[i]] - A[a[i]] == c[i]) score += d[i];
        }
        ans = max(ans, score);

//        rep(i,A.size()) cout << A[i] << ' ';
//        cout << score << endl;
    } while(next_permutation(comb.begin(), comb.end()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);
        int m = Integer.valueOf(arr01[1]);
        System.out.println(n == m ? "Yes" : "No");

    }

}

Measured memory_bytes: 19924
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  long long Y;
  cin >> N >> Y;
  for(int x = 0; x <= N; x++){
    for(int y = 0; y <= N-x; y++){
      int z = N-x-y;
      if(10000*x + 5000*y + 1000*z == Y){
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int num[100001];
int main(void)
{
	int n,m,a,b,i;
	scanf("%d%d",&n,&m);
	FOR(i,0,m){
		scanf("%d%d",&a,&b);
		num[a]++,num[b]++;
	}
	FOR(i,1,n+1){
		if(num[i]%2){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}
    
    
    

Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int a,b,c,tmp;
  scanf("%d %d %d", &a, &b, &c);
  if(b<a){tmp=a;a=b;b=tmp;}
  if(c<b){tmp=b;b=c;c=tmp;}
  if(b<a){tmp=a;a=b;b=tmp;}
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (int i=0; i < n; i++)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using LP = pair<ll,ll>;
using P = pair<int,int>;
const ll mod = 1e9+7;

const int inf = 5000;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};
int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<int>> dist(h, vector<int>(w, inf));
	priority_queue<P, vector<P>, greater<P>> q;
	auto toId = [&](int i, int j){
		return i*w+j;
	};
	auto push = [&](int i, int j, int x){
		if (dist[i][j]<=x) return;
		int id = toId(i, j);
		dist[i][j] = x;
		q.emplace(x, id);
	};
	rep(i, h) rep(j, w){
		char s;
		cin >> s;
		if (s == '#') push(i, j, 0);
	}
	while (!q.empty())
	{
		int x = q.top().first;
		int id = q.top().second;
		int i = id/w;
		int j = id%w;
		q.pop();
		rep(v, 4){
			int ni = i + di[v];
			int nj = j + dj[v];
			if (ni < 0 or ni >= h or nj < 0 or nj >= w) continue;
			push(ni, nj, x+1);
		}
	}
	int ans = 0;
	rep(i, h) rep(j, w) ans = max(ans, dist[i][j]);
	cout << ans << endl;


	

}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  vll b(n-1);
  REP(i, n-1)
    cin >> b[i];

  vll a(n);
  REP(i, n){
    if(i == 0)
      a[i] = b[i];
    else if(i == n-1)
      a[i] = b[i-1];
    else
      a[i] = min(b[i], b[i-1]);
  }

  ll ans = 0;
  REP(i, n)
    ans += a[i];

  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
function main(_stdin) {
    const stdin = _stdin.split('\n').filter(e => e.length);
    const [price, length] = stdin.shift().split(' ').map(Number);
    const coins = stdin.shift().split(' ').map(Number);

    const table = [];
    table[0] = 0;

    for(let i = 0; i<= length;i++){
        for (let j = coins[i]; j<= price; j++){
            table[j] = table[j] ? Math.min(table[j], table[j - coins[i]] + 1) : j / coins[i];
        }
    }

    console.log(table[price]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 18944
import Data.List -- sort
import Control.Monad -- replicateM

readInt = read <$> getLine :: IO Integer
arrayInt = map read . words <$> getLine :: IO [Integer]
writeln x = putStrLn $ unwords x :: IO ()

main = do
    ss <- map (\ c -> read [c]) <$> getLine
    print $ min (eval (cycle [0,1]) ss) (eval (cycle [1,0]) ss)

eval a b = sum $ zipWith (\ x y -> if x == y then 0 else 1) a b


Measured memory_bytes: 11284
// Aizu 1153: Equal Total Scores
// 2017.9.13 bal4u@uu

#include <stdio.h>

#define INF 0x7fffff
int a[102], b[102];

int main()
{
	int na, nb, sa, sb, i, j, aa, bb, ss;

	while (scanf("%d%d", &na, &nb) && na) {
		for (sa = i = 0; i < na; i++) scanf("%d", a+i), sa += a[i];
		for (sb = j = 0; j < nb; j++) scanf("%d", b+j), sb += b[j];
		sa -= sb, ss = INF;
		for (i = 0; i < na; i++) for (j = 0; j < nb; j++) {
			if ((a[i] - b[j]) << 1 == sa) {
				if (a[i] + b[j] < ss) aa = a[i], bb = b[j], ss = aa + bb;
			}
		}
		if (ss == INF) puts("-1");
		else printf("%d %d\n", aa, bb);
	}
	return 0;
}

Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solve(int N, const vector<string> &A, int s)
{
	//cout << "s=" << s << endl;

	vector<string> T = A;

	vector<bool> visited(N, false);

	vector<int> v;
	v.push_back(s);

	int ans = 0;
	while (!v.empty()) {
		++ans;
		vector<int> next;

		for (auto x : v) {
			visited[x] = true;
		}
		for (auto x : v) {
			for (int i = 0; i < N; ++i) {
				if (T[x][i] == '1') {
					if (visited[i]) {
						//cout << "ng" << endl;
						return -1;
					}
					next.push_back(i);
					//cout << i << " ";
					T[x][i] = '0';
					T[i][x] = '0';
				}
			}
		}
		v = move(next);
	}
	return ans;
}

int solve(int N, const vector<string> &A)
{
	int ans = -1;
	int s;
	for (s = 0; s < N; ++s) {
		ans = max(ans, solve(N, A, s));
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	vector<string> S(N);
	for (auto &x : S) {
		cin >> x;
	}

	cout << solve(N, S) << endl;
}


Measured memory_bytes: 516
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
vector<int>adj[M];
int a[M],vis[M];
int n,m,cur;
priority_queue<int,vector<int>,greater<>>pq[M+2];
void dfs(int u)
{
    vis[u]=1;
    pq[cur].push(a[u]);
    for(auto v:adj[u])
    {
        if(vis[v]==0)
        {
            dfs(v);
        }
    }
}
 main()

{
    fast
    cin>>n>>m;
    f(i,1,n)
    {
        cin>>a[i];
    }
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        u++;v++;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(m==n-1)
    {
        cout<<"0"<<endl;return 0;
    }
    cur=0;
    f(i,1,n)
    {
        if(vis[i]==0)
        {
            cur++;
            dfs(i);
        }
    }
    int nd=2*(cur-1);
    if(n<nd)
    {
        cout<<"Impossible"<<endl;return 0;
    }
    int ses=0;
    f(i,1,cur)
    {
        ses+=pq[i].top();
        pq[i].pop();
    }

    f(i,1,cur)
    {
        while(!pq[i].empty())
        {
            pq[M].push(pq[i].top());
            pq[i].pop();
        }
    }
    f(i,1,cur-2)
    {
        ses+=pq[M].top();
        pq[M].pop();
    }
    cout<<ses<<endl;
    return 0;

}





































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

int main()
{
	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
	#endif*/

	int n, c = 0;
	cin >> n;
	int p[n];
	for(int i = 0;i < n;i++)
		cin >> p[i];

	for(int i = 1;i < n-1;i++)
	{
		if(((p[i] > p[i-1])and(p[i] < p[i+1])) or ((p[i] < p[i-1])and(p[i] > p[i+1])))
		{
			c++;
		}
	}

	cout << c;
}

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

int main() {
    int n, k; scanf("%d%d", &n, &k);
    vector <int> cnt(n + 1);
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }
    sort(cnt.begin(), cnt.end(), greater <int>());
    int sum = 0;
    for (int i = 0; i < k; ++i) sum += cnt[i];
    printf("%d\n", n - sum);
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc149/abc149_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

vector<int> sieve(int N) {
  vector<bool> e(N + 1, true);
  e[0] = false;
  e[1] = false;
  int sqrtN = ceil(sqrt(N)) + 1;
  rep(p, sqrtN) {
    if (!e[p]) continue;
    for (int i = pow(p, 2); i <= N; i += p) {
      e[i] = false;
    }
  }
  vector<int> ret;
  rep(i, N + 1) {
    if (e[i]) ret.push_back(i);
  }
  return ret;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int x;
  cin >> x;

  auto primes = sieve(2e5);
  int id = upper_bound(primes.begin(), primes.end(), x) - primes.begin();
  ll ans;
  if (primes[id-1] == x) {
    ans = x;
  } else {
    ans = primes[id];
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
x, y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]

if (x==2) or (y==2):
    print("No")
elif (x in a) and (y in a):
    print("Yes")
elif (x in b) and (y in b):
    print("Yes")
else:
    print("No")




Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf (ll)2e18
#define EPS 1e-12
#define MOD 998244353ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n;
	cin >> n;
	map<int, int> mp;
	fore(i, 0, n - 1)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	fore(i, 1, n + 1)
		cout << mp[i] << '\n';
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	fore(t, 0, q)
	{
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 13040
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define all(x) (x).begin(), (x).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];

    vector<int> cnt(3, 0);
    rep(i, 0, n) {
        if (p[i] <= a) cnt[0]++;
        else if (p[i] <= b) cnt[1]++;
        else cnt[2]++;
    }
    cout << min(min(cnt[0], cnt[1]), cnt[2]) << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import java.math.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static double a, b, c, d, e, f;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }
    static boolean read(){
        if(!sc.hasNext())
            return false;
        a = sc.nextDouble();
        b = sc.nextDouble();
        e = sc.nextDouble();
        c = sc.nextDouble();
        d = sc.nextDouble();
        f = sc.nextDouble();
        return true;
    }
    static void solve(){
        double det = a*d - b*c;
        double x = (d*e - b*f)/det, y = (-c*e + a*f)/det;
        x = Math.floor(x*1000 + 0.5)/1000;
        y = Math.floor(y*1000 + 0.5)/1000;
        System.out.printf("%.3f %.3f\n", x, y);
    }
}

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

int main(void){
    int n;
    stack<int> s;
    while(scanf("%d",&n)!=EOF){
        if(n!=0) s.push(n);
        else{
            cout << s.top() << "\n";
            s.pop();
        }
    }
}



Measured memory_bytes: 3116
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

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


int main() {
	int A;
	char n;
	int B;
	cin >> A >> n >> B;

	if (n == '+') {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
	return a<b;
}
bool cmp1(int a,int b)
{
	return a>b;
}
int main()
{
	int n,m;
	cin>>n>>m;
	int a[n+1],b[m+1];
	cin>>a[0]>>b[0];
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=m;i++) cin>>b[i];
	sort(a,a+n+1,cmp1);
	sort(b,b+m+1,cmp);
	if(a[0]<b[0]) cout<<"No War\n";
	else cout<<"War\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string N;
    cin >> N;
    if((N.at(0) == N.at(1) && N.at(1) == N.at(2)) || (N.at(1) == N.at(2) && N.at(2) == N.at(3))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=998244353;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int n;
vl x(60),y(60);

int fnc(ll dx,ll dy){
    int res = 0;
    rep(i,n){
        ll nx = x[i] + dx;
        ll ny = y[i] + dy;
        rep(j,n){
            if(i==j) continue;
            if(x[j]==nx && y[j]==ny){
                res++;
                break;
            }
        }
    }
    return res;
}

int main(){
    cin >> n;
    rep(i,n) cin >> x[i] >> y[i];
    vector<pair<ll,ll>> cn;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            ll dx = x[j] - x[i];
            ll dy = y[j] - y[i];
            cn.push_back({dx,dy});
            cn.push_back({-dx,-dy});
            //cout << dx << " " << dy << endl;
        }
    }
    ll ma = 0;
    rep(i,cn.size()){
        chmax(ma,fnc(cn[i].first,cn[i].second));
    }
    ll ans = 1 + ((n-1) - ma);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
            puts("DENIED");
            return 0;
        }
    }
    puts("APPROVED");
}

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

int SumOfDigits(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  int min = 100000;
  for(int A=1; A<N; A++){
    int a = SumOfDigits(A);
    int b = SumOfDigits(N-A);
    if(min>a+b){
      min = a+b;
    }
  }
  cout << min;
  return 0;
}

Measured memory_bytes: 3564
<?php
list($N,$M,$X) = explode(" ",trim(fgets(STDIN)));
$A = explode(" ",trim(fgets(STDIN)));

$FEE = 0;
$fee = 0;
$x = $X;

while($X<$N){
	foreach($A as $value){
  if($value ==$X){	
    $FEE++;   
  }
}
$X++;
}

while($x>0){
	foreach($A as $value){
  if($value ==$x){	
    $fee++;   
  }
}
$x--;
}

if($FEE<$fee){
echo $FEE;
}else{
echo $fee;
}

Measured memory_bytes: 3576