akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2120
def LI(): return map(int,input().split())
def I() :return int(input())

n=I()
lst=list(LI())
for i in lst:
    if i %2==0:
        if i % 3==0 or i % 5==0:
            continue
        else:
            print("DENIED")
            break
else:print("APPROVED")

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int m,f,r;
    while(true){
        cin >> m >> f >> r;
        char result;
        if((m==-1||f==-1)||(m+f<30))result='F';
        else if(m+f>=80)result='A';
        else if(m+f>=65)result='B';
        else if(m+f>=50)result='C';
        else if(m+f<=50)r>=50 ? result= 'C' : result= 'D';
        if(m==-1&&f==-1&&r==-1)break;
        cout << result << endl;
    }return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  string S;
  cin >> S;
  int K;
  cin >> K;
  int N = S.length();
  long long dp[N][N][K + 1];
  for (int i = 0; i < N; i++)
    for (int k = 0; k <= K; k++) dp[i][i][k] = 1;
  for (int i = 0; i + 1 < N; i++)
    for (int k = 0; k <= K; k++)
      dp[i][i + 1][k] = S[i] == S[i + 1] || k > 0 ? 2 : 1;
  for (int d = 2; d < N; d++)
    for (int l = 0; l + d < N; l++) {
      int r = l + d;
      for (int k = 0; k <= K; k++) {
        dp[l][r][k] = max(dp[l + 1][r][k], dp[l][r - 1][k]);
        if (S[l] == S[r]) {
          dp[l][r][k] = max(dp[l][r][k], dp[l + 1][r - 1][k] + 2);
        } else if (k > 0) {
          dp[l][r][k] = max(dp[l][r][k], dp[l + 1][r - 1][k - 1] + 2);
        }
      }
    }
  cout << dp[0][N - 1][K] << '\n';
  return 0;
}


Measured memory_bytes: 110956
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

     if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n){
ll ans = 1 ;
for(ll i = 1 ; i <= n ; ++i)
    ans *= i ;
return ans ;
}
int main()
{
    FastInputOutput() ;
    ll x , t ;
    cin >> x >> t ;
    if(x == t || x < t)
        cout << 0 << endl;
    else
        cout << x - t << endl ;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}

ll INF = 1e+18;
int iINF = 1e9;
int MAXI = 1e8 + 1;
using vec = vector<int>;

int 
main()
{
  int N; cin >> N;
  vec arr(N + 1);
  repe(i, 1, N) cin >> arr[i];
  vec ball(N + 1, 0);
  int num = 0;

  for(int i = N; i >= 1; --i){
    int val = i;
    int cnt = 0;
    while(true){
      val += i;
      if(val > N) break;
      if(ball[val] == 1) ++cnt;
    }
    if(arr[i] != (cnt % 2)) ball[i] = 1, ++num;
  }
  cout << num << endl;
  rep(i, 1, N + 1){
    if(ball[i] == 1) cout << i << " ";
  }
}


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

uint64_t ans=0;
string s;

void dfs(int dep, uint64_t tmp, uint64_t sum){
  int t=s.at(dep) -'0';
  tmp+=t;
  if(dep==s.length()-1){
    ans += sum+tmp;
  }else{
    dfs(dep+1, tmp*10, sum);
    dfs(dep+1, 0, sum+tmp);
  }
}

int main() {
  cin >> s;
  dfs(0,0,0);
  cout <<ans <<endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
l = [[0,0]  for i in range(N*M+1)]
for e in A:
    if l[e][0] == 1:
        print(0)
        exit()
    l[e][0] += 1
for e in B:
    if l[e][1] == 1:
        print(0)
        exit()
    l[e][1] += 1
    
ans = 1
A = 0
B = 0
for x in range(N*M,0,-1):
    if l[x] == [1,1]:
        A += 1
        B += 1
    elif l[x] == [1,0]:
        A += 1
        ans *= B
    elif l[x] == [0,1]:
        B += 1
        ans *= A
    elif l[x] == [0,0]:
        ans *= A * B - (N*M - x)
    ans %= 10**9 + 7
print(ans)

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

int main()
{
    int  a,b;
    cin>>a>>b;
    double fa=a,fb=b;
    cout<<fixed;
    cout<<setprecision(5)<<(a/b)<<" "<<(a%b)<<" "<<(fa/fb);
    cout<<"\n";
        return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define fi first
#define sc second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#ifdef CURIOUSCAT
#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
#else
#define Pr(f,...) 
#endif

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50; 
const int oo=1e9+7;

int n,a[N],gd_c0,b[N],ans,c[N],c0,X,P,m,ind[N],oud[N],sz[N],bl[N],cc,cir[N];
vector<int> g[N],c1,c2;
void dfs(int v) {
	bl[v] = cc;
	++sz[cc]; 
	cir[cc] &= ind[v]==oud[v] && ind[v]==1; 
	for (int d : g[v]) if (!bl[d]) dfs(d);
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in","r",stdin); 
#endif
	read(n), read(m); 
	rep(i, 1, m) {
		read(a[i]), read(b[i]), read(c[i]); 
		g[a[i]].pb(b[i]), g[b[i]].pb(a[i]); 
		++ind[b[i]], ++oud[a[i]]; 
	}
	rep(i, 1, n) if (!bl[i]) {
		++cc; cir[cc] = 1; dfs(i); 
		if (cir[cc]&&sz[cc]>1) ++X; 
	}
	rep(i, 1, m) {
		int u = bl[a[i]];
		if (a[i] != b[i]) {
			++P; 
			c0 += c[i]-1; 
			gd_c0 |= c[i]>1&&(!cir[u]);
		} else {
			if (cir[u] && sz[u]==1){
				if (c[i]>=2) c2.pb(c[i]-2); 
			} else if (c[i]>1) c1.pb(c[i]-1); 	
		}
	}
	//ans=P+X+2Y+Z,st wc0+wc1+wc2>=x
	Pr("%d,%d,%d,%d,%d\n",P,X,c0,(int)c1.size(),(int)c2.size());
	if(X&&(!c1.size()&&!gd_c0)){
		cout<<-1<<endl;
		return 0;
	}
	if(c0>=X){
		cout<<P+X<<endl;
	}else{
		ans=oo;
		sort(all(c1),greater<int>()); 
		sort(all(c2)); 
		int p=0,cw=accumulate(all(c2),0)+c0;
		for(int i=0;i<=c1.size();++i){
			if(cw<X);
			else{
				while(p!=c2.size()&&cw-c2[p]>=X)cw-=c2[p],++p;
				if(gd_c0||i)cmin(ans,1*i+2*((int)c2.size()-p));
			}
			if(i<c1.size())cw+=c1[i];
		}
		cout<<(ans==oo?-1:P+X+ans)<<endl;
	}
	return 0; 
}



Measured memory_bytes: 12372
#include <bits/stdc++.h>
using namespace std;
bool com(char a,char b){
    return a<b;
}
int main()
{
    int a,b,c,i,n;
    cin>>n;
    char arr[100][100];
    for(i = 0;i < n;i++){
        scanf("%s",arr[i]);
    }
    b = 0x3f3f3f3f;
    c = 0;
    for(i = 0;i < n;i++)
	{
        a = strlen(arr[i]);
        if(a < b)
		{
            b = a;
            c = i;
        }
    }

    char dp[100];
    int j = 0,k=0,m;
    char s;
    for(i = 0;i < strlen(arr[c]);i++){
        for(a = 0;a < n;a++){
            for(b = 0;b < strlen(arr[a]);b++){
                if(arr[a][b]==arr[c][i]&&a!=c){
                    j++;
                    s = arr[a][b];
                    arr[a][b] = arr[a][0];
                    arr[a][0] = s;
                    break;
                }
            }
        }
        if(j==n-1){
            dp[k] = arr[c][i];
            k++;
            for(m = 0;m < n;m++){
                if(m!=c){
                    arr[m][0] = '0';
                }
            }
        }
        j = 0;
    }
    sort(dp,dp+k,com);
    for(i = 0;i < k;i++){
        cout<<dp[i];
    }
    if(strlen(dp)==0){
        cout<<"The answer is an empty string.";
    }
}


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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for(auto p : mp){
        if(p.second > p.first)ans += (p.second - p.first);
        else if(p.second < p.first)ans += p.second;
    }

    cout << ans << endl;

    return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N;
    cin >> N;

    vector<i64> a(N*3);
    rep(i,0,N*3) cin >> a[i];

    vector<i64> s(N*3,-inf64);
    i64 p=0;
    priority_queue<i64,vector<i64>,greater<i64>> top;
    rep(i,0,N*3){
        top.push(a[i]);
        p+=a[i];
        if(top.size()>N){
            p-=top.top();
            top.pop();
        }
        if(top.size()==N) s[i]=p;
    }

    vector<i64> t(N*3,inf64);
    i64 q=0;
    priority_queue<i64,vector<i64>> bottom;
    for(int i=N*3-1; i>=0; --i){
        bottom.push(a[i]);
        q+=a[i];
        if(bottom.size()>N){
            q-=bottom.top();
            bottom.pop();
        }
        if(bottom.size()==N) t[i]=q;
    }

    i64 ans=-inf64;
    rep(i,0,N*3-1) ans=max(ans,s[i]-t[i+1]);

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 9588
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
inline T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
inline T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}

int main()
{
	long long int n, k; cin >> n >> k;
	vector<long long int> h(n, 0);

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

	sort(h.begin(), h.end());
	long long int ans = numeric_limits<int>::max();
	for (auto iter = h.begin(); iter != (h.end()-k+1);++iter)
	{
		ans = ans > * (iter + k-1) - *iter ? *(iter + k-1) - *iter : ans;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>

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

using namespace std;

int n;
string s;
int c[26][50];

int main(){
  cin >> n;
  rep(i, n){
    cin >> s;
    rep(j, s.size()){
      ++c[s[j] - 'a'][i];
    }
  }
  rep(i, 26){
    int p = *min_element(c[i], c[i] + n);
    rep(j, p){
      cout << char('a' + i);
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

import bisect

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

time = []
minValue = 10
minIndex = -1
for i in range(5):
	x = readInt()
	time.append(x)
	if int(str(x)[-1])<minValue and int(str(x)[-1]) != 0:
		minValue = int(str(x)[-1])
		minIndex = i

ans = 0

for i in time:
	tar = i-1
	if tar<11:
		x = 10
	else:
		x = int(str(int(str(tar)[:-1])+1)+"0")
	ans+=x

tyo = 10-int(str(time[minIndex])[-1])
if tyo==10:
	tyo=0

print(ans-tyo)

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
 #define LOOP 10000000

int main() {

  int H, W, X;
  int masu[110][110] = {0};
  int tmp, ans;

  cin >> H >> W >> X;

  tmp = max(H, W);

  ans = X / tmp;
  if(X % tmp != 0)ans++;

  cout << ans << endl;






  
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
#define fi first
#define se second
#define debug if(DEBUG)
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using pi = pair<ll,ll>;
 
template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}
 
template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}
 
template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}
 
bool DEBUG=true;

// Code from here ! ==================================================================

int main(void){
  ll N; cin >> N;
  vector<ll> P(N), pos(N);
  rep(i,N){
    cin >> P[i];
    P[i]--;
    pos[P[i]] = i;
  }
 
  ll sub = 1, ans = 0;
  rep(i,N-1){
    if (pos[i] < pos[i+1]){
      sub++;
    }
    else{
      ans = max(ans, sub);
      sub = 1;
    }
  }
 
  ans = max(ans, sub);
  cout<<N-ans<<endl;
}
















Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;
using u64 = uint64_t;

int main() {
	string N;
	cin >> N;
	
	vector<vector<u32>> dp(N.size() + 1, vector<u32>(3));
	
	dp[0][0] = stoi(N.substr(0, 1));
	dp[0][1] = 10 - stoi(N.substr(0, 1));
	
	for(u32 i=1; i<N.size(); i++) {
		u32 sp = stoi(N.substr(i, 1));
		
		// seisan
		dp[i][0] = sp + min(dp[i-1][0], dp[i-1][1] + 1);

		// kurikosi
		dp[i][1] = min(10 - sp + dp[i-1][0], dp[i-1][1] + 9 - sp);
	}
	
	dp[N.size()][0] = min(dp[N.size()-1][0], dp[N.size()-1][1] + 1);
	cout << dp[N.size()][0];
	
	return 0;
}

Measured memory_bytes: 55940
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
int n,k,cnt=-1;
int p[500010],mx[2000010],pos[500010],ans[500010];
vector<int>edge[500010];
void modify(int x,int l,int r,int pos,int v)
{
    if(l==r)
    {
        mx[x]=v;
        return;
    }
    int mid=(l+r)>>1;
    if(pos<=mid)
        modify(x<<1,l,mid,pos,v);
    else modify(x<<1|1,mid+1,r,pos,v);
    mx[x]=max(mx[x<<1],mx[x<<1|1]);
}
int query(int x,int l,int r,int a,int b)
{
    if(a<=l&&r<=b)
        return mx[x];
    int mid=(l+r)>>1,res=0;
    if(a<=mid)
        res=max(res,query(x<<1,l,mid,a,b));
    if(b>mid)
        res=max(res,query(x<<1|1,mid+1,r,a,b));
    return res;
}
void dfs(int x)
{
    ans[++cnt]=x;
    sort(edge[x].begin(),edge[x].end());
    for(int i=0; i<(int)edge[x].size(); i++)
        dfs(edge[x][i]);
}
inline int read()
{
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9')
        ch=getchar();
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x;
}
int main()
{
    n=read(),k=read();
    for(int i=1; i<=n; i++)
    {
        p[i]=read();
        pos[p[i]]=i;
    }
    pos[n+1]=n+1;
    for(int i=1; i<=n; i++)
    {
        int id=query(1,1,n,pos[i]+1,pos[i]+k-1);
        if(!id)
            id=n+1;
        edge[pos[id]].push_back(pos[i]);
        modify(1,1,n,pos[i],i);
    }
    dfs(n+1);
    for(int i=1; i<=n; i++)
        p[ans[i]]=i;
    for(int i=1; i<=n; i++)
        printf("%d\n",p[i]);
    return 0;
}


Measured memory_bytes: 65920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] a = new String[n];
		String[] b = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		b = a.clone();

		bubbleSort(a);
		selectionSort(b);
		System.out.print(printString(a));
		System.out.println("Stable");
		System.out.print(printString(b));
		if (printString(a).equals(printString(b))) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}

	}
	static String printString(String[] a) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			if (i != a.length-1) {
				sb.append(" ");
			}
		}
		sb.append("\n");
		return sb.toString();
	}
	static void bubbleSort(String[] a) {
		int n = a.length;
		for (int i = n-1; i >= 0; i--) {
			for (int j = n-1; j > 0; j--) {
				String tmp = a[j];
				if (Integer.parseInt(a[j].substring(1, 2)) < Integer.parseInt(a[j-1].substring(1, 2))) {
					a[j] = a[j-1];
					a[j-1] = tmp;
				}
			}
		}
	}
	static void selectionSort(String[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int min = Integer.MAX_VALUE;
			int minj = 0;
			for (int j = i+1; j < n; j++) {
				if (min > Integer.parseInt(a[j].substring(1, 2))) {
					min = Integer.parseInt(a[j].substring(1, 2));
					minj = j;
				}
			}
			if (Integer.parseInt(a[i].substring(1, 2)) > min) {
				String tmp = a[i];
				a[i] = a[minj];
				a[minj] = tmp;
			}
		}
	}

}



Measured memory_bytes: 26584
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;
 
void solve(){
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	if(n<=k){
		cout << s;
	}
	else{
		string t = s.substr(0, k);
		t += "...";
		cout << t;
	}
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}

Measured memory_bytes: 3644
N,K = map(int,input().split())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
C = sorted(list(C.items()),key=lambda x:x[1],reverse=True)
if len(C)<=K:
    print(0)
else:
    cnt = 0
    for i in range(K,len(C)):
        cnt += C[i][1]
    print(cnt)

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vector<vector<char>> table(H,vector<char>(W));

    vector<bool> hflag(H,true);
    vector<bool> wflag(W,true);
    REP(i,H){
        REP(j,W){
            cin >> table[i][j];
            if(table[i][j]=='#'){
                hflag[i] = false;
                wflag[j] = false;
            }
        }
    }

    REP(i,H){
        if(hflag[i]==true) continue;
        REP(j,W){
            if(wflag[j]==true) continue;
            cout << table[i][j];
        }
        if(i < H-1)cout << endl;
    }


    }

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int A[200000];

int main()
{
    int N, M, i, A, total;

    scanf("%d%d", &N, &M);
    total = 0;
    for(i = 0; i < M; ++i){
        scanf("%d", &A);
        total += A;
    }
    if(total > N)
        printf("-1");
    else
        printf("%d", N - total);

    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long long> d(N);
    vector<pair<int, int>> t;
    map<long long, int> a;
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
        a[d[i]] = i;
    }

    vector<int> weigtht(N, 1);
    for (int it = 0; it < N - 1; it++)
    {
        auto target = a.rbegin();
        int i = target->second;
        long long dis = d[i];
        long long next = dis - (N - weigtht[i]) + weigtht[i];
        if (a.find(next) == a.end() || a[next] == i)
        {
            cout << "-1" << endl;
            return 0;
        }
        int j = a[next];
        weigtht[j] += weigtht[i];
        t.push_back({i, j});
        a.erase(--a.end());
    }

    vector<vector<int>> g(N);
    for (int i = 0; i < N - 1; i++)
    {
        g[t[i].first].push_back(t[i].second);
        g[t[i].second].push_back(t[i].first);
    }
    vector<int> valid(N, -1);
    valid[0] = 0;
    vector<int> que(1, 0);
    for (int i = 0; i < (int)que.size(); i++)
    {
        for (int &j : g[que[i]])
        {
            if (valid[j] == -1)
            {
                que.push_back(j);
                valid[j] = valid[que[i]] + 1;
            }
        }
    }

    long long int node_0_d = 0;
    for (int i = 0; i < N; i++)
    {
        if (valid[i] != -1)
        {
            node_0_d += valid[i];
        }
    }

    if ( node_0_d != d[0] )
    {
        cout << "-1" << endl;
        return 0;
    }

    for (int i = 0; i < N - 1; i++)
    {
        cout << t[i].first + 1 << " " << t[i].second + 1 << endl;
    }
    return 0;
}

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

int main() {

  long K;
  cin>>K;
  long ans=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
        long tmp=gcd(i,j);
        tmp= gcd(tmp,k);
        ans+= tmp;
      }
    }
  }

cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string T;cin>>T;
	int N = T.length();
	FOR(i,0,N-1){
		if (T[i] == '?') T[i] = 'D';
	}
	cout<<T;
}


Measured memory_bytes: 3700
#                           जय श्री राम

import sys; import math; from collections import *
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().split())
def get_list(): return list(get_ints())
def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9+7); SEXYMOD = 998244353; MAXN = int(1e5)

#sys.stdin  = open("input.txt","r"); sys.stdout = open("output.txt","w")

# for _testcases_ in range(int(input())):
n, k = get_ints()
li = get_list()
print(sum(sorted(li)[:k]))


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 67252
from math import log2
from math import ceil
N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
    if i >= K:
        ans += 1 / N
    else:
        n = ceil(log2(K / i))
        ans += 1 / N * pow(1 / 2, n)
print(ans)

Measured memory_bytes: 3060
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::collections::BTreeSet;

fn main() {
    input!(h: i64, w: i64, n: usize, ab: [(i64, i64); n]);
    let mut count: Vec<i64> = vec![0; 10];
    let set = ab.iter().map(|&(a, b)| (a, b)).collect::<BTreeSet<_>>();
    let mut candidates = BTreeSet::new();
    for &(a, b) in ab.iter() {
        for da in (-1)..2 {
            for db in (-1)..2 {
                let a = a + da;
                let b = b + db;
                if a <= 1 || b <= 1 || a >= h || b >= w {
                    continue;
                }
                candidates.insert((a, b));
            }
        }
    }

    for &(a, b) in candidates.iter() {
        let mut c = 0;
        for da in (-1)..2 {
            for db in (-1)..2 {
                let a = a + da;
                let b = b + db;
                if set.contains(&(a, b)) {
                    c += 1;
                }
            }
        }
        count[c] += 1;
    }

    let sum = count.iter().sum::<i64>();
    count[0] = (h - 2) * (w - 2) - sum;
    for &count in count.iter() {
        println!("{}", count);
    }
}


Measured memory_bytes: 39164
#include <stdio.h>
int main(void){
    int N,K,Q,tmp;
    scanf("%d%d%d",&N,&K,&Q);
    int a[N];
    for(int i=0;i<N;i++)a[i]=0;
    for(int i=0;i<Q;i++){
        scanf("%d",&tmp);
        a[tmp-1]++;
    }
    for(int i=0;i<N;i++){
        if(K>(Q-a[i]))printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(void)
{
	int n, i,  b, c, d; 
	int num[4][13] = {};
	char a;	

	scanf("%d" ,&n);
	for(i=0;i<n;i++){
		scanf("%s %d", &a ,&b);
		if(a == 'S'){
			num[0][b-1] = 1;
		}
		else if(a == 'H'){
			num[1][b-1] = 1;
		}
		else if(a == 'C'){
			num[2][b-1] = 1;
		}
		else if(a == 'D'){
			num[3][b-1] = 1;
		}
	}

	for(c=0;c<4;c++){
		for(d=0;d<13;d++){
			if(num[c][d] != 1){
				if(c == 0){
					printf("S %d\n", d+1);
				}
				else if(c == 1){
					printf("H %d\n", d+1);
				}
				else if(c == 2){
					printf("C %d\n", d+1);
				}
				else if(c == 3){
					printf("D %d\n", d+1);
				}
			}
		}
	}
	

	return 0;
}
				 

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(void){
    int a,b; cin>>a>>b;
    cout<<(a+b)%24<<endl;
}


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

#define int long long

const int INF = (int) 1e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
    sum += v[i];
  }
  vector< vector<int> > dp(N + 1, vector<int>(sum + 1, INF));
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= sum; j++) {
      if (j == 0) {
        dp[i][j] = 0;
      } else if (i > 0 && j >= v[i - 1]) {
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
      } else if (i > 0) {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }
  int ans = -INF;
  for (int i = 0; i <= sum; i++) {
    if (dp[N][i] <= W) {
      ans = i;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <functional>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;
#define MAX 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)

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

	int n, a, b;
	cin >> n >> a >> b;
	string s; cin >> s;
	int sum = 0;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a') {
			if (sum < a + b) {
				cout << "Yes" << endl;
				sum++;
			}
			else cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			if (sum < a + b && cnt<b) {
				cout << "Yes" << endl;
				sum++;
				cnt++;
			}
			else cout << "No" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
int a[1010];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    printf("%d\n",a[n-1]-a[0]);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[10009], sum;
int main(){
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        while( a[i]%2 == 0){
            a[i] /= 2;
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

ll dp[1000005][2];

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

    string s;
    cin >> s;
    int n = s.length();
    reverse(s.begin(), s.end());
    dp[0][1] = 1;
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';
        if(num == 9){
            dp[i + 1][0] = dp[i][0] + num;
            dp[i + 1][1] = min(dp[i][0] + 1, dp[i][1]);
        }
        else{
            dp[i + 1][0] = min(dp[i][0] + num, dp[i][1] + num + 1);
            dp[i + 1][1] = min(dp[i][0] + 10 - num, dp[i][1] + 9 - num);
        }
    }
    cout << min(dp[n][0], dp[n][1] + 1) << endl;
}

Measured memory_bytes: 17052
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())
import sys
sys.setrecursionlimit(10**6)

n,k,c=sep()
s=input()
c1=[0]*(n+5)
c2=[0]*(n+5)
for i in range(n):
    if s[i]=="x":
        c1[i]=c1[i-1]
    else:
        c1[i]=max(c1[i-1],c1[i-c-1]+1)
for i in range(n-1,-1,-1):
    if s[i]=="x":
        c2[i]=c2[i+1]
    else:
        c2[i]=max(c2[i+1],c2[(i+c+1)%n]+1)
ans=[]
if c2[1]==k-1 and s[0]=="o":
    ans.append(1)

for i in range(1,n-1):
    if s[i]=="x":
        continue
    if c1[i-1] + c2[i+1]==k-1:
        ans.append(i+1)

if n!=1:
    if c1[n-2]==k-1 and s[0]=="o":
        ans.append(n)

for i in ans:
    print(i)




Measured memory_bytes: 85364
#include <stdio.h>

int main(){
	int loop_i,loop_j;
	for(loop_i = 1;loop_i < 10;loop_i++){
		for(loop_j = 1;loop_j < 10;loop_j++){
			printf("%dx%d=%d\n",loop_i,loop_j,loop_i*loop_j);
		}
	}

	return 0;
}

Measured memory_bytes: 924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c,k,cnt=0,m,cc=0;
  cin>>n>>c>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  m=a[0]+k;
  cc++;
  for(int i=1;i<n;i++){
    if(a[i]<=m&&cc<c){
      cc++;
    }else{
      cnt++;
      cc=1;
      m=a[i]+k;
    }
  }
  cout<<cnt+1<<endl;
}

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

int main()
{

   int a;

   cin >> a;
   
   if (a%1000 == 0)
   cout << a % 1000 ;
   
   else 
   {
      cout << 1000 - a % 1000;
   }


    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#define N 10000

int main(void){
  int i,num,j;
  int l,m,n;
  int ans[N],ansflag;

  for(i=0;;i++){
    scanf("%d",&l);
    if(l==0)
      break;
    ansflag=0;
    for(j=0;j<12;j++){
      scanf("%d%d",&m,&n);
      l-=m-n;
      if(ansflag==0 && l<=0){
        ans[i]=j+1;
        ansflag=1;
      }
    }
  }
  num=i;
  for(i=0;i<num;i++)
    if(ans[i]==0)
      printf("NA\n");
    else
      printf("%d\n",ans[i]);
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


long long N, M;

int main() {
	while (cin >> N >> M) {
        long long pow = 1LL<<M;
        long long ikkai = 1900LL * M + 100LL * (N - M);
        cout <<  ikkai * pow << endl;
    }
}





















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,ans;
double t,h[10100],minn=0x7f7f7f7f;
int main(){
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		h[i]=abs(t-0.006*h[i]-a);
	}
	for(int i=1;i<=n;i++){
		if(h[i]<minn){
			ans=i;
			minn=h[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
const int MAX=5e5+10;
//const int INF=1e9+15;



int main(){
	int N;
	ll D;
	cin>>N>>D;
	ll d[MAX];
	rep1(i,N)cin>>d[i];
	int Q;
	cin>>Q;
	
	ll now[MAX];
	now[0]=D;
	rep1(i,N)now[i]=min(now[i-1], abs(now[i-1]-d[i]));
	if(now[N]!=0){
		rep(_,Q)cout<<"YES"<<endl;
		return 0;
	}
	int ur[MAX];
	ur[N]=1;
	for(int i=N-1; i>=0; i--){
		if(d[i+1]>=2*ur[i+1]) ur[i]=ur[i+1];
		else ur[i]=ur[i+1]+d[i+1];
	}
	rep(_,Q){
		int q;
		cin>>q;
		q--;
		if(now[q]>=ur[q+1])printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 11648
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dxt[6] = {0, 0, -1, -1, 1, 1};
const int dyt[6] = {-2, 2, 1, -1, -1, 1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 30;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const int BIG = 1e9 + 239;
const int MOD = 998244353; //1e9 + 7; //;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937 rnd(239); //rnd(chrono::high_resolution_clock::now().time_since_epoch().count())

//constants
const int M = 2e5 + 239;
const int N = 2e3 + 239;
const int L = 20;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int X = 310;

int n, m;
bitset<X> a[X];
bool used[X];

int32_t main()
{
    #ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            int x;
            cin >> x;
            a[i][j] = x;
        }
    int pr = 1;
    for (int x = 0; x < m; x++)
    {
        int t = -1;
        for (int i = 0; i < n; i++)
            if (!used[i] && a[i][x])
            {
                t = i;
                break;
            }
        if (t == -1)
        {
            pr = (pr * 2) % MOD;
            continue;
        }
        used[t] = true;
        for (int i = 0; i < n; i++)
            if (!used[i] && a[i][x])
                a[i] ^= a[t];
    }
    int ans = 1;
    for (int i = 0; i < m; i++)
        ans = (ans * 2) % MOD;
    ans -= pr;
    if (ans < 0) ans += MOD;
    for (int i = 0; i < n - 1; i++)
        ans = (ans * 2) % MOD;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
 
int main() {
  int N, a;
  int count40 = 0;
  int count41 = 0;
  int count42 = 0;
  cin >> N;
  rep (i,N) {
    cin >> a;
    if ( a % 4 == 0 ) {
      count40 ++;
    }
    else if ( a % 2 == 0 ) {
      count42 ++;
    }
    else {
      count41 ++;
    }
  }
  if (count41 == 0) {
    cout << "Yes" << endl;
  }
  else if ( count40 + 1 >= count42 + count41 ) {
    cout << "Yes" << endl;
  }
  else if (count40 >= count41) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define ln(a) cout << (a) << endl
#define debug(a, n) rep(hoge, n) printf("%lld%c", a[hoge], hoge == (n) - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define EPS 0.00000001

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

signed main() {
    ll h;
    cin >> h;
    ll ans = 1;
    while(h) {
        h >>= 1;
        ans <<= 1;
    }
    ans--;
    ln(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
#include <queue>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007



signed main(){

	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	for (int i = 0; i <= N - 1; i++){
		if (i*C - (N - 1 - i)*D <= B - A && B - A <= i*D - (N - 1 - i)*C){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = 1000000000
for i in range(0, 200100, 2):
    ans = min(ans, C * i + max(X - (i / 2), 0) * A + max(Y - (i / 2), 0) * B)
print(int(ans))

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

int main(){
  int n;
  int m;
  int incar;
  int outcar;
  int cars;
  int maxcars;
  
  cin >> n;//調査時間を取得
  cin >> m;//開始時トンネル内車台数取得

  incar=m;//トンネルに車を予め入れておく
  cars=m;//トンネル内の車の合計も入れておく
  maxcars=m;//最大値も入れておく
  
  for(int i=0;i<n;i++){//調査を取得
    cin >> incar >> outcar;
    cars=cars+incar;
    cars=cars-outcar;
    if(cars<0){//トンネル内の車の合計が0を下回ったら
      cout << "0" << endl;
      return 0;
    }
    if(cars>maxcars) maxcars=cars;//最大値更新
  }

  cout << maxcars << endl; //結果出力
  
  return 0;
}


Measured memory_bytes: 3080
(defun abc122a ()
  (let ((b (read-line)))
    (cond
      ((equal b "A")
       (format t "T"))
      ((equal b "T")
       (format t "A"))
      ((equal b "C")
       (format t "G"))
      ((equal b "G")
       (format t "C")))))

(abc122a)

Measured memory_bytes: 5216