akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
vector<ll> ans = vector<ll>(2001, 0);

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

bool comp(pair<int,pair<int,int>> a, pair<int, pair<int, int>> b){
	return a.first <= b.first;
}

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

	string s;
	cin >> s;

	cout << s << ((s[s.size() - 1] == 's') ? "es" : "s") << endl;
}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin); 
	int ans=1,tot=1,n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x%2==0)
			ans*=2;
		tot*=3;	
	}
	printf("%d\n",tot-ans);
	return 0;
}


Measured memory_bytes: 256
def gcd(a,b)
    a,b = b,a%b while b > 0
    a
end

t = gets.chomp.to_i
t.times do
  a, b, c, d = gets.chomp.split(' ').map(&:to_i)
  if a < b
    puts 'No'
    next
  end

  if b > d
    puts 'No'
    next
  end

  if c > b
    puts 'Yes'
    next
  end

  first_action = a % b
  unit = gcd(b, d)
  if (c - first_action) / unit < (b - 1 - first_action) / unit
    puts 'No'
  else
    puts 'Yes'
  end
end


Measured memory_bytes: 1916
s = input()
if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 3060
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

int N;
int a[200001];

int ans = 0;
int b[200001];

void solve(){
	memset(b,-1,sizeof(int)*(N+1));
	for(int i=N;i>=1;i--){
		int counter = 0;
		for(int j=(N/i)*i;j>=1;j-=i){
			if(b[j]<0){
				if(a[i]==0){
					b[j] = counter;
					ans+=b[j];
				}else{
					if(counter==0) b[j] = 1;
					else b[j] = 0;
					ans+=b[j];
					counter = -1;
				}
				if(counter>0) counter--;
			}else{
				counter+=b[j];
				counter%=2;
			}
		}
	}
}
 
int main(){
	cin>>N;
	for(int i=1;i<=N;i++) cin>>a[i];

	solve();

	cout << ans <<endl;
	for(int i=1;i<=N;i++){
		if(b[i]==1) cout<<i<<" ";
	}
	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define rrng(obj) (obj).rbegin(), (obj).rend()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,v.size())i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(v.size())o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pair<char,int> a,pair<char,int> b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  ll n,k;
  cin>>n>>k;
  int ans=0;
  do{
    n/=k;
    ans++;
  }while(n!=0);
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int h,w,i,j,flag=1;
char a[51][51]={'0'};
scanf("%d %d",&h,&w);
for(i=0;i<h;i++)
{
  scanf("%s",a[i]);
}
for(i=0;i<h;i++)
{
  for(j=0;j<w;j++)
  {
    if(a[i][j]=='#')
    {
      if((i==0||a[i-1][j]!='#')&&(j==0||a[i][j-1]!='#')&&(a[i+1][j]!='#')&&(a[i][j+1]!='#'))flag=0;
    }
  }
}
if(flag)printf("Yes");
else printf("No");
}


Measured memory_bytes: 128
n = int(input())
w = list(map(int,input().split()))
sum_w = sum(w)
ans = float('inf')
s1 = []
for i in range(n):
  s1.append(w[i])
  ans = min(ans,abs(sum(s1)- (sum_w - sum(s1))))
print(ans)

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

int main(){
    int K, T;
    cin >> K >> T;
    int cakes[T];
    for(int i = 0; i < T; i++){
        cin >> cakes[i];
    }
    sort(cakes, cakes + T);
    int sum = 1;
    for(int i = 0; i < T - 1; i++){
        sum += cakes[i];
    }
    cout << max(0, cakes[T - 1] - sum) << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
s = []
for i in range(n):
    l = list(map(int, input().split()))
    rang = [l[0] - l[1], l[0] + l[1]]
    s.append(rang)
s_sort = sorted(s, key=itemgetter(1))
ans = 0
last = -float("inf")
for i in range(n):
    if last <= s_sort[i][0]:
        ans += 1
        last = s_sort[i][1]
print(ans)


Measured memory_bytes: 26368
/*
    発狂案件
 */

#include <cstdio>
#include <cmath>
using namespace std;

int n;
int ans;

int main() {
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        int t;

        scanf("%d", &t);
        ans++;
        for (int j=1; j<=(int)floor(sqrt(t)); j++) {
            if ((t-j)%(j*2+1) == 0) {
                ans--;
                break;
            }
        }
    }

    printf("%d\n", ans);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

bool colors[100005];
unordered_map<ll, int> ans;

ll to_id(ll a, ll b) {
    return a * 100001 + b;
}

void dfs(const Graph &graph, int v, int prev_c) {
    colors[v] = true;
    int cnt = 1;
    for (int u: graph[v]) {
        if (colors[u] == 0) {
            if (cnt == prev_c) {
                cnt ++;
            }
            ans[to_id(v, u)] = cnt;
            dfs(graph, u, cnt);
            cnt++;
        }
    }
}

void Main() {
    int N;
    cin >> N;
    Graph graph(N);
    vector<P> items;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        items.push_back({a, b});
    }
    dfs(graph, 0, -1);

    ll m = 0;
    for (P p : ans) {
        m = max(m, p.second);
    }
    cout << m << '\n';
    rep(i, N - 1) {
//        print(items[i]);
//        print(to_id(items[i].first, items[i].second));
        cout << ans[to_id(items[i].first, items[i].second)] << '\n';
    }

}

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


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

const int MAX = 101;

int W, H;
char G[MAX][MAX];

bool dfs(int x, int y, char from, char to) {
  static int dx[] = {1,0,-1,0};
  static int dy[] = {0,1,0,-1};
  G[y][x] = to;
  bool res = false;
  for(int i = 0; i < 4; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= W || ny < 0 || ny >= H) {
      res = true;
      continue;
    }
    if(G[ny][nx] != from) continue;
    res |= dfs(nx, ny, from, to);
  }
  return res;
}

int main() {
  while(cin >> W >> H && (W|H)) {
    int sx, sy;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
        if(G[i][j] == '&') {
          sx = j;
          sy = i;
          G[i][j] = '.';
        }
      }
    }
    for(int i = 0; ; ++i) {
      if(dfs(sx, sy, '.', '#')) {
        cout << i << endl;
        break;
      }
      dfs(sx, sy, '#', '.');
    }
  }
  return 0;
}

Measured memory_bytes: 1932
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e6 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
int ans ;
void read (vector< int > & a){
    for( int i = 0 ; i < a.size() ; i++)    cin>>a[i];
}
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    vector < ll > cont(26,0);
    for( int i = 0 ; i < n; i++ ){
        cont[s[i]-'a']+=1;
    }
    ll ans = 1 ;
    for( int i = 0 ; i < 26 ; i++){
        ans*=cont[i]+1;
        if(ans>=mod){
            ans%=mod;
        }
    }
    cout << ans - 1 << " " ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}
/*
    update - o(1) - log time
*/


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define MAX 1000005
 typedef struct  d{
  char name[11];
  int time;
  char sname[11];
  int stime;
  char Ansname[11];
  int Anstime;
}date;
 date tn[MAX];
 
int main(){
  int n,q,i,str,tmp,tmp2,j,k=0;
  scanf("%d%d",&n,&q);

  for(i=1;i<n+1;i++){
    scanf("%s ",tn[i].name);
     scanf("%d",&tn[i].time);
  }
  tmp2=n+1;
  i=1;
  while(1){
   
    tn[i].stime=(tn[i].time-q);
    if(tn[i].stime>0){
       
     
      tn[tmp2].time=tn[i].stime;
      strcpy(tn[i].sname,tn[i].name);
      strcpy(tn[tmp2].name,tn[i].sname);
      str+=q;
      if(tmp2==n+1){
	tmp2=1;
      }
      else{
	tmp2++;
      }
      if(i==n+1){
	i=1;
      }
      else{
	i++;
      }
      
    }
    else{
     
      str+=tn[i].time;
      tn[k].Anstime=str;
      tn[i].time=0;
      strcpy(tn[k].Ansname,tn[i].name);
      k++;
      strcpy ( tn[i].name," ");
      if(i==n+1){
	i=1;
      }
      else{
	i++;
      }
    }
    if(k==n){
      break;
    }

  }
  for(j=0;j<n;j++){
    printf("%s %d\n",tn[j].Ansname,tn[j].Anstime);
  }
  return 0;
}



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

int main()
{
    string s; cin>>s;
    int k; cin>>k;

    int n=s.size();
    for(int i=0; i<n; ++i) {
        int x=s[i]-'a';
        if (x and k>=26-x) {
            s[i]='a';
            k-=26-x;
        }
    }
    k%=26;
    s[n-1]=(s[n-1]-'a'+k)%26+'a';
    cout<<s<<endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    int min = INF;
    rep(i, n) cin >> w[i];
    rep(i,n){
        int left = 0;
        int right = 0;
        rep(j,i+1){
            left += w[j];
        }
        repk(j,i+1,n){
            right += w[j];
        }
        chmin(min, abs(right - left));
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
long int N;
scanf ("%d",&N);
long long int A[N];
long long int B = 1;
long long int x = 1000000000000000000;

for (int i = 0; i < N; i++ ){
scanf ("%lld",&A[i]);
if (A[i]==0){
    printf ("0\n");
    return 0; 
}
}
for (int i = 0; i< N; i++){
    if ( x < A[i] ){
        printf ("-1\n"); 
        return 0;
    }
     else {
	x= x/ A[i];
	B = B*A[i];
}
}
printf ("%lld\n",B);
return 0;
}

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

def divisor(n):
    d=[]
    N=n
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            d.append((i, n//i))
    return d

ans = 0
d = divisor(m)

for x, y in d:
    if x >= n:
        ans = max(ans, y)
    if y >= n:
        ans = max(ans, x)
print(ans)


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

int f(int N){
  int ret = 0;
  while(N > 0){
    ++ret;
    N /= 10;
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 0; i <= N; ++i){
    if(f(i)%2) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
ax = []
ay = []
for i in range(n):
    x,y = map(int, input().split())
    ax.append((x,i))
    ay.append((y,i))

ax.sort()
ay.sort()

edge = []
for i in range(n-1):
    v = ax[i][1]
    u = ax[i+1][1]
    c = abs(ax[i][0]-ax[i+1][0])
    edge.append((c,v,u))

    v = ay[i][1]
    u = ay[i+1][1]
    c = abs(ay[i][0]-ay[i+1][0])
    edge.append((c,v,u))

edge.sort()



class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return

        if x<y:
            self.par[y] = x
        else:
            self.par[x] = y
    def same(self, x, y):
        return self.find(x) == self.find(y)

t = UnionFind(n)
res = 0
for e in edge:
    cost = e[0]
    v = e[1]
    u = e[2]

    if not t.same(v,u):
        # print((v,u,cost))
        t.unite(v,u)
        res += cost

print(res)


Measured memory_bytes: 52960
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e3+5;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d2 == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String firstLine = sc.nextLine();
		int numOfInputs = Integer.valueOf(firstLine.split(" ")[0]);
		String[] inputArray = new String[numOfInputs];
		for(int i=0;i<numOfInputs;i++){
			inputArray[i] = sc.next();
		}
		Arrays.sort(inputArray);

		StringBuilder sb = new StringBuilder();
		for(String input : inputArray){
			sb.append(input);
		}
		
		System.out.print(sb.toString());
		return;
	}
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> a(n),b(n);
  for(int i=0;i<n;++i) cin >> a[i];
  for(int i=0;i<n;++i) cin >> b[i];

  ll A,B;
  A=0;
  B=0;
  for(int i=0;i<n;++i){
    if(a[i]>b[i]) B+=a[i]-b[i];
    if(b[i]>a[i]) A+=(b[i]-a[i])/2;
  }
  if(A>=B) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3724
n,y=map(int,input().split())
is_none=True

for i in range(n+1):
    ai=10000*i
    if ai > y: continue
    else:
        for j in range(n+1-i):
            bj=5000*j
            if ai + bj > y :break
            else : 
                k=n-i-j
                if  ai + bj + 1000*k == y:
                    is_none=False
                    break
        if not is_none:break

if is_none:print(-1,-1,-1)
else: print(i,j,k)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int N, C, K; cin >> N >> C >> K;
VI T(N); rep(i, 0, N) scanf("%d", &T[i]);

sort(ALL(T));

int bus=0, pass, leavetime;

for(int i = 0; i < N;){
    pass = 0;
    leavetime= T[i] + K;
    for (i; i < N && pass < C && T[i] <= leavetime; ++i) {
        ++pass;
    }
    ++bus;
}

cout << bus << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val N = readLine()!!.toLong()
    var ans = 0L
    var i = 1L
    while (i * i < N) {
        if (N % i == 0L) {
            if (N / i < i - 1) {
                ans += i - 1
            }
            if(i < N / i - 1) {
                ans += N / i - 1
            }
        }
        ++i
    }
    println(ans)
}

Measured memory_bytes: 31796
x = int(input())

ans = 0
if x // 11:
    ans += x // 11 * 2
    pt = x // 11 * 11
    x -= pt

if x == 0:
    print(ans)
elif 0 < x <= 6:
    print(ans + 1)
else:
    print(ans + 2)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace  std;
int  n , a[200020];
int maxx1[200020];
int maxx2[200020];
int main ( ) {
	scanf("%d" ,&n);
	for(int  i = 1 ; i <= n; i++){
	    scanf("%d" ,&a[i]);
	    maxx1[i] = max(maxx1[i - 1] , a[i]);
	}
	for(int i = n; i >= 1 ; i--){
		maxx2[i] = max(maxx2[i + 1] , a[i]);
	}
	for(int i = 1; i <= n ;i++){
 		int ans = max(maxx1[i - 1] , maxx2[i + 1]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3968
N = int(input())
 
XYHA = []
 
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        continue
    XYHA.append([x,y,h])

for i in range(101):
    for j in range(101):
        HC = XYHA[0][2] + abs(XYHA[0][0] - i) + abs(XYHA[0][1] - j)
        for k in range(1, len(XYHA)):

            H = XYHA[k][2] + abs(XYHA[k][0] - i) + abs(XYHA[k][1] - j)

            if HC != H:
                break
            elif k == len(XYHA) - 1:
                print(i,j,HC)
                exit()

print(XYHA[0][0],XYHA[0][1],XYHA[0][2])

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> np(N,0); // next points
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    np.at(a-1) |= 1<<(b-1);
    np.at(b-1) |= 1<<(a-1);
  }
  int res = 0;
  vector<int> p(N);
  for(int i=0;i<N;i++) p.at(i) = i;
  do{
    if(p.at(0)==0){
      for(int i=1;i<N;i++){
        if(!(np.at(p.at(i-1))>>(p.at(i))&1)){
          break;
        }else if(i==N-1){
          res++;
        }
      }
    }
  }while(next_permutation(p.begin(), p.end()));
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int n;
int cur = 1;
bool exi[11][11];
bool on_line(P x, P l, P r) {
	if (l.first > r.first)swap(l, r);
	if (l.first == r.first) {
		if (x.first != l.first)return false;
		else {
			if (l.second > r.second)swap(l, r);
			if (x.second < l.second)return false;
			else if (x.second > r.second)return false;
			else return true;
		}
	}
	if (x.first < l.first)return false;
	if (x.first > r.first)return false;
	int dx1 = x.first - l.first, dy1 = x.second - l.second;
	int dx2 = x.first - r.first, dy2 = x.second - r.second;
	return dx1 * dy2 == dx2 * dy1;
}
bool kousa(P l1, P r1, P l2, P r2) {
	vector<P> v;
	if (on_line(l1, l2, r2))v.push_back(l1);
	if (on_line(r1, l2, r2))v.push_back(r1);
	if (on_line(l2, l1, r1))v.push_back(l2);
	if (on_line(r2, l1, r1))v.push_back(r2);
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	return v.size() >= 2;
}
int ans = mod;
int col[11];
int num = 0;
void dfs(int id) {
	if (id == cur+1) {
		rep1(i, cur) {
			Rep1(j,i+1, cur) {
				if (exi[i][j] && col[i] == col[j])return;
			}
		}
		ans = min(ans, num);
		return;
	}
	rep(i, num) {
		col[id] = i; dfs(id+1);
	}
	col[id] = num; 
	num++; dfs(id+1); num--;
}
void solve() {
	ans = mod;
	cur = 1;
	rep(i, 11)rep(j, 11)exi[i][j] = false;
	map<string, int> mp;
	vector<vector<P>> v(n);
	vector<int> ids(n);
	rep(i, n) {
		string s; cin >> s;
		if (!mp[s]) {
			mp[s] = cur; cur++;
		}
		int id = mp[s];
		ids[i] = id;
		int x, y;
		while (cin >> x) {
			if (x == -1)break;
			cin >> y;
			v[i].push_back({ x,y });
		}
	}
	rep(i, n) {
		Rep(j, i + 1, n) {
			if (ids[i] == ids[j])continue;
			bool f = false;
			rep(k, v[i].size()) {
				P le1 = v[i][k], ri1 = v[i][(k+1)%v[i].size()];
				rep(l, v[j].size()) {
					P le2 = v[j][l], ri2 = v[j][(l+1)%v[j].size()];
					if (kousa(le1, ri1, le2, ri2))f = true;
				}
			}
			if (f) {
				exi[ids[i]][ids[j]] = exi[ids[j]][ids[i]] = true;
			}
		}
	}
	cur--;
	rep(i, 11)col[i] = -1; num = 0;
	dfs(0);
	cout << ans << endl;
	/*cout << "answer_is_ "<<ans << endl;
	rep1(i, cur) {
		Rep1(j,i+1,cur) {
			if (exi[i][j])cout << i << " " << j << endl;
		}
	}*/
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n, n) {
		solve();
	}
	//stop
	return 0;
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define endl '\n'
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
long long int gcd(long long int x,long long int  y){
   if(y==0)return x;
   return gcd(y,x%y);
}
long long exp(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = exp(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int prime(long long x){
if(x==2)return 1;
else{
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)
            return 0;
    }
}
return 1;
}
//main
int main() {
IOS;
int n;
ll con=0;
cin>>n;
for(int i=1;i<n;i++){
if(n%i==0){
    con+=n/i;
    con--;
}
else con+=n/i;
}
cout<<con;
return 0;
}
//jaeger


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll B(0);
  ll bsize = 0;
  for(int i = 0; i < N; i++){
    ll A;
    cin >> A;
    if(i == 0){
      B.push_back(A);
      bsize++;
    }
    else if(B.at(0) < A){
      B.at(0) = A;
    }
    else if(B.at(bsize-1) >= A){
      B.push_back(A);
      bsize++;
    }
    else{
      int ok = bsize-1;
      int ng = 0;
      while(ok - ng > 1){
        int mid = (ok + ng) / 2;
        if(B.at(mid) < A) ok = mid;
        else ng = mid;
      }
      B.at(ok) = A;
    }
  }
  cout << B.size() << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    for(int i=1;i<10;i++){
        if(a%i==0 && a/i<10){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

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

int X, A, B;

int main() {
    cin >> X >> A >> B;

    if (B <= A) {
        cout << "delicious" << endl;
    } else if (B <= A + X) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int cal(int a,int b,char op){
   if(op=='+'){
      return a+b;
   }else{
      return a-b;
   }

}
int main(void){
   string s;
   cin>>s;
   int a,b,c,d;
   a=s[0]-'0';
   b=s[1]-'0';
   c=s[2]-'0';
   d=s[3]-'0';
   for(int i=0;i<(1<<3);i++){
      string op="";
      for(int j=0;j<3;j++){
         if((i>>j)&1){
            op+="+";
         }else{
            op+="-";
         }
      }
      //cout<<op<<endl;
      int tmp=cal(cal(cal(a,b,op[0]),c,op[1]),d,op[2]);
      if(tmp==7){
         cout<<a<<op[0]<<b<<op[1]<<c<<op[2]<<d<<"=7"<<endl;
         return 0;
      }
   }
   return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<int, int> mapo, mape;
  rep(i, n) {
    int v;
    cin >> v;
    if (i%2) mapo[v]++;
    else mape[v]++;
  }
  int mo1 = 0, mo2 = 0, me1 = 0, me2 = 0;
  int numo, nume;
  for (auto x : mapo) {
    if (x.second > mo2) mo2 = x.second;
    if (mo1 < mo2) {
      swap(mo1, mo2);
      numo = x.first;
    }
  }
  for (auto x : mape) {
    if (x.second > me2) me2 = x.second;
    if (me1 < me2) {
      swap(me1, me2);
      nume = x.first;
    }
  }
  if (numo != nume) cout << n - mo1 - me1 << endl;
  else cout << min(n-mo1-me2, n-mo2-me1) << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    int n, p;
    cin >> n;
    vector<int> dp(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> p;
        dp[p] = dp[p - 1] + 1;
    }
    cout << n - *max_element(dp.begin(), dp.end()) << "\n";
    return 0;
}

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

const long long INF = 0x3f3f3f3f3f3f3f3f;

map <long long, long long> dp;
long long a, b, c, d;

long long dfs(long long n) {
	if (n < 0) return INF;
	if (n == 0) return 0;
	if (dp.count(n)) return dp[n];
	long long res = INF;
	for (long long nn = n - 1; nn <= n + 1; nn++) {
		if (nn % 2 == 0 && nn / 2 < n) res = min(res, dfs(nn / 2) + abs(n - nn) * d + a);
	}
	for (long long nn = n - 2; nn <= n + 2; nn++) {
		if (nn % 3 == 0 && nn / 3 < n) res = min(res, dfs(nn / 3) + abs(n - nn) * d + b);
	}
	for (long long nn = n - 4; nn <= n + 4; nn++) {
		if (nn % 5 == 0 && nn / 5 < n) res = min(res, dfs(nn / 5) + abs(n - nn) * d + c);
	}
	if (INF / n >= d) res = min(res, n * d);
	return dp[n] = res;
}

int main () {
	int T; cin >> T;
	while (T--) {
		long long n; cin >> n >> a >> b >> c >> d;
		dp.clear();
		cout << dfs(n) << endl;
	}
	return 0;
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int get_dist(int a,int b,int x,int y){
    return min(b-a,abs(a-x)+abs(b-y)+1);
}
void solve(){
    int n,x,y;
    cin>>n>>x>>y;
    vector<int> v(n,0);
    rep(i,1,n+1){
        rep(j,i+1,n+1){
            v[get_dist(i,j,x,y)]++;
        }
    }
    rep(i,1,n) cout<<v[i]<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
 
namespace ABC
{
  public class Program
  {
    public static void Main(string[] args)
    {
      Console.SetOut(new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false});

      var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
      int a = ab[0];
      int b = ab[1];
      if(a==1)a=100;
      if(b==1)b=100;
      if(a>b){
        Console.WriteLine("Alice");
      }else if(a<b){
        Console.WriteLine("Bob");
      }else{
        Console.WriteLine("Draw");
      }
      Console.Out.Flush();
    }
  }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
int pd(char c)
{
	if(c=='b') return 1;
	if(c=='d') return 4;
	if(c=='p') return 2;
	if(c=='q') return 3;
}
int main()
{
    string s;
    int i,x,flag=1;
    cin>>s;
    x=s.length();
    if(x%2) flag=0;
    if(flag)
    for(i=0;i<x/2;i++)
    {
    	if(pd(s[i])+pd(s[x-i-1])!=5)
    	{
    		flag=0;
    		break;
		}
	}
	if(flag==0) cout<<"No";
	else cout<<"Yes";

 return 0;
}


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



int main() {
  int n;
  
  cin>>n;
  int ans=0;
 
  
  rep(i,n){
    if(i==0)continue;
    ans+=(n-1)/i;
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  string s;
  int n,i,ans=0;
  cin >> n >> s;
  for(i=0;i<n-2;i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3536
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

ll g(ll a, ll b, ll x){
    ll res1 = (a * x)/b;
    ll res2 = a * (x/b);

    return res1 - res2;
}

int main(){
    ll a, b, n;
    cin >> a >> b >> n;

    if(n > b) cout << max(g(a, b, b-1), g(a, b, b+1)) << endl;

    else if(n == b) cout << g(a, b, n-1) << endl;

    else cout << g(a, b, n) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int a,b,c;
    scanf("%d/%d/%d",&a,&b,&c);
    printf("%d/%02d/%02d\n",2018,b,c);
    // insert code here...
    //td::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long x,y;
	scanf("%lld%lld",&x,&y);
    long long sum=0,ans;
		
		ans=0;
		while (x<y){
			x*=2;
			ans++;
		}		
		
	if (y%x==0) ans++;
	printf("%lld",ans);
	return 0;
}

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

int main(void) {

    string words; cin >> words;
    map<char, int> word_cnt;
    for (auto word: words) {
        ++word_cnt[word];
    }

    bool flag = true;
    for (auto word: word_cnt) {
        if (word.second%2 != 0) flag = false;
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; t=1; while(t--)
typedef long long int ll;
int main() {
    FIO;
    test{
        string s;
        cin>>s;
        ll ans=0;
        if(s[2]==s[3]){
            ans++;
        }
        if(s[4]==s[5]){
            ans++;
        }
        ans==2 ? cout<<"Yes\n" : cout<<"No\n";
    }
	return 0;
}

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

int main(){
    int n; cin>>n;
    int h[30];
    for(int i=0;i<n;i++)cin>>h[i];
    int ans=1,m=h[0];
    for(int i=1;i<n;i++){
        if(m<=h[i]){
            ans++;
            m=h[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, k;
    cin >> n >> k;
    vint a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    vll s(n + 1);
    rep(i, n) s[i + 1] = s[i] + a[i];

    ll ans = 0;
    rep(i, k + 1)
    {
        if (i > n)
            break;

        ll left = s[i];

        rep(j, k - i + 1)
        {
            if (i + j > n)
                break;
            ll l = k - i - j;
            if (l < 0)
                continue;

            ll right = s[n] - s[n - j];

            multiset<ll> st;
            rep(x, i) st.emplace(a[x]);
            rep(x, j) st.emplace(a[n - 1 - x]);
            ll now = left + right;
            while (st.size() && l)
            {
                ll x = *(st.begin());
                if (x >= 0)
                    break;
                l--;
                st.erase(x);
                now -= x;
            }

            // printf("%d %d %d: %ld %ld, ", i, j, l, left, right);
            // cout << now << endl;
            ans = max(now, ans);
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

  vector<int> p(N, 0);
  rep(i, N) cin >> p[i];
  
  sort(p.begin(), p.end());
  
  int value = 0;
  rep(i, K) value += p[i];
  
  cout << value;
}

Measured memory_bytes: 3592
n, k = map(int, input().split())
al = list(map(int, input().split()))

dp = [n]*41

for i in range(n):
    i_bit = bin(al[i])[2:]
    lenb = len(i_bit)
    for j in range(lenb-1,-1,-1):
        dp[lenb-1-j] -= int(i_bit[j])

temp = k
res = 0
m = n//2

for i in range(40,-1,-1):
    if dp[i] > m and 2**i <= temp:
        temp -= 2**i
        res += (2**i)*(dp[i]) 
    else:
        res += (2**i)*(n-dp[i])

print(res)

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

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int MAX_SIZE = 5e5;
const ll P = 239;
const ll MOD = 228228227;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;


void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto& i: a) cin >> i;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
           for (int k = j + 1; k < n; ++k) {
               set<int> x;
               x.insert(a[i]);
               x.insert(a[j]);
               x.insert(a[k]);
               if (a[k] < a[i] + a[j] && a[i] < a[j] + a[k] && a[j] < a[i] + a[k] && sz(x) == 3) {
                   ++ans;
               }
           }
        }
    }
    cout << ans << en;
}

int main() {
    fast_in_out();
    START_TIME = clock();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */

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

using namespace std;
const long long int MOD=1e9+7;

int main(){
  long long n;
  cin >> n;
  if(n%2 == 1)cout << 0 << endl;
  else if(n == 0)cout << 0 << endl;
  else{
    long long keta=1, ans=0;
    n /= 10;
    ans += n;
    while(n>0){
      ans += n/5;
      n /= 5;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static String S;

    public static void main(String... args) {
        Scanner IN   = new Scanner(System.in);
        S = IN.next();
        long K = IN.nextLong();
        System.out.println(calc(K, 0));
    }

    static Character calc(long k, int i) {
        if (k == 1) {
            return S.charAt(i);
        } else {
            if (S.charAt(i) != '1') {
                return S.charAt(i);
            } else {
                return calc(k - 1, i + 1);
            }
        }
    }
}


Measured memory_bytes: 23124
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string> 
#include <iomanip>
#include <list>
#include <random>
#include <numeric> //iota - iota(v.begin(), v.end(), x) x, x + 1, x + 2...

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef int INT;
#define int ll
#define mmin(a, b) a = min(a, b)
#define mmax(a, b) a = max(a, b)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end()
#define sz(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

/*
tuple<int, string> f() {
return {485, "Hello"};
}
int a;
string b;
tie(a, b) = f();
*/

const double PI = 2 * acos(0.0), eps = 1e-8;
const int oo = 1000000000000000000;

template<class T>
void show(const vector<T> &a) {
	cout << sz(a) << endl;
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const ll M = 998244353;

ll MOD(ll a) {
	if (a >= 0) return a >= M ? a % M : a;
	if (a <= -M) a %= M;
	return a ? a + M : a;
}

int gcd(int a, int b)
{
	while (a > 0)
	{
		if (a < b)
			swap(a, b);
		a %= b;
	}
	return b;
}


/*______________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
______________________________________________________________________________________________________________________________*/



int o = 1000000;

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);


	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] -= (i + 1);
	}

	sort(all(a));
	

	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += abs(a[i] - a[n / 2]); 
	}

	cout << sum;


}

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

int main(){
  int A,B;
  cin >> A >> B;
  for(int i=1;;i++){
    if((int)(i*0.08)==A){
      if((int)(i*0.1)==B){
        cout << i << endl;
        return 0;
      }
    }
    if(i*0.08>100){
      cout << -1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256