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

using namespace std;

int main()
{
    long long int N,m=0,n=1,P=0;
    cin>>N;
    P=N;
    while(n!=0)
    {
       if(N/10==0) n=0;
       m=m+N%10;
       N=N/10;
    }
    if(P%m==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3552
abc = sorted(list(map(int, input().split())))

ans = 0
while len(set(abc)) != 1:
    ans += 1
    if abc[-1] - abc[0] >= 2:
        abc[0] += 2
    else:
        abc[0] += 1
        abc[1] += 1

    abc.sort()

print(ans)


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

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

int m = 1000000;
bool prime[100000000];

void eratos(int n) {
    for (int i = 0; i < n; ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for (int i = 2; i < sqrt(n); ++i) {
        if (prime[i]) {
            for (int j = i+i; j <= n; j += i) prime[j] = false;
        }
    }
}

int main() {
    eratos(m);

    int a, d, n;
    while (cin >> a >> d >> n && a && d && n) {
        int c = 0;
        for (int i = a; i < m; i += d)
            if (prime[i])
                if (++c == n) { cout << i << endl; break; }
    }
}

Measured memory_bytes: 3936
#include <iostream>
#include <stdio.h>
using namespace std;
int n,c=0,i,x;
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(i%2&&x%2)
            c++;
    }
    printf("%d",c);
    return 0;
}


Measured memory_bytes: 3812
N, M = map(int, input().split())

ans = [-1] * N

for _ in range(M):
    s, i = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != i:
        print(-1)
        exit()
    ans[s] = i

if N > 1 and ans[0] == -1:
    ans[0] = 1

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

ans = int(''.join(map(str, ans)))

if len(str(ans)) != N:
    print(-1)
    exit()

print(ans)

Measured memory_bytes: 3064
I = input
s = I()
q = int(I())
a = [], []
i = 0
for _ in range(q):
  x = I()
  if x[0] == '1':
    i ^= 1
  else:
    f = int(x[2]) - 1
    a[i ^ f].append(x[4])
r = ''.join(reversed(a[0])) + s + ''.join(a[1])
print(r[::-1] if i else r)


Measured memory_bytes: 6272
/*
  AOJ 2629
  Title:Manhattan
  @kankichi573
*/
#include <stdio.h>
#include <float.h>
#include <math.h>

main()
{

  double ret,a,r2=sqrt(2.0);
  
  scanf("%lf",&a);
  if(a<=r2/2)
    ret=1.0;
  else if (a>=1.0 && a<=r2)
    ret=2.0;
  else if (a>=2.0 && a<=3/r2)
    ret=3.0;
  else
    ret=a*r2;
  printf("%2.12lf\n",ret);

  return(0);
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll s;
int main() {
	cin >> s;
	if (s == 1e18) {
		cout << "1000000000 0 0 0 0 1000000000" << endl;
		return 0;
	}
	if (s <= (ll)1e9) {
		cout << "0 0 1 0 0 " << s << endl;
	}
	else {
		ll sq = sqrt(s);
		ll b;
		if (sq * (sq + 1) > s) b = sq + 1;
		else {
			sq++;
			b = sq;
		}
		cout << "0 " << sq << " " << b << " " << sq - 1 << " " << b - s % b << " 0" << endl;
	}
}





Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=200000;
int main(){
	int R[MAX],n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>R[i];
	int maxv=-2000000000;
	int minv=R[0];
	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);
		minv=min(minv,R[i]);
	}
	cout<<maxv<<endl;
	return 0;
}


Measured memory_bytes: 3816
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n>>m;
  pri1(max(0,n-2*m));
}

Measured memory_bytes: 896
n = gets.to_i
numbers = gets.split(' ').map(&:to_i)
alice = []
bob = []

while numbers.length > 0
  max = numbers.max
  i = numbers.index(max)
  numbers.delete_at(i)

  alice << max

  break unless numbers.length > 0

  max = numbers.max
  i = numbers.index(max)
  numbers.delete_at(i)

  bob << max
end

puts (alice.inject(:+) - bob.inject(:+)).abs

Measured memory_bytes: 1788
n=int(input())
ss=[x for x in input().split()]     
ss2=ss.copy()

def BubbleSort(C, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if (C[j][1] < C[j-1][1]):
                C[j], C[j-1] = C[j-1], C[j]
#                 print(C, i, j)
    return C

def SelectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if(C[j][1] < C[minj][1]):
                minj = j
        C[minj], C[i] = C[i], C[minj]
    return C

ss = BubbleSort(ss, len(ss))
ss2 = SelectionSort(ss2, len(ss2))
output = [[str(t) for t in row ] for row in ss]
print(" ".join([ "".join(row) for row in output]))
print('Stable')
output = [[str(t) for t in row ] for row in ss2]
print(" ".join([ "".join(row) for row in output]))
if(ss == ss2):
    print('Stable')
else:
    print('Not stable')



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

int main()
{
    int n,i;
    cin >> n;
    vector<long long> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    bool flag = true;
    long long longer = 0,shorter = 0;
    for(i = n-2;i >= 0;--i){
        if(flag){
            if(a.at(i+1) == a.at(i)){
                longer = a.at(i);
                --i;
                flag = false;
            }
        }else{
           if(a.at(i+1) == a.at(i)){
                shorter = a.at(i);
                break;
            } 
        }
    }
    cout << longer*shorter << endl;
    return 0;
}

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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000009
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    LLI W, H, x, y;
    cin >> W >> H >> x >> y;
    printf("%1.16f %d", W * H * 0.5, (x * 2 == W && y * 2 == H));

    return 0;
}

Measured memory_bytes: 256
N=int(input())
for i in range(N):
    a,b,c=map(int,input().split())
    A=a*a
    B=b*b
    C=c*c
   
   
    if a>b and a>c and A==B+C:
        print('YES')
    elif b>a and b>c and B==A+C:
        print('YES')
    elif c>a and c>b and C==A+B:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5596
import java.util.Scanner

object Main {
  def main(args:Array[String]) = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    if (3 <= N && N <= 100) {
      val Ls = List.fill(N)(sc.nextInt())

      val s = Ls.sortWith((a, b) => a > b)
      if (s.head < s.tail.sum) println("Yes") else println("No")
    } else {
      println("No")
    }

  }
}

Measured memory_bytes: 27172
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int K;cin>>K;
	string s;cin>>s;
	if(len(s)<=K)cout<<s<<endl;
	else cout<<s.substr(0,K)+"..."<<endl;
}


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


int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  int dp[N]={};
  for (int i=1;i<N;i++){
    if (S.at(i)=='E') dp[0]++;
  }
  for (int i=1;i<N;i++){
    if (S.at(i)==S.at(i-1)){
      if (S.at(i)=='E') dp[i] = dp[i-1]-1;
      if (S.at(i)=='W') dp[i] = dp[i-1]+1;
    }
    else dp[i] = dp[i-1];
  }
  sort(dp, dp+N);

  cout << dp[0] << endl;

}
 

Measured memory_bytes: 1796
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(){
	int n;
	
	while (cin >> n, n){
		REP(i,n){
			int m, e, j;
			
			scanf("%d %d %d", &m, &e, &j);
			
			if (m == 100 || e == 100 || j == 100){
				cout << "A" << endl;
			}
			else if (m+e >= 90*2){
				cout << "A" << endl;
			}
			else if (m+e+j >= 80*3){
				cout << "A" << endl;
			}
			else if (m+e+j >= 70*3){
				cout << "B" << endl;
			}
			else if (m+e+j >= 50*3 && (m >= 80 || e >= 80)){
				cout << "B" << endl;
			}
			else cout << "C" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3152
#include <cstdio>

using namespace std;

#define MAX 500000
#define INF 2000000000; 

int count = 0;

void merge(int A[], int left, int mid, int right) {
	int n1, n2;
	int L[MAX/2 + 2], R[MAX / 2 + 2];
	n1 = mid - left;
	n2 = right - mid;
	
	for (int i = 0; i < n1; i++){
		L[i] = A[left + i];
	}

	for (int j = 0; j < n2; j++) {
		R[j] = A[mid + j];
	}
	L[n1] = R[n2] = INF; //番兵
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		count++;
		if(L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}else {
			A[k] = R[j];
			j++;
		}
	}
}


void mergeSort(int A[], int left, int right) {	
	if(left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}


int main(){
	int n;
	int A[MAX];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	mergeSort(A, 0, n);

	for (int i = 0; i < n; i++) {
		i != (n-1) ? printf("%d ", A[i]) : printf("%d\n", A[i]);
	}

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




Measured memory_bytes: 6580
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define orep(i, n) for (int i = 1; i <= (int)n; i++)
#define vec vector
#define pb push_back

vec<vec<int>> good = {{0, 0}, {2, 1}, {3, 2}, {1, 3}};
vec<vec<char>> GOOD = {{'S', 'W'}, {'S', 'W'}, {'W', 'S'}, {'W', 'S'}};
vec<vec<int>> bad = {{1, 3}, {2, 1}, {0, 0}, {3, 2}};
vec<vec<char>> BAD = {{'W', 'S'}, {'S', 'W'}, {'S', 'W'}, {'W', 'S'}};
// {"SSS", "SWW", "WWS", "WSW"};
// {"SSW", "WWW", "WSS", "SWS"};

int func(string s, int start)
{
	s += s[0];
	int prev = start;
	string ans;
	if (s[0] == 'o') {
		if (start == 0) ans = "SSS";
		else if (start == 1) ans = "SWW";
		else if (start == 2) ans = "WWS";
		else ans = "WSW";
	} else {
		if (start == 0) ans = "SSW";
		else if (start == 1) ans = "WWW";
		else if (start == 2) ans = "WSS";
		else ans = "SWS";
	}

	rep(i, s.length() - 1) {
		if (s[i] == 'o' && s[i + 1] == 'o') {
			ans += GOOD[prev][0];
			prev = good[prev][0];
		} else if (s[i] == 'o' && s[i + 1] == 'x') {
			ans += GOOD[prev][1];
			prev = good[prev][1];
		} else if (s[i] == 'x' && s[i + 1] == 'o') {
			ans += BAD[prev][0];
			prev = bad[prev][0];
		} else {
			ans += BAD[prev][1];
			prev = bad[prev][1];
		}
	}
	if (start == prev) {
		for (int i = 1; i < ans.length() - 2; i++) cout << ans[i];
		cout << endl;
		return 1;
	} else return 0;
}

int main(void)
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	if (s[0] == 'o') {
		rep(i, 4) {
			if (func(s, i)) return 0;
		}
		cout << - 1 << endl;
	} else {
		rep(i, 4) {
			if (func(s, i)) return 0;
		}
		cout << - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
char s[15];
int main(){
	scanf("%s",s+1);
	if(strlen(s+1)<4)puts("No");
	else if(s[1]!='Y')puts("No");
	else if(s[2]!='A')puts("No");
	else if(s[3]!='K')puts("No");
	else if(s[4]!='I')puts("No");
	else puts("Yes");
	return 0;
}

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



int main(void) {

	int N, f, b, s1 = 0, s2 = 0;
	int W[101];

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

	f = 0;
	b = N - 1;

	while (!(b<f)) {
		if (s1 <= s2) {
			s1 += W[f];
			f++;
		}
		else {
			s2 += W[b];
			b--;
		}
	}

	cout << (max(s1, s2) - min(s1, s2)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long n,t=1,i,m=1;
    cin>>n;
    long long ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
        if(ara[i]==0){
            t=0;
        }
    }
    if(t==1){
        for(i=0;i<n;i++){
            if(m>1000000000000000000/ara[i]){
                m=-1;
                break;
            }
            else{
                m*=ara[i];
            }
        }
        cout<<m<<endl;
    }
    else
         cout<<0<<endl;

    return 0;
}



Measured memory_bytes: 4372
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;
  string t;
  
  cin >> s >> t;
  cout<<t<<s<<endl;
  return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) //cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 5e5 + 10;
const ll INF = (ll) LONG_LONG_MAX / 100;
const ld EPS = (ld) 1e-8;
const ll P = 104107;

ll mul(ll a, ll b){
	return (a * b) % MOD;
}

ll pw(ll b, ll p){
	if(p == 0) return 1;
	if(p & 1) return mul(b, pw(b, p - 1));
	return pw(mul(b, b), p / 2);
}
ll inv(ll x){
	return pw(x, MOD - 2);
}

ll a[MAXN];
vector<ll> V[MAXN];
map<ll, ll> mp;
ll dp[MAXN];
ll ps[MAXN], ps2[MAXN];

int main(){
	ll n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	ps[1] = a[1];
	for(int i = 2; i <= n; i++) ps[i] = ps[i - 1] ^ a[i];
	ll rr = 1;
	for(int i = 1; i <= n; i++){
		if(mp.count(ps[i]) == 0){
			mp[ps[i]] = rr;
			rr ++;
		}
		V[mp[ps[i]]].pb(i);
	}
	for(int i = 1; i <= n; i++) ps2[i] = ps2[i - 1] + (ps[i] == 0);
	
	ll m , cnt,s, ans = 0;
	for(auto x : mp){
		debug(x.F);
		if(x.F == 0) continue;
		if(ps[n] != 0 and ps[n] != x.F) continue;
		
		m = V[x.S].size();
		s = 1;
		ll lt = -1;
		dp[0] = 1;
		if(ps[n] == 0) ans ++;
		lt = 0;
		for(int i = 1; i < m; i ++){
			debug(i);
			cnt = 0;
			if(lt != -1) cnt = ps2[V[x.S][i]] - ps2[V[x.S][lt]];
			
			dp[i] = (dp[i - 1] - 1ll) + (cnt * s) + 1ll;
			dp[i] %= MOD;
			if(ps[n] == 0) ans += dp[i];
			ans %= MOD;
			s += dp[i];
			s %= MOD;
			lt = i;
		}
		if(ps[n] != 0) ans += dp[m - 1];
		ans %= MOD;
	}
	debug(ans);
	if(ps[n] == 0) ans += pw(2, V[mp[0]].size() - 1);
	cout << ((ans % MOD) + MOD) % MOD;
	return 0;
}


/*
fuck hashal
*/



Measured memory_bytes: 53872
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
    const ll INF = 1LL << 60;

    ll dp[100010];

    REP(i,100010)dp[i]=INF;

    dp[0] = 0;

    int N;
    cin >> N;
    vint H(N);
    cin >> H;
    for(int i=1; i<N; i++){
        chmin(dp[i],dp[i-1] + abs(H[i] - H[i-1]));
        if(1 < i){
            chmin(dp[i],dp[i-2] + abs(H[i] - H[i-2]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	cout << N / 3 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1, 0, 1, 1, -1, -1}, dx = {1,-1,0,0, 0, 1, -1, 1, -1};
//vector<int> dy = {0, 0, 1, -1}, dx = {1, -1, 0, 0};

int N, Q;
int N_ = 1;
const int segSize = (1 << 18) - 1;
vector<ll> Seg(segSize, INT_MAX), lazySeg(segSize);
bool lated[segSize];

void eval(int k, int l, int r){
    if(lated[k]){
        Seg[k] = lazySeg[k];
        if(r - l > 1){
            lazySeg[2*k+1] = lazySeg[k];
            lazySeg[2*k+2] = lazySeg[k];
            lated[2*k+1] = 1;
            lated[2*k+2] = 1;
        }
        lated[k] = 0;
    }
}

void update(int a, int b, int x, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
        lazySeg[k] = x;
        lated[k] = 1;
        eval(k, l, r);
    }
    else{
        update(a, b, x, 2*k+1, l, (l+r)/2);
        update(a, b, x, 2*k+2, (l+r)/2, r);
        Seg[k] = min(Seg[2*k+1], Seg[2*k+2]);
    }
}

int find(int a, int b, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return INT_MAX;
    if(a <= l && r <= b) return Seg[k];
    return min(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
}


int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cin >> N >> Q;
    while(N_ < N) N_ *= 2;
    for(int i = 0; i < 2*N_+1; i++) Seg[i] = 2147483647;
    
    for(int i = 0; i < Q; i++){
        int com; cin >> com;
        if(com == 0){
            int s, t, x; cin >> s >> t >> x;
            update(s, t+1, x, 0, 0, N_);
        }else{
            int s, t; cin >> s >> t;
            cout << find(s, t+1, 0, 0, N_) << endl;
        }
    }
}


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

class cD
{
public:
	void N()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[2];
		nD[2] = nD[6];
		nD[6] = nD[5];
		nD[5] = nTemp;
	}

	void S()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[5];
		nD[5] = nD[6];
		nD[6] = nD[2];
		nD[2] = nTemp;
	}

	void W()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[3];
		nD[3] = nD[6];
		nD[6] = nD[4];
		nD[4] = nTemp;
	}

	void E()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[4];
		nD[4] = nD[6];
		nD[6] = nD[3];
		nD[3] = nTemp;
	}

	void Rotate()
	{
		int nTemp = 0;
		nTemp = nD[2];
		nD[2] = nD[3];
		nD[3] = nD[5];
		nD[5] = nD[4];
		nD[4] = nTemp;
	}

	int nD[7] = { 0 };
};
int main()
{
	cD D, D2;
	for (int i = 1; i <= 6; i++)
	{
		cin >> D.nD[i];
	}
	for (int i = 1; i <= 6; i++)
	{
		cin >> D2.nD[i];
	}

	int nT = D2.nD[1], nF = D2.nD[2];
	for (int j = 1; j <= 6; j++)
	{
		if (nT == D.nD[j])
		{
			if (1 == j)
			{
				break;
			}
			else if (2 == j)
			{
				D.N();
			}
			else if (3 == j)
			{
				D.W();
			}
			else if (4 == j)
			{
				D.E();
			}
			else if (5 == j)
			{
				D.S();
			}
			else
			{
				D.S();
				D.S();
			}
		}
	}

	int nC = 4;
	int nFlag;
	while (nC--)
	{
		nFlag = 0;
		D.Rotate();
		for (int i = 1; i <= 6; i++)
		{
			if (D.nD[i] == D2.nD[i])
			{
				nFlag++;
			}
		}
		if (6 == nFlag)
		{
			break;
		}
	}

	nC = 4;

	if (6 != nFlag)
	{
		while (nC--)
		{
			nFlag = 0;
			D.N();
			for (int i = 1; i <= 6; i++)
			{
				if (D.nD[i] == D2.nD[i])
				{
					nFlag++;
				}
			}
			if (6 == nFlag)
			{
				break;
			}
		}
	}


	if (6 == nFlag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  size_t n;
  //n=2000;
  cin>>n;
  size_t l[n];
  for(size_t i=0;i<n;i++){
    cin>>l[i];
    //l[i]=rand();
  }
  sort(l,l+n);
  size_t ans=0;
  for(size_t i=0;i<n;i++){
    for(size_t j=i+1;j<n;j++){
      for(size_t k=j+1;k<n;k++){
        ans+=(l[i]+l[j]>l[k]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
	int n,m;

	cin >> n >> m;

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

	
	for (int i = 0; i < n; i++) {
		cout << vec[i] << endl;
	}

}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << "\n";
}

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

#define ll long long
#define ull unsigned long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}

char s[3050];
char t[3050];

ll dp[3050][3050];

ll lens, lent;

void Print(ll i, ll j)
{
  //  cout << i << " " << j << " " << dp[i][j] << endl;
    if (dp[i][j] == 0)
        return ;
    if (s[i] == t[j] && dp[i-1][j-1]+1 >= max(dp[i-1][j], dp[i][j-1]))
    {
        Print(i-1, j-1);
        printf("%c",s[i]);
    }
    else
    {
        if (dp[i-1][j] >= dp[i][j-1])
        {
            Print(i-1, j);
     //       printf("%c", s[i]);
        }
        else
        {
            Print(i, j-1);
   //         printf("%c", t[j]);
        }
    }
}

int main ()
{
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n, cap;

    s[0] = t[0] = '#';

    while(ss(s+1) != EOF)
    {
        ss(t+1);

        ll ans = 0;

        memset(dp, 0, sizeof(dp));
        lens = strlen(s)-1;
        lent = strlen(t)-1;
        for (i = 1; i <= lens; i++)
        {
            for (j = 1; j <= lent; j++)
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                if (s[i] == t[j])
                    dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
            }
        }
        Print(lens, lent);
        printf("\n");
    }
    return 0;
}


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

int main() {
  int H,W;
  while(H!=0 || W!=0) {
      cin >> H >> W;
      for (int i=0 ; i<H ; i++) {
          for (int j=0; j<W; j++) {
              if (i==0 || i==H-1 || j==0 || j==W-1) cout << "#";
              else cout << ".";
              if (j==W-1) cout << endl;
          }
          if (i==H-1) cout << endl;
      }
  }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll memo[100001];
vector<ll> v[100001];

ll hoge(ll i){
    if(memo[i]!=0){
        return memo[i];
    }
    if(v[i].size()==0){
        return 0;
    }
    ll ans=0;
    rep(j,0,v[i].size()-1){
        ans=max(ans,hoge(v[i][j])+1);
    }
    return memo[i]=ans;
}

int main(){fastio
    ll n,m;cin>>n>>m;
    ll x,y;
    rep(i,0,m-1){
        cin>>x>>y;
        v[x].pb(y);
    }
    ll ans=0;
    rep(i,1,n){
        ans=max(ans,hoge(i));
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 8576
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int N, K;
string S;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  cin >> S;
  K--;

  string ans = "";
  for (int i = 0; i < N; i++) {
    if (i == K) {
      if (S[i] == 'A') {
        ans += "a";
      } else if (S[i] == 'B') {
        ans += "b";
      } else {
        ans += "c";
      }
    } else {
      ans += S[i];
    }
  }

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

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 300000
#define LL long long
#define MO 998244353
LL fac[MAXN+5],inv[MAXN+5];
LL powmod(LL a,LL b)
{
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
void Init()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=MAXN;i++)
		fac[i]=i*fac[i-1]%MO;
	inv[MAXN]=powmod(fac[MAXN],MO-2);
	for(int i=MAXN-1;i>=1;i--)
		inv[i]=(i+1)*inv[i+1]%MO;
}
LL n,A,B,k,x,y,d,tot;
LL Solve(int i,int j)
{
	return inv[i]*inv[j]%MO*inv[n-i]%MO*inv[n-j]%MO;
}
int main()
{
	Init();
	scanf("%lld%lld%lld%lld",&n,&A,&B,&k);
	LL ans=0;
	for(int i=0;i<=n&&i*A<=k;i++)
	{
		LL L=k-A*i;
		if(L%B==0&&L/B<=n)
		{
			ans+=Solve(i,L/B);
			if(ans>=MO) ans-=MO;
		}
	}
	printf("%lld\n",ans*fac[n]%MO*fac[n]%MO);
}

Measured memory_bytes: 4864
import sys

N = int(sys.stdin.readline().strip())

S = []
for _ in range(N):
    s_i = sys.stdin.readline().strip()
    S.append(s_i)

# left bracket - right bracketを高さとした、最小の高さと最終的な高さの座標列
# ex)
# ")": (-1, -1)
# "(": (1, 1)
# "()": (1, 0)
# ")()(": (-1, 0)
# "))))(((((: (-4, 1)

plus_seqs = []
minus_seqs = []
for s_i in S:
    h = 0
    min_h = float("inf") 
    for bracket in s_i:
        if bracket == "(":
            h += 1
        else:
            h -= 1
        min_h = min(min_h, h)
            
    if h >= 0:
        plus_seqs.append((min_h, h))
    else:
        # minus_seqs.append((-1 * min_h, -1 * h))
        minus_seqs.append((min_h - h, -1 * h))

# print(plus_seqs)
# print(minus_seqs)

hight = 0
for (min_h, h) in sorted(plus_seqs, reverse=True):
    if hight + min_h < 0:
        print("No")
        sys.exit()
    hight += h

hight2 = 0
for (min_h, h) in sorted(minus_seqs, reverse=True):
    if hight2 + min_h < 0:
        print("No")
        sys.exit()
    hight2 += h

# print(hight, hight2)
if hight == hight2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 199172
#include<iostream>
using namespace std;
 
int main(void){
  int r, g, b, x;
  cin >> r >> g >> b;
  x =r*10*10 + g*10 + b;

  if(x%4==0){
      cout << "YES" << endl;
  }
  else{
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		int b = Integer.parseInt(br.readLine());
		String ans = "No";

		if (a % 500 <= b) {
			ans = "Yes";
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 21076
k, x = map(int, input().split())

A = []
for i in range(k-2, -1, -1):
    A.append(x-i-1)
for i in range(k):
    A.append(x+i)
s = ""
for i in A:
    s += str(i) + " "
print(s[:-1])

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;

string s;
set<int> st[26];
int dp[200005],nex[200005];
string ans;

int solve(int v){
	if(v==s.size()+1) return 0;
	if(dp[v]<1e9)return dp[v];
	for(int i=0;i<26;i++){
		int k=solve(*st[i].upper_bound(v))+1;
		if(k<dp[v]){
			dp[v]=k;
			nex[v]=i;
		}
	}
	return dp[v];
}

void create(int v){
	if(nex[v]==-1)return;
	ans+=(char)('a'+nex[v]);
	create(*st[nex[v]].upper_bound(v));
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> s;
	int n=s.size();
	for(int i=0;i<n;i++){
		st[s[i]-'a'].insert(i+1);
	}
	for(int i=0;i<26;i++){
		st[i].insert(n+1);
	}
	for(int i=0;i<200005;i++){
		dp[i]=1e9;
		nex[i]=-1;
	}
	solve(0);
	ans="";
	create(0);
	cout << ans << endl;
}

Measured memory_bytes: 13844
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

const int N = 100010;
int n,a[N];
int main(){
	scanf("%d",&n);
	ll sum  =0;
	for(int i =0;i<n;i++) scanf("%d",a+i),sum+=a[i];
	ll t =0;
	
	for(int i =0;i<n;i++) t+=a[(i+1)%n]-a[i];
	if(t==0 && sum%(1ll*(1+n)*n/2)==0) {
		ll k = sum/(1ll*(1+n)*n/2);
		bool pd =true;
		for(int i =0;i<n;i++) if((k-(a[(i+1)%n]-a[i]))%n!=0 || k-(a[(i+1)%n]-a[i])<0) pd=  false;
		if(pd) puts("YES") ;else puts("NO");
	} else puts("NO");
	return 0;
}

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

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

    long long lucas[N + 1];
    lucas[0] = 2;
    lucas[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        lucas[i] = lucas[i - 1] + lucas[i - 2];
    }
    cout << lucas[N] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
  int n,t,a;
  cin>>n>>t>>a;
  double cmin=INT_MAX;
  int idx;
  for(int i=0;i<n;i++)
  {
      int h;
      cin>>h;
      double x=t-(h)*(0.006);
      if(cmin>(abs(a-x)))
  {
        idx=i;
        cmin=(abs(a-x));
  }
  }
  cout<<idx+1;


 return 0;
}








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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int M = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> q(N);
    vector<bool> b(N, false);
    for(int i = 0; i < N; ++i) {
        cin >> q[i];
        for(int x = 2; x * x <= q[i]; ++x) {
            if(q[i] % x == 0) b[i] = true;
        }
    }

    // dp[i][pre is p]
    vector<vector<int>> dp(N + 1, vector<int>(2));
    dp[0][0] = 1;
    for(int i = 0; i < N; ++i) {
        if(i == 0 && !b[i]) {
            dp[i + 1][1] = 1;
            continue;
        }
        for(int j = 0; j < 2; ++j) {
            if(j == 0) {
                if((i < 2 || (q[i - 2] != q[i] && q[i - 2] < q[i]))
                    && !b[i]) {
                    (dp[i + 1][1] += dp[i][j]) %= M;
                }
            } else { // pre is p
                if(q[i - 1] == q[i]) {
                    (dp[i + 1][0] += dp[i][j]) %= M;
                } else {
                    if(q[i - 1] < q[i] && !b[i]) {
                        (dp[i + 1][1] += dp[i][j]) %= M;
                    }
                    (dp[i + 1][0] += dp[i][j]) %= M;
                }
            }
        }
    }
    int ans = (dp[N][0] + dp[N][1]) % M;
    cout << ans << endl;
}



Measured memory_bytes: 8584
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <string>
#include <queue>
#include <map>
#include <stack>
#define inf 0x7fffffff
#define int long long

using namespace std;

int n, a[2000005], l[2000005], r[2000005];
stack<int> s;

signed main(void) {
	scanf("%lld", &n);
	for(int i=1; i<=n; i++) scanf("%lld", &a[i]);
	for(int i=1; i<=n; i++) {
		while(!s.empty() && a[s.top()]>=a[i]) s.pop();
		l[i] = s.empty() ? (i) : (i-s.top());
		s.push(i);
	}
	while(!s.empty()) s.pop();
	for(int i=n; i>=1; i--) {
		while(!s.empty() && a[s.top()]>=a[i]) s.pop();
		r[i] = s.empty() ? (n-i+1) : (s.top()-i);
		s.push(i);
	}
	int ans = 0;
	for(int i=1; i<=n; i++) ans += (l[i]*r[i])*a[i]/*, cout<< l[i]<< ' '<< r[i]<< '\n'*/;
	cout<< ans<< '\n';
} 

Measured memory_bytes: 9984
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define SUM_MAX 3000

struct pair {
    int whole;
    int sugar;
};

int main(void) {
    int wa, wb;
    get_int2(&wa, &wb);
    int sa, sb;
    get_int2(&sa, &sb);
    int ulimit, sum;
    get_int2(&ulimit, &sum);

    static char water_cand[31];
    water_cand[0] = 1;
    int i, j;
    for(i = 0; i <= 30; i++) {
        for(j = 0; j <= 30; j++) {
            int w = wa*i+wb*j;
            if(w*100 > sum) continue;
            water_cand[w] = 1;
        }
    }
    static char sugar_cand[3001];
    for(i = 0; i <= 3000; i++) {
        for(j = 0; j <= 3000; j++) {
            int s = sa*i+sb*j;
            if(s > sum) break;
            sugar_cand[s] = 1;
        }
    }

    int w, s;
    struct pair sol = {wa*100, 0};
    double density = 0;
    for(w = 1; w <= 30; w++) {
        if(!water_cand[w]) continue;;
        for(s = 1; s <= sum; s++) {
            if(!sugar_cand[s]) continue;
            int whole = w*100+s;
            // too much sugar
            if(s > ulimit*w) break;
            if(whole > sum) break;
            double d = (double)s*100/whole;
#ifdef DEBUG
            printf("water: %d, salt: %d -> %lf\n", w*100, s,d);
#endif
            // update
            if(d > density) {
                sol = (struct pair){.whole=whole, .sugar=s};
                density = d;
            }
        }
    }

    printf("%d %d\n", sol.whole, sol.sugar);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, c, k;
	cin >> n >> c >> k;
	vector<lli> t(n);
	rep(i,n) cin >> t[i];
	sort(all(t));
	int cnt=1;
	lli ans=0;
	lli memo = t[0];
	loop(i, 1, n){
		if(t[i] <= memo+k && cnt<c){
			cnt++;
		}else{
			memo = t[i];
			cnt = 1;
			ans++;
		}
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


int n;
P p[114514];
signed main() {
	cin >> n;
	int mal = 0, mir = inf;
	rep(i, n) {
		cin >> p[i].first >> p[i].second; p[i].second++;
		chmax(mal, p[i].first); chmin(mir, p[i].second);
	}
	int ans = 0;
	rep(i, n) {
		chmax(ans, max(0ll, mir - mal) + p[i].second - p[i].first);
	}
	rep(i, n) {
		int a = -max(0ll, mir - p[i].first);
		int b = max(0ll, p[i].second - mal);
		p[i] = { b,a };
	}
	sort(p, p + n);
	int memo = inf;
	rep(i, n) {
		P q = p[i];
		if (i) {
			chmax(ans, memo + q.first);
		}
		chmin(memo, -q.second);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>

int main(int argc, char const* argv[])
{
	std::map<std::string,std::vector<unsigned>> index;
	std::vector<std::string> words;
	std::string word;
	unsigned page;
	while (std::cin >> word >> page) {
		if (index[word].size()==0)
			words.push_back(word);
		index[word].push_back(page);
	}
	std::sort(words.begin(),words.end());
	for (auto& s : words) {
		std::cout << s << std::endl;
		auto& cindex = index[s];
		std::sort(cindex.begin(),cindex.end());
		bool b{false};
		for (auto& p : cindex) {
			if (b) {
				std::cout << ' ';
			}
			b = true;
			std::cout << p ;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3136
import std.stdio, std.string, std.conv, std.math;
void main() {
	int n = readln.chomp.to!int;
	long debt = 100000;
	foreach(i;0..n) debt = ((((debt + (debt*0.05)) / 1000.0).ceil) * 1000).to!long;
	debt.writeln;
}

Measured memory_bytes: 2432
a = [ list(map(int,input().split())) for i in range(3)]    # 二重リスト（配列）に標準入力　
n = int(input())                                           # 標準入力（整数）
d = [[0 for i in range(3)] for j in range(3)]              # 要素が全て0の３×３の二重リスト（配列）

for k in range(n):              #  n回繰り返す
    b = int(input())            #　標準入力（整数）
    for i in range(3):          
        for j in range(3):
            if a[i][j] == b:    #  aに、bと同じ数字があるか見る
                d[i][j] = 1     #　あれば、対応するdに1を代入

ans = 'No'                      #  最初はNoと仮定
count = 0

ans = 'No'
for i in range(3):
    if ans == 'Yes':
        break;
    count = 0
    for j in range(3):
        count += d[i][j]
        if count == 3:
            ans = 'Yes'
        
for i in range(3):
    if ans == 'Yes':
        break;
    count = 0
    for j in range(3):
        count += d[j][i]
    if count == 3:
        ans = 'Yes'


# 左上から右下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][i]
    if count == 3:
        ans = 'Yes'

#右上から左下にかけて斜めにビンゴしているか確認
count = 0
for i in range(3):
    if ans == 'Yes':
        break;
    count += d[i][2 - i]
    if count == 3:
        ans = 'Yes'
            

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,k;
struct Permutation{
	int a[101000];
	int& operator [] (int x){return a[x];}
	void init(){
		for(int i=1;i<=n;i++) read(a[i]);
	}
}P,Q;
Permutation inv(Permutation p){
	Permutation res;
	for(int i=1;i<=n;i++) res[p[i]]=i;
	return res;
}
Permutation operator * (Permutation p1,Permutation p2){
	Permutation res;
	for(int i=1;i<=n;i++) res[i]=p1[p2[i]];
	return res;
}
Permutation fp(Permutation a,int k){
	Permutation res;
	for(int i=1;i<=n;i++) res[i]=i;
	for(;k;k>>=1,a=a*a)
		if(k&1) res=a*res;
	return res;
}
int main(){
	read(n);read(k);
	P.init();
	Q.init();
	Permutation ans,res,f[10];
	res=Q*inv(P)*inv(Q)*P;
	f[1]=P;f[2]=Q;
	for(int i=3;i<=6;i++) f[i]=f[i-1]*inv(f[i-2]);
	ans=fp(res,(k-1)/6)*f[(k-1)%6+1]*fp(inv(res),(k-1)/6);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 20096
import java.io.FileInputStream
import java.util.*


var sc: Scanner = Scanner(System.`in`)
fun main(args: Array<String>) {
    if (args.size > 0) {
        System.setIn(FileInputStream(args[0]))
    }
    sc = Scanner(System.`in`)

    problem()

}

fun problem() {

    val A = sc.nextInt()
    val B = sc.nextInt()
    val C = sc.nextInt()

    if (A + B >= C) {
        println("Yes")
    }
    else {
        println("No")
    }

    //var ans = sortedList.joinToString("")
    //println(Q)
}


Measured memory_bytes: 31268
n, q = map(int, input().split())
process = []
for _ in range(n):
    name, time = input().split()
    process.append([name, int(time)])
process.append([])

def reduce(index):
    left_time = process[index][1] - q
    return [process[index][0], left_time]

head = 0
tail = n
quene_len = len(process)
elapsed_time = 0

while head != tail:
    if process[head][1] > q:
        process[tail] = reduce(head)
        elapsed_time += q
        head = (head+1)%quene_len
        tail = (tail+1)%quene_len
    else:
        elapsed_time += process[head][1]
        print(process[head][0], elapsed_time)
        head = (head+1)%quene_len


Measured memory_bytes: 14220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  char S;
  cin>>S;
  cout<<char(S+1)<<endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var red = 0;
            var blue = 0;
            var ans = 0;
            for (int i = 0; i < S.Length; i++)
            {
                var chk = S[i];
                if (chk == '0')
                {
                    if (blue > 0)
                    {
                        blue--;
                        ans += 2;
                    }
                    else
                    {
                        red++;
                    }
                }
                else if (chk == '1')
                {
                    if (red > 0)
                    {
                        red--;
                        ans += 2;
                    }
                    else
                    {
                        blue++;
                    }
                }
            }            

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld ;
#define pb push_back
#define fi first
#define se second
const int N = 1e5+6;
const ll mod = 1e9+7;
void solve(){
    int n,m;
    cin>>n>>m;
    string a = "";
    string b = "";
    for(int i=0;i<n;i++){
        a+=char('0'+m);
    }
    for(int i=0;i<m;i++){
        b+=char('0'+n);
    }
    cout<<min(a,b)<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    preprocess();
    int t =1;
 //   cin>>t;
    while(t--)solve();
    return 0;
}




Measured memory_bytes: 256