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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    string s; cin>>s;
    vi arr[3];
    for(i = 0; i < s.size(); i++){
        if(s[i] == 'R') arr[0].pb(i);
        else if(s[i] == 'G') arr[1].pb(i);
        else arr[2].pb(i);
    }
    ll sum = 0;
    for(i = 0; i < s.size(); i++){
        for(j = i+1; j < s.size(); j++){
            if(s[i] == s[j]) continue;
            int x = -1;
            if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')) x = 2;
            else if((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')) x = 1;
            else x = 0;
            auto it = up(all(arr[x]), j);
            sum += (arr[x].end()-it);
            it = lb(all(arr[x]), j + (j - i));
            if(it != arr[x].end() && *it == (j + (j-i))) sum--;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int a, b, sum, subt;
    char opr;
    cin >> a >> opr >> b;
    sum = a + b;
    subt = a - b;
    if(opr == '+') {
        cout << sum;
    }
    else
        cout << subt;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c=0,e=0;
    cin>>a>>b;
    int d[a+1][b+1];
    for(int i=0;i<a;i++){
        for(int o=0;o<b;o++){
            cin>>d[i][o];
            c+=d[i][o];
        }
        d[i][b]=c;
      e+=c;
        c=0;
    }
    for(int i=0;i<b;i++){
        for(int o=0;o<a;o++){
            c+=d[o][i];
        }
        d[a][i]=c;
        c=0;
    }
  d[a][b]=e;
    for(int i=0;i<a+1;i++){
        for(int o=0;o<b+1;o++){
            if(o<b)cout<<d[i][o]<<" ";
            else cout<<d[i][o];
        }
        cout<<endl;
    }
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N;
    cin >> N;
    if( N >= 1000) cout << "ABD" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector<int> S(n);
    for (size_t i=0; i<n; ++i)
        scanf("%d", &S[i]);

    size_t q;
    scanf("%zu", &q);

    vector<int> T(q);
    for (size_t i=0; i<q; ++i)
        scanf("%d", &T[i]);

    size_t C=0;
    for (size_t i=0; i<q; ++i) {
        vector<int>::iterator ub, lb;
        ub = upper_bound(S.begin(), S.end(), T[i]);
        lb = lower_bound(S.begin(), S.end(), T[i]);
        C += !!(ub-lb);
    }

    printf("%zu\n", C);
    return 0;
}

Measured memory_bytes: 2928
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)

int n, m;
bool graph[8][8] = {};

int dfs(int v, int n, bool visited[8]) {
	bool all_visited = true;

	REP(i, n) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited == true) {
		return 1;


	}

	int ret = 0;

	REP(i, n) {
		if (graph[v][i] == true && visited[i] == false) {
			visited[i] = true;
			ret += dfs(i, n, visited);
			visited[i] = false;
		}
	}

	return ret;
}



int main() {

	
	cin >> n >> m;

	
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		graph[a - 1][b - 1] = true;
		graph[b - 1][a - 1] = true;
	}

	bool visited[8] = {};

	visited[0] = true;
	cout << dfs(0, n, visited) << endl;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000

#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	if(b==0) return a;
	else return gcd(b,a%b);
}
ll extgcd(ll a,ll b,ll &x,ll &y){
	ll g = a; x = 1; y = 0;
	if(b != 0) g = extgcd(b,a%b,y,x),y-=(a/b)*x;
	return g;
}
ll AxB(ll A,ll B,ll C){
	//minimum non-negaitive x such that Ax godo b (mod C)
	if(B%gcd(A,C) != 0) return -1;
	ll x,y;
	extgcd(A,C,x,y);
	x = x*B/gcd(A,C)%(C/gcd(A,C));
	ll f = C/gcd(A,C);
	if(x > 0){
		x %= abs(f);
	}
	else{
		x = (x%abs(f)+abs(f))%abs(f);
	}
	return x;
}
ll modpow(ll x,ll n,ll mod)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int q;
ll a,m;
vector<ll>A;
ll rec(ll a,ll m){
	if(a == 0) return m*100LL;
	if(a == 1) return m*100LL+1LL;
	if(m == 1) return m*100LL;
	//a>=2 && m>=2
	//例外
	//cycを求める
	ll M = m;
	rep(i,A.size()){
		while(M%A[i] == 0) M/=A[i];
	}
	ll MM = M;
	for(ll x=2;x*x<=M;x++){
		if(M%x == 0){
			MM = (MM/x) * (x-1);
			while(M%x == 0) M/=x;
		}
	}
	if(M != 1) MM = (MM/M) * (M-1);
	ll cur = 1;
	ll ok = MM/gcd(MM,m)*m;
	rep(x,100){
		if(cur%m == x%m){
		    if(ok>=100) return x+ok;
		    else return x+ok*100LL;
		}
		cur = cur*a%m;
	}
	//cyc = MM
	ll ans = rec(a,MM);
	if(ans == -1) return -1;
	//a^ansとansがmod cycで合同
	ll dif = modpow(a,ans,m)-ans;
	dif = (dif%m+m)%m;
	//difはcyc*?1-m*?2と思える
	//dif+m*?をcycの倍数にしたい、これは上より必ず可能
	//mxと-difがmod cycで合同
	ll q = AxB(m,(MM-dif%MM)%MM,MM);
	if(q<0) return -1;
	ans = (ans+dif+m*q%ok)%ok;
	if(ans<100){
	    if(ok>=100) ans+=ok;
	    else ans+=ok*100LL;
	}
	return ans;
}
int main(){
	cin>>q;
	rep(e,q){
		cin>>a>>m;
		A.clear();
		ll b = a;
		for(ll i=2;i*i<=b;i++){
			if(b%i==0){
				A.pb(i);
				while(b%i==0) b/=i;
			}
		}
		if(b != 1) A.pb(b);
		ll K = rec(a,m);
		if(K >= 0){
		    ll Q = modpow(a,K,m);
		    ll R = K%m;
		    assert(Q == R);
		}
		cout<<K<<endl;
	}
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

march :: [String] -> String -> String
march [] x = x
march (a:an) x = if (elem (head a) "MARCH")
                 then march an ((head a):x)
                 else march an x
            
nls :: [Int] -> [Int]
nls ls = if (length ls) < 5
         then nls (0:ls)
         else ls
         
main = do
    n <- readLn :: IO Int
    sn <- replicateM n getLine
    let ls = map length (group $ sort $ march sn [])
    let [a,b,c,d,e] = nls ls
    print (a*b*c + a*b*d + a*b*e + a*c*d + a*c*e + a*d*e + b*c*d + b*c*e + b*d*e + c*d*e)

Measured memory_bytes: 49532
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
 
 
int main() {
    ios_base::sync_with_stdio(false);
 
    ll a,b,n;
    cin >> a >> b >> n;
    ll x=(b-1<n)?(b-1):n;
    ll ans=(a*x)/b;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3652
from math import gcd


def lcm(arr):
    ret = 1
    for a in arr:
        ret = ret * a // gcd(ret, a)
    return ret


def aoj():
    N = int(input())
    print(lcm([int(x) for x in input().split()]))


if __name__ == '__main__':
    aoj()



Measured memory_bytes: 5668
N = int(input())
alist = input().split()
count = [0 for i in range(100001)]
for a in alist:
	a = int(a)
	if a<100001:
		count[a]+=1
good = 0
for i in range(100001):
	if count[i] >= i:
		good += i
print(N-good)

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

int main() {
    
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            cout<<i<<"x"<<j<<"="<<i*j<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int  main()
{
	int a[51],n,m,sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;i>=n-m;i--)
	{
	sum+=a[i];
	}
	cout<<sum;
	return 0;
} 



Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  const n = parseInt(input.split("\n")[0], 10);
  var arrV = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
    arrV.sort(function(a,b){
      if( a < b ) return -1;
      if( a > b ) return 1;
      return 0;
  });
  var ans=arrV[0];
  for(var i=0; i<n-1; i++){
    ans=(ans+arrV[i+1])/2
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define OUT(x) cout << x << endl
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//Union-Find木
template<size_t NODE_MAX>
struct UnionFindTree
{
    static const int MAX = NODE_MAX;
    int par[NODE_MAX];

    void init(int N)
    {
        //初めはすべて孤立したグループとしてみなす
        for(int i=0; i<N; ++i) {
            par[i] = i;
        }
    }

    int find(int x)
    {
        if(par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if(x == y) return;
        else par[x] = y;
    }
};

UnionFindTree<2*100000> uf;
int main(){
  int n,m;
  cin >> n >> m;
  int id[100010] ={};
  uf.init(n+1);
  for(int i=1;i<=n;++i){
    int in;
    cin >> in;
    id[in] = i;
  }
  REP(i,m){
    int a,b;
    cin >> a >> b;
    uf.unite(a,b);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(uf.same(i,id[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int a[4];
cin >>a[0] >> a[1] >> a[2] >>a[3];
	sort(a,a+4);
	if(a[0] == a[1] && a[2] == a[3]) cout << "yes" <<endl;
	else cout << "no" << endl;



return 0;
}

Measured memory_bytes: 3092
import numpy as np

N, K, Q = map(int, input().split())
Participants = np.array([K] * (N + 1)) - Q

for _ in range(Q):
    A = int(input())
    Participants[A] += 1

for i in range(1, N + 1):
    if Participants[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
const int N=2e5+10;
ll n,k,a[N],x,y,z;

ll ok(ll x){
    ll sum=0;
    REP(i,n){
        if(a[i]>0){
            ll l=0,r=n;
            while(r-l>0){
                ll m=(l+r)/2;
                if(a[i]*a[m]<x)l=m+1;else r=m;
            }
            sum+=l;
        }else{
            ll l=0,r=n;
            while(r-l>0){
                ll m=(l+r)/2;
                if(a[i]*a[m]<x)r=m;else l=m+1;
            }
            sum+=n-l;
        }
    }
    REP(i,n)if(a[i]*a[i]<x)sum--;
    sum/=2;
    return sum;
}

void solve() 
{
    cin>>n>>k;
    REP(i,n)cin>>a[i];
    sort(a,a+n);
    //x=lower_bound(a,a+n,0)-a;
    //y=upper_bound(a,a+n,0)-a-x;
    //z=n-x-y;
    ll r=(ll)1e18;ll l=-r;
    while(r-l>1){
        ll m=(l+r)/2;
        if(ok(m)<k)l=m;
        else r=m;
    }
    cout<<l<<endl;
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
const int maxn = 1e5 + 10;

int main()
{
    string x;
    cin >> x;
    if (x[2] == x[3] && x[4] == x[5])
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 888
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

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

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n, m, q;
int v[N], d[N], c[N];
int color[N][11];
vector < int > g[N];

void paint(int v, int d, int T){
  color[v][d] = max(color[v][d], T);
  if(d){
    for(int i : g[v]){
      if(!color[i][d - 1]){
        paint(i, d - 1, T);
      }
    }
  }
}

int main(){
  scanf("%d %d", &n, &m);
  for(int i = 1; i <= m; ++i){
    int x, y;
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  scanf("%d", &q);
  for(int i = 1; i <= q; ++i){
    scanf("%d %d %d", v + i, d + i, c + i);
  }
  for(int i = q; i >= 1; --i){
    paint(v[i], d[i], i);
  }
  for(int i = 1; i <= n; ++i){
    int mx = 0;
    for(int j = 0; j <= 10; ++j){
      mx = max(mx, color[i][j]);
    }
    printf("%d\n", c[mx]);
  }

  return 0;
}


Measured memory_bytes: 16888
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    
    infants = [(ai, i) for i, ai in enumerate(A)]
    infants.sort(reverse=True)
    
    dp = [[0] * (N + 1) for _ in range(N + 1)]
    ans = 0
    for x in range(N):
        for y in range(N):
            if x + y == N:
                ans = max(ans, dp[x][y])
                break
            act_level, idx = infants[x + y]
            dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + act_level * abs(idx - x))
            dp[x][y + 1] = max(dp[x][y + 1], dp[x][y] + act_level * abs(idx - (N - y - 1)))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 100028
import java.util.*;
import java.lang.*;
 
 //O(100000000)
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;
        String s1 = sc.next();
        char[] c = s1.toCharArray();
        
        if(c[0]=='1')cnt++;
        if(c[1]=='1')cnt++;
        if(c[2]=='1')cnt++;
        if(c[3]=='1')cnt++;
        if(c[4]=='1')cnt++;
        if(c[5]=='1')cnt++;

        System.out.print(cnt);
        System.out.println();
    }

}

Measured memory_bytes: 20560
#include <bits/stdc++.h>
using namespace std;
// #include"prettyprint.hpp"
typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int n, k; cin >> n >> k;
    int h[n + 1];
    for (int i = 1; i <= n; ++i) cin >> h[i];
    int dp[n + 1];
    dp[1] = 0, dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = 1e9;
        for (int j = 1; j <= k and j < i; ++j) {
            dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
        }
    }
    // debug(arr(dp, n + 1));
    cout << dp[n] << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3")
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x)
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

	int N, K; cin >> N >> K;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	VL sums(N + 1, 0); {
		FOR(i, 0, N) {
			sums[i + 1] = sums[i] + a[i];
		}
	}
	auto query = [&sums](int l , int r) {
		return sums[r] - sums[l];
	};
	VL subs; {
		FOR(i, 0, N) {
			FOR(j, i + 1, N+1) {
				subs.push_back(query(i, j));
			}
		}
	}
	DD(De(subs));
	N = SZ(subs);
	for (int i = 60; i >= 0; i--) {
		vector<LL> X;

		for (auto& r : subs) {
			if (r&(1LL << i)) {
				X.push_back(r);
				r ^= 1LL << i;
			}
		}

		if (X.size() >= K) subs = X;
	}

	cout << subs[0] << endl;

	return 0;
}


Measured memory_bytes: 6128
// Author : ps41

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const int M = 1e9 + 7, N = 1e6 + 5;

int lpf[N], mobius[N]; 

// Function to calculate least 
// prime factor of each number 
void least_prime_factor() 
{ 
    for (int i = 2; i < N; i++) 

        // If it is a prime number 
        if (!lpf[i]) 

            for (int j = i; j < N; j += i) 

                // For all multiples which are not 
                // visited yet. 
                if (!lpf[j]) 
                    lpf[j] = i; 
} 

// Function to find the value of Mobius function 
// for all the numbers from 1 to n 
void Mobius() 
{ 
    for (int i = 1; i < N; i++) { 

        // If number is one 
        if (i == 1) 
            mobius[i] = 1; 
        else { 

            // If number has a squared prime factor 
            if (lpf[i / lpf[i]] == lpf[i]) 
                mobius[i] = 0; 

            // Multiply -1 with the previous number 
            else
                mobius[i] = -1 * mobius[i / lpf[i]]; 
        } 
    } 
} 
int gcd_pairs(int a[], int n) 
{
    int maxi = 0; 
    int fre[N] = { 0 }; 
    for (int i = 0; i < n; i++) { 
        fre[a[i]]++; 
        maxi = max(a[i], maxi); 
    } 
    least_prime_factor(); 
    Mobius(); 
    int ans = 0; 
    for (int i = 1; i <= maxi; i++) { 
        if (!mobius[i]) 
            continue; 

        int temp = 0; 
        for (int j = i; j <= maxi; j += i) 
            temp += fre[j]; 

        ans += temp * (temp - 1) / 2 * mobius[i]; 
    }  
    return ans; 
} 

int main() 
{ 
    int n;
    cin >> n;
    int a[n];
    int g = a[0];
    for (int i = 0; i < n; i++) cin >> a[i], g = __gcd(g, a[i]);
    if (gcd_pairs(a, n) == (n * (n - 1)) / 2) cout << "pairwise coprime";
    else if (g == 1) cout << "setwise coprime";
    else cout << "not coprime" ;
    return 0; 
} 


Measured memory_bytes: 19236
#include <stdio.h>

int main(void) {
  int i, j, k, a[100], n, l, flag = 1, temp, count = 0;
  char buf[2];
  scanf("%d", &l);
  for (i = 0; i < l; i++) {
    scanf("%d", &a[i]);
  }

  while (flag) {
    flag = 0;
    for (j = l - 1; j > 0; j--) {
      if (a[j] < a[j - 1]) {
        temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
        flag = 1;
        count++;
      }
    }
  }

    for (k = 0; k < l; k++) {
      printf("%d", a[k]);
      if (k < l - 1) {
        printf(" ");
      }
    }
    printf("\n");
    printf("%d\n", count);
    return 0;
  }



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define db(x) cerr << #x << ": " << x << "\n";

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

    int K;
    cin >> K;
    ll ans = 0;
    for(int i=1; i<=K; i++)
        for(int j=1; j<=K; j++)
            for(int z=1; z<=K; z++)
                ans += __gcd(i,__gcd(j,z));
    cout << ans << '\n';
}


Measured memory_bytes: 3648
N = int(input())
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
a = 0
b = 0
for x in range(N):
    B[x] = B[x] + a
    if A[x] > B[x]:
        b = b + B[x]
        a = 0
    else:
        b = b + A[x]
        if A[x] > a:
            a = B[x] - A[x]
        else:
            a = B[x] - a
if A[N - 1] > B[N - 1]:
    print(b)
else:
    if A[N] > a:
        print(b + a)
    else:
        print(b + A[N])

Measured memory_bytes: 18752
#include<bits/stdc++.h>
#define LL  long long
#define INF 0x7FFFFFFF
using namespace std;
 
int nums[100 + 5];
int main(){
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 0; i < n; ++i){
		cin >> nums[i];
		sum = sum + nums[i];
	}
	int now = 0;
	int ans = INF;
	for(int i = 0; i < n; ++i){
		now = now + nums[i];
		ans = min(ans, abs(now * 2 - sum));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	int l0 = 2;
	int l1 = 1;
	vector<ll> vec;
	vec.push_back(l0);
	vec.push_back(l1);
	for (int i = 1; i <= 86; i++) {
		vec.push_back(vec[i - 1] + vec[i]);
	}
	cout << vec[N] << endl;
	return 0;
}

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

struct pos{
	int d, h;
	int y, x;
};

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int brd[50][50];
int n, m;
int used[50][50];
P g;
pos st;

int main(){
	cin >> n >> m;
	rep(i,n){
		string str;
		cin >> str;
		rep(j,str.size()){
			if(str[j] == '#') brd[i][j] = 1;
			else brd[i][j] = 0;
			if(str[j] == 'G') g = P(i,j);
			if(str[j] == 'v'){
				st.d = 3; st.h = 2;
				st.y = i; st.x = j;
			}
			if(str[j] == '<'){
				st.d = 2; st.h = 2;
				st.y = i; st.x = j;
			}
			if(str[j] == '>'){
				st.d = 0; st.h = 2;
				st.y = i; st.x = j;
			}
			if(str[j] == '^'){
				st.d = 1; st.h = 2;
				st.y = i; st.x = j;
			}
		}
	}
	used[st.y][st.x] = 1;
	for(int i = 0; i < 10000; i++){
		if(st.y == g.first && st.x == g.second) break;
		if(i == 9999){
			puts("-1");
			return 0;
		}
		if(0<=st.y+dy[(st.d+4-1)%4]&&st.y+dy[(st.d+4-1)%4]<=n-1&&
		   0<=st.x+dx[(st.d+4-1)%4]&&st.x+dx[(st.d+4-1)%4]<=m-1&&
		   brd[st.y+dy[(st.d+4-1)%4]][st.x+dx[(st.d+4-1)%4]] == 0){
			used[st.y+dy[(st.d+4-1)%4]][st.x+dx[(st.d+4-1)%4]] = 1;
			st.y += dy[(st.d+4-1)%4];
			st.x += dx[(st.d+4-1)%4];
			st.d = (st.d+4-1)%4;
		} else if(0<=st.y+dy[st.d]&&st.y+dy[st.d]<=n-1&&
		   0<=st.x+dx[st.d]&&st.x+dx[st.d]<=m-1&&
		   brd[st.y+dy[st.d]][st.x+dx[st.d]] == 0){
			used[st.y+dy[st.d]][st.x+dx[st.d]] = 1;
			st.y += dy[st.d];
			st.x += dx[st.d];
		} else{
			st.d = (st.d+1)%4;
		}
		
		//cout << st.y << " " << st.x << endl;
	}
	
	int ans = 0;
	rep(i,n) rep(j,m) ans += used[i][j];
	cout << ans << endl;
}

Measured memory_bytes: 1232
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(int i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	int a[h][w];
	rep(i, 0, h) rep(j, 0, w) scanf("%d", &a[i][j]);
	rep(i, 0, h) rep(j, 0, w){
		int b;
		scanf("%d", &b);
		a[i][j] = abs(a[i][j]-b);
	}

	//std::vector<std::vector<std::bitset<15000>>> dp(h, std::vector<std::bitset<15000>>(w));
	std::bitset<15000> dp[h][w];
	dp[0][0].set(0);
	rep(i, 0, h) rep(j, 0, w) {
		rep(k, 0, 15000) if(dp[i][j][k]) {
			if(j<w-1){
				dp[i][j+1].set(k+a[i][j]);
				dp[i][j+1].set(abs(k-a[i][j]));
			}
			if(i<h-1){
				dp[i+1][j].set(k+a[i][j]);
				dp[i+1][j].set(abs(k-a[i][j]));
			}
		}
	}
		
	int ans = 15000;
	rep(i, 0, 15000){
		if(dp[h-1][w-1][i]) ans = std::min({ans, i+a[h-1][w-1], abs(i-a[h-1][w-1])});
	}
	printf("%d\n", ans);
	return 0;
}


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

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *NodePointer;

NodePointer r,NIL;


void insert(int k){
  NodePointer y = NIL;
  NodePointer x = r;

  NodePointer z = (NodePointer)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
  z->p = y;

  if(y == NIL){
    r = z;
  }else if(z->key < y->key){
    y->l = z;
  }else{
    y->r = z;
  }
}

void inorder(NodePointer u){
  if(u == NIL){
    return;
  }
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(NodePointer u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void print(){
  inorder(r);
  puts("");
  preorder(r);
  puts("");
}

int main(){
  int n,i,j,z;
  char s[10];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%d",s,&z);
    if(s[0] == 'i'){
      insert(z);
    }else{
      print();
    }
  }

  return 0;
}

Measured memory_bytes: 24048
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n,sum;
int main(){
    cin>>n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(),v.end());
    rep(i,n-1){
        sum+=v[i];
    }
    if(v[n-1]<sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
#print(N, M, X, Y)
#print(x)
#print(y)
x.append(X)
y.append(Y)


def is_war(x, y):
    flag = "No War"
    for i in x:
        for j in y:
            if i >= j:
                flag = "War"
                return flag
    return flag


flag = is_war(x, y)
print(flag)

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

int main() {
    int n;
    int w[110];
    int s1, s2;
    int ans = INT_MAX;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }
    
    for (int i = 0; i < n; i++) {
        s1 = 0;
        s2 = 0;
        
        for (int ii = 0; ii < n; ii++) {
            if (ii <= i) {
                s1 += w[ii];
            }
            else {
                s2 += w[ii];
            }
        }
        
        ans = min(ans, abs(s1 - s2));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    int N; cin >> N;
    vector<int> A(N);
    for (auto&& i : A) cin >> i;
    for (auto&& i : A) { int k = 0; while (i%2==0) i/=2, k++; i = k; }
    cout << *min_element(A.begin(), A.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
if a[0]*a[1] > a[0]-a[1] and a[0]*a[1] > a[0]+a[1]:
    print(a[0]*a[1])
elif a[0]-a[1] > a[0]+a[1]:
    print(a[0]-a[1])
else:
    print(a[0]+a[1])

Measured memory_bytes: 9048
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = min(a, b) + min(c, d);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let c: String = read();
    let mut c = c.chars().collect::<Vec<char>>();
    let mut left: usize = 0;
    let mut right: usize = n - 1;
    if !c.contains(&'R') || !c.contains(&'W') {
        print!("0");
        return;
    }
    let mut ans = 0;
    loop {
        while c[left] == 'R' {
            left += 1;
        }
        while c[right] == 'W' {
            right -= 1;
        }
        if left > right {
            break;
        }
        c.swap(left, right);
        ans += 1;
    }
    print!("{}", ans);
}


Measured memory_bytes: 3200
N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
for n in range(N):
    S[n+1] = S[n] + A[n]
B = {}
for s in range(len(S)):
    B[S[s]] = 0
for s in range(len(S)):
    B[S[s]] += 1
res = 0
for v in B.values():
    if v > 1:
        res += v * (v - 1) // 2
print(res)


Measured memory_bytes: 43868
#include <iostream>
#include <vector>
#include <queue>

// 実は一本道 
int main()
{
    int N;
    std::cin >> N;

    std::vector<int> a(N);
    for(int i=0; i<N; i++)
    {
        int tmp;
        std::cin >> tmp;
        a[i] = tmp - 1; // iを押したらa[tmp]が光る 
    }

    int ans = -1;

    int now = 0;
    int cnt = 0;
    while(true)
    {
        // std::cout << "e\n";
        if(now == 2-1)
        {
            ans = cnt;
            break;
        }
        int next = a[now];
        // そこから進まない 
        if(next == now)
        {
            break;
        }else if(cnt > N)
        {
            break;
        }

        now = next;
        cnt++;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))
ans = -1
minv = float('inf')
for i, h in enumerate(H):
	if abs(a - (t - h*0.006)) < minv:
		minv = abs(a - (t - h*0.006))
		ans = i + 1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int N,head[MAXN],sumE;
int mask[MAXN],ans;
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u,int fa) {
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            dfs(v,u);
        }
    }
    mask[u] = 0;
    vector<int> vec;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            mask[u] |= mask[v];
            vec.pb(mask[v]);
        }
    }
    int t = 0;
    for(int i = 0 ; i <= 20 ; ++i) {
        if(mask[u] >> i & 1) {
            if(t == i) ++t;
            int cnt = 0;
            for(auto k : vec) {
                if(k >> i & 1) ++cnt;
            }
            if(cnt > 1) t = max(t,i + 1);
        }
    }
    mask[u] |= (1 << t);
    ans = max(ans,t);
    for(int i = 0 ; i < t ; ++i) {
        if(mask[u] >> i & 1) mask[u] ^= (1 << i);
    }
    return ;
}
void Solve() {
    read(N);
    int a,b;
    for(int i = 1 ; i < N ; ++i) {
        read(a);read(b);add(a,b);add(b,a);
    }
    dfs(1,0);
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 8320
n = int(input())
a = list(map(int, list(input().split(" "))))
result = {}

for i in range(n):
  x = a[i]
  if x not in result:
    result[x] = 1;
  else:
    result[x] = result[x] + 1;

  y = x + 1
  if y not in result:
    result[y] = 1;
  else:
    result[y] = result[y] + 1;

  z = x - 1
  if z not in result:
    result[z] = 1;
  else:
    result[z] = result[z] + 1;

print(max(result.values()))


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

int main() {
	long long N, M;
	cin >> N >> M;
	vector<pair<long long,long long>>A(M);
	vector<pair<pair<long long, long long>, long long>> B(M);
	for (long long i = 0; i < M; i++) {
		cin >> A.at(i).first >> A.at(i).second;
		B.at(i) = make_pair(A.at(i), i);
	}
	sort(B.begin(), B.end());
	vector<string>ans(M);
	long long pre = A.at(B.at(0).second).first;
	long long k = 0;
	for (int i = 0; i < M; i++) {
		string S = to_string(A.at(B.at(i).second).first);
		for (int j = 0; j < 6 - S.size(); j++) {
			ans.at(B.at(i).second).push_back('0');
		}
		for (int j = 0; j < S.size(); j++) {
			ans.at(B.at(i).second).push_back(S.at(j));
		}
		if (A.at(B.at(i).second).first == pre) k++;
		else {
			pre = A.at(B.at(i).second).first;
			k = 1;
		}
		string T = to_string(k);
		for (int j = 0; j < 6 - T.size(); j++) {
			ans.at(B.at(i).second).push_back('0');
		}
		for (int j = 0; j < T.size(); j++) {
			ans.at(B.at(i).second).push_back(T.at(j));
		}
	}
	for (long long i = 0; i < M; i++) {
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 12416
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e5;
const int DD = 10;
int visit[DD + 2][N + 5];

vector<int> lst[N + 5];

int V[N + 5], D[N + 5], C[N + 5];
queue<pair<int,int> > q;

void hora(int tc) {
	int n, m;
	cin>>n>>m;
	while(m--) {
		int u, v;
		cin>>u>>v;
		lst[u].pb(v), lst[v].pb(u);
	}
	int Q;
	cin>>Q;
	for(int i = 0;i < Q;i++) cin>>V[i]>>D[i]>>C[i];
	memset(visit, -1, sizeof visit);
	for(int i = Q - 1;i >= 0;i--) {
		int start = V[i];
		int step = D[i];
		int col = C[i];
		if(visit[step][start] != -1) continue;
		visit[step][start] = i;
		q.push({step, start});
		while(!q.empty()) {
			int step = q.front().F;
			int pos = q.front().S;
			q.pop();
			if(step == 0) continue;
			for(int x: lst[pos]) {
				if(visit[step - 1][x] != -1) continue;
				visit[step - 1][x] = i;
				q.push({step - 1, x});
			}
		}
	}
	for(int i = 1;i <= n;i++) {
		int maxi = -1;
		for(int j = 0;j <= DD;j++) maxi = max(maxi, visit[j][i]);
		if(maxi == -1) cout<<0<<endl;
		else cout<<C[maxi]<<endl;
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 12840
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long C = scan.nextLong();
        long K = scan.nextLong();
        long[] l = new long[N];
        for (int i = 0; i < N; i++) {
            l[i] = scan.nextLong();
        }
        Arrays.sort(l);
        long[] r = new long[N];
        for (int i = 0; i < N; i++) {
            r[i] = l[i] + K;
        }
        int answer = 0;
        long current = Long.MAX_VALUE;
        long number_of_people = 0;
        for (int i = N-1; 0 <= i; i--) {
            if (number_of_people == C) {
                answer += 1;
                number_of_people = 0;
                current = l[i];
            }
            if (r[i] < current) {
                answer += (number_of_people + (C-1))/C;
                number_of_people = 1;
                current = l[i];
                continue;
            }
            number_of_people += 1;
        }
        answer += (number_of_people + (C - 1)) / C;
        System.out.println(answer);
    }
}


Measured memory_bytes: 50108
#include<iostream>
#include<math.h>

using namespace std;
long long a[3000000];
long min(long x,long y){
    if(x<y)return x;
    else return y;
}
int main(){
    long long d,n,i,sum=0,ans=0,mina=10000000000000000;
    
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
        ans+=a[i];
    }

    for(i=1;i<n;i++){
        sum+=a[i];
        d=ans-sum-sum;
        if(d<0)d=-d;
        if(d<mina){
            mina=d;
        }
    }
    cout<<mina;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
int main(void){

	vector<int> a;
	int b[100];
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;

	scanf("%d", &n);
	s = 0;
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		a.push_back(x);
		s = s + x;
	}
	if (s % 10 != 0){
		printf("%d\n", s);
		return 0;
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++){
		if (a[i] % 10 != 0){
			printf("%d\n", s - a[i]);
			return 0;
		}
	}

	printf("0\n");
	return 0;
}


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

int main() {
int N;
 double a;
  cin >> N;
	if(N%2 == 0){
    	cout << 0.500000 << endl;
    }
  else {
    a = N;
    cout << fixed << setprecision(12) << (a+1)/2/a << endl;
		
       }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    sort (h.begin(), h.end());
    int ans = INT_MAX;
    for (int i = 0; i <= n-k; i++)
        ans = min(ans, h[i+k-1]-h[i]);

    cout << ans << endl;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
 
using namespace std;
typedef long long ll;
 
const ll M = (long long) 1e9+7;
const ll NMAX=2002;
 
vector<ll> fac(NMAX); 
vector<ll> ifac(NMAX); 
 
 
ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){ 
    if(a == 0 && b == 0)return 1;
    if(b == 0) return 1;
    if(a < b || a < 0 || b<0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
 
int main()
{
    ll N,K;
    cin >> N >> K;
    ll NR, NB;

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<NMAX; i++){
        fac[i+1] = fac[i]*(i+1) % M; 
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; 
    }
 
    for(ll i=1; i<=K; i++){
        ll j;
        if(N-K==0){
            j=1;
        }else{
            j=2;
        }
        NR= comb(N-K-1, i-2)+j*comb(N-K-1, i-1)+comb(N-K-1, i);
        NB= comb(K-1, i-1);
        ll ans;
        ans=(NR*NB)%M;
        if(N-K==0 && i>1) ans=0;
        cout << ans << endl;
    }

    return 0;
}

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

void fnInput(vector<int>& rvnHigh)
{
  int nHighSiz;
  cin >> nHighSiz;
  rvnHigh.resize(nHighSiz);

  for (int& rnHigh : rvnHigh)
    cin >> rnHigh;
}

llong fnMinStepHigh(vector<int>& rvnHigh)
{
  llong nMinStepHigh = 0;

  for (int i = 0; i < rvnHigh.size() - 1; ++i)
    if (rvnHigh[i] - rvnHigh[i + 1] > 0)
    {
      nMinStepHigh += rvnHigh[i] - rvnHigh[i + 1];
      rvnHigh[i + 1] = rvnHigh[i];
    }

  return nMinStepHigh;
}
  
int main()
{
  vector<int> vnHigh;
  
  fnInput(vnHigh);
  cout << fnMinStepHigh(vnHigh) << endl;

  return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll n,m,l,r,i,j,maxi=INT_MIN,mini=INT_MAX;
    cin>>n>>m;
    while(m--)
    {
        cin>>l>>r;
        maxi=max(maxi,l);
        mini=min(mini,r);
    }
    cout<<max(0*1ll,mini-maxi+1)<<endl;



    return 0;
}





Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    string s;
    cin >> n >> s;
    REP(i, s.size()) {
        int x = s[i] - 'A';
        if (x+n >= 26) {
            int y = (s[i] + n) - 'A';
            y %= 26;
            s[i] = 'A' + y;
        } else s[i] = s[i] + n;
    }
    cout << s << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

vector<int> v[2020];
vector<int> g[2020];
bitset<2020> bs[2020];

int main(){
  int n,x,y; cin >> n >> x >> y;
  x--;y--;
  for(int i = 0; i < n; ++i)v[i].push_back(i);
  for(int i = 0; i < n; ++i)bs[i][i] = 1;
  for(int i = 1; i < n; ++i)g[i].push_back(i-1);
  for(int i = 0; i < n-1; ++i)g[i].push_back(i+1);
  g[x].push_back(y);
  g[y].push_back(x);
  for(int i = 1; i < n; ++i){
    int cnt = 0;
    vector<int> w[2020];
    for(int j = 0; j < n; ++j){
      for(auto e:g[j]){
	for(auto ee:v[e]){
	  if(bs[j][ee])continue;
	  w[j].push_back(ee);
	  bs[j][ee] = 1;
	  cnt++;
	}
      }      
    }
    for(int i = 0; i < n; ++i)v[i] = move(w[i]);
    cout << cnt/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define N 509
using namespace std;

int n,m,a[N],ans[N*N],q[N];
void gg(){
	puts("No"); exit(0);
}
bool cmp(int x,int y){ return a[x]<a[y]; }
int main(){
	scanf("%d",&n); m=n*n;
	int i,j,k,l;
	for (i=1; i<=n; i++){
		scanf("%d",&a[i]);
		if (ans[a[i]]) gg(); ans[a[i]]=i;
	}
	for (i=1; i<=n; i++) q[i]=i;
	sort(q+1,q+n+1,cmp);
	for (l=1; l<=n; l++){
		i=q[l];
		for (j=1,k=1; j<a[i] && k<i; j++) if (!ans[j]){
			ans[j]=i; k++;
		}
		if (k<i) gg();
	}
	for (l=n; l; l--){
		i=q[l];
		for (j=m,k=n; j>a[i] && k>i; j--) if (!ans[j]){
			ans[j]=i; k--;
		}
		if (k>i) gg();
	}
	puts("Yes");
	for (i=1; i<=m; i++) printf("%d%c",ans[i],(i<m)?' ':'\n');
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
bool can[50][51];
bool tmp[51];
int need[50];

void apply(bool *a, int mod) {
    for (int i = mod; i <= 50; ++i) {
        if (a[i]) {
            a[i % mod] = true;
        }
    }
}

int main() {
    scanf("%d", &n);
    forn(i, n) {
        int x;
        scanf("%d", &x);
        can[i][x] = true;
    }
    forn(i, n) {
        scanf("%d", need + i);
    }
    forn(i, n) {
        forn(j, 51) tmp[j] = can[i][j];
        for (int k = 50; k >= 1; --k) {
            apply(tmp, k);
        }
        if (!tmp[need[i]]) {
            cout << -1 << endl;
            return 0;
        }
    }
    LL ans = 0;
    for (int mod = 50; mod >= 1; --mod) {
        bool ok = true;
        forn(i, n) {
            forn(j, 51) tmp[j] = can[i][j];
            for (int k = mod - 1; k >= 1; --k) {
                apply(tmp, k);
            }
            if (!tmp[need[i]]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            continue;
        }
        ans += 1ll << mod;
        forn(i, n) {
            apply(can[i], mod);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256