akhauriyash/Code-Regression huggingface dataset:
N=int(input())
xl=[]
for _ in range(N):
    x,l=map(int,input().split())
    xl.append([x+l,2*l])
xl.sort()
r=-10**9
ans=0

for i in range(N):
    if xl[i][0]-xl[i][1]>=r:
        ans+=1
        r=xl[i][0]

print(ans)

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

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

ll ngcd(vector<ll> a)
{
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size() && res != 1; i++)
  {
    res = gcd(a[i], res);
  }
  return res;
}

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//実行部
void Main()
{
  ll n; cin >> n;
  vll a(n);
  rep(i, n)
  {
    cin >> a[i];
  }
  ll ans = 0;
  ll flag = *max_element(all(a));
  if (flag == 0)
  {
    fin(ans);
  }
  while(1)
  {
    ll F = 0;
    for(F = 0;F < n;F++)
    {
      if(a[F] != 0)
      break;
    }
    for(ll i = F;i < n;i++)
    {
      if(a[i] == 0)
      {
        break;
      }
      a[i]--;
    }
    ans++;
    ll flag = *max_element(all(a));
    if(flag == 0)
    {
      fin(ans);
    }
  }
}

//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

int a, b;

main() {
  while(1) {
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    vector< multiset<int> > V;
    for(int i = 1; i <= a; i++) {
      if(a % i != 0) continue;
      for(int j = 1; j <= b; j++) {
	if(b % j != 0) continue;
	multiset<int> s;
	s.insert(i);
	s.insert(a/i);
	s.insert(j);
	s.insert(b/j);
	V.push_back(s);
      }
    }
    int min = -1;
    for(vector< multiset<int> >::iterator it = V.begin();
	it != V.end(); it++) {
      int sum = 0;
      int tmp[4];
      int index = 0;
      for(multiset<int>::iterator itms = it->begin();
	  itms != it->end(); itms++) {
	tmp[index++] = *itms;
      }
      for(int i = 0; i+1 < 4; i++) {
	sum += (int)pow(double(tmp[i] - tmp[i+1]), 2.0);
      }
      if(min == -1 || sum < min) {
	min = sum;
      }
    }
    cout << min << endl;
  }
}

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




int main(){
    long long int n,x,t;
    cin>>n>>x>>t;
    long long int ans=(n/x)*t;
    ans+=((n%x>0)?1:0)*t;
    cout<<ans<<endl;
    
}


       
    
    
    

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

int A,B,C,N,M;

int main(){
  
  cin >> A >> B >> C;
  cin >> N;
  
  M = 1;
  for(int i = 0 ; i < N ;i++) M = M*2;
  
  if(A>=B && A>=C)cout << A*M+B+C <<endl;
  else if(B>=C && B>=C)cout << B*M+A+C <<endl;
  else if(C>=B && C>=A) cout << C*M+B+A <<endl;
  
  
}

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

typedef pair <int, int> ii;

const int Maxn = 100005;
const int Inf = 2000000007;

int n;
int a[Maxn];
vector <ii> res;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    int fir = a[1];
    int lst = a[n];
    for (int i = 2; i < n; i++)
        if (a[i] >= 0) {
            res.push_back(ii(fir, a[i]));
            fir -= a[i];
        } else {
            res.push_back(ii(lst, a[i]));
            lst -= a[i];
        }
    res.push_back(ii(lst, fir));
    lst -= fir;
    printf("%d\n", lst);
    for (int i = 0; i < res.size(); i++)
        printf("%d %d\n", res[i].first, res[i].second);
    return 0;
}


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

#define MAX_N 2000

#define sqrInf 999999999

using namespace std;

int n;
int rez;

int ap[MAX_N + 1];

int dp[MAX_N + 1][MAX_N + 1];
int cate[MAX_N + 1][MAX_N + 1][4];

struct elem
{
    char c;
    int nr;
};

elem v[(MAX_N << 1) + 1];

struct poza
{
    int i, nr;
    int cate;
};

poza w[MAX_N + 1];
poza b[MAX_N + 1];

int pozw[MAX_N + 1];
int pozb[MAX_N + 1];

struct cmp2
{
    bool operator () (const poza &a, const poza &b) const
    {
        return (a.nr < b.nr);
    }
};

inline int poz(int a)
{
    return (a > 0 ? a : -a);
}

void readFile()
{
    cin >> n;

    int i, j;
    int kw = 0;
    int kb = 0;
    for(i = 1; i <= (n << 1); i ++)
    {
        cin >> v[i].c >> v[i].nr;

        if(v[i].c == 'W')
        {
            w[++ kw] = {i, v[i].nr};
            pozw[v[i].nr] = i;
        }

        else
        {
            b[++ kb] = {i, v[i].nr};
            pozb[v[i].nr] = i;
        }
    }
}

void baga(int cr, int a[], int b[])
{
    int i, j;
    for(i = 1; i <= n; i ++)
    {
        for(j = 1; j <= n; j ++)
        {
            cate[i][j][cr] = cate[i][j - 1][cr];

            if(b[j] > a[i])
                cate[i][j][cr] ++;
        }
    }
}

void getPlaces()
{
    baga(0, pozb, pozw);
    baga(1, pozw, pozb);
    baga(2, pozb, pozb);
    baga(3, pozw, pozw);
}

void getDp()
{
    int i, j;
    for(i = 0; i <= n; i ++)
    {
        for(j = 0; j <= n; j ++)
            dp[i][j] = sqrInf;
    }

    dp[0][0] = 0;

  //  cout << w[2].i << " " << w[1].i << "\n";

  //  cout << cate[2][1][3] << "\n";

    for(i = 0; i <= n; i ++)
    {
        for(j = 0; j <= n; j ++)
        {
          //  cout << i << " " << j << " " << dp[i][j] << " COST J + 1 " << (pozw[j + 1] + cate[j + 1][i][1] + cate[j + 1][j][3] - (i + j + 1)) << " COST I + 1 "
          //  <<  (pozb[i + 1] + cate[i + 1][j][0] + cate[i + 1][i][2] - (i + j + 1)) << "\n";

          //  if(i == 0 && j == 1)
           //     cout << "POZ " << pozw[j + 1] << " B " << cate[j + 1][i][1] << " W " << cate[j + 1][j][3] << " LOC " << (i + j + 1) << "\n";

            if(j + 1 <= n)
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (pozw[j + 1] + cate[j + 1][i][1] + cate[j + 1][j][3] - (i + j + 1)));

            if(i + 1 <= n)
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (pozb[i + 1] + cate[i + 1][j][0] + cate[i + 1][i][2] - (i + j + 1)));
        }
    }
}

void printFile()
{
    cout << dp[n][n] << "\n";
}

void solve()
{
    getPlaces();

    getDp();
}

int main()
{
    readFile();

    solve();

    printFile();

    return 0;
}


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

using namespace std;


int main() {
    unsigned int w, h, n;
    cin >> w >> h >> n;
    int m[w][h]={};

    int x, y, a;
    while (n--) {
        cin >> x >> y >> a;
        for (int i = 0; i < w; ++i) {
            for (int j = 0; j < h; ++j) {
                if (a == 1 && i < x) m[i][j] = 1;
                if (a == 2 && i + 1 > x) m[i][j] = 1;
                if (a == 3 && j < y) m[i][j] = 1;
                if (a == 4 && j + 1 > y) m[i][j] = 1;
            }
        }

    }

    int ans = w * h;
    for (int i = 0; i < w; ++i) {
        for (int j = 0; j < h; ++j) {
            ans -= m[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n];
    int count;
    count=0;
    for (int i=0; i<n;i++){cin>>a[i];
    }
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n;j++){
            count+=a[i]*a[j];
    }
      
    
    
}
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int  l,r,d,i,count=0;
    scanf("%d %d %d",&l,&r,&d);
    for(i=l;i<=r;i++){
        if(i%d==0)count++;
    }
    printf("%d\n",count);
    return 0;
}


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

using namespace std;

int main()
{
    string a;
    cin >> a;
    set <char> s;

    for(int i = 0; i < a.size(); i++){
        s.insert(a[i]);
    }
    if(s.size() == 2){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          int const N = 3009;
          long long dp[N][N];
          long long a[N];
          long long fun(int i,int j)
          {
               if(i==j)
                    return a[i];
               else if(j == i+1)
                    return (a[i] > a[j] ? (a[i]- a[j]) : (a[j] - a[i]));
               else if(dp[i][j] != -1)
                    return dp[i][j];
               else
                    return dp[i][j] = max(a[i] + min(-a[i+1] + fun(i+2,j), -a[j] + fun(i+1,j-1)), 
                                   a[j] + min(-a[i] + fun(i+1,j-1), -a[j-1] + fun(i,j-2)));
          }
          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          int n;
          cin >> n;
          for(int i = 1; i <= n; i++)
               cin >> a[i];
          memset(dp, -1 ,sizeof(dp));
          cout << fun(1, n) << endl;




          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

Measured memory_bytes: 71168
import java.util.Scanner;

import java.util.*;

public class Main{
	static public void  main(String[] args){
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] x = new int[m];
		int[] d = new int[m-1];


		for(int i = 0; i < m; i++){
			x[i] = scan.nextInt();
		}
		Arrays.sort(x);
		for(int i = 1; i < m ; i++){
			d[i-1] = Math.abs(x[i] - x[i-1]);
		//	System.err.println(d[i-1]);
		}
		Arrays.sort(d);

		int sum = 0;
		for(int i = 0; i <= d.length - n ; i++){
			sum += d[i];
		}
		System.out.println(sum);

	}
}


Measured memory_bytes: 55412
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int n , k;
	cin >> n >> k;
	ll i, a[n];
	for(i = 0; i< n;i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	ll sum =0 ;
	for(i = 0 ; i < n-k;i++)
	{
		sum += a[i];
	}
	cout << sum <<"\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define int long long int
#define FILEIO  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
#define maxn 1000000
 

using namespace std;

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

signed main() {
//FILEIO;
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int n , k;
cin>>n>>k;
int arr[n];
for (int i = 0; i < n; ++i)
{
	/* code */
	cin>>arr[i];
}
sort(arr , arr + n);
int ans = 0;
for(int i = 0; i < k ; i++)
{
	ans += arr[i];
}
cout<<ans;










    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <cctype>
#include <numeric>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;

int main()
{
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  REP(i, N)
  {
    cin >> x[i];
  }
  if (N == 1)
  {
    cout << abs(x[0] - X) << endl;
    return 0;
  }
  x.push_back(X);
  sort(ALL(x));
  int res = abs(x[0] - x[1]);
  REP(i, N)
  {
    res = __gcd(abs(x[i] - x[i + 1]), res);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
a, b, c, k = map(int, input().split())

if(k <= a):
    print(k)
elif(k <= a+b):
    print(a)
else:
    if(a <= k-a-b):
        print(-1*(k-a-b-a))
    elif(a > k-a-b):
        print(a-(k-a-b))

Measured memory_bytes: 8932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n , m;
    cin >> n >> m;
    cout << (n*500 >= m ? "Yes\n" : "No\n");

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int dq,n,s,tot,q[N];
ll sum,ans;
int x[N],p[N];
signed main(){
	n=read(); s=read();
	for(int i=1;i<=n;i++){
		x[i]=read(); p[i]=read();
	}
	int l=1,r=n;
	int pos=lower_bound(&x[1],&x[n+1],s)-x;
	dq=0;
	if(pos==1){
		cout<<x[n]-s<<endl; return 0;
	}
	if(pos>n){
		cout<<s-x[1]<<endl; return 0;
	}
	if(p[1]<p[n]){dq=1; sum=p[1]; q[++tot]=x[1]; l++;}else {sum=p[n]; q[++tot]=x[n]; r--;}
	while(1){
		if(dq){
			if(r<pos)break;
			if(p[r]>sum){
				dq^=1; q[++tot]=x[r];
			}
			sum+=p[r];
			r--;
		}else{
			if(l>=pos)break;
			if(p[l]>=sum){
				dq^=1; q[++tot]=x[l];
			}
			sum+=p[l];
			l++;
		}
	}
	reverse(&q[1],&q[tot+1]);
	q[0]=s; for(int i=1;i<=tot;i++)ans+=abs(q[i]-q[i-1]);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<vector<ll> >g;
vector<ll>d;
ll n,m,ans=0;
void dfs(ll v)
{
    if (g[v].size()==0)
    {
        d[v]=1;
        return ;
    }
    for (int i=0;i<g[v].size();i++)
    {
    ll k=g[v][i];
    if (d[k]==0)
        dfs(k);
    d[v]=max(d[v],d[k]+1);
    }
}
main (){
    cin>>n>>m;
    g.resize(n+1);
    d.resize(n+1,0);
    for (int i=1;i<=m;i++)
    {
        ll a,b;
        cin>>a>>b;
        g[a].push_back(b);
    }
    for (int i=1;i<=n;i++)
        if (d[i]==0)
        dfs(i);
    for (int i=1;i<=n;i++)
        ans=max(ans,d[i]-1);
    cout<<ans;

return 0;}


Measured memory_bytes: 8576
n,x=map(int,input().split())
a=list(map(int,input().split()))
sum=[0]*(n)
ans=0
for i in range(0,n-1):
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        if a[i]>x:
            a[i+1]=0
        else:
            a[i+1]=x-a[i]
print(ans)

Measured memory_bytes: 85796
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	int x = int.Parse(s.Substring(0, 2));
	int y = int.Parse(s.Substring(2, 2));

	bool cx = (1 <= x) && (x <= 12);
	bool cy = (1 <= y) && (y <= 12);

	if (cx && cy)
	{
	    WriteLine("AMBIGUOUS");
	}
	else if (cx)
	{
	    WriteLine("MMYY");
	}
	else if (cy)
	{
	    WriteLine("YYMM");
	}
	else
	{
	    WriteLine("NA");
	}
    }
}


Measured memory_bytes: 11092
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 998244353
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
//#define base 1000000000000000000
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}

using namespace std;

const ull ba=233;
const db eps=1e-8;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=200000+10,maxn=200000+10,inf=0x3f3f3f3f;

ll a[N];
map<ll,ll>ma;
int main()
{
    int n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]),ma[a[i]]++;
    sort(a+1,a+1+n);
    for(int i=n;i>=1;i--)
    {
        ll now=1;
        while(now<=a[i])now<<=1;
        if(now==a[i]*2)
        {
            if(ma[a[i]]>=2)ans++,ma[a[i]]-=2;
        }
        else if(ma[now-a[i]]>=1&&ma[a[i]]>=1)ans++,ma[now-a[i]]--,ma[a[i]]--;
    }
    printf("%d\n",ans);
    return 0;
}
/********************

********************/


Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n;
    cin>>n;
    FOR(i,1,3501){
        FOR(j,1,3501){
            int a=n*i*j;
            int b=4*i*j-n*j-n*i;
            if(b==0)continue;
            if(a%b==0&&a/b>0){
                int k=a/b;
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

long long int n,ans,i,a[100010],m;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;ans=1;m=1e18;
	for (i=1;i<n+1;i++) cin>>a[i];
	for (i=1;i<n+1;i++) if (a[i]==0)
	{
		cout<<0;return 0;
	}
	for (i=1;i<n+1;i++)
	{
		if (m/a[i]<ans || (m/a[i]==ans && m%a[i]!=0))
		{
			cout<<-1;return 0;
		}
		ans=ans*a[i];
	}
	cout<<ans;
}


Measured memory_bytes: 4400
# 価値の低い2つから順に合成すればよい
import heapq

N = int(input())
v_l = list(map(int, input().split()))

while len(v_l) > 1:
    heapq.heapify(v_l)
    tmp1 = heapq.heappop(v_l)
    tmp2 = heapq.heappop(v_l)
    heapq.heappush(v_l, (tmp1+tmp2)/2)

print(v_l[0])

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e5+100;
int n,k;
int a[maxn];

int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%d%d",&n,&k)!=EOF)
    {
        int t;
        for (int i=1;i<=n;i++) scanf("%d",&t);
        int ans=1;
        n-=k;
        ans+=n/(k-1);
        if (n%(k-1)) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int h,w,n;
  cin >> h >> w >> n;
  int sr,sc;
  cin >> sr >> sc;
  string s,t;
  cin >> s >> t;
  int dl=0,dr=w+1,du=0,dd=h+1;
  for(int i=n-1;i>=0;--i) {
    if(t[i]=='L') dr=min(dr+1,w+1);
    if(t[i]=='R') dl=max(dl-1,0);
    if(t[i]=='U') dd=min(dd+1,h+1);
    if(t[i]=='D') du=max(du-1,0);
    if(s[i]=='L') ++dl;
    if(s[i]=='R') --dr;
    if(s[i]=='U') ++du;
    if(s[i]=='D') --dd;
    if(dr-dl < 2 || dd-du < 2) break;
  }
  bool flag = du < sr && sr < dd && dl < sc && sc < dr;
  cout << (flag?"YES":"NO") << endl;
}


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

int main(){
	ll a,b,x;
	cin>>a>>b>>x;
	long double A=a,B=b,X=x,pie=3.1415926535897932384626;
	long double num;
	if(a*a*b<=2*x){
		num=atan(2.0*(A*A*B-X)/(A*A*A));

	}else{
		num=atan(A*B*B/(2.0*X));
	}
	num*=180.0/pie;
	cout<<fixed<<setprecision(20)<<num;
	return 0;
}


Measured memory_bytes: 3848
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
a = 0
b = 0
n = iin()
x = [int(x) for x in input().split()]
x.sort(reverse=True)
for i in range(n):
    if i%2 :
        a = a + x[i]
    else:
        b = b + x[i]
print(b-a)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

vector<vector<ll>>g;
ll n;ll ans=0;
void dfs(ll v,vector<bool>&c){
    bool flg=true;
    for (int i = 0; i < n; ++i) {
        if(c[i]&&i!=v)flg=false;
    }
    if(flg){
        ans++;
        return;
    }
    c[v]=false;
    for(auto u:g[v]){
        if(!c[u])continue;
        dfs(u,c);
    }
    c[v]=true;
};

int main(){
    ll m;cin >>n>>m;
    g.assign(n,vector<ll>());
    for (int i = 0; i < m; ++i) {
        ll a,b;cin >>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<bool>c(n,true);
    dfs(0,c);
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans;
string s;
int32_t main(){
CODE_START;
cin>>s;
if(s[0]=='1'){
    ans++;
}
if(s[1]=='1'){
    ans++;
}
if(s[2]=='1'){
    ans++;
}
cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#define int long long
const int inf=1145141919;
const int mod=1000000007;
using namespace std;
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
signed main(){
	int i,j;
	string s;
	cin>>s;
	for(i=0;i+1<s.size();i++)
		if(s[i]=='A'&&s[i+1]=='C'){
			cout<<"Yes"<<endl;
			return 0;
		}
	cout<<"No"<<endl;
}

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

using namespace std;
#define         MAX         2*10000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)
#define         inf         10000000


double ans = 100.0;
double tmp;

int main(){

    //input;
    //output;

    long long x;
    cin>>x;

    int cnt = 1;
    while(ans<x){
        cnt++;
        tmp = floor(ans/100.0);
        ans += tmp;

    }

    cout<<cnt-1<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int int64;

typedef pair< int , int > Pi;
int dy[] = { 0, 1, 0, -1}, dx[] = { 1, 0, -1, 0};

Pi Find(const char& c){
  static const string mas[] = {"ABC","DEF","GHI"};
  for(int i = 0; i < 3; i++){
    if(mas[i].find(c) != string::npos){
      return make_pair( i, mas[i].find(c));
    }
  }
}

int main(){
  string s;
  for(int i = 0; i < 1000; i++){
    cin >> s;

    bool ok = true;
    Pi pos = Find(s[0]);
    for(int j = 1; j < s.size() && ok; j++){
      Pi nextpos = Find(s[j]);

      bool flag = false;
      for(int k = 0; k < 4; k++){
        if(Pi(pos.first + dy[k], pos.second + dx[k]) == nextpos){
          flag = true;
        }
      }
      ok &= flag;

      pos = nextpos;
    }

    if(ok) cout << s << endl;
  }
}

Measured memory_bytes: 1184
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
B = [0]
b = 0
for i in range(1,N+2):
    B.append(B[i-1]+abs(b-A[i]))
    b = A[i]
for i in range(1,N+1):
    x,y = B[i]-B[i-1],B[i+1]-B[i]
    z = abs(A[i+1]-A[i-1])
    print(B[N+1]-x-y+z)

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

int main() {
    int x,y,xx,yy;
    cin>>x>>y>>xx>>yy;
    int dx=xx-x;
    int dy=yy-y;
    for (int i=0;i<dx;i++)
        cout<<"R";
    for (int i=0;i<dy;i++)
        cout<<"U";
    for (int i=0;i<dx;i++)
        cout<<"L";
    for (int i=0;i<dy;i++)
        cout<<"D";
    cout<<"D";
    for (int i=0;i<dx+1;i++)
        cout<<"R";
    for (int i=0;i<dy+1;i++)
        cout<<"U";
    cout<<"L";
    cout<<"U";
    for (int i=0;i<dx+1;i++)
        cout<<"L";
    for (int i=0;i<dy+1;i++)
        cout<<"D";
    cout<<"R"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll k, n;
    cin >> k >> n;
    vi a(n + 1);
    REP(i, 0, n) {
        cin >> a[i];
    }
    a[n] = k + a[0];
    vi dist_list(n);
    REP(i, 0, n) {
        dist_list[i] = a[i + 1] - a[i];
    }
    cout << accumulate(begin(dist_list), end(dist_list), 0LL) - *max_element(begin(dist_list), end(dist_list)) << endl;
    return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 = 1e9;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableFromN[2505];
bool ok[2505];

void dfs(int v){
	if(reachableFrom1[v]) return;
	reachableFrom1[v] = true;
	for(int u : to[v]){
		dfs(u);
	}
}

void rdfs(int v){
	if(reachableFromN[v]) return;
	reachableFromN[v] = true;
	for(int u : rto[v]){
		rdfs(u);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, p;
	cin >> n >> m >> p;
	vector<tuple<int, int, int>> edges;
	rep(i,m){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		c -= p;
		c = -c;
		edges.emplace_back(a, b, c);
		to[a].push_back(b);
		rto[b].push_back(a);
	}
	dfs(0);
	rdfs(n-1);
	rep(i,n) ok[i] = reachableFrom1[i]&reachableFromN[i];
	vector<int> d(n, INF);
	d[0] = 0;
	bool upd = true;
	int step = 0;
	while(upd){
		upd = false;
		rep(i,m){
			int a, b, c;
			tie(a, b, c) = edges[i];
			if(!ok[a]) continue;
			if(!ok[b]) continue;
			int newD = d[a] + c;
			if(newD < d[b]){
				upd = true;
				d[b] = newD;
			}
		}
		step++;
		if(step > n){
			cout << -1 << endl;
			return 0;
		}
	}
	int ans = -d[n-1];
	chmax(ans, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            long[] a = cin.ReadLongArray(n);

            long[] x = new long[n];

            // x_0
            x[0] = a.Sum();
            for (int i = 1; i < n - 1; i += 2)
            {
                x[0] -= 2 * a[i];
            }

            // x_i
            for (int i = 1; i < n; i++)
            {
                x[i] = 2 * a[i - 1] - x[i - 1];
            }

            Console.WriteLine(String.Join(" ", x));
        }
    }

    class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 29020
#include <cstdio>
#include <deque>
#include <vector>
using namespace std;
int m, x, y, v[100005];
vector<int> g[100005];
deque<int> ans;

void f(int p, int q) {
	v[p] = 1;
	if(q==0) ans.push_front(p);
	else if(p!=1) ans.push_back(p);
	for(int i=0; i<g[p].size(); i++)
		if(!v[g[p][i]]) {f(g[p][i], q); return;}
}

int main() {
	scanf("%*d%d", &m);
	while(m--) {
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	f(1, 0);
	f(1, 1);
	printf("%d\n", ans.size());
	while(!ans.empty()) {
		printf("%d ", ans.back());
		ans.pop_back();
	}
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int INF = 1000;
int main(){
  cout << fixed << setprecision(5);
  while (1){
    int r, n;
    cin >> r >> n;
    if (r == 0 && n == 0){
      break;
    }
    vector<int> H(40, 0);
    for (int i = 0; i < n; i++){
      int xl, xr, h;
      cin >> xl >> xr >> h;
      xl += 20;
      xr += 20;
      for (int j = xl; j < xr; j++){
        H[j] = max(H[j], h);
      }
    }
    double ans = INF;
    for (int i = 20 - r; i < 20 + r; i++){
      ans = min(ans, H[i] + r - sqrt(pow(r, 2) - pow(min(abs(i - 20), abs(i - 19)), 2)));
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3288
<?php

list($N, $K) = explode(" ", trim(fgets(STDIN)));
$cans = explode(" ", trim(fgets(STDIN)));

$min = 999999999;
$target_offset = $K - 1;
for ($i = 0; $i < count($cans) - $K + 1; $i++) {

    $min = get_min($min, $cans, $i, $target_offset);
}

$cans_rev = array_reverse($cans);
for ($i = 0; $i < count($cans_rev) - $K + 1; $i++) {

    $min = get_min_rev($min, $cans_rev, $i, $target_offset);
}

print $min .PHP_EOL;

function get_min($min, $cans, $i, $target_offset)
{
    $offset = offset($cans, $i, $target_offset) + abs($cans[$i]);
    if($min > $offset)
    {
        $min = $offset;
    }
    return $min;
}

function get_min_rev($min, $cans, $i, $target_offset)
{
    $offset = offset_rev($cans, $i, $target_offset) + abs($cans[$i]);
    if($min > $offset)
    {
        $min = $offset;
    }
    return $min;
}

function offset($cans, $i, $target_end)
{
    if($cans[$i] < 0 && $cans[$i + $target_end] < 0)
    {
        return abs($cans[$i] - $cans[$i + $target_end]);
    }
    elseif ($cans[$i] < 0 && $cans[$i + $target_end] >= 0)
    {
        return abs($cans[$i]) + $cans[$i + $target_end];
    }
    else
    {
        return $cans[$i + $target_end] - $cans[$i]; 
    }
}

function offset_rev($cans, $i, $target_end)
{
    if($cans[$i] < 0 && $cans[$i + $target_end] < 0)
    {
        $value = abs($cans[$i] - $cans[$i + $target_end]);
    }
    elseif ($cans[$i] >= 0 && $cans[$i + $target_end] < 0)
    {
        $value =  $cans[$i] + abs($cans[$i + $target_end]);
    }
    else
    {
        $value =  $cans[$i] - $cans[$i + $target_end];
    }
    return $value;
}

Measured memory_bytes: 16884
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    long long N, K;
    cin >> N >> K;


    long long cnt = 0;
    while(N > 0){
        N /= K;
        cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3584
//AtCoder ABC086 C - Traveling
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
struct Pt{
    ll t=0;
    ll x=0,y=0;
};
int main() {
    ll N;
    cin>>N;
    vector<Pt> tbl(N+1); //0はスタート位置
    for(ll i=1;i<=N;++i){
        auto&& p=tbl[i];
        cin>>p.t>>p.x>>p.y;
    }
    bool ans=true;
    for(int i=0;i<tbl.size()-1;++i){
        //次にいけるか
        const auto& st = tbl[i];
        const auto& ed = tbl[i+1];
        ll dist=abs(ed.x-st.x)+abs(ed.y-st.y);
        ll dur=ed.t-st.t;
        if (dist>dur) {
            ans=false;
        } else if((dur-dist)%2!=0){
            ans=false;
        }
        if (!ans)break;
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cmath>
using namespace std;
int main(void)
{	
	double x[20],y[20],s,z,ss,l1,l2,l3;
	int i,j,n;
	n=0;
	while(scanf("%lf,%lf",&x[n],&y[n])!=EOF) n++;
	s=0.0;
	for(i=1;i<n-1;i++)	{
		l1=sqrt((x[0]-x[i])*(x[0]-x[i])+(y[0]-y[i])*(y[0]-y[i]));
		l2=sqrt((x[0]-x[i+1])*(x[0]-x[i+1])+(y[0]-y[i+1])*(y[0]-y[i+1]));
		l3=sqrt((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i]));
		z=(l1+l2+l3)/2.0;
		ss=sqrt(z*(z-l1)*(z-l2)*(z-l3));
		s+=ss;
	}
	printf("%lf\n",s);
	return 0;
}


Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,inf=1e9+10,mod=1e9+7;
int a[M];
pii cur[M];
main()
{
	int n,k;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>cur[i].F,cur[i].S=i;
	sort(cur+1,cur+n+1);
	int ans=0;
	for(int i=2;i<=n;i+=2)
	{
		if(cur[i].S%2!=0)ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 1792
N = int(input())
tlist = [int(input()) for _ in range(N)]
def _gcd(x, y):
    x = abs(x)
    y = abs(y)
    while y:
        x, y =  y, x % y
    return x
def _lcm(x, y):
    x = abs(x)
    y = abs(y)
    return x * y // _gcd(x, y)
ans = 1
for t in tlist:
    ans = _lcm(ans , t)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  string a;
  ci(a);
  ll b=a.size();
  ll d=0,e=0;
  For(i,0,b){
    if(a[i]=='0')
      d++;
    else
      e++;
  }
  co(2*min(d,e));
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            checked
            {
                string[] s;
#if true
                int N = int.Parse(Console.ReadLine());
#else
                s = Console.ReadLine().Split(' ');
                int N = int.Parse(s[0]);
                int K = int.Parse(s[1]);
#endif

                int[] v = new int[N];

#if true
                s = Console.ReadLine().Split(' ');
                for (int i = 0; i < N; i++)
                {
                    v[i] = int.Parse(s[i]);
                }
#else
                for (int i = 0; i < N; i++)
                {
                    v[i] = int.Parse(Console.ReadLine());
                }
#endif

                int[] c = new int[N];

                for (int i = 1; i < N; i++)
                {
                    if (i - 2 >= 0)
                    {
                        c[i] = Math.Min(c[i - 1] + Math.Abs(v[i] - v[i - 1]),
                                      c[i - 2] + Math.Abs(v[i] - v[i - 2]));
                    }
                    else
                    {
                        c[i] = c[i - 1] + Math.Abs(v[i] - v[i - 1]);
                    }
                }

                Console.WriteLine(c[N-1]);
            }
        }
    }
}


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

// Problem https://atcoder.jp/contests/abc081/tasks/arc086_a

int solver(int allBall,int kindNum,vector<int> ballNo){
    int result=0;
    vector<int> bukket(allBall+1);
    for(int j=0;j<allBall;j++){
        bukket.at(ballNo.at(j)) = bukket.at(ballNo.at(j))+1;
    }
    sort(bukket.begin(),bukket.end(),greater<int>());
    for(int j=0;j<kindNum;j++){ 
        result = bukket.at(j)+result;
     } 
    result = allBall - result;
    return result;
}


int main(void){
    int answer=0;
    int N,K;
    cin >> N >> K;
    vector<int> Ai(N);
    for(int j=0;j<N;j++){
        cin >> Ai.at(j);
    }
    answer = solver(N,K,Ai);
    cout << answer << endl;
}

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

using namespace std;

int main() {
  int n;
  string s, t;
  cin >> n;
  cin >> s >> t;
  string ans = "";
  for (int i = 0; i < s.size(); ++i) {
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
int find(int a){
     if(par[a]==a)return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);if(a==b)return ;
     parent[b]=a;
}*/
 
 
 
 
 
 
 


int main(){
    int n;
    cin>>n;
    string s;cin>>s;
    set<int> st[26];
    for(int i=0;i<s.length();i++){
         st[s[i]-'a'].insert(i+1);
    }
    int q;cin>>q;
    while(q--){
         int t;
         cin>>t;
         if(t==1){
              int index;char x;cin>>index>>x;
              auto it=st[s[index-1]-'a'].lower_bound(index);
              st[s[index-1]-'a'].erase(it);
              s[index-1]=x;
              st[x-'a'].insert(index);
         }
         else if(t==2){
              int l,r;
              cin>>l>>r;
              int ct=0;
              for(int i=0;i<26;i++){
                   auto it=*st[i].lower_bound(l);
                   if(it>=l&&it<=r)ct++;
                   
              }
              cout<<ct<<endl;
         }
    }

}

























Measured memory_bytes: 27256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

struct Mod {
    static constexpr auto kMod = 998244353L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kMod - 2);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const { return (n + m.n) % kMod; }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

main() {
    int64_t n;
    cin >> n;

    vector<int64_t> nums(n);
    for (auto i : irange(0L, n)) {
        int64_t d;
        cin >> d;
        ++nums[d];

        if (i == 0 && d != 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    if (nums[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    Mod ans = 1;
    for (auto i : irange(1L, n)) {
        ans *= Mod(nums[i - 1]).pow(nums[i]);
    }

    cout << ans.n << endl;
}

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

#define ll unsigned long long
#define inf 1e18
#define mod 1e9+7
#define w(x) int x; cin >> x; while(x--)
#define sp(x, y) fixed << setprecision(y) << x;
#define pb push_back


const int maxn = 1e6;
const ll mx = 1e18;

ll n;
void solve() {
    cin >> n;
    cout << (n * (n - 1)) / 2;
}

int main() {

    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
	ll n,t,i,j,x,k,y;
    cin>>n>>k>>x;
    
    if(k*x>=n) cout<<"Yes";
    else cout<<"No";
    
	return 0;
}

Measured memory_bytes: 3608
N = int(input())
A = list(map(int,input().split()))

left=0;right=0
SUM = 0
ans = 0
for left in range(N):
  while right < N and  SUM+A[right] == SUM^A[right]:
    SUM += A[right]
    right += 1
    #print(left,right,SUM)
  ans += right-left
  #print(ans)
  if right == left:
    right += 1
    #print(left,right,SUM)
  else:
    SUM -= A[left]
print(ans)

Measured memory_bytes: 24712
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int K, N;
    cin >> K >> N;

    vector<int> A(200010);
    A[0] = 0;
    int max = 0;
    int d;
    int tmp;
    for (int i = 1; i <= N + 1; i++)
    {
        if (i == N + 1)
        {
            d = K - A[N] + A[1];
        }else
        {
            cin >> A[i];
            d = A[i] - A[i - 1];
        }
        if (d > max) max = d;
    }

    cout << K - max << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

int x[4]={-1,0,0,1},y[4]={0,-1,1,0};
int main(){
    int a,b;
    string s[20];
    while(cin>>a>>b,a|b){
	P n,m;
	for(int c=0;c<a;c++){cin>>s[c];
	    for(int i=0;i<b;i++){
		if(s[c][i]=='A'){n=P(c,i);s[c][i]='.';}
		else if(s[c][i]=='B'){m=P(c,i);s[c][i]='.';}
		}
	    }
	string d;cin>>d;
	int mincost[20][20];
	memset(mincost,-1,sizeof(mincost));
	queue<P>Q;
	Q.push(n);
	mincost[n.first][n.second]=0;
	while(Q.size()){
	    P t=Q.front();Q.pop();
	    for(int i=0;i<4;i++){
		int dx=t.first+x[i],dy=t.second+y[i];
		if(dx>=0&&dx<a&&dy>=0&&dy<b&&mincost[dx][dy]==-1&&s[dx][dy]=='.'){
		    mincost[dx][dy]=mincost[t.first][t.second]+1;
		    Q.push(P(dx,dy));
		    }
		}
	    }
	    int X=m.first,Y=m.second;
	for(int i=0;i<1000;i++){
            if(mincost[X][Y]!=-1&&mincost[X][Y]<=i){cout<<i<<" "<<X<<" "<<Y<<endl;goto r;}
	    switch(d[i%d.length()]){
		case '2':X++;break;
		case '6':Y++;break;
		case '4':Y--;break;
		case '8':X--;break;
	    }
	    if(X==a)X=a-1;
	    if(X==-1)X=0;
	    if(Y==b)Y=b-1;
	    if(Y==-1)Y=0;
	     }
	     puts("impossible");
	     r:;
	    }
    }

Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int length, result, flag;
char S[100005], change[5];

int main()
{
    change[0] = '0';
    change[1] = '1';
    scanf("%s", S);
    length = strlen(S);
    int count = 0;
    for(int i = 0; i < length; i++)
    {
        if(S[i] != change[flag])
        {
            count++;
        }
        flag = !flag;
    }
    result = count;
    flag = 1;
    count = 0;
    for(int i = 0; i < length; i++)
    {
        if(S[i] != change[flag])
        {
            count++;
        }
        flag = !flag;
    }
    printf("%d", min(result, count));
}

Measured memory_bytes: 384
while True:
    try:
        s=str(input())
        JOI=0
        IOI=0
        for i in range(len(s)-2):
            if s[i]=="J" and s[i+1]=="O" and s[i+2]=="I":
                JOI+= 1
            elif s[i] =="I" and s[i+1]=="O" and s[i+2]=="I":
                IOI+= 1
        print(JOI)
        print(IOI)
    except:
        break


Measured memory_bytes: 5576