akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

//BEGIN CUT HERE
//Binary Indexed Tree
//1-indexed
//1-indexed!!
//1-indexed!!!!
//ある二次元平面に対して累積和が必要なときに、使ってください
//できること
//1.ある二次元平面の限られた範囲[y1,y2][x1,x2]に値wを加えること
//2.ある二次元平面の限られた範囲[0,y][0,x]の累積和を求めること(prefix)
class Two_d_Bit{
public:
    Two_d_Bit(int h,int w):height_size(h),width_size(w){
        bit.resize(static_cast<unsigned long>(height_size + 10));
        for (auto &i : bit)i.resize(static_cast<unsigned long>(width_size + 10), 0);
    }

    //add(int a,int b,ll v)は
    //for(int i=a;i<=height_size;i++)
    //  for(int j=b;j<=width_size;j++)
    //    v[i][j]+=v;
    //を意味します
    //1-indexed!!
    void add(int a,int b,ll v){
        for(int h=a;h<=height_size;h+=h&-h){
            for(int w=b;w<=width_size;w+=w&-w){
                bit[h][w]+=v;
            }
        }
    }

    void add(int y1,int x1,int y2,int x2,ll w){//add(int y1,int x1,int y2,int x2,ll w)は
        add(y1,x1,w);                          //for(int i=y1;i<=y2;i++)
        add(y2+1,x1,-w);                       //  for(int j=x1;j<=x2;j++)
        add(y1,x2+1,-w);                       //    v[i][j]+=w;
        add(y2+1,x2+1,w);                      //を意味します
    }                                          //1-indexed!!!!

    //sum(int a,int b)は
    //ll res=0;
    //for(int i=1;i<=a;i++)
    //  for(int j=1;j<=b;j++)
    //    res+=v[i][j];
    //を意味します
    //1-indexed!!!!
    ll sum(int a,int b){
        ll res=0;
        for(int h=a;h>0;h-=h&-h){
            for(int w=b;w>0;w-=w&-w){
                res+=bit[h][w];
            }
        }
        return res;
    }
private:
    int height_size;
    int width_size;
    vector<vector<ll> > bit;
};
//END CUT HERE

//!!!!!!!!!!!!!!!!!!!!!!!!!!未検証です!!!!!!!!!!!!!!!!!!!!!!!!!
//使えそうな問題があったらコードを提出してみてください
/*int main(){
    int n;cin>>n;
    Two_d_Bit bit(n,n);
    bit.add(2,2,4,4,1);
    bit.add(1,1,5,5,1);
    bit.add(1,1,2,2,1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<bit.sum(i,j)<<" ";
        }
        cout<<"\n";
    }
    return 0;
}*/

int main(){
    int n;cin>>n;
    Two_d_Bit bit(1001,1001);
    for(int i=0;i<n;i++){
        int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
        x1++;y1++;
        bit.add(y1,x1,y2,x2,1);
    }
    ll ans=0;
    for(int i=1;i<=1000;i++){
        for(int j=1;j<=1000;j++){
            ans=max(ans,bit.sum(i,j));
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

	bool ans = false;
	while (a <= b) {
		if (a % k == 0) {
			ans = true;
			break;
		}
		++a;
	}

	if (ans) {
		cout << "OK";
	} else {
		cout << "NG";
	}
	
	return 0;
}
	

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

int main(void){
 int number;
 cin >> number;
  while(number!=0){
    if(number%10==7){
      cout << "Yes";
      return 0;
    }
    number /= 10;
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int main(){
	long a,b;
	cin >> a >> b;
	long count=0;
	for(long i=a;i<=b;i++){
		if(i/10000==i%10 && (i/1000)%10==(i%100)/10){
			count++;
		}	
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())
# A, B, H, M = input().split()
# print(A, B, H, M)

def get_point(radians_theta, r):
    # 0° -> x:0, y=r とみなす
    # radians_theta 0 ~ 360
    # print(radians_theta, r)
    x = r * math.sin(math.radians(radians_theta))
    y = r * math.cos(math.radians(radians_theta))
    return x, y

def calc_rad_big_hand(H, M):
    # 長針
    return H * 30 + M / 2

def calc_rad_little_hand(M):
    # 短針
    return M * 6

def calc_result(A,B,H,M):
    H = int(H)
    M = int(M)
    A = int(A)
    B = int(B)
    big_hand_rad = calc_rad_big_hand(H, M)
    little_hand_rad = calc_rad_little_hand(M)
    big_x, big_y = get_point(big_hand_rad, A)
    little_x, little_y = get_point(little_hand_rad, B)
    return math.sqrt((big_x - little_x)**2 + (big_y-little_y)**2)

print(calc_result(A,B,H,M))


Measured memory_bytes: 9604
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  vector<ll> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(),A.end());

  if(A.at(0)%2==0 || A.at(1)%2==0 || A.at(2)%2==0) cout << 0 << endl;
  else cout << A.at(0)*A.at(1) << endl;
  
  return 0;
}


Measured memory_bytes: 3576
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n==0 && m==0) break;
			
			char[] a = new char[n+2];
			Arrays.fill(a,'#');
			a[0] = 'X';
			a[n+1] = 'X';
			for(int i=0;i<m;i++){
				char c = sc.next().charAt(0);
				if(c=='A'){
					for(int j=1;j<=n;j++){
						if(a[j]=='#'){
							a[j] = c;
							break;
						}
					}
				}else if(c=='B'){
					boolean flag = true;
					for(int j=n;j>0;j--){
						if(a[j]=='#' && a[j-1]!='A' && a[j+1]!='A'){
							a[j] = c;
							flag = false;
							break;
						}
					}
					if(flag==true){
						for(int j=1;j<=n;j++){
							if(a[j]=='#'){
								a[j] = c;
								break;
							}
						}
					}
				}else if(c=='C'){
					if(i==0){
						if(n%2==1) a[(n+1)/2] = c;
						else a[n/2+1] = c;
					}else{
						for(int j=1;j<=n;j++){
							if(a[j]!='#'){
								if(a[j+1]=='#'){
									a[j+1] = c;
									break;
								}
								if(a[j-1]=='#'){
									a[j-1] = c;
									break;
								}
							}
						}
					}
				}else if(c=='D'){
					if(i==0){
						a[1] = c;
					}else{
						int max = -1;
						int p = -1;
						for(int j=1;j<=n;j++){
							if(a[j]=='#'){
								int min = Integer.MAX_VALUE;
								for(int k=j-1;k>=0;k--){
									if(k==0) break;
									if(a[k]!='#'){
										min = Math.min(min, (j-1)-k);
										break;
									}
								}
								for(int k=j+1;k<=n+1;k++){
									if(k==n+1) break;
									if(a[k]!='#'){
										min = Math.min(min, k-(j+1));
										break;
									}
								}
								if(min>max){
									max = min;
									p = j;
								}
							}
						}
						a[p] = c;
					}
				}
			}
			for(int i=1;i<=n;i++) System.out.print(a[i]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 27240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

int main()
{
    int n, ans = 50, count;
    vector<pair<ll, ll>> point;
    cin >> n;
    point.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> point[i].first >> point[i].second;
    }
    sort(point.begin(), point.end());
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ll p = point[j].first - point[i].first;
            ll q = point[j].second - point[i].second;
            count = 0;
            for (int y = 0; y < n; y++)
            {
                for (int x = y + 1; x < n; x++)
                {
                    if (point[x].first - point[y].first == p && point[x].second - point[y].second == q)
                    {
                        count++;
                    }
                }
            }
            ans = min(ans, n - count);
        }
    }
    if (n == 1)
    {
        ans = 1;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
  ll h;
  cin >> h;

  ll ans = 1;
  ll cur = 1;
  while (h > 1) {
    h /= 2;
    cur *= 2;
    ans += cur;
  }
  cout << ans << endl;
  return 0;
}



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

const int INF = 1e9;

int main() {
  string s, t;
  cin>>s>>t;
  int n = s.length();
  for (int offset=0; offset<n; offset++) {
    bool ok = true;
    for (int i=0; i<n; i++) {
      if (s[i] != t[(i + offset) % n]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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 int

int main() {
    int n, k;
    cin >> n >> k;
    ll x[n];
    rep(i, n) {
        cin >> x[i];
    }
    ll ans = 100000000000000007;
    for (int i = 0; i < n - k + 1; i++) {
        int r = i + k - 1;
        ll A = min(abs(x[i]), abs(x[r])), B = max(abs(x[i]), abs(x[r]));
        if (x[i] * x[r] < 0) {
            ans = min(ans, 2 * A + B);
        } else {
            ans = min(ans, B);
        }
    }

    if (ans == 100000000000000007) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
    using namespace std;
    unsigned long p;
    cin >> p;
    vector<unsigned long> a(p);
    copy_n(istream_iterator<unsigned long>(cin), p, a.begin());
    vector<unsigned long> alpha(p);
    {
        vector<unsigned long> coef(p);
        coef[0] = p - 1;
        for(unsigned long i = 0; i < p; ++i){
            alpha[p - i - 1] = inner_product(a.begin(), a.end(), coef.begin(), 0UL) % p;
            for(unsigned long j = p; j--; )coef[j] = ((j ? coef[j - 1] : 0) + p - coef[j]) % p;
        }
    }
    vector<unsigned long> ans(p);
    ans[0] = alpha[0];
    for(unsigned long i = 1, l = p - 1; i < p; ++i, (l *= (p - i)) %= p)for(unsigned long k = p; k--; )ans[k] = ((k ? ans[k - 1] : l * alpha[i]) + (i + 1) * ans[k]) % p;
    copy(ans.begin(), ans.end(), ostream_iterator<unsigned long>(cout, " "));
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int n; cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            //if(i == j) continue;
            ans += arr[i]*arr[j];
        }
    }
    cout<<ans<<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 dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

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

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

	vector<int> cnt(1e6 + 1, 0);
	for (int i = 0; i < n; i++) {
		int cur = v[i];
		for (int j = 2; j * j <= cur; j++) {
			if (cur % j == 0) {
				cnt[j]++;
				while (cur % j == 0) cur /= j;
			}
		}
		if (cur != 1) cnt[cur]++;
	}
	bool b = true;
	for (int i = 0; i < 1e6 + 1; i++) {
		if (cnt[i] >= 2) b = false;
	}
	if (b) {
		cout << "pairwise coprime" << endl;
	} else {
		int g = v[0];
		rep(i,n) g = gcd(g, v[i]);
		if (g == 1) cout << "setwise coprime" << endl;
		else cout << "not coprime" << endl;
	}
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for (auto i = 0; i < s.size(); i++){
		if (s[i]!=','){ cout << s[i]; }
		else { cout << " "; }
	} cout << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;

int main(){
	ll ans=0,N,K,L,R;
	cin >> N >> K >> L >> R;
	ll x = N/2;
	ll y = N-x;
	vector<ll> S1(x),S2(y),A[x+1],B[y+1];
	FOR(i,0,x) cin >> S1[i];
	FOR(i,0,y) cin >> S2[i];

	A[0].push_back(0);
	B[0].push_back(0);

	FOR(i,0,x){
		FORR(j,0,x){
			for(auto a:A[j]){
				A[j+1].push_back(S1[i]+a);
			}
		}
	}
	FOR(i,0,y){
		FORR(j,0,y){
			for(auto b:B[j]){
				B[j+1].push_back(S2[i]+b);
			}
		}
	}

	FOR(i,1,x+1)SORT(A[i]);
	FOR(i,1,y+1)SORT(B[i]);

	FOR(i,0,min(x,K)+1){
		if( K-i > y )continue;
		for(auto a:A[i]){
			ll l = POSL(B[K-i],L-a);
			ll r = POSU(B[K-i],R-a) - 1;
			ans += r-l+1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 23512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll r,b;
int main(void){
	int n; cin>>n;
	string s; cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			r++;
		}else{
			b++;
		}
	}
	if(r>b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n"
         
    #define int long long 
    #define double long double
         
    #define bp __builtin_popcountll
    #define inf 1e16
    
    const int N=1e5+5; 
    const int M=1e6+6;
    const int MOD=1e9+7;
    void solve()
    {        
    	int n,x,y;
    	cin>>n>>x>>y;
    	int p=y-x;
    	int dis[n+1]={0};
    	
    	for(int i=1;i<=n-1;i++)
    	{
    		dis[i]=n-i;
    	}
    	for(int i=1;i<=n;i++){
    		for(int j=i+1;j<=n;j++){
    			int d=j-i;
    			int pp=min(d,abs(i-x)+1+abs(j-y));
    			pp=min(pp,abs(i-y)+1+abs(j-x));
    			dis[d]--;
    			dis[pp]++;
    		}
    	}
    	for(int i=1;i<=n-1;i++){
    		cout<<dis[i]<<endl;
    	}
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

vector<ll> c(202020, 0);
using Graph = vector<vector<int>>;
using pml = pair<map<ll, ll>, ll>;

void printmp(map<ll, ll> &mp){
    for(auto x: mp){
        cerr << x << " ";
    }
    cerr << endl;
}

ll N;
ll kazu = 0;
vector<ll> cnt(202020, 0);
vector<ll> sz(202020, 0);
map<ll, ll> dfs(ll now, ll par, Graph &G){
    sz[now] = 1;
    map<ll, ll> mp;
    for(auto next: G[now]){
        if(next == par) continue;
        auto mpch = dfs(next, now, G);

        sz[now] += sz[next];
        //ll val = szch - mpch[c[now]];
        ll val = sz[next];
        if(mpch.find(c[now]) != mpch.end()) val -= mpch[c[now]];
        cnt[c[now]] -= val*(val+1)/2;

        if((int)mp.size() < (int)mpch.size()) swap(mp, mpch);

        /*
        cout << "mp: ";
        printmp(mp);
        cout << "mpch: ";
        printmp(mpch);
        cout << endl;
        */

        for(auto x: mpch){
            mp[x.first] += x.second;
            kazu++;
        }
        mpch.clear();
    }

    /*
    dump(now)
    printmp(mp);
    dump(sz)
    dump(mp[c[now]])
    */

    //ll val = sz - 1 - mp[c[now]];
    //cnt[c[now]] -= val*(val+1)/2;
    mp[c[now]] = sz[now];
    
    /*
    REP(i, N){
        cout << cnt[i] << " ";
    }
    cout << endl;
    cout << endl;
    */
    return mp;
}

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

    cin >> N;

    REP(i, N) cin >> c[i], c[i]--;

    Graph G(N);
    REP(i, N-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    auto mp = dfs(0, -1, G);

    //printmp(mp);
    vector<ll> nokori(N, N);
    
    for(auto x: mp){
        nokori[x.first] = N - x.second;
    }
    //cout << nokori << endl;
    REP(i, N) cnt[i] -= nokori[i]*(nokori[i]+1)/2;

    REP(i, N){
        cout << N*(N+1)/2 + cnt[i] << endl;
    }

    //dump(kazu)

    return 0;
}

Measured memory_bytes: 71992
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

string Sa, Sb, Sc;

int main() {
  cin >> Sa >> Sb >> Sc;

  int turn = 'a';
  int a, b, c;
  a = b = c = 0;
  while (true) {
    switch (turn) {
      case 'a':
        if (a == Sa.size()) {
          cout << "A" << endl;
          goto end;
        }
        turn = Sa[a++];
        break;
      case 'b':
        if (b == Sb.size()) {
          cout << "B" << endl;
          goto end;
        }
        turn = Sb[b++];
        break;
      case 'c':
        if (c == Sc.size()) {
          cout << "C" << endl;
          goto end;
        }
        turn = Sc[c++];
        break;
    }
  }

end:
  return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<double, int> pdi;

int main(){

	pdi v[3][8];
	
	for(int i=0; i<24; ++i){
		
		double a;
		int b;
		
		scanf("%d %lf", &b, &a);
		v[i/8][i%8] = make_pair(a, b);
	}
	
	for(int i=0; i<3; ++i){
		sort(v[i], v[i]+8);
	}
	
	vector<pdi> rest;
	
	for(int i=0; i<24; ++i){
	
		if(i%8<2)
			printf("%d %.2f\n", v[i/8][i%8].second, v[i/8][i%8].first);
		else
			rest.push_back(v[i/8][i%8]);
	}
	
	sort(rest.begin(), rest.end());
	
	for(int i=0; i<2; ++i){
		printf("%d %.2f\n", rest[i].second, rest[i].first);
	}
	
	return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1 == 0) {
        cout << 1 << endl;
    } else if(x2 == 0) {

        cout << 2 << endl;
    } else if(x3 == 0) {

        cout << 3 << endl;
    } else if(x4 == 0) {

        cout << 4 << endl;
    } else if(x5 == 0) {

        cout << 5 << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
N = int(input())
ans = 0
l = list()
for i in range(1, int(N**0.5)+1):
  if N % i == 0:  # i is a divisor of N
    if i > 1:
      m = i-1
      if N//m == N % m:ans += m
    if i != N//i:
      m = N//i-1
      if N//m == N % m:ans += m
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
int main(){
    int N,c;
    c = 1;
    cin >> N;
    for (int i = 0; i <= N/7; i ++){
        if((N - i * 7) % 4 == 0){
            cout << "Yes" << endl;
            c = 0;
            break;
        }
    }
    if(c)   cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(size_t i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int i = 0;
    int index = 1;
    while(i<=n){
        i++;
        index = v[index-1];
        if(index==2) break;
    }
    if(i==n+1) cout << -1 << endl;
    else cout << i << endl;
    return 0;
}

Measured memory_bytes: 640
#author: dokueki




inp = []
for i in range(3):
    a = list(map(int, input().split()))
    inp.append(a)
res = []
for _ in range(int(input())):
    res.append(int(input()))
for i in range(3):
    for j in range(3):
        for k in res:
            if inp[i][j] == k:
                inp[i][j] = -1
r1, r2, r3, c1, c2, c3, d1, d2 = 0, 0, 0, 0, 0, 0, 0, 0
for i in range(3):
    if inp[i][0] == -1:
        r1 += 1
    if inp[i][1] == -1:
        r2 += 1
    if inp[i][2] == -1:
        r3 += 1
    if inp[0][i] == -1:
        c1 += 1
    if inp[1][i] == -1:
        c2 += 1
    if inp[2][i] == -1:
        c3 += 1
    if inp[i][i] == -1:
        d1 += 1
if inp[0][2] == inp[1][1] == inp[2][0] == -1:
    d2 += 3
if r1 == 3 or r2 == 3 or r3 == 3 or c1 == 3 or c2 == 3 or c3 == 3 or d1 == 3 or d2 == 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
X=int(input())

p=[True for _ in range(0,200000+1)]
p[0]=False
p[1]=False
for i in range(2,200000+1):
    if p[i]==False:
        continue
    for j in range(2,200000//i):
        p[i*j]=False

while p[X]==False:
    X+=1
print(X)


Measured memory_bytes: 10560
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

const ll mod = 1e9+7;

ll modpow(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll nckm(ll n, ll k){
    ll ans = 1;
    REP(d, k){
        ans *= (n-d) % mod;
        ans *= modpow(d+1, mod-2) % mod;
    }
    return ans % mod;
}

int main(){
    ll N; cin >> N;
    if(N==1){
        cout << 1 << endl; return 0;
    }
    
    vl A(N+1); REP(i, N) cin >> A[i];
    A[N] = LINF;
    
    vl B;
    REP(i, N){
        if(A[i] != A[i+1]) B.pb(A[i]);
    }
    
    if(B.size() == 1){
        cout << 1 << endl; return 0;
    }
    
    ll ans = 1;
    ll idx = 0;
    while(idx < B.size()-1){
        if(B[idx]<B[idx+1]){
            while(idx < B.size()-1 && B[idx]<B[idx+1]) idx++;
            if(idx != B.size()-1) ans++;
            idx++;
        }
        else{
            while(idx < B.size()-1 && B[idx]>B[idx+1]) idx++;
            if(idx != B.size()-1) ans++;
            idx++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Count(int a, int b, int N)
        {
            int cnt = (a == b && N >= a) ? 1 : 0;
            for (int i = 1; true; i *= 10)
            {
                a *= 10;
                for (int j = 0; j < i; ++j)
                {
                    if (a + (j * 10) + b > N) { return cnt; }
                    ++cnt;
                }
            }
        }

        static long Solve(int N)
        {
            long sum = 0;
            for (int i = 1; i <= 9; ++i)
            {
                for (int j = 1; j <= 9; ++j)
                {
                    sum += Math.BigMul(Count(i, j, N), Count(j, i, N));
                }
            }
            return sum;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            Console.WriteLine(Solve(N));
        }
    }
}


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

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p.at(i);
    int check = 0;
    for(int i = 1 ; i <= N ; i++){
        if(p.at(i -1) != i) check++;
    } 
    if(check > 2) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
using namespace std;
int n,w,e,minn=300005,ans,add[300005];
char s[300005],ch;
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++){
		if(s[i]=='W'){
			add[i]+=w;
			w++;
		}else{
			add[i]+=w;
		}
	}
	for(int i=n-1;i>=0;i--){
		if(s[i]=='E'){
			add[i]+=e;
			e++;
		}else{
		    add[i]+=e;
		}
	}
	for(int i=0;i<n;i++){
	    minn=min(minn,add[i]);
	   // printf("%d ",add[i]);
	}
	printf("%d",minn);
	return 0;
} 

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define maxs 202020
#define mme(i,j) memset(i,j,sizeof(j))
#define ll long long
#define pb push_back
using namespace std;
char s[maxs];

int main()
{
    while(~scanf("%s",s+1))
    {
        int ans=0;
        int len=strlen(s+1);
        if(s[1]==s[len]){
            if(len%2)
                puts("Second");
            else
                puts("First");
            continue;
        }
        else {
            if(len%2){
                printf("First\n");
            }else puts("Second");
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K; cin >> K;
  int A, B; cin >> A >> B;
  int i = 1, C = K * i;
  while(C <=1000){
    if(C >= A && C <= B){
      cout << "OK" << endl;
      return 0;
    }
    i++;
    C = K * i;
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================
	

	string S;
	cin >> S;


	ll N = S.length() + 1;

	vll L(N), R(N); // >, <
	for (ll i = 0; i < N; i++) {
		L[i] = 0;
		R[i] = 0;
	}
	
	for (ll i = 0; i < N-1; i++) {
		if (S[i] != '<') {
			L[i+1] = 0;
		}
		else {
			L[i+1] = L[i] + 1;
		}


		if (S[N-i-2] != '>') {
			R[N - i - 2] = 0;
		}
		else {
			R[N - i - 2] = R[N - i - 1] + 1;
		}

	}


	ll ans = 0;
	for (ll i = 0; i < N; i++) {
		ans += max(L[i], R[i]);
	}

	cout << ans;






}


Measured memory_bytes: 8732
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc.Split(bufio.ScanWords)
	var N int
	nextInt(&N)
	a := map[string]bool{}
	var ans int
	for i:=0; i<N; i++{
		k := nextLine()
		if a[k] {
			continue
		}
		ans++
		a[k] = true
	}
	fmt.Printf("%d", ans)
}

const MAX_INT int = 1_000_000_000

var sc = bufio.NewScanner(os.Stdin)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)

func nextLine() string {
	buffer := make([]byte, 0)
	for true {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func nextInt(A ...*int) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.Atoi(L[i])
	}
}
func nextInts(A *[]int) {
	L := strings.Split(nextLine(), " ")
	(*A) = make([]int, len(L))
	for i, l := range L {
		(*A)[i], _ = strconv.Atoi(l)
	}
}

func nextInt64(A ...*int64) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.ParseInt(L[i], 0, 64)
	}
}

func max(a int, b int) int {
	if a >= b {
		return a
	}
	return b
}



Measured memory_bytes: 16976
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	vector<int> n(4);
	rep(i, 4) cin >> n[i];
	vector<int> cnt(4);
	rep(i, 4) {
		if (n[i] == 1) cnt[0]++;
		else if (n[i] == 4) cnt[1]++;
		else if (n[i] == 7) cnt[2]++;
		else if (n[i] == 9) cnt[3]++;
	}
	bool ans = true;
	rep(i, 4) {
		if (cnt[i] != 1) ans = false;
	}
	if (ans) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
#1_7_A
class Node():
    def __init__(self, node_id, children):
        self.node_id    =   node_id
        self.parent     =   -1
        self.depth      =   0
        self.typ        =   "leaf"
        self.children   =   children

    def set_attr(self, parent, depth):
        self.parent =   parent
        self.depth  =   depth
        for child_id in self.children:
            self.typ = "internal node"
            tree[child_id].set_attr(self.node_id, self.depth + 1)
        if self.parent == -1:
            self.typ = "root"

n = int(input())
tree = [None for i in range(n)]
root = set(range(n))

for i in range(n):
    info = list(map(int, input().split()))
    tree[info[0]] = Node(info[0], info[2:])
    root -= set(info[2:])

root_id = root.pop()
tree[root_id].set_attr(-1, 0)

for node in tree:
    print("node {}: parent = {}, depth = {}, {}, {}".format(node.node_id, node.parent, node.depth, node.typ, node.children))

Measured memory_bytes: 52076
import java.util.Scanner;
import java.util.Arrays;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int a[] = new int[3];
a[0]=sc.nextInt();
a[1]=sc.nextInt();
a[2]=sc.nextInt();
Arrays.sort(a);
System.out.println(a[0]+a[1]);
 }
}

Measured memory_bytes: 23636
#include <iostream>
#include <limits.h>
using namespace std;

int main(void){
    long long n, x, a[100010], min = 1e9, minnum;
    cin >> n >> x;
    long long sum = 0;
    for (int i = 0; i < n; i++) { 
        cin >> a[i];
        sum += a[i];
        if (min > a[i]) { 
            min = a[i];  minnum = i;
        }
    }

    if (min >= x) { 
        cout << sum - x * ((n + 1) / 2);
        return 0;
    }

    int p = min, q = x - min;
    long long ans = 0;
    for (int i = minnum - 1; i >= 0; i--) {
        if (minnum % 2 == i % 2) {
            if (p < a[i]) ans += a[i] - p;
            else {
                p = a[i];  q = x - a[i];
            }
        }
        else{
            if (q < a[i]) ans += a[i] - q;
            else {
                q = a[i];  p = x - a[i];
            }
        }
    }
    p = min;  q = x - min;
    for (int i = minnum + 1; i < n; i++) {
        if (minnum % 2 == i % 2) {
            if (p < a[i]) ans += a[i] - p;
            else {
                p = a[i];  q = x - a[i];
            }
        }
        else{
            if (q < a[i]) ans += a[i] - q;
            else {
                q = a[i];  p = x - a[i];
            }
        }
    }
    
    cout << ans;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static double ReadDouble()
        {
            return double.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void A()
        {
            long N = ReadLong();
            Console.WriteLine(N * N * N);
        }

        static void B()
        {

        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void Main(string[] args)
        {
            A();
            //B();
            //C();
            //D();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
	#include <algorithm>
	#include <vector>
	using namespace std;

	int main() {
		int N;
		cin >> N;
		vector<int>p;
		vector < int>t;
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			p.push_back(a);
			if (a % 10 != 0) {
				t.push_back(a);
			}
		}
		int suma = 0;
		for (int i =0; i <N; i++) 
		{
			suma += p[i];
		}
		int minElement = *std::min_element(t.begin(), t.end());

		
		if (suma % 10 == 0 && !t.empty()) {
			suma -= minElement;
			cout << suma << endl;

		}
		else if (t.empty()) {
			cout << 0 << endl;
	
		}
		else cout << suma << endl;
		
		return 0;
	}	

Measured memory_bytes: 3616
n, m, q = [int(item) for item in input().split()]

lr = [[int(item) for item in input().split()] for _ in range(m)]
pq = [[int(item) for item in input().split()] for _ in range(q)]

field = [[0] * (n+1) for _ in range(n+1)]
cumsum = [[0] * (n+1) for _ in range(n+1)]

for item in lr:
  field[item[0]][item[1]] += 1
  
for i in range(1,n+1):
  for j in range(1,n+1):
    cumsum[i][j] = field[i][j] + cumsum[i][j-1]

for i in range(1,n+1):
  for j in range(1,n+1):
    cumsum[i][j] += cumsum[i-1][j]

for p, q in pq:
  print(cumsum[q][q] - cumsum[p-1][q] - cumsum[q][p-1] + cumsum[p-1][p-1])

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


int main() {
    int H, W;
    cin >> H >> W;

    int ai, A[H][W];
    rep(y, H) rep(x, W) cin >> ai, A[y][x] = ai % 2;

    vector<tuple<int, int, int, int>> vec;
    rep(y, H) {
        if (y%2==0) {
            for (int x=0; x<W; x++) {
                if (A[y][x] % 2 == 1) {
                    if ((x==W-1) && (y<H-1)) {
                        vec.push_back(make_tuple(y, x, y+1, x));
                        A[y+1][x]++;
                    } else if (x<W-1) {
                        vec.push_back(make_tuple(y, x, y, x+1));
                        A[y][x+1]++;
                    }   
                }
            }
        } else {
            for (int x=W-1; x>=0; x--) {
                if (A[y][x] % 2 == 1) {
                    if ((x==0) && (y<H-1)) {
                        vec.push_back(make_tuple(y, x, y+1, x));
                        A[y+1][x]++;
                    } else if (x>0) {
                        vec.push_back(make_tuple(y, x, y, x-1));
                        A[y][x-1]++;
                    }                    
                }
            }
        }
    }

    cout << vec.size() << endl;
    for (auto v: vec) {
        cout << get<0>(v)+1 << " " << get<1>(v)+1 << " ";
        cout << get<2>(v)+1 << " " << get<3>(v)+1;
        cout << endl;
    }

    return 0;
}

 

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

ll beki(ll x, ll n, const ll &p) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

void solve() {
    ll k;
    cin >> k;
    int rem = 0;
    rep(i, k + 1) {
        rem = (rem + beki(10, i, k) * 7) % k;
        if (rem == 0) {
            cout << i + 1 << endl;
            return;
        }
    }
    cout << -1 << endl;
    return;
}

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

Measured memory_bytes: 3628
import sys
import math
import numpy as np
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
A = l()
c = Counter(A)
n = len(list(c))
if n <= K:
    print(0)
else:
    v = list(c.values())
    v.sort()
    print(sum(v[:n-K]))

Measured memory_bytes: 52832
#include <stdio.h>
#define N 100
#define VSUM 100000

int main(void){
    int n,w;
    long long int sumv = 0;
    long long int res = 0;
    int wi[N+1], v[N+1];
    static long long int memo[N+1][VSUM+1];
    int i,j;
    long long int inf = 1LL<<60;
    
    for(i = 0; i < N+1; i++){
        memo[i][0] = 0;
        for(j = 1; j < VSUM+1; j++){
            memo[i][j] = inf;
        }
    }
    
    scanf("%d %d", &n, &w);
    
    for(i = 1; i <= n; i++){
        scanf("%d %d", &wi[i], &v[i]);
        sumv += v[i];
    }
    
    for(i = 1; i <= n; i++){
        for(j = 1; j <= sumv; j++){
            memo[i][j] = memo[i-1][j];
            if(j-v[i] >= 0){
                if(memo[i][j] >= memo[i-1][j-v[i]] + wi[i]){
                    memo[i][j] = memo[i-1][j-v[i]] + wi[i];
                }
            }
            //printf("%d %d %lld\n", i, j, memo[i][j]);
        }
    }
    
    for(i = 1; i <= sumv; i++){
        if(w >= memo[n][i]){
            res = (long long int)i;
        }
        //printf("%d %lld\n", i, memo[n][i]);
    }
    printf("%lld\n", res);
    
    return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    ll a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll minmove=min({a,b,c,d,e});
    cout<<(minmove+n-1)/minmove+4<<endl;
    return 0;
}

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

int main() {
	string s; cin >> s;
    int n = s.length();
  	int min = 753;
    for (int i = 0; i < n - 2; ++i) {
    	int m = (int)(s[i] - '0') * 100 + (int)(s[i+1] - '0') * 10 + (int)(s[i+2] - '0');  
		min = (abs(753 - m) < min) ? abs(753 - m) : min;
    }
  	cout << min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  string s;
  cin>>s;
  s[3] = '8';
  cout<<s<<endl;
  
}

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

constexpr int MAX = 110;
constexpr int INF = 1e9;

int N;
int G[MAX][MAX];
bool seen[MAX];
int par[MAX];
int d[MAX];

int main(){
  cin >> N;
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < N; j++ ){
      cin >> G[i][j];
      if( G[i][j] == -1 ) G[i][j] = INF;
    }
  }

  for( int i = 0; i < MAX; i++ ){
    par[i] = -1;
    d[i] = INF;
  }
  d[0] = 0;

  while( 1 ){
    int mincost = INF;
    int u;
    for( int i = 0; i < N; i++ ){
      if( d[i] < mincost && !seen[i] ){
	mincost = d[i];
	u = i;
      }
    }

    if( mincost == INF ) break;
    seen[u] = true;
    
    for( int i = 0; i < N; i++ ){
      if( G[u][i] != INF && !seen[i] ){
	if( G[u][i] < d[i] ){
	  d[i] = G[u][i];
	  par[i] = u;
	}
      }
    }
  }

  int ans = 0;
  for( int i = 1; i < N; i++ ){
    ans += G[par[i]][i];
  }

  cout << ans << endl;
}



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

int grid[101][101];

int main()
{
    int h, w, n, c, x = 0, y = 0;

    cin >> h >> w >> n;

    for (int i = 1; i <= n; ++i)
    {
        cin >> c;

        for (int j = 0; j < c; ++j)
        {
            grid[y][x] = i;

            if (y == 0 || y % 2 == 0)
                ++x;
            else
                --x;

            if (x < 0)
            {
                ++y;
                x = 0;
            }
            else if(x >= w)
            {
                ++y;
                x = w-1;
            }
        }
    }

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
            cout << grid[i][j] << ' ';
        cout << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll cnt = 0;

    if(N * 2 > M){
        cout << M / 2 << endl;
        return 0;
    }

    cnt += N;
    M -= 2 * N;

    cnt += M / 4;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! p {
    ($x:expr $(, $tail:expr)*) => {
        let mut s = String::new();
        s.push_str(format!("{:?}", $x).as_str());
        $(
            s.push_str(format!(", {:?}", $tail).as_str());
        )*
        println!("{}", s);
    };
}

#[allow(unused_macros)]
macro_rules! pl {
    ($($x:expr), *) => {
        $(println!("{:?}", $x);)*
    };
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    println!("{}", solve(stdin!()));
}

fn solve(src: String) -> String {
    input! {
        source = src,
        n: usize, m: usize, c: i32,
        b: [i32; m],
        a: [[i32; m]; n],
    }
    let mut ans = 0;
    for i in 0..n {
        let mut sum = 0;
        for j in 0..m {
            sum += a[i][j] * b[j];
        }
        sum += c;
        if sum > 0 {
            ans += 1;
        }
    }
    ans.to_string()
}

// Test Code

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input.to_string()), $output);
            )*
        }
    };
}

test! {
r"2 3 -10
1 2 3
3 2 1
1 2 2
" => "1",

r"5 2 -4
-2 5
100 41
100 40
-3 0
-6 -2
18 -13
" => "2",

r"3 3 0
100 -100 0
0 100 100
100 100 100
-100 100 100
" => "0",
}


Measured memory_bytes: 4352