akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int n;
ll p[51];
ll b[51];

ll solve(int x,ll y){
    if (y==0){
        return 0;
    }
    if (y==1 && x==0){
        return 1;
    }
    if (y==1){
        return 0;
    }
    else if (y<=b[x-1]+1){
        return solve(x-1,y-1);
    }
    else if (y==b[x-1]+2){
        return p[x-1]+1;
    }
    else if (y<=2*b[x-1]+2){
        return solve(x-1,y-2-b[x-1])+p[x-1]+1;
    }
    else{
        return p[x-1]*2+1;
    }
}

int main() {
    cin>>n;
    ll x;
    cin>>x;
    p[0]=1;
    b[0]=1;
    rep(i,n){
        p[i+1]=2*p[i]+1;
        b[i+1]=2*b[i]+3;
    }
    ll ans=solve(n,x);
    cout<<ans<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from collections import defaultdict
import math
import re
import bisect

def main():
    #A, B, C, D = map(int, input().split())
    N = int(input())
    diff_list = []
    for i in range(N):
        A, B = map(int, input().split())
        diff_list.append((B, A))

    diff_list = sorted(diff_list, key=lambda x: x[0])

    t = 0
    for i in range(N):
        B, A = diff_list[i]
        t += A
        if t > B:
            print("No")
            return

    print("Yes")

if __name__ == '__main__':
    main()


Measured memory_bytes: 33956
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int N,len;
char S[1000001];

int mybsearch(int l,int h);
bool check(int k);

int main(void){
  scanf("%d%*c",&N);
  scanf("%s",S);
  len=strlen(S);
  printf("%d\n",mybsearch(0,N/3));
  return 0;
}

int mybsearch(int l,int h){
  int mid;
  if(l==h) return l;
  else if(l+1==h){
    if(check(h)) return h;
    else return l;
  }
  mid=(l+h)/2;
  return check(mid)?mybsearch(mid,h):mybsearch(l,mid);
}

bool check(int k){
  int I_num=0,O_num=0,ans=0;
  int i,j;
  for(i=len-1;i>=0;i--){
    if(S[i]=='I'){
      if(I_num<k) I_num++;
      else if(ans<O_num) ans++;
    }else if(S[i]=='O'){
      if(O_num<I_num) O_num++;
    }else{
      if(ans<O_num) ans++;
    }
  }
  return k==ans;
}

Measured memory_bytes: 1576
import sys

l=[0 for i in range(26)]
for e in sys.stdin:
    for c in e:
        if str.isupper(c) or str.islower(c):
            l[ord(str.lower(c))-ord('a')]+=1
for i in range(26):
    print(chr(i+ord('a')),l[i],sep=' : ')


Measured memory_bytes: 5576
#include <fstream>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <string>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <queue>


using namespace std;


typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef double ld;


#define ALL(a) a.begin(),a.end()
const int INF = 1e9, sze = 5e3 + 100, N = 11;
const ll MOD1 = 998244353;
const ld EPS = 1e-6;



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

	ll n, k;
	cin >> n >> k;
	ll ans = 0;

	if (!(k & 1) && k / 2 <= n)
		ans += ((n - k / 2) / k + 1) * ((n - k / 2) / k + 1) * ((n - k / 2) / k + 1);
	

	for (int i = 1; i <= n; ++i)
	{
		if (i % k == 0)
			ans += (n / k) * (n / k);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #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 REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n;
vi coef;
vi primes;

bool operate(int p){
    vi workcoef(all(coef));
    REP(i,n-p+1){
        workcoef[i+p-1] += workcoef[i];
        workcoef[i] = 0;
    }
    REP(i,n+1) {
        if (workcoef[i] % p != 0) return false;
    }
    return true;
}

signed main(){
    I(n);
    primes.pb(2);
    for(int i=3; i*i <= mod; i+=2){
        bool flag = true;
        for(auto p: primes){
            if (p*p > i) break;
            flag &= (i%p != 0);
        }
        if (flag) primes.pb(i);
    }
    coef.resize(n+1);
    REP(i,n+1) {
        I(coef[i]);
        int p0 = abs(coef[i]);
        if (p0 < 2) continue;
        bool p0flag = true;
        for(auto p: primes) p0flag &= (p0%p != 0);
        if (p0flag) primes.pb(p0);
    }
    for(auto pcand: primes)
        if (operate(pcand)) cout << pcand << endl;
    
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            String s = in.scanString();
            int cost = 700;
            for (int i = 0; i < s.length(); i++) if (s.charAt(i) == 'o') cost += 100;
            out.println(cost);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 24788
#include<bits/stdc++.h>
using namespace std;
string s;
int l,k;
int main()
{
	cin>>s;
	k=s.find('C');
	l=s.size();
	if (k==-1)
	{
		cout<<"No"<<endl;
		return 0;
	}	  
	for (int i=k;i<l;++i)
	  if (s[i]=='F')
	  {
	  	cout<<"Yes"<<endl;
	  	return 0;
	  }
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        long A = scanner.nextLong();
        long B = scanner.nextLong();
        long N = scanner.nextLong();
        long x;
        if(B > N){
            x = N;
        }else{
            x = B-1;
        }
        long ans = (long)((double)A*(double)x/(double)B) - A * (long)((double)x/(double)B);
        System.out.println(ans);
    }
}

Measured memory_bytes: 35768
#include<iostream>
#include<vector>
#include<sstream>
#include<istream>

using namespace std;

int main(){
    int N,tmp,alice=0,bob=0;
    string s;
    
    cin>>N;
    cin.ignore();
    getline(cin,s);

    stringstream ss{s};
    string buf;
    vector<int> v;
    
    
    while (std::getline(ss, buf, ' ')) {
        v.push_back(stoi(buf));
    }

    for(int i=0;i<N-1;i++)
        for(int j=N-1;j>i;j--){
            if(v[j]>v[j-1]){
                tmp=v[j];
                v[j]=v[j-1];
                v[j-1]=tmp;
            }
        }
    
    
    for(int i=0;i<N;i++){
        if(i%2==0){alice+=v[i];}
        else{bob+=v[i];}
    }

    cout<<alice-bob<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int a[110][110]; int b[110]; int c[110];
int main() {
	int n, m; int sum = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			sum += a[i][j];
			b[i] += a[i][j];
			c[j] += a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << a[i][j] << " ";
		}
		cout << b[i] << endl;
	}
	for (int i = 0; i < m; i++) {
		cout << c[i]  << " ";
	}
	cout << sum << endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

    int N;
    cin >> N;

    vector<long long> A(N);

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

    int cnt_minus = 0;
    for(int i = 0; i < N; i++){
        if(A[i] < 0){
            cnt_minus++;
        }
    }

    vector<long long> absA(N);
    for(int i = 0; i < N; i++){
        absA[i] = abs(A[i]);
    }


    long long ans = 0;
    if(cnt_minus % 2 == 0){
        for(int i = 0; i < N; i++){
            ans += absA[i];
        }
    }else{

        long long min_val = 0;
        min_val = *min_element(absA.begin(), absA.end());

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

        ans = ans - 2 * min_val;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();

    int gu = 0;
    for(int i=1; i<N; i++){
        gu += i;  
      }
    int ki = 0;
    for(int i=1; i<K; i++){
        ki += i;  
    }
 	System.out.println(gu+ki);
      }
}


Measured memory_bytes: 35700
def factorials_with_inv(k,mod):
    """
    0! ... k! とそれらのmod逆元を求めて返す
    """
    fac = [1]*(k+1)
    inv = [1]*(k+1)
    t = 1
    for i in range(1,k+1):
        t *= i
        t %= mod
        fac[i] = t

    t = pow(t,-1,mod)
    for i in reversed(range(1,k+1)):
        inv[i] = t
        t *= i
        t %= mod

    return fac, inv

def solve(X):
    MOD = 10**9+7
    N = len(X)-1
    DX = [b-a for a,b in zip(X,X[1:])]

    fac,inv = factorials_with_inv(N,MOD)
    res = 0
    s2 = 0
    s1 = 0
    s0 = 1

    P = fac[N]
    for k,d in enumerate(DX, start=2):
        x = s0-s1*(k-1)
        s2 = s1
        s1 = s0
        s0 = s0*k + x*(k+1) - s2
        x %= MOD
        s2 %= MOD
        s1 %= MOD
        s0 %= MOD
        res += x*P*inv[k-1]*d
        res %= MOD
    return res

if __name__ == '__main__':
    N = int(input())
    X = list(map(int,input().split()))
    print(solve(X))

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

int main(){
  int N, A;
  cin >> N >> A;
  int amari;
  amari = N / 500;
  int nokori;
  nokori = N - 500 * amari;
  if(nokori<=A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin>>s;
    int n = sz(s);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += (s[i] - '0');
    }
    if(sum%9){
        cout<<"No\n";
    }else{
        cout<<"Yes\n";
    }
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int h,n,a[1005],b[1005],dp[10005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>h>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(int i=1;i<=h;i++)
	{
		dp[i]=inf;
		for(int j=1;j<=n;j++)
			dp[i]=min(dp[i],dp[max(0,i-a[j])]+b[j]);
	}
	cout<<dp[h]<<endl;
	return 0;
}


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

int N,M;
int parent[MAX_N];
int size[MAX_N];
int depth[MAX_N];

int value[MAX_N];

int A[MAX_M],B[MAX_M];

vector<int> G[MAX_N];

void init(){
  for(int i=0;i<N;i++){
    parent[i]=i;
    size[i]=1;
  }
}

int find(int a){
  if(parent[a]==a)return a;
  else return find( parent[a] );
}

void unite(int a,int b){
  a=find(a);
  b=find(b);
  if(a==b)return;

  if(size[a]<size[b])swap(a,b);
  parent[b]=a;
  size[a]+=size[b];
}

void dfs(int pos,int cnt){
  depth[pos]=cnt;
  for(int i=0;i<(int)G[pos].size();i++)
    dfs(G[pos][i],cnt+1);
}

int main(){
  scanf("%d %d",&N,&M);
  init();
  for(int i=0;i<M;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    a--,b--;
    unite(a,b);
    A[i]=a;
    B[i]=b;
  }

  for(int i=0;i<N;i++){
    if(parent[i]!=i){
      G[ parent[i] ].push_back(i);
    }
  }

  for(int i=0;i<N;i++){
    if( parent[i]==i ){
      dfs(i,0);
    }
  }

  for(int i=0;i<M;i++){
    int a=A[i];
    int b=B[i];

    while(a!=b){
      if( depth[a] < depth[b] )swap(a,b);
      value[a]++;
      a=parent[a];
    }
    
  }

  bool ans=true;
  for(int i=0;i<N;i++)
    if(value[i]%2==1)ans=false;

  if(ans)printf("YES\n");
  else printf("NO\n");
  
  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n;
vector<int> g[3000];
ll a[3000];
int dp[3000];

int dfs(int v,int prv) {
	if(dp[v]!=0) return dp[v];
	for(auto u:g[v]) {
		if(u!=prv&&a[u]<a[v]&&dfs(u,v)==-1) return dp[v]=1;
	}
	return dp[v]=-1;
}

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

	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n-1) {
		int u,v;cin>>u>>v;;u--,v--;
		g[u].pb(v),g[v].pb(u);
	}
	REP(i,n) {
		dfs(i,-1);
	}
	bool fst=true;
	REP(i,n) {
		if(!fst) cout<<' ';
		if(dp[i]==1) {
			cout<<i+1;
			fst=false;
		}
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll n,ans=0; cin>>n; 
  vector<ll>b(n-1);
  rep(i,n) cin>>b[i];
  rep(i,n){ 
    if(i==0) ans+=b[0];
    else if(i==n-1) ans+=b[n-2];
  else{
  ans+=min(b[i-1],b[i]);
  }
  }
  cout<<ans<<endl;
}

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

typedef struct{
    int a;
    int b;
}TEST;

int comp( const void *c1, const void *c2 )
{
  TEST test1 = *(TEST *)c1;
  TEST test2 = *(TEST *)c2;

  int tmp1 = test1.b;
  int tmp2 = test2.b;

  return tmp2 - tmp1;
}


int main(){
    int N, M;
    int A[110000];
    int i,j;
    TEST base[110000];
    int num, tmp;
    long long ans;

    scanf("%d %d", &N, &M);
    for(i=0; i<N; i++){
        scanf("%d", &A[i]);
    }
    for(i=0; i<M; i++){
        scanf("%d %d", &base[i].a, &base[i].b);
    }

    qsort(A, N, sizeof(int), asc);
    qsort(base, M, sizeof(TEST), comp);

    num=0;
    tmp=0;
    ans=0;

    for(i=0; i<N; i++){
        if(A[i]<base[tmp].b){
            A[i]=base[tmp].b;
            num++;
        }
        if(num>=base[tmp].a){
            tmp++;
            num=0;
        }
        ans+=A[i];
    }

    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 2164
from itertools import permutations

N, M, R = (int(i) for i in input().split())
#print(N, M, R)

r=[int(i) for i in input().split()]
#print(r)

dist=[[float('inf') for i in range(201)] for j in range(201)]
for i in range(201):
    dist[i][i] = 0

for i in range(M):
  a,b,c=(int(i) for i in input().split())
  dist[a][b]=c
  dist[b][a]=c

for k in range(200+1):
  for i in range(200+1):
      for j in range(200+1):
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])

dict0=float('inf')
mylist=list(permutations(r,len(r)))
#print(mylist)

for i in mylist:
  tmp=0
  for j in range(len(i)-1):
    tmp+=dist[i[j]][i[j+1]]
  if tmp < dict0:
    dict0=tmp

print(dict0)


Measured memory_bytes: 77912
fn main() {
    // stdinのロックを取得し、StdinReaderを作る。
    let stdin = std::io::stdin();
    let mut r = utils::StdinReader::new(stdin.lock());

    let n = r.readl::<u32>();  // 次の改行まで読む

    let a = if (n % 2 == 0) { n } else { n * 2};
    println!("{:}", a);
}

mod utils {

    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        // 区切り文字：スペース
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        // 区切り文字：改行
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            // self.bufに次のトークンをセットする
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (), // 区切り文字だけなのでもう一度ループ
                    _ => {
                        // トークンが得られた
                        // 最後の文字が区切り文字なら削除
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break; // ループから脱出
                    }
                }
            }

            // 文字列をT型へパースする
            let elem = str::from_utf8(&self.buf).expect("invalid utf-8 string");
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
        }
    }

}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  vector<bool> s(3, false);
  for (int i = 0; i < 3; ++i) {
    int pos = (int)S[i] - (int)'a';
    if (s[pos]) {
      cout << "No" << endl;
      return 0;
    }
    s[pos] = true;
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

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

    if (a<b) swap(a, b);
    
    int res = 0;
    if (a>b) res = 2*a - 1;
    else if (a==b) res = 2*a;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



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

	int n, q;
	cin >> n >> q;
	int s = 1;
	rep(i,q) {
		int t, k;
		cin >> t >> k;
		if (t == 0) {
			if (k < s)cout << n - (s - k) + 1 << endl;
			else cout << k - s + 1 << endl;
		}
		else {
			if (k < s)s = s - k;
			else s += n - k;
		}
	}


	return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  vll a(n), b(n);
  rep(i, n) scan(a[i]);
  rep(i, n) b[i] = a[(i + 1) % n] - a[i];
  ll sum = SUM(a);
  if (sum % (n*(n + 1) / 2) != 0) {
	cout << "NO" << endl;
	return 0;
  }
  cnt = sum / (n*(n + 1) / 2);
  rep(i, n) b[i] -= sum / (n*(n + 1) / 2);
  ok = true;
  rep(i, n) {
	if (b[i] % n != 0 || b[i] > 0) ok = false;
	tmp += abs(b[i]) / n;
  }
  //rep(i, n) cout << b[i] << endl;
  if (ok && cnt == tmp) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  int price = 700;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'o') {
      price += 100;
    }
  }
  
  cout << price << endl;
}
      

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

using namespace std;
const int INF = 1e9;
vector<int> prices;
int n, m, x;
vector< vector<int> > a;
int ans = INF;

void rec(int cur, vector<int> learnt, vector<bool> used) {
  if (cur >= n) {
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      if ( learnt[i] < x) ok = false;
    }

    if (ok) {
      int sum = 0;
      for (int i = 0; i < n; ++i) {
	if (used[i]) {
	  sum += prices[i];
	}
      }
      ans = min(ans, sum);
    }
    return;
  }

  rec(cur + 1, learnt, used);
  
  for (int i = 0; i < m; ++i) {
    learnt[i] += a[cur][i];
  }
  used[cur] = true;
  rec(cur + 1, learnt, used);
}

int main() {
  cin >> n >> m >> x;

  for (int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    prices.push_back(c);
    vector<int> t(m); 
    for (int j = 0; j < m; ++j) cin >> t[j];
    a.push_back(t);
    
  }
  vector<int> l(m, 0);
  vector<bool> u(n, false);
  rec(0, l, u);
  if (ans == INF) {
    puts("-1");
  } else {
    cout << ans << '\n';
  }
  return 0;
}



Measured memory_bytes: 3640
N, M = map( int, input().split())
Q = [[int(s) for s in input().split()] for _ in range(M)]
Q = sorted(Q)
ans = 1
LQ = len(Q)
while LQ != 0:
    stan = Q[0][1]
    k = 1
    while LQ != 0:
        if Q[0][0] < stan:
            stan = min(stan,Q.pop(0)[1])
            LQ -= 1
        else:
            ans += 1
            break
print(ans)

Measured memory_bytes: 23284
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int h,w,a,b;
	std::cin >> h >> w >> a >> b;
	std::vector<std::vector<int> > mat(h,std::vector<int>(w,0));
	rep(i,a) rep(j,b) {
		mat[j][i]=1;
	}
	for(int i=a;i<w;i++) for(int j=b;j<h;j++) mat[j][i]=1;

	for(auto v:mat) {
		for(auto i:v) std::cout << i;
		std::cout << ENDL;
	}

	return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int A, B;
	cin >> A >> B;
	if (max(A, B) > 8) {
		cout << ":(";
		return 0;
	}
	cout << "Yay!";
}

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

Measured memory_bytes: 2444
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 2005;

int a[N * 3], f[N][N], g[N], gt[N], now, ans;
void update(int x, int y, int t) {
    f[x][y] = max(f[x][y], t);
    now = max(now, t);
    gt[x] = max(gt[x], t);
    gt[y] = max(gt[y], t);
}
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) f[i][j] = -INF;
    for (int i = 1; i <= n; i++) gt[i] = -INF;
    update(a[1], a[2], 0);
    for (int j = 1; j <= n; j++) g[j] = gt[j];
    ans = now;
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        int x = a[i * 3], y = a[i * 3 + 1], z = a[i * 3 + 2];
        if (x == y && x == z) {
            cnt++;
            continue;
        }
        if (x == y || x == z || y == z) {
            if (x == z) swap(y, z);
            if (y == z) swap(x, z);
            int t = f[z][z];
            int sb = f[x][z]; // 可能会被改掉
            for (int j = 1; j <= n; j++) {
                update(j, z, max(f[j][x], j == z ? sb : f[x][j]) + 1);
            }
            update(x, y, t + 1);
        } else {
            update(x, y, f[z][z] + 1);
            update(x, z, f[y][y] + 1);
            update(y, z, f[x][x] + 1);
        }
        for (int j = 1; j <= n; j++) {
            update(j, x, g[j]);
            update(j, y, g[j]);
            update(j, z, g[j]);
        }
        update(x, y, ans);
        update(x, z, ans);
        update(y, z, ans);
        for (int j = 1; j <= n; j++) g[j] = gt[j];
        ans = now;
    }
    ans = max(ans, f[a[n * 3]][a[n * 3]] + 1);
    printf("%d\n", ans + cnt);
    return 0;
}


Measured memory_bytes: 19528
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; string s; cin >> n >> s;
    int cnt = 0;
    int l = 0, r = n-1;
    
    while(l < r){
        while(s[l] != 'W' && l < r){
            l++;                
        }
        while(s[r] != 'R' && l < r){
            r--;
        }
        if(l < r){
            cnt++;
            l++; r--;
        }
    }
    cout << cnt << endl;
    return;
}

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

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	long long r = 1;
	int s = 0;
	for (int i = 0; i < N; ++ i) {
		while (s < i) {
			if (A[i-1] < 2*i-1-2*s) ++ s; else break;
		}
		int n = i - s + 1;
		(r *= n) %= mod;
	}
	cout << r << endl;
}


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

int main()
{
    int h, m, s;
    
    cin  >> s;
    h = s/3600;
    m = (s%3600)/60;
    s = (s%3600)%60;
    cout << h <<":"<< m << ":" << s << "\n";
    return 0;
}


Measured memory_bytes: 3088
import java.util.*;

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

        Scanner scan = new Scanner(System.in);
		
      	int N = scan.nextInt();
      
      	if(N == 1){
        	System.out.println(1); 
        	return;
        }
      	
      	System.out.println(N * N * N);
       	
    }
}


Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTollGates solver = new BTollGates();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTollGates {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int x = in.nextInt();
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < m; i++) set.add(in.nextInt());
            int lcost = 0, rcost = 0, cost;
            for (int i = x + 1; i < n; i++) {
                if (set.contains(i)) rcost++;
            }
            for (int i = x - 1; i > 0; i--) {
                if (set.contains(i)) lcost++;
            }
            cost = Math.min(lcost, rcost);
            out.println(cost);
        }

    }
}



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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll max_number = 1e6;
    vector<ll> zyu(max_number+1,0);
    vector<bool> moto(max_number+1, false);
    vector<bool> moto2(max_number+1, true);
    for(i = 0;i < n;++i){
        ll a;
        cin >> a;
        ++zyu.at(a);
        moto.at(a) = true;
    }
    for(i = 0;i <= max_number;++i){
        if(moto.at(i) & moto2.at(i)){
            for(j = 2*i;j <= max_number;j += i){
                moto2.at(j) = false;
            }
        }
    }
    ll ans = 0;
    for(i = 0;i <= max_number;++i){
        if(moto.at(i) && moto2.at(i) && zyu.at(i) == 1) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11444
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<(n); ++i)
using namespace std;
typedef long long ll;
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;

    cin >> N;

    rep1(i, 10)
    {
        rep1(j, 10)
        {
            if (i * j == N)
            {
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";
 
    return 0;
}

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

int main() {
  int H,W;
  cin >> H>>W;
  vector <string> img(H);
  for(int i=0;i<H;i++){
    cin >> img.at(i);
  }
  for(int i=0;i<W+2;i++)
    cout<<"#";
  cout <<endl;
  for(int i=0;i<H;i++){
  cout<<"#";
  cout<<img.at(i);
    cout<<"#"<<endl;
  }
   for(int i=0;i<W+2;i++)
    cout<<"#";
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll x, y, z, k;

	cin >> x >> y >> z >> k;

	vector<ll> v1(x, 0);
	vector<ll> v2(y, 0);
	vector<ll> v3(z, 0);
	vector<ll> v4, v5;

	REP(i, x) {
		cin >> v1[i];
	}

	REP(i, y) {
		cin >> v2[i];
	}

	REP(i, z) {
		cin >> v3[i];
	}

	REP(i, x) {
		REP(j, y) {
			v4.push_back(v1[i] + v2[j]);
		}
	}

	sort(v4.begin(), v4.end(), greater<ll>());

	REP(i, min(k, x * y)) {
		REP(j, z) {
			v5.push_back(v4[i] + v3[j]);
		}
	}

	sort(v5.begin(), v5.end(), greater<ll>());

	REP(i, k) {
		cout << v5[i] << endl;
	}
}

Measured memory_bytes: 43240
/* 
 * Author: pawanmsr
 */

// #include <iostream>
// #include <iomanip>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <queue>
// #include <deque>
// #include <bitset>
// #include <iterator>
// #include <list>
// #include <stack>
// #include <map>
// #include <set>
// #include <functional>
// #include <numeric>
// #include <utility>
// #include <limits>
// #include <fstream>
// #include <cstring>

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
int n;

// Functions //
void normal(char q, string x) {
    if (x.length() == n) cout << x << endl;
    else {
        for (char i='a'; i<=q; i++)
            normal(i==q ? char(q + 1) : q, x + i);
    }
}

// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    cin >> n;
    string x = "";
    normal('a', x);
    return 0;
}


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

int main(){
        int N,D,X; cin>>N>>D>>X;
        vector<int> A(N);
        for(int i=0; i<N; i++){
                cin>>A[i];
                X+=D/A[i]+(D%A[i]?1:0);
        }
        cout<<X<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int[] a=fs.readArray(n);
		sort(a);
		
		long ans=0;
		ArrayList<Integer> res=new ArrayList<>();
		res.add(a[n-1]);
		for (int i=n-2; i>=0; i--)
			for (int j=0; j<2; j++) res.add(a[i]);
		for (int i=0; i<n-1; i++) ans+=res.get(i);
		System.out.println(ans);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 61888
<?php
// Your code here!
list($x,$y) = explode(" ", trim(fgets(STDIN)));
$turu = 2;
$kame = 4;

if($y % 2 != 0){
    echo "No";
    exit;
}
if($x * 4 < $y){
    echo "No";
    exit;
}

for($i=0;$i<=$x;$i++){
    // ($x-$i.$i);
    if(($x-$i) * 2 + $i * 4 == $y){
        echo "Yes";
        exit;
    }
}
echo "No";

?>


Measured memory_bytes: 16156
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var l1 = o.getArray(0);
    var N = l1[0];
    var K = l1[1];
    var hs = o.getArray(1);

    var results = hs.filter(function (h) {
        return h >= K;
    });

    return results.length;
}


Measured memory_bytes: 28620
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,C,K;
	while(cin>>N>>C>>K) {
		VI T(N);
		REP(i, N) cin>>T[i];
		sort(ALL(T));
		ll ans=0, t=-INF, n=0;
//		DD(T);
		REP(i, N) {
//			DD(i);
//			DD(t);
//			DD(n);
			if(T[i]<=t&&t<=T[i]+K && n<C) {
				n++;
			} else {
//				DD("new bus");
				ans++;
				t=T[i]+K;
				n=1;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

ll N;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;

	ll imax = sqrt(N);
	for(ll i=imax;i>0; i--) {
		ll p = N/i;
		ll r = N%i;

		if(r==0) {
			cout << (i-1)+(p-1) << endl;
			return 0;
		}
	}

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll mx=-1,sum=0,n;cin>>n;
	ll a[n],b[n],c[n-1];
	rep(i,0,n)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	rep(i,0,n-1)cin>>c[i];
	ll ans=0;
	rep(i,0,n){
		ans+=b[a[i]-1];
		if(i>=1)if(a[i]==a[i-1]+1)ans+=c[a[i-1]-1];
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split(" ");
  var A = Number(input[0]);
  var B = Number(input[1]);
  var C = Number(input[2]);
  var result = 0;

  var water = B + C;
  if(A < water){
    result = water - A;
  }
  else{
    result = 0;
  }
  console.log(result)
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACatsAndDogs solver = new ACatsAndDogs();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACatsAndDogs {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), x = in.nextInt() - a;
            out.println(0 <= x && x <= b ? "YES" : "NO");
        }

    }
}



Measured memory_bytes: 25172
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

#include <boost/format.hpp>

using namespace std;

# define p(s) cout << s << endl;
# define printStr(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

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

    printStr(n<=999,"ABC","ABD");
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
x = abs(30*H +0.5*M -6*M)
c = min(x,360-x)
ans = (A ** 2) + (B ** 2)  - (2 * A * B * math.cos(math.radians(c)))
#print(ans,c,math.cos(math.radians(c)))
ans = math.sqrt(ans)
print(ans)

Measured memory_bytes: 9440
n = int(input())
s = list(str(input()))
list_check = []
num_east = 0
for i in range(0,n):
    if s[i] == "E":
        num_east += 1
    list_check.append(num_east)

calc_min = 10 ** 9
for i in range(0,n):
    if s[i] == "E":
        calc = ( (i+1) - list_check[i] ) + (list_check[-1] - list_check[i])
    else:
        calc = ( (i) - list_check[i] ) + (list_check[-1] - list_check[i])
    if calc_min > calc:
        calc_min = calc

print(calc_min)


Measured memory_bytes: 17528
import math
n = int(input())
a_e_list = []
for i in range(5):
  a_e_list.append(int(input()))
score = 0  
for i in range(5):
  if i == 0:
    score += math.ceil(n /a_e_list[0])
  else:
    s = n - a_e_list[i] * (score - i)
    if s <= 0:
      score += 1
    else:
      score += math.ceil(s/a_e_list[i])

      
print(score)
      
  
  
  


Measured memory_bytes: 3060