akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  inl(N , M , D);
  out(1.0 / N / N * (N - D) * (1 + (D != 0) ) * (M - 1) );
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		float f=0;
		
		int r = a/2;
		f= 1-(float)r/(float)a;
		System.out.println(f);

	}
}


Measured memory_bytes: 22736
#include <cstdio>
#include <cstring>
#include <list>
using namespace std;

void Execute(list<int> &ls, char cmd[]) {
    if (strcmp(cmd, "insert") == 0) {
        int val;
        scanf("%d", &val);
        ls.push_front(val);
    } else if (strcmp(cmd, "delete") == 0) {
        int val;
        scanf("%d", &val);
        for (list<int>::iterator it = ls.begin(); it != ls.end(); it++) {
            if (*it == val) {
                ls.erase(it);
                break;
            }
        }
    } else if (strcmp(cmd, "deleteFirst") == 0) {
        ls.pop_front();
    } else if (strcmp(cmd, "deleteLast") == 0) {
        ls.pop_back();
    }
}

int main() {
    int n;
    scanf("%d", &n);

    list<int> ls;
    char cmd[12];
    for (int i = 0; i < n; i++) {
        scanf("%s", cmd);
        Execute(ls, cmd);
    }
    int i = 0;
    for (list<int>::iterator it = ls.begin(); it != ls.end(); it++) {
        if (i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");
    return 0;
}


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

int main()
{
    map <int, int> m;
    int n, c;
    cin >> n;
    while (n--) {
        cin >> c;
        m[c]++;
    }
    int ans(0);
    int unu(0);
    for (auto & i : m) {
        //cout << i.first << ' ' << i.second << '\n';
        if (i.second > 2)
            i.second = (i.second - 1) % 2 + 1;
        if (i.second == 2)
            unu++;
        ans++;
    }
    if (unu & 1)
        ans--;

    cout << ans;
    return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(c<=a+b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int X;
		X = scan.nextInt();

		if (X == 3 || X == 5 || X == 7) {
			System.out.println("YES");

		} else {
			System.out.println("NO");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int divisorNum(int i) {
    int ans = 0;
    for (int j=1; j*j<=i; j++) {
        if (i%j==0) {
            if (j*j==i) ++ans;
            else ans += 2;
        }
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i=1; i<=n; i+=2) {
        if (divisorNum(i)==8) ++ans;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
#一時保存
def count(target):
    num=0
    for i in range(N):
        temp=target//F[i]
        num+=max(A[i]-temp,0)
    return num

N,K=map(int,input().split())

A=list(map(int,input().split()))
F=list(map(int,input().split()))

A.sort()
F.sort(reverse=True)


ok=10**16+1
ng=0

if count(0)<=K:
    print(0)
    exit()


while ok-ng>1:
    mid=(ok+ng)//2
    if count(mid)>K:
        ng=mid
    else:
        ok=mid
ng=0
while ok-ng>1:
    mid=(ok+ng)//2
    if count(mid)>K:
        ng=mid
    else:
        ok=mid


print(ok)



Measured memory_bytes: 119884
#include <cstdio>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

std::vector<int> primes;
bool used[55556];

void sieve()
{
  used[0] = used[1] = true;

  for( int i = 2; i <= 55555; ++i ) if( !used[i] )
  {
    primes.push_back( i );

    for( int j = i; j <= 55555; j += i )
      used[j] = true;
  }

  return;
}

int N;

int main()
{
  sieve();

  scanf( "%d", &N );

  int cnt = 0;
  for( auto v : primes ) if( v % 5 == 1 && cnt < N )
  {
    printf( "%d%c", v, cnt==N-1?'\n':' ' );

    ++cnt;
  }

  return 0;
}

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

using namespace std;

#define int long long


	bool k(int a, int b) {
		if (a >= b) {
			return 1;
		}
		else {
			return 0;
		}
	};

signed main() {
	int n;

	cin >> n;

	vector<int>h(n);

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

		int t = 0;
		int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (k(h[i], h[i + 1])) {
			t++;
		}
		else {
			if (t >= ans) {
				ans = t;
			}
			t = 0;
		}
	}

	if (t >= ans) {
		ans = t;
	}

	cout << ans;


	return 0;
}


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

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

int main(){
   ll n;cin >>n;
   ll ans=0;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        ans+=a-1;
    }
    cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll m, k;
    cin >> m >> k;
    vector<ll> tmp;

    if (m == 0){
        if (k==0) cout << 0 << " " << 0 << endl;
        else cout << -1 << endl;
        return 0;
    }
    else if (m == 1){
        if (k == 0) cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    else if (1<<m <= k){
        cout << -1 << endl;
        return 0;
    }

    rep(i, 1<<m){
        if(i!=k) tmp.push_back(i);
    }

    rep(i, tmp.size()) cout << tmp[i] << " ";
    cout << k << " ";
    rrep(i, tmp.size()) cout << tmp[i] << " ";
    cout << k << endl;

    return 0;
}


Measured memory_bytes: 4188
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    double x, h;
    while(cin >> x >> h && (x || h) ) {
        printf("%.6f", x * sqrt(x * x + 4 * h * h) + x * x);
        cout << endl;
    }
     
    return 0;
}

Measured memory_bytes: 0
function Main(input){
    input = input.split("\n");
    var k = 0;
    while(1){
        var n = parseInt(input[k++],10);
        if(n == 0)
            break;

        input[k] = input[k].split(" ");

        var min = 1000000000;
        for(var i = 0;i < n;i++){
            for(var j = i + 1;j < n;j++){
                var a = Math.abs(parseInt(input[k][i],10) - parseInt(input[k][j],10));
                if(min > a)
                    min = a;
            }
        }
        console.log(min);
        k++;
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 18436
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, D = map(int, input().split())

while True:
    C -= B
    if C <= 0:
        break

    A -= D
    if A <= 0:
        break

if C <= 0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)


Measured memory_bytes: 9184
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main
{
	public static void main (String[] arg)throws IOException
	{
		int sum[]= new int[101];
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String line;
		int max=0;
		while ((line = input.readLine()) != null && !line.isEmpty()) {
			int	num=Integer.parseInt(line);
			sum[num]++;
		}
		for(int i=0;i<100;i++){
			max=Math.max(max, sum[i]);
		}
		for(int j=0;j<100;j++){
			if(sum[j]==max){
			System.out.println(j);
			}
		}
	}
}	

Measured memory_bytes: 17020
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000123456LL

int main(){
  int n;
  cin>>n;
  using P = pair<long,int>;
  vector<vector<P>> vec(n);
  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    vec[a].pb(mp(c,b));
    vec[b].pb(mp(c,a));
  }

  int q,k;
  cin>>q>>k;
  k--;

  vector<long> d(n,INF);
  d[k] = 0;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(mp(0,k));
  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    int v = p.second;
    long dd = p.first;
    if(dd < d[v]) continue;
    for(auto to : vec[v]){
      long nd = dd + to.first;
      int ni = to.second;
      if(d[ni] > nd){
        d[ni] = nd;
        pq.push(mp(nd, ni));
      }
    }
  }
// dbg(d);
  rep(_,q){
    int x,y;
    cin>>x>>y;
    x--;y--;
    cout << d[x]+d[y] << endl;
  }


  return 0;
}


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

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

#define fr first
#define sc second

int main(){
	static int n;
	static int a[100010];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&a[i]);
	}
	
	map<int,int> cnt[2];
	for(int i = 0 ; i < n ; i ++){
		cnt[i&1][a[i]] ++;
	}
	
	int ret[2][2] = {};
	int id[2][2];
	for(int i = 0 ; i < 2 ; i ++){
		for(map<int,int>::iterator itr = cnt[i].begin() ; itr != cnt[i].end() ; itr++){
			if(itr->sc > ret[i][1]){
				ret[i][1] = itr->sc;
				id[i][1] = itr->fr;
				if(ret[i][0] < ret[i][1]){
					swap(ret[i][0],ret[i][1]);
					swap(id[i][0],id[i][1]);
				}
			}
		}
	}
	
	int RET = 0;
	if(id[0][0] != id[1][0])RET = ret[0][0]+ret[1][0];
	else {
		RET = max( ret[0][0]+ret[1][1] , ret[0][1]+ret[1][0] );
	}
	
	cout << n-RET << endl;
}



Measured memory_bytes: 5376
package main

import "fmt"

func main() {
	var N, M, sum int
	fmt.Scan(&N, &M)
	A := make([]int, N)
	for i:= range A {
		fmt.Scan(&A[i])
		sum += A[i]
	}

	if N >= sum {
		fmt.Print(N-sum)
	} else{
		fmt.Print(-1)
	}


}

Measured memory_bytes: 10480
#include <iostream>
#include <string>

namespace Mylib{
    using namespace std;
    
    void Instring(string& x){
        cin >> x;
    }
    
    void showString(string& x){
        cout << x << endl;
    }
    
    bool checkAtoB(string& x){
        for(int i=1;i<x.length();i++){
            if(x[i-1]!=x[i])return true;
        }
        return false;
    }
    void showflag(bool flg){
        if(flg==true){
            cout << "Yes" << endl;
            
        }else{
            cout << "No" << endl;
        }
    }
    
}
int main(void){
    std::string inStr;
    Mylib::Instring(inStr);
    bool flag;
    flag=Mylib::checkAtoB(inStr);
    Mylib::showflag(flag);
    
    
    
    
    return 0;
}

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

int main() {
  int H, M, H2, M2, K;
  cin >> H >> M >> H2 >> M2 >> K;
  int T = 60*(H2-H)+(M2-M);
  cout << T-K << endl;
}

Measured memory_bytes: 3636
import math
def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
s = n // 3
a = 0
if(s >= 1):
    for i in range(1, s+1):
        t = n - 3*i
        a += C(t+i-1, i-1)
    print(a%1000000007)
else:
    print(0)
    

Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void)
{ 
  string first,sec;
  cin >> first;
  cin >> sec;
  reverse(first.begin(), first.end());
  if(first == sec)
    cout << "YES" << endl;
  else
   cout << "NO" << endl;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin>>a.at(i);
  if(n%2==0)
  {
    for (int i = n/2; i > 0; i--)
      cout<<a.at(i*2-1)<<' ';
    for (int i = 0; i < n/2; i++)
      cout<<a.at(i*2)<<' ';
  }
  else
  {
    for (int i = (n+1)/2; i > 0; i--)
      cout<<a.at((i-1)*2)<<' ';
    for (int i = 0; i < (n-1)/2; i++)
      cout<<a.at(i*2+1)<<' ';
  }
  cout<<endl;
  return(0);
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=100000;i++){
        if(i*i>n){
            cout<<(i-1)*(i-1)<<endl;
            return(0);
        }
    }
    return(0);
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
        int m = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= d; j++) {
                // 2桁以上の場合のみ
                if (j >= 10) {
                    int d1 = Character.getNumericValue(Integer.toString(j).charAt(0));
                    int d10 = Character.getNumericValue(Integer.toString(j).charAt(1));
                    if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) {
                            cnt++;
                        }
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) (v.begin(),v.end())
#define ff first
#define ss second
const ll maxn=2e5+10;
const ll mod=998244353;


int main() {
  	fast;
  	ll n,i,j,k,cnt=0;
  	cin>>n;
  	string s;
  	cin>>s;
  	
  	ll pr[n],pg[n],pb[n];
  	memset(pr,0,sizeof(pr));
  	memset(pg,0,sizeof(pg));
  	memset(pb,0,sizeof(pb));
  	for(i=0;i<n;i++)
  	{
  		if(s[i]=='R')
  		{
  			pr[i]=pr[i-1]+1;	
  			pb[i]=pb[i-1];
  			pg[i]=pg[i-1];
		}
		if(s[i]=='B')
  		{
  			pb[i]=pb[i-1]+1;	
  			pr[i]=pr[i-1];
  			pg[i]=pg[i-1];
		}
		if(s[i]=='G')
  		{
  			pg[i]=pg[i-1]+1;	
  			pb[i]=pb[i-1];
  			pr[i]=pr[i-1];
		}
		  
	}
  	for(i=0;i<n;i++)
  	{
  		for(j=i+1;j<n;++j)
  		{
  			if(s[i]==s[j])
  				continue;
  			if(s[i]=='R' && s[j]=='B' || s[i]=='B' && s[j]=='R')
  			{
  				cnt+=pg[n-1]-pg[j];
  				if(s[2*j-i]=='G')
  					--cnt;
			}
			if(s[i]=='R' && s[j]=='G' || s[i]=='G' && s[j]=='R' )
  			{
  				cnt+=pb[n-1]-pb[j];
  				if(s[2*j-i]=='B')
  					--cnt;
			}
			if(s[i]=='G' && s[j]=='B' || s[i]=='B' && s[j]=='G' )
  			{
  				cnt+=pr[n-1]-pr[j];
  				if(s[2*j-i]=='R')
  					--cnt;
			}
		}
  	}
  	
	cout<<cnt<<endl;
	
	
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    char c ;
    cin >> c ;
    if(c-'Z'<=0){
        cout << "A" <<endl;
    }
    else{
        cout <<"a" <<endl;
    }


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <iomanip>
#include <cmath>


using namespace std;
using ull = unsigned long long;


int main()
{
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;

        vector<int> v(n);

        for (int i = 0; i < n && cin >> v[i]; ++i);

        
        double mean {};
        double sqrSum {};

        for (auto d : v)
        {
            mean += d;
            sqrSum += d * d;
        }
        mean /= n;
        
        double sigma = sqrt(sqrSum / n - mean * mean);

        cout << fixed << setprecision(6) << sigma << endl;


    }




    return 0;
}

Measured memory_bytes: 3208
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}

// ------------------- include, typedef, define END. -------------------

void solveAndOutput(MuMAPIC &result){
	foreach_it(MuMAPIC, it, result){
		cout << (*it).second << endl;
	}
}

int main(){
	/* 方針
	 * A:381 , B:370 , C:40 , ...
	 * 百の位は勝ち数, 十の位は(9-負け数), 一の位は引き分け数.
	 * 入力チーム数が10以下（= 繰り上がり繰り下がりがないこと）を前提としている.
	 */

	int n = 0, in = 0;
	char in_char;
	while (cin >> n, n){
		MuMAPIC result;

		// 各team入力
		FOR(teamSum, 0, n){
			// seisekiCount[0] = win, [1]=lose, [2]=hikiwake
			VI seisekiCount(3, 0);
			int temp_mapin = 0;

			cin >> in_char;

			FOR(i, 0, n - 1){
				cin >> in;
				seisekiCount[in]++;
			}
			temp_mapin = seisekiCount[0] * 100 + (9 - seisekiCount[1]) * 10 + seisekiCount[2];
			result.insert(MP(temp_mapin, in_char));
		}
		// all teams input END.
		solveAndOutput(result);
	}
	return 0;
}

Measured memory_bytes: 1188
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static class Period {
        int s;
        int e;

        public Period(int s, int e) {
            this.s = s;
            this.e = e;
        }
    }

    static void solve(Scanner scanner) {
        boolean[] prime = new boolean[100_001];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 2; i < 100_001; i++) {
            if (!prime[i]) {
                continue;
            }
            for (int j = 2 * i; j < 100_001; j+=i) {
                prime[j] = false;
            }
        }

        Bit bit = new Bit(100_000);
        for (int i = 2; i < 100_000; i++) {
            if (prime[i] && prime[(i + 1) / 2]) {
                bit.add(i, 1);
            }
        }

        int Q = Integer.parseInt(scanner.nextLine());
        for (int i = 0; i < Q; i++) {
            int[] q = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            System.out.println(bit.sum(q[1]) - bit.sum(q[0] - 1));
        }
    }

    static class Bit {
        int[] bit;
        int n;

        Bit(int n) {
            this.n = n;
            bit = new int[n + 1];
        }

        void add(int i, int x) {
            bit[i] += x;
            while (i + (i & -i) <= n) {
                i += (i & -i);
                bit[i] += x;
            }
        }

        int sum(int i) {
            int sum = bit[i];
            while (i - (i & -i) > 0) {
                i -= (i & -i);
                sum += bit[i];
            }
            return sum;
        }
    }
}

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

using namespace std;

int main()
{
  int N;

  cin >> N;

  vector<int> x;
  x.resize(N);
  vector<int> y;
  y.resize(N);
  map<pair<int,int>, int> diff;


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

  int max_ = 0;
  for(int i = 0;
      i < N;
      ++i)
    {
      for(int j = 0;
          j < N;
          ++j)
        {
          if(i != j)
            {
              int dist_x = x[i] - x[j];
              int dist_y = y[i] - y[j];
              auto it = diff.find(make_pair(dist_x, dist_y));
              if(it == diff.end())
                {
                  diff.insert(make_pair(make_pair(dist_x, dist_y), 1));
                  max_ = max(1, max_);
                }
              else
                {
                  ++(it->second);
                  max_ = max(it->second, max_);
                }
            }
        }
    }

  cout << N - (max_ + 1) + 1 << endl;

  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int[] L = new int[N];
			for(int i = 0; i < L.length; i++) {
				L[i] = in.nextInt();
			}
			Arrays.sort(L);
			int total = 0;
			for(int i = 0; i < L.length - 1; i++) {
				total += L[i];
			}
			if(total > L[L.length - 1]) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

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

int main(){
  char str[1001],p[1001];
  string command;
  int q,i,a,b,j,c,k;

  cin >> str;
  cin >> q;
  
  for(i=0;i<q;i++){
    cin >> command;
    if( command != "replace" ) cin >> a >> b;
    else{
      cin >> a >> b >> p;
    }

    if( command=="print" ){
      for(j=a;j<=b;j++){
	cout << str[j];
      }
      cout << endl;
    }else if( command=="reverse" ){
      double n = (b-a)/2.0;
      n = ceil( n );
      
      for(k=a,j=b,c=0;c<n;k++,j--,c++){
	char dummy = str[k];
	str[k] = str[j];
	str[j] = dummy;
      }
    }else{
      for(j=a,k=0;j<=b;j++,k++){
	str[j]=p[k];
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M (ll)1000000007
#define MM (ll)1e8
#define INF (ll)1e18
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001

int main() {
    char s[52][52];

    ll h;
    ll w;
    cin >> h >> w;

    fill(&s[0][0], &s[0][0] + sizeof(s), '.');

    arep(i, 1, h + 1) arep(j, 1, w + 1) cin >> s[j][i];

    bool isOK = true;
    arep(i, 1, h) {
        arep(j, 1, w) {
            if (s[j][i] == '#') {
                if (s[j - 1][i] == '.' && s[j + 1][i] == '.' &&
                    s[j][i - 1] == '.' && s[j][i + 1] == '.') {
                    isOK = false;
                    break;
                }
            }
        }
        if (!isOK) break;
    }

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

Measured memory_bytes: 3620
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li = [0] + li
zantei = 0
point = 0
for i in range(len(li)):
    if li[i-1] <= li[i]:
        point += li[i]-li[i-1]

print(point)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i[] = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
    int k, a, b;cin >> k >> a >> b;
    bool m = false;
    for(int i = a;i <= b;i++){
        if(i%k == 0){
            m = true;
            break;
        }
    }
    if(m){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }

}


Measured memory_bytes: 3624
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

def main():
    N = input()
    n = int(N)
    s = 0

    while n:
        s += n % 10
        n = n // 10
    if int(N) % s == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61924
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,k,a;
    cin>>n>>k;
    std::deque<pair<long long int,int>> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(pair(a,0));
    }
    long long int tmp=0;
    std::deque<long long int> loop;
    while (1) {
        deq[tmp].second++;
        if (deq[tmp].second==2) {
            loop.emplace_back(deq[tmp].first);
        } else if (deq[tmp].second==3) {
            break;
        }
        tmp=deq[tmp].first-1;
    }
    std::deque<long long int> not_loop;
    tmp=0;
    for (int i=0;i<n;i++) {
        if (deq[tmp].second==1) {
            not_loop.emplace_back(deq[tmp].first);
        } else {
            break;
        }
        tmp=deq[tmp].first-1;
    }
    loop.emplace_front(loop.back());
    loop.pop_back();
    tmp=0;
    if (k<=not_loop.size()) {
        for (int i=0;i<k;i++) {
            tmp=deq[tmp].first-1;
        }
        cout<<tmp+1<<endl;
    } else {
        k-=not_loop.size();
        cout<<loop[k%loop.size()]<<endl;
    }
}

Measured memory_bytes: 8372
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

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

int n, a[100010], f[100010];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    FOR(i,1,n) {
        cin >> a[i];
        f[a[i]]++;
    }
    FOR(i,1,100000)
        if (f[i]) {
            if (f[i] % 2) f[i] = 1;
            else f[i] = 2;
        }
    int u=0, v=0;
    FOR(i,1,100000)
        if (f[i] == 2) u++;
        else if (f[i] == 1) v++;
    if (u%2) v--;
    cout << u+v;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
#define endl '\n'


 
void ComputeAdd(vector<array<ll,3>>& A, vector<ll>& min_dist_n_street, vector<int>& ys, vector<int>& xs) {
  int n_street = xs.size() + ys.size();
  ll all_dist = 0;
  for (int ii = 0; ii < A.size(); ++ii) {
    auto& [x,y,p] = A[ii];
    ll dist = min(abs(x),abs(y));
    for (int xx : xs) dist = min(dist, abs(xx-x));
    for (int yy : ys) dist = min(dist, abs(yy-y));
    all_dist += dist*p;
  }
  min_dist_n_street[n_street] = min(min_dist_n_street[n_street], all_dist);
}


void DFS(int i, vector<array<ll,3>>& A, vector<ll>& min_dist_n_street, vector<int>& ys, vector<int>& xs) {
  if (i == A.size()) return;
  DFS(i+1, A, min_dist_n_street, ys, xs);
  

  xs.push_back(A[i][0]);
  ComputeAdd(A, min_dist_n_street, ys, xs);
  DFS(i+1, A, min_dist_n_street, ys, xs);
  xs.pop_back();

  ys.push_back(A[i][1]);
  ComputeAdd(A, min_dist_n_street, ys, xs);
  DFS(i+1, A, min_dist_n_street, ys, xs);
  ys.pop_back();
}


int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  // cin >> TT;
  ll N;
  cin >> N;
  vector<array<ll,3>> A(N);
  for (auto& aa : A) cin >> aa[0] >> aa[1] >> aa[2];
  vector<ll> min_dist_n_street(N+1, INT64_MAX/2);
  vector<int> xs;
  vector<int> ys;
  ComputeAdd(A, min_dist_n_street, ys, xs);
  DFS(0,  A, min_dist_n_street, ys, xs);

  for (int k = 0; k <= N; ++k) {
    cout << min_dist_n_street[k] << endl;
  }
}


Measured memory_bytes: 3540
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)

N, M = MAP()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)
    if l > M*2:
        print(0)
        exit()

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = M*2 // l + 1
print(ans // 2)


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    
    int n;
    cin >> n;

    int ans = 0, mn = (int)(1e9);
    while (n--) {
        int x;
        cin >> x;
        if (x <= mn) {
            mn = x;
            ++ans;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

long d[200][200];

int r;
int p[8];

long f(int k, int s){
	k=k|(1<<s);
	if(k==(1<<r)-1) return 0;
	long ans=LONG_MAX;
	for(int i=0; i<r; i++){
		if((k&(1<<i))==0){
			long now = d[p[s]][p[i]] + f(k, i);
			if(now<ans) ans=now;
		}
	}
	return ans;
}

int main(void){
	int n=nextint();
	int m=nextint();
	r=nextint();
	for(int i=0; i<r; i++){
		p[i]=nextint()-1;
	}
	for(int i=0; i<m; i++){
		int a=nextint()-1;
		int b=nextint()-1;
		int c=nextint();
		d[a][b]=c;
		d[b][a]=c;
	}
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(d[i][k]!=0 && d[k][j]!=0)
					if(d[i][j]==0 || d[i][k]+d[k][j]<d[i][j]) d[i][j]=d[i][k]+d[k][j];
			}
		}
	}
	long ans=LONG_MAX;
	for(int i=0; i<r; i++){
		long now = f(0, i);
		if(now<ans) ans=now;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 1896
import java.math.BigDecimal;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
       
        String res = "Yes";
        for (char c='a'; c<='z'; c++){
            int count = 0;
            for (int i=0; i<w.length(); i++){
                if (w.charAt(i) == c){
                    count++;
                }
            }
            if (count%2 == 1){
                res = "No";
                break;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }






int main() {
  cout<<fixed<<setprecision(10);

  ll N,C,K;cin>>N>>C>>K;
  vint T(N);rep(i,N)cin>>T[i];

  vsort(T);


  ll ans = 0;
  ll dept = T[N-1];
  ll pool = C;
  ans++;
  repr(i,N){
    // cout << i << endl;
    if(T[i]>=dept-K && pool>0){
      pool--;
      // cout << "true" << endl;
    }else{
      pool = C;
      dept = T[i];
      pool--;
      ans++;
      // cout<<"false"<<endl;
    }
  }

  cout << ans << endl;
}

















//


Measured memory_bytes: 1024
field = [[0 for i in range(10)]for i in range(15)]
nums = int(input())
for i in range(nums):
	b,f,r,v = map(int,input().split())
	field[(b-1)*4+f-1][r-1] += v
for i in range(15):
	if (i % 4 == 3):
		print('#'*20)
	else:
		print(' '+' '.join(map(str,field[i])))


Measured memory_bytes: 5608
import heapq

N,M=map(int,input().split())

L=[[]    for i in range(3*N)]

for i in range(M):
  u,v=map(int,input().split())
  u,v=u-1,v-1
  L[u].append(N+v)
  L[N+u].append(2*N+v)
  L[2*N+u].append(v)

S,T=map(int,input().split())

D=[10**6 for i in range(3*N)]
D[~-S]=0
A=[(0,~-S)]
heapq.heapify(A)

while len(A)>0:
  d,v=heapq.heappop(A)
  if D[v]<d:
    continue
  for i in L[v]:
    if D[i]>D[v]+1:
      D[i]=D[v]+1
      heapq.heappush(A,(D[v]+1, i))

print(D[~-T]//3 if D[~-T]!=10**6 else -1)


Measured memory_bytes: 60036
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	scanf("%d", &n);
	vector<tuple<LL,LL,LL>> ds(n);
	for(int i = 0; i < n; ++i){
		LL a, b;
		scanf("%lld%lld", &a, &b);
		ds[i] = make_tuple(a + b, a, b);
	}
	sort(RALL(ds));
	LL ans = 0;
	for(int i = 0; i < n; ++i){
		cauto d = ds[i];
		if(i & 1){ ans -= get<2>(d); }
		else{ ans += get<1>(d); }
	}
	printf("%lld\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long LL;

LL Fab(LL x)
{
	return (x>0)?(x):(-x);
}

int main()
{
	int n;
	scanf("%d",&n);
	LL *a=new LL[n];
	LL sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",a+i);
		sum+=a[i];
	}
	LL sum_temp=a[0];
	LL min_diff=Fab(sum-2*sum_temp);
	for(int i=1;i<n-1;i++)
	{
		sum_temp+=a[i];
		if(min_diff>Fab(sum-2*sum_temp))
			min_diff=Fab(sum-2*sum_temp);
	}
	printf("%lld",min_diff);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int a[26]={0};
  for ( auto &c:s ) {
    a[c-'a']=1;
  }
  for ( int i=0; i<26; i++ ) {
	if ( !a[i] ) {
      printf("%c\n", (char)('a'+i));
      return 0;
    }
  }
  puts("None");
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::string;

bool xor_count_char(char a, char b)
{
  return !(a == b);
}

int main()
{
  const std::array<char, 2> numc = {'0', '1'};
  string s;
  cin >> s;

  size_t sum1 = 0;
  size_t sum2 = 0;
  {
    size_t start = 0;
    // size_t s2 = 1;
    for (size_t i = 0; i < s.size(); ++i)
    {
      if (xor_count_char(s[i], numc[start % 2]))
        sum1++;

      // if (xor_count_char(s[i], numc[s2 % 2]))
      //   sum2++;
      start++;
      // s2++;
    }
  }
  sum2 = s.size() - sum1;
  // cout << sum1 << ", " << sum2 << "\n";
  cout << std::min(sum1, sum2) << "\n";
  return 0;
}


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

using namespace std;
typedef long long int lli;
typedef pair<lli,lli> P;
const int MAX=2e5+5;

int main(){
	string S;
	cin>>S;
	int N=S.size();
	lli leb[MAX];
	lli bla=0;
	rep(i,N){
		if(S[i]=='W')leb[i]=bla;
		else{
			leb[i]=0;
			bla++;
		}
	}
	lli ans;
	rep(i,N){
		ans+=leb[i];
	}
	cout<<ans;
}

Measured memory_bytes: 2180