akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
#define data data1
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD1;

int pow26[100];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int n;
           cin>>n; 
           int len=1;
           int cur=26;
           pow26[0]=1;
           pow26[1]=26;
           while(cur<n)
           {
                 n-=cur;
                 cur*=26;
                 len++;
                 pow26[len]=cur;
           }

           string ans="";
           rep(i,1,len+1)
           {
                rep(j,0,26)
                {
                      if(pow26[len-i]<n)
                      {
                            n-=pow26[len-i];
                      }
                      else
                      {
                            ans+=(char)(j+'a');
                            break;
                      }
                }
           }
           cout<<ans<<endl;
      }      
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3652
import fractions

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a


def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


a, b, n = map(int, input().split(" "))
x = 0

#if a != b:
#    a,b = reduce(a,b)
    

#print(a,b)

if b <= n :
    x = b - 1
else:
    x = n


ans = (a*x)//b - a*(x//b)

#print(a,b,x)
print(ans)

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var A = int.Parse(ss[0]);
            var B = int.Parse(ss[1]);
            var C = int.Parse(ss[2]);

            if ((A <= C && C <= B) || (B <= C && C <= A))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //Aの倍数秒後にB毎生産
            //T+0.5秒後までに生産されるビスケット
            int N = int.Parse(Console.ReadLine());
            
            
            int[] value= Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] cost = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            //q[0]が最も大きくてq[1]が最も小さい
            for (int i = 0; i < value.Length; i++)
            {
                value[i] -= cost[i];
            }


            int cnt = value.Where(x => x > 0).Sum();
            Console.WriteLine(cnt);
        }

    }
}


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

using namespace std;

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

#define ll long long

int main()
{
	int N, T, c, t, ans = INT_MAX / 2 - 1;
	bool tle = true;
	cin >> N >> T;
	rep (i, N) {
		cin >> c >> t;
		if (t <= T) {
			ans = min(ans, c);
			tle = false;
		}
	}
	if (tle)
		cout << "TLE" << endl;
	else
		cout << ans << endl;
}



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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define DMAX 100100
#define NMAX 
#define MMAX 

using namespace std;

int n, k, x, pos[DMAX], use[DMAX], m, y, d, ok = 1;
string s;
vector <pair<int, int> > v[DMAX];


template<class T>
ostream& operator<<(ostream& out, vector<T> v)
{
	out << v.size() << '\n';
	for(auto e : v)
		out << e << ' ';
	return out;
}

void dfs(int node) {
	use[node] = 1;
	for(auto i : v[node]) {
		if(use[i.first]) {
			if(pos[i.first] != pos[node] + i.second)
			{
				// dbg(node);
				ok = 0;
			}
		}
		else {
			pos[i.first] = pos[node] + i.second;
			dfs(i.first);
		}
	}
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		cin >> x >> y >> d;
		v[x].push_back({y, d});
		v[y].push_back({x, -d});
	}

	pos[1] = 0;
	for(int i = 1; i <= n; i++)
		if(!use[i])
			pos[i] = 0, dfs(i);
	// dbg(ok);
	s = ok ? "Yes\n" : "No\n";
	cout << s;
/*
	int nr = 0;
	for(int i = 1; i <= n; i++)
		if(dg[i] == 0) 
			q.push(i), nr++;


	while(!q.empty()) {
		int node = q.top();
		q.pop();
		if()
		for(auto i : v[node]) {
			dg[i.first]--;
			if(pos[i.first] )
			if()
		}
	}
*/
} 

Measured memory_bytes: 11520
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
int iSP(Pt a, Pt b, Pt c) {
	int s = sig((b - a).det(c - a));
	if (s) return s;
	if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b
	if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c
	return 0;
}
int iLL(Pt a, Pt b, Pt c, Pt d) {
	if (sig((b - a).det(d - c))) return 1; // intersect
	if (sig((b - a).det(c - a))) return 0; // parallel
	return -1; // correspond
}
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}
Pt p[60];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			double x,y;scanf("%lf%lf",&x,&y);
			p[i]=Pt(x,y);
		}p[a]=p[0];
		vector<Pt>v;
		for(int i=0;i<a;i++)for(int j=i+1;j<a;j++)for(int k=0;k<a;k++)for(int l=k+1;l<a;l++){
			if(iLL(p[i],p[j],p[k],p[l])==1)v.push_back(pLL(p[i],p[j],p[k],p[l]));
		}
		int ret=0;
		for(int i=0;i<v.size();i++){
			bool ok=true;
			for(int j=0;j<a;j++){
				if(iSP(p[j],v[i],p[j+1])==1)ok=false;
			}
			if(ok)ret=1;
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 51932
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            Func<long, long, long> F = (x, y) => Math.Max(x.ToString().Length, y.ToString().Length);
            var answer = (long)1e18;
            for (var a = 1; a <= (long)Math.Sqrt(N); a++)
            {
                if (N % a != 0) continue;
                var b = N / a;
                answer = Math.Min(answer, F(a, b));
            }

            Console.WriteLine(answer);
        }
    }
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	bool case1 = (a == 7) && (b == 5) && (c == 5);
	bool case2 = (a == 5) && (b == 7) && (c == 5);
	bool case3 = (a == 5) && (b == 5) && (c == 7);
	if (case1 || case2 || case3) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k; cin >> n >> k;

    int h[n];
    rep(i, n){
        cin >> h[i];
    }

    int ans = 0;
    rep(i, n){
        if(h[i] >= k){
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int n, k;
vector<int> a;
ll memo[110][100100];

ll dp(int i, int j){
    if(j == 0) return 1;
    if(j < 0) return 0;
    if(i == -1) return 0;
    if(memo[i][j] != -1) return memo[i][j];

    ll res = 0;
    res += dp(i - 1, j) % MOD;
    res += dp(i, j - 1) % MOD;
    ll tmp = dp(i - 1, j - a[i] - 1) % MOD;
    res -= tmp;
    res %= MOD;
    if(res < 0) res += MOD;

    return memo[i][j] = res;
}

int main(void){
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= k; j++){
            memo[i][j] = -1;
        }
    }

    cout << dp(n - 1, k) << endl;
}

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);
//#define int long long

struct RollingHash2D{
  typedef unsigned long long ull;
 
  struct RollingHash{
	typedef unsigned long long ull;
	string S;
	ull B;
	int len;
	vector<ull> hash,p;
	RollingHash(){}
	RollingHash(string S_,ull B_=1000000007LL):
  	S(S_),B(B_),len(S.length()),hash(len+1),p(len+1){
  	hash[0]=0;p[0]=1;
  	for(int i=0;i<len;i++){
    	hash[i+1]=hash[i]*B+S[i];
    	p[i+1]=p[i]*B;
  	}
	}
	//S[l,r)
	ull find(int l,int r){
  	return hash[r]-hash[l]*p[r-l];
	}
  };
 
  vector<string> S;
  int h,w,r,c;
  ull B;
  vector<ull> p;
  vector<vector<ull> > hash;
  vector<RollingHash> rh;
  RollingHash2D(){}
  RollingHash2D(vector<string> S_,int r_,int c_,ull B_=1000000009LL):
	S(S_),h(S_.size()),w(S_[0].size()),r(r_),c(c_),B(B_),
	p(h+1),hash(h+1,vector<ull>(w-c+1,0)),rh(h){
	for(int i=0;i<h;i++) rh[i]=RollingHash(S[i]);
	p[0]=1;
	for(int i=0;i<h;i++) p[i+1]=p[i]*B;
	for(int j=0;j<w-c+1;j++){
  	hash[0][j]=0;   		 
  	for(int i=0;i<h;i++)
    	hash[i+1][j]=hash[i][j]*B+rh[i].find(j,j+c);
	}
  }
  //[i,i+r) * [j,j+c)
  ull find(int i,int j){
	return hash[i+r][j]-hash[i][j]*p[r];
  }
};


signed main(){
	int h,w;
	cin>>h>>w;
	vector<string> s;
	lp(i,h){
		string sh;
		cin>>sh;
		s.push_back(sh);
	}
	int r,c;
	cin>>r>>c;
	vector<string> t;
	lp(i,r){
		string sh;
		cin>>sh;
		t.push_back(sh);
	}
	RollingHash2D srh(s,r,c),trh(t,r,c);
	lp(i,h-r+1){
		lp(j,w-c+1){
			if(srh.find(i,j)==trh.find(0,0)){
				cout<<i<<" "<<j<<endl;
			}
		}
	}
    return 0;
}



Measured memory_bytes: 38404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int P = sc.nextInt();

		System.out.println((A * 3 + P) / 2);
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,z,w,a[2020];
int main()
{
	cin>>n>>z>>w;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(n==1)
	{
		cout<<abs(w-a[0]);
	}
	else
	{
		cout<<max(abs(w-a[n-1]),abs(a[n-1]-a[n-2]));
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int N,M,x;
    long a=0,b=0,c=0,d=0,e=0;
    long long ans;
    cin >> N ;
    vector<string>  blue(N);
    for(int i = 0; i < N; i++){
        cin >> blue[i];
        if(blue[i][0] == 'M'){
            a++;
        }
        else if(blue[i][0] == 'A'){
            b++;
        }
        else if(blue[i][0] == 'R'){
            c++;
        }
        else if(blue[i][0] == 'C'){
            d++;
        }
        else if(blue[i][0] == 'H'){
            e++;
        }
        }
        ans = a*b*c+a*b*d+a*b*e+b*c*d+b*c*e+c*d*e+a*c*d+a*c*e+b*d*e+a*d*e;
        cout << ans << endl;
    
 
    return 0;
}

Measured memory_bytes: 6144
import math


a, b, x = map(int, input().split())

if a * a * b < 2 * x:
    p1 = 2 * (a * a * b - x)
    p2 = a * a * a
else:
    p1 = a * b * b
    p2 = 2 * x

res = math.degrees(math.atan(p1 / p2))
print(res)


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

int main() {
    int x;
    cin >> x;
    int ans;
    for(int i=x;i<=100010;i++){
        int judge = 0;
        for(int j=2; j<i; j++){
            if(i%j == 0){
                judge = 1;
                break;
            }
        }
        if(judge == 0){
            ans = i;
            break;
        }
    }
    cout << ans ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N;
  cin>>N;
  vector<double> x(N);
  vector<string> u(N);
  rep(i,N)cin>>x[i]>>u[i];
  double ans=0;
  rep(i,N){
    if(u[i]=="JPY") ans += x[i];
    else ans += x[i]*380000.0;
  }
  cout<<setprecision(16)<<ans<<endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

const int max_n = 1e5 + 5;

int n;
vector<PII> v;
int usun[max_n];

lint rob() {
	FOR(i,0,n) usun[i] = 0;
	HEAP<PII> maxl;
	HEAP<PII> minp;
	FOR(i,0,n) maxl.push(mp(v[i].st, i));
	FOR(i,0,n) minp.push(mp(-v[i].nd, i));
	lint loc = 0;
	int pos = 0;
	if (-minp.top().st > 0) return 0;
	while (1) {
		if (minp.size() == 0) return loc + abs(pos);
		int kto = minp.top().nd;
		bool ok = true;
		while (usun[kto] == 1) {
			minp.pop();
			if (minp.size() > 0) {
				kto = minp.top().nd;
			} else {
				ok = false;
				break;
			}
		}
		if (!ok) return (loc + abs(pos));
		int newpos = -minp.top().st;
		if (newpos >= pos) return loc + abs(pos);
		loc += pos-newpos;
		pos = newpos;
		usun[kto] = 1;
		minp.pop();
		
		if (maxl.size() == 0) return loc + abs(pos);
		kto = maxl.top().nd;
		ok = true;
		while (usun[kto] == 1) {
			maxl.pop();
			if (maxl.size() > 0) {
				kto = maxl.top().nd;
			} else {
				ok = false;
				break;
			}
		}
		if (!ok) return (loc + abs(pos));
		newpos = maxl.top().st;
		if (newpos <= pos) return loc + abs(pos);
		loc += newpos-pos;
		pos = newpos;
		usun[kto] = 1;
		maxl.pop();
	}
}

int main() {
	read(n);
	FOR(I,0,n) {
		make2(a, b);
		v.pb(mp(a,b));
	}
	lint ans = rob();
	FOR(i,0,n) {
		v[i] = mp(-v[i].nd, -v[i].st);
	}
	ans = max(ans, rob());
	printf("%lld\n", ans);
}




Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
  long int A[100010], N, Q, a, b, c;
  for(int i = 0; i<100010; i++){
    A[i] = 0;
  }
  long int sum = 0;
  cin >> N;
  for(int i = 0; i<N; i++){
    cin >> a;
    A[a]++;
    sum += a;
  }
  cin >> Q;
  for(int j = 0; j<Q; j++){
    cin >> b >> c;
    sum += (c-b)*A[b];
    A[c] += A[b];
    A[b] = 0;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000, MAX_Q = 200000;
int N, Q;
int S[MAX_N], T[MAX_N], X[MAX_N];
int D[MAX_Q];

struct Event {
  int time, type, x;
};

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

  cin >> N >> Q;
  rep(i, N) cin >> S[i] >> T[i] >> X[i];
  rep(i, Q) cin >> D[i];

  vector<Event> events;

  rep(i, N) {
    events.push_back((Event){S[i]-X[i], 1, X[i]});
    events.push_back((Event){T[i]-X[i], -1, X[i]});
  }

  sort(all(events), [](const Event& e1, const Event& e2){
      if (e1.time != e2.time) {
        return e1.time < e2.time;
      } else {
        return e1.type < e2.type;
      }});


  sort(D, D+Q);
  set<int> st;
  int event_idx = 0;
  for (int i = 0; i < Q; ++i) {
    while (event_idx < len(events) && events[event_idx].time <= D[i]) {
      Event& e = events[event_idx++];
      if (e.type == 1) {
        st.insert(e.x);
      } else {
        st.erase(e.x);
      }
    }

    if (st.size() == 0) {
      cout << -1 << endl;
    } else {
      cout << *(st.begin()) << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 19052
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m,Q;
	cin >> n >> m >> Q;
	vector<int> l(m),r(m);
	vector<vector<int> > t(n+1);
	for(int i = 0; i < n+1; i++){
		t[i].resize(n+1);
	}
	for(int i = 0; i < m; i++){
		cin >> l[i] >> r[i];
		t[l[i]][r[i]]++;
	}

	vector<vector<int> > s(n+1);
	for(int i = 0; i < n+1; i++){
		s[i].resize(n+1);
		s[i].assign(s[i].size(),0);
		s[i][0] = t[i][0];
	}

	for(int i = 0; i < n+1; i++){
		for(int j = 1; j < n+1; j++){
			s[i][j] += t[i][j] + s[i][j-1];
		}
	}

	for(int i = 0; i < Q; i++){
		int p,q;
		cin >> p >> q;
		int res = 0;
		for(int i = p; i <=q; i++){
			res += s[i][q] - s[i][p-1];
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
using namespace std;
#define MOD 1000000007
int count(int n, int k){
    //0+1+...+k-1
    long long x0 = ((long long)k*(long long)(k-1))/2;
    //n-k+1 + ... + n-1 + n
    long long x1 = ((long long)(2*n-k+1)*(long long)(k))/2;
    //x0, x0+1, ..., x1
    long long num = x1 - x0 + 1;
    return num % MOD;
}
int main(void){
    int n,k;
    cin >> n >> k;
    long long sum=0;
    for(int ki=k;ki<=n+1;ki++){
        sum+=count(n,ki);
        sum=sum%MOD;
    }
    cout << sum << endl;    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif
    
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (i & 1) {
            if (s[i] == 'g')
                ans++;
        }   
        else {
            if (s[i] == 'p')
                ans--;
        }   
    }   
    cout << ans << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, W;
int w[110], v[110];
int dp[110][100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> W;
  REP(i,N) cin >> w[i] >> v[i];
  REP(i,N) REP(j,W+1) {
    chmax(dp[i+1][j], dp[i][j]);
    if (j+w[i]<=W) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
  }
  cout << dp[N][W] << endl;

  return 0;
}

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAX = 2e5 + 5;
int a[MAX];

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		cin >> a[1];
		ll xorr = a[1];
		for(int i = 2; i <= n; i++)
		{
			cin >> a[i];
			xorr ^= a[i];
		}
		for(int i = 1; i <= n; i++)
		{
			ll val = xorr;
			cout << (a[i] ^ val) << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4324
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=700;
  REP(i,3){
    if(s[i]=='o'){
      ans +=100;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> datafront(100000), databack(100000);
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (i % 2 == 0) datafront.at(a - 1)++;
    else databack.at(a - 1)++;
  }
  int flag = 0;
  if ((datafront.begin() - max_element(datafront.begin(), datafront.end())) == (databack.begin() - max_element(databack.begin(), databack.end()))) flag++;
  sort(datafront.begin(), datafront.end());
  sort(databack.begin(), databack.end());
  if (flag == 0) cout << N - datafront.at(100000 - 1) - databack.at(100000 - 1) << endl;
  else cout << min(N - datafront.at(100000 - 2) - databack.at(100000 - 1), N - datafront.at(100000 - 1) - databack.at(100000 - 2)) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
#define mod 1000000007
int main(){
    ll n, k, ans=0, x;
    cin >> n >> k;
    vector<ll> a, b;
    a.push_back(0);
    b.push_back(n);
    for (int i=1; i<=n; i++){
        a.push_back((i+a[i-1])%mod);
        b.push_back(((n-i)+b[i-1])%mod);
    }

    for (int i=0; i<=n; i++){
        //cout << a[i] << " " << b[i] << endl;
        if (i>=k-1){
            x = b[i]-a[i];
            ans=(ans+x+1)%mod;
            if (ans<0) ans+=mod;
        }
    }

    cout << ans;
    return 0;
}







Measured memory_bytes: 6524
#include<stdio.h>
#include<stdlib.h>

struct list{
  struct list *link;
  int value;
};

struct list *head;

void make(int n){
  int i;
  struct list *p[n], *prev = NULL;
  for(i = 0; i < n; i++){
    p[i] = malloc(sizeof(*p[i]));
    p[i]->value = n - i;
    p[i]->link = NULL;
    if(prev == NULL){
      prev = p[i];
      continue;
    }
    prev->link = p[i];
    prev = p[i];
  }
  head = p[0];
}

void traverse(void){
  struct list *node = head;
  while(node != NULL){
    printf("%d\n", node->value);
    node = node->link;
  }
}

void move_list(int p, int c){
  int i;
  struct list *next = head, *prev = head, *top;
  if(p == 1){
    return ;
  }
  for(i = 0; i < p - 1; i++){
    prev = next;
    next = next->link;
  }
  top = next;
  for(i = 0; i < c - 1; i++){
    next = next->link;
  }
  prev->link = next->link;
  next->link = head;
  head = top;
  
}

int main(void){
  int n, r, p, c, i;
  while(1){
    scanf("%d %d", &n, &r);
    if(n == 0 && r == 0){
      break;
    }

    make(n);

    for(i = 0; i < r; i++){
      scanf("%d %d", &p, &c);
      move_list(p, c);
    }

    printf("%d\n", head->value);
  }
  return 0;
}

Measured memory_bytes: 936
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
ll n, m, x = 0, y,z,w,h, sum= 1, ans = 0;
string s, t;
int main() {
	cin >> n >> s >> t;
	if (s[0] == t[0]) sum *= 3,x = 1,y = 0;
	else sum *= 6,x = 2,y=1;
	for (int i = x; i < n; i++) {
		if (s[i] == t[i] && y == 0) sum *= 2;
		else if (s[i] == t[i]) y = 0;
		else if (s[i] != t[i] && y == 0) sum *= 2, y = 1, i++;
		else sum *= 3, y = 1, i++;
		sum %= MOD;
	}cout << sum << endl;
}

Measured memory_bytes: 256
//ΔARC 084D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int N = 1e5+15;
int n,d[N];
vector<int> v[N];
void bfs0(int t){
	int i,s,x;
	s=v[t].size();
	for(i=0;i<s;i=i+1){
		x=v[t][i];
		if(!d[x*10%n]){
			d[x*10%n]=t;
			v[t].push_back(x*10%n);
			s++;
		}
	}
}
void bfs1(int t){
	int i,s,x;
	s=v[t].size();
	for(i=0;i<s;i=i+1){
		x=v[t][i];
		if(!d[(x+1)%n]){
			d[(x+1)%n]=t+1;
			v[t+1].push_back((x+1)%n);
		}
	}
}
int main()
{
	int i,t;
	scanf("%d",&n);
	d[1]=1;
	v[1].push_back(1);
	t=1;
	while(!d[0]){
		bfs0(t);
		bfs1(t);
		t++;
	}
	cout<<d[0]<<endl;
	return 0;
}

Measured memory_bytes: 3648
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import combinations as comb
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig
from statistics import mean

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    XY = input([[int, 2], N])
    ans = []
    for p in perm([x for x in range(N)]):
        last = p[0]
        temp = 0
        for xy in p[1:]:
            temp += ((XY[last][0] - XY[xy][0]) ** 2 +
                     (XY[last][1] - XY[xy][1]) ** 2) ** 0.5
            last = xy
        ans.append(temp)
    print(mean(ans))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 6708
#include <stdio.h>
#include <math.h>
int main(){
	int n, ans, sum;
	scanf("%d",&n);
	int x[n];
	for (int i = 0;i < n;i++){
		scanf("%d",&x[i]);
		sum += x[i];
	}
	double ave = round((double) sum/(double) n);
	for (int i = 0;i < n;i++){
		ans += pow((double)(x[i] - ave), 2.0);
		}
	printf("%d",ans);
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    int a[n];
    f1(i,0,n)
    cin>>a[i];
    int ans=mod;
    f1(i,1,n)
    {
    	int sum1=0,sum2=0;
    	f1(j,0,i)
    	{
    		sum1+=a[j];
    	}
    	f1(j,i,n)
    	{
    		sum2+=a[j];
    	}
    	ans=min(ans,abs(sum2-sum1));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
a,b,c,d=[int(i) for i in input()]
#ans=a
p=["+","+","+","+","-","-","-","-"]
q=["+","+","-","-","+","+","-","-"]
r=["+","-","+","-","+","-","+","-"]
for i,j,k in zip(p,q,r):
    ans=a
    if i=="+":
        ans+=b
    else:
        ans-=b
    if j=="+":
        ans+=c
    else:
        ans-=c
    if k=="+":
        ans+=d
    else:
        ans-=d
    if ans==7:
        print("{}{}{}{}{}{}{}=7".format(str(a),i,str(b),j,str(c),k,str(d)))
        break

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

int main(){
  int N;
  cin >> N;
  vector<int> T(N);
  int sum = 0;
  for(int i = 0; i < N;i++){
    cin >> T.at(i);
    sum += T.at(i);
  }
  int M;
  cin >> M;
  for(int i=0 ; i < M;i++){
    int p,x;
    cin >> p >>x;
    cout << sum - T.at(p-1) + x << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
int main(void)
{
	int n[100],num,i;
	scanf("%d",&num);
	for(i=0;i<num;i++)
		scanf("%d",&n[i]);
	for(i=0;i<num;i++){
		printf("%d",n[num-i-1]);
		if(num-i-1 !=0)
			printf(" ");
		else
			printf("\n");
	}
	return 0;
	
}


Measured memory_bytes: 600
using System;
class aoj
{
    static void Main()
    {
        for (;;)
        {
            string a = Console.ReadLine();
            char b = ' ';
            string[] c = a.Split(b);
            int d, e;
            d = int.Parse(c[0]);
            e = int.Parse(c[1]);
            if (d == 0 && e == 0) break;
            for (int i = 0; i < d; i++)
            {
                for (int j = 0; j < e; j++)
                {
                    if (0 < i && i < d - 1)
                    {
                        if (j == 0 || j == e - 1)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    else
                    {
                        Console.Write("#");
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8852
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll q;
multiset<ll> r;
multiset<ll> l;
ll sum=0;
int main(){
	cin>>q;
	REP(i,q){
		ll t;
		cin>>t;
		if(t==1){
			ll a,b;
			cin>>a>>b;
			sum+=b;
			/*if(r.size()!=0&&l.size()!=0){
				if(*(--r.end())<=a&&a<=*l.begin()){
				}else{
					sum+=(min(abs(*(--r.end())-a),abs(*l.begin()-a)));
				}
			}else if(r.size()!=0){
				sum+=abs(*(r.begin())-a);
			}*/
			 int precenter = a;
            if(r.size() != 0) precenter = *r.rbegin();
			if(r.size()==l.size()){
				if(*l.begin()>=a){
					r.insert(a);
				}else{
					l.insert(a);
					ll t=*l.begin();
					l.erase(l.begin());
					r.insert(t);
				}
			}else{
				if(*(--r.end())<=a){
					l.insert(a);
				}else{
					r.insert(a);
					auto itr=(--r.end());
					ll t=*(itr);
					r.erase(itr);
					l.insert(t);
				}
			}
			sum+= abs(a - *r.rbegin());
            if(r.size() == l.size()) sum+= precenter - *r.rbegin();
		}else{
			cout<<*(--r.end())<<" "<<sum<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int N;
vector<int> a;
vector<int> l;
vector<ll> ans;

void dps(int depth,int num,int A,int B,int C){
    if(N==depth){
        if(A!=0&&B!=0&&C!=0){
            //cout << depth << " " << A << " " << B << " " << C << endl;
            num += (abs(A-a[0])+abs(B-a[1])+abs(C-a[2]));
            /*if(A==98&&B==91&&C==80){
                cout << depth << " " << A << " " << B << " " << C << endl;
                cout << num << endl;
            }*/
            ans.pb(num);
        }
        return;
    }
    for(int i=0;i<4;i++){
        if(i==0){
            A+=l[depth];
            if(A-l[depth]!=0)num+=10;
            dps(depth+1,num,A,B,C);
            if(A-l[depth]!=0)num-=10;
            A-=l[depth];
        }
        if(i==1){
            B+=l[depth];
            if(B-l[depth]!=0){
                num+=10;
            }
            dps(depth+1,num,A,B,C);
            if(B-l[depth]!=0){
                num-=10;
            }
            B-=l[depth];
        }
        if(i==2){
            C+=l[depth];
            if(C-l[depth]!=0){
                num+=10;
            }
            dps(depth+1,num,A,B,C);
            if(C-l[depth]!=0){
                num-=10;
            }
            C-=l[depth];
        }
        if(i==3){
            dps(depth+1,num,A,B,C);
        }
    }
}

int main(){

    a = vector<int>(3);

    cin >> N >> a[0] >> a[1] >>a[2];
    l = vector<int>(N);

    for(int i=0;i<N;i++){
        cin >> l[i];
    }

    dps(0,0,0,0,0);

    /*for(int i=0;i<ans.size();i++){
        cout << ans[i] << " ";
    }
    cout << endl;*/

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

    cout << ans[0] << endl;

    return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.Arrays;

public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint a(N);
    REP(i,N){
        int t; cin>>t;
        a[t-1]++;
    }
    sort(ALL(a),greater<int>());

    int ans=0;
    REP(i,K)
        ans+=a[i];
    ans=N-ans;

    cout<<ans<<endl;

}


Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  if(n % k == 0) cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;

string A[800];
int dist[800][800];
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	int sx, sy;
	for (int i = 0; i < H; i++) {
		cin >> A[i];
		for (int j = 0; j < W; j++) {
			if (A[i][j] == 'S') sx = j, sy = i;
		}
	}
	memset(dist, -1, sizeof(dist));
	dist[sy][sx] = 0;
	queue<P> Q;
	Q.push(P(sx, sy));
	int ans = 1 << 30;
	while (!Q.empty()) {
		P p = Q.front(); Q.pop();
		int x = p.first, y = p.second;
		if (dist[y][x] > K) break;
		int d = min(x, W - 1 - x);
		d = min(d, y);
		d = min(d, H - 1 - y);
		ans = min(ans, 1 + (d + K - 1) / K);
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (0 > nx || nx >= W || 0 > ny || ny >= H || A[ny][nx] == '#' || dist[ny][nx] != -1) continue;
			dist[ny][nx] = dist[y][x] + 1;
			Q.push(P(nx, ny));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3584
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int[] cnt = new int[4];
         int N = int.Parse(ReadLine());
         for(int i = 0; i < N; i++){
             string s = ReadLine();
             if(s == "AC") cnt[0]++;
             else if(s == "WA") cnt[1]++;
             else if(s == "TLE") cnt[2]++;
             else if(s == "RE") cnt[3]++;
         } 
         WriteLine("AC x " + cnt[0]);
         WriteLine("WA x " + cnt[1]);
         WriteLine("TLE x " + cnt[2]);
         WriteLine("RE x " + cnt[3]);
      }
   }
}

Measured memory_bytes: 30716
N=int(input())
s=[input() for _ in range(N)]
abcount=0
righta=0
leftb=0
bothab=0
buf=""
for i in range(N):
    buf=s[i]
    l=len(buf)
    if (buf[0]=="B")and(buf[l-1]=="A"):
        bothab=bothab+1
    elif (buf[0]=="B"):
        leftb=leftb+1
    elif (buf[l-1]=="A"):
        righta=righta+1
    for j in range(l-1):
        if (buf[j]=="A")and(buf[j+1]=="B"):
            abcount=abcount+1
abcount=abcount+max(0,bothab-1)
#print(bothab,righta,leftb,abcount)
if (righta>0)and(bothab>0):
    abcount=abcount+1
    righta=righta-1
if (leftb>0)and(bothab>0):
    abcount=abcount+1
    leftb=leftb-1
abcount=abcount+min(righta,leftb)

'''
abcount=abcount+min(bothab,righta,leftb)*2


if min(bothab,righta,leftb)==bothab:
    leftb=leftb-bothab
    righta=righta-bothab
    abcount=abcount+min(leftb,righta)
elif min(bothab,righta,leftb)==righta:
    bothab=bothab-righta
    leftb=leftb-righta
    abcount=abcount+max(0,bothab-1)
    if leftb>0:
        abcount=abcount+1
else:
    bothab=bothab-leftb
    righta=righta-leftb
    abcount=abcount+max(0,bothab-1)
    if righta>0:
        abcount=abcount+1
'''
print(abcount)


Measured memory_bytes: 45368
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 昇順にソート済みのarrから、n以上の最小の要素を探索して返します。
# 存在しない場合は、Noneを返します。
def bin_gte(arr, n):
    l = 0
    r = len(arr) - 1
    c = (l+r)//2
    while l < r:
        c = (l+r)//2
        if arr[c] >= n:
            r = c
        else :
            l = c+1
    c = max(0, (l+r)//2)
    if arr[c] >= n:
        return (c, arr[c])
    else:
        return None


s = input()
t = input()
n = len(s)
m = len(t)
appears = [ [] for _ in range(26)]
for i,app in enumerate(appears):
    char = chr(ord('a') + i)
    base = 0
    while True:
        f = s.find(char, base)
        if f == -1:
            break
        app.append(f)
        base = f+1

cur = 0
loop = 0
for char in t:
    appear = appears[ord(char) - ord('a')]
    if len(appear) == 0:
        print('-1')
        exit()

    nex = bin_gte(appear, cur)

    if nex == None:
        loop += 1
        cur = appear[0]+1
    else:
        cur = nex[1]+1

print(loop * n + cur)

# print(appears)
# print(appears[ord('t') - ord('a')])

Measured memory_bytes: 46428
n,m = map(int,input().split())

arr = []

for i in range(n):
    a,b,c = map(int,input().split())
    arr.append([a,b,c])

def tobin(x, n):
    return format(x, 'b').zfill(n)

ans = 0
for i in range(8):
    temp = tobin(i,3)
    buf = [0 for i in range(n)]
    for i in range(3):
        for j in range(n):
            if temp[i] == "0":
                buf[j] += -arr[j][i]
            else:
                buf[j] += arr[j][i]
    buf.sort(key=lambda x:-x)
    temp = 0
    for i in range(m):
        temp += buf[i]
    if temp > ans:
        ans = temp
print(ans)






Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; ll C;
  cin >> N >> C;
  vector<ll> X(N+2), V(N+2);
  rep(i, N) cin >> X[i+1] >> V[i+1];
  X[N+1] = C;
  vector<ll> sumL(N+2), sumR(N+2);
  rep(i, N+1) sumL[i+1] = sumL[i]+V[i+1];
  rep(i, N+1) sumR[N-i] = sumR[N+1-i]+V[N-i];
  rep(i, N+2) sumL[i] -= X[i];
  rrep(i, N+2) sumR[i] -= C-X[i];
  ll ans = 0;
  {
    map<ll, set<int, greater<int>>> mp;
    multiset<ll, greater<ll>> se;
    rep(i, N+2) {
      se.insert(sumR[i]);
      mp[sumR[i]].insert(i);
    }
    rep(i, N+1) {
      se.erase(se.find(sumR[i]));
      ll maxR = *se.begin();
      ll cur = sumL[i] + maxR - min(X[i], C-X[*mp[maxR].begin()]);
      ans = max(ans, cur);
    }
  }
  {
    map<ll, set<int>> mp;
    multiset<ll, greater<ll>> se;
    rep(i, N+2) {
      se.insert(sumL[i]);
      mp[sumL[i]].insert(i);
    }
    for(int i=N+1; i>0; i--) {
      se.erase(se.find(sumL[i]));
      ll maxL = *se.begin();
      ll cur = sumR[i] + maxL - min(C-X[i], X[*mp[maxL].begin()]);
      ans = max(ans, cur);
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 25108
#include <iostream>
using namespace std;
int main() {
    char a,b;
    cin >> a >> b;
    string aa="",bb="";
    for (int i=0; i<(b-'0'); i++) aa += a;
    for (int i=0; i<(a-'0'); i++) bb += b;
    if (aa <= bb )
        cout << aa << endl;
    else
        cout << bb << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        if (N.charAt(N.length()-1) == 's') {
            System.out.println(N + "es");
        } else {
            System.out.println(N + "s");
        }
    }
}

Measured memory_bytes: 38444