akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
typedef vector<ll> vc;
typedef vector<string> vcs;
typedef vector<pair<ll, ll>> vcp;
typedef vector<tuple<ll, ll, ll>> vct;

//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n;
	cin >> n;
	vc v(n);
	map<ll, ll> mp;
	REP(i, n) {
		cin >> v[i];
		mp[v[i]]++;
	}
	sort(ALL(v), greater<ll>());
	int f = 0;
	REP(i, v.size() - 1)
	{
		if (mp[v[i]] >= 4)
		{
			if (f) cout << v[i] * f << endl;
			else cout << v[i] * v[i] << endl;
			return 0;
		}
		if (mp[v[i]] >= 2)
		{
			if (f)
			{
				cout << f*v[i] << endl;
				return 0;
			}
			f = v[i];
			i++;
			mp[v[i]] -= 2;
		}
	}
	cout << 0 << endl;
}

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

int main(){
    string S;
    cin>>S;
    int max=0;
    int cnt=0;
    int N;
    N=S.size();
    for(int i=0;i<N;i++){
        if(S.at(i)=='A' || S.at(i)=='C' || S.at(i)=='G' || S.at(i)=='T'){
            cnt++;
        }
        else if(max<cnt){
            max=cnt;
            cnt=0;
        }
        else{
            cnt=0;
        }
    }
    if(max<cnt){
        max=cnt;
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        String s = in.next();int cnt=0;
        for(int i=0;i<n-2;i++){
            if(s.charAt(i)=='A'&&s.charAt(i+1)=='B'&&s.charAt(i+2)=='C') cnt++;
        }out.println(cnt);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 23124
import java.util.*;

// ABC 22-C
// http://abc022.contest.atcoder.jp/tasks/abc022_c
 
public class Main {

	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);
		
		long n = in.nextLong();
		for (int i = (int) Math.sqrt(n); i > 0; i--) {
			if (n % i == 0) {
				System.out.println(Math.max(numDigit(i), numDigit((int) (n / i))));
				break;
			}
		}
	}
	
	public static int numDigit(int n) {
		int answer = 0;
		while (n > 0) {
			answer++;
			n /= 10;
		}
		return answer;
	}
}

Measured memory_bytes: 21076
# coding: utf-8
# Your code here!

SA, SB, SC = list(input()), list(input()), list(input())
next = "a"

while True:
    if next == "a":
        if len(SA) == 0:
            print("A")
            break
        else:
            next = SA[0]
            del SA[0]
    elif next == "b":
        if len(SB) == 0:
            print("B")
            break
        else:
            next = SB[0]
            del SB[0]
    else:
        if len(SC) == 0:
            print("C")
            break
        else:
            next = SC[0]
            del SC[0]


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		int K = stdIn.nextInt();
		
		int fromA = 0;
		int fromB = 0;
		int fromC = 0;
		
		if(K <= A) {
			fromA = K;
		}else {
			fromA = A;
			if(K - A <= B) {
				fromB = K - A;
			}else {
				fromB = B;
				fromC = K - A - B;
			}
		}
		
		System.out.println(fromA - fromC);

	}

}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n, x; cin >> n >> x;
  vi l(n); rep(i,n) cin >> l[i];
  int d = 0, ans = 0;
  if(d <= x) ans++;
  rep(i,n){
    d += l[i];
    if(d <= x) ans++;
  }
  cout << ans << endl;
}


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

ll n,l,a[100000];

int main(){
    cin>>n>>l;
    rep(i,n)cin>>a[i];
    int x=0;
    rep(i,n-1)if(a[i]+a[i+1]>=l)x=i+1;
    if(x==0){
        cout<<"Impossible\n";
        return 0;
    }
    cout<<"Possible\n";
    for(int i=1;i<x;i++)cout<<i<<endl;
    for(int i=n-1;i>=x;i--)cout<<i<<endl;
}

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

const int N = 3e5 + 9;

vector<int> build_lps(string p) {
    int sz = p.size();
    vector<int> lps;
    lps.assign(sz + 1, 0);
    int j = 0;
    lps[0] = 0;
    for(int i = 1; i < sz; i++) {
        while(j >= 0 && p[i] != p[j]) {
            if(j >= 1) j = lps[j - 1];
            else j = -1;
        }
        j++;
        lps[i] = j;
    }
    return lps;
}
inline int min_rep(int n, int lps) {
	return n % (n - lps) == 0 ? n - lps : n;
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s; cin >> s;
    int n = s.size();
    auto lps = build_lps(s);
    int cur = min_rep(n, lps[n - 1]);
    if (cur == 1) return cout << n << '\n' << 1 << '\n', 0;
    if (cur == n) return cout << 1 << '\n' << 1 << '\n', 0;
    cout << 2 << '\n';
    int ans = 0;
    vector<int> ok(n, 0);
    for (int i = 0; i + 1 < n; i++) {
    	if (min_rep(i + 1, lps[i]) == i + 1) ok[i] ++;
    }
    reverse(s.begin(), s.end());
    lps = build_lps(s);
    for (int i = 0; i + 1 < n; i++) {
    	if (min_rep(i + 1, lps[i]) == i + 1) ok[n - i - 2] ++;
    }
    for (int i = 0; i + 1 < n; i++) ans += ok[i] == 2;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
map<string,ll>mp;
map<ll,ll>mpp;

int main(){

     ll n,m,i,j,k,s=0,t;

     cin>>k>>n>>m;

    for(i=n;i<=m;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

string S;

int main() {
  cin >> S;

  int N = S.size();
  int ans = 0;

  for (int i = 0; i < N / 2; ++i) {
    ans += S[i] != S[N - 1 - i];
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int count = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        int sum = 500 * i + 100 * j + 50 * k;
        if (sum == X) count++;
      }
    }
  }
  cout << count;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  string n;
  cin >> n;
  bool c = true;
  if(n[0] != '1')c=false;
  for(int i = 1; i < n.size(); i++)if(n[i] != '0')c=false;
  if(c) cout << 10;
  else{
    int ans=0, a = atoi(n.c_str());
    rep(i, n.size()){
      ans += a % 10;
      a /= 10;
    }
    cout << ans;
  }    
}

Measured memory_bytes: 256
n, W = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(n)]
dp = [float("inf") for _ in range(1000*n+1)]
dp[0] = 0
#dp[i][j]: i個目まで選んで価値jにするのに必要な重さ(Wを超えないように記録)
for i in range(n):
	for v in range(1000*n, t[i][1]-1, -1):
		if dp[v - t[i][1]] + t[i][0] <= W:
			dp[v] = min(dp[v], dp[v - t[i][1]] + t[i][0])
		

#print(dp[1][30], dp[2][30])
#print(dp)

ans = 0
for v in range(1000*n+1):
	if dp[v] <= W:
		ans = v

print(ans)

Measured memory_bytes: 54400
/*input
4
2 2 1 3
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll n; cin >> n;
	vector<ll> v(n);
	for(ll i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	ll left = n - 2, idx = n - 2, sum = v[n - 1];
	while(left > 0) {
		sum += min(left, (ll)2) * v[idx];
		left -= 2;
		idx--;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector< pair<int, int> > vec;
	pair<int, int> p;
	int temp0, temp1;

	for (int i = 0 ;; ++i)
	{
		cin >> temp0 >> temp1;
		if (temp0 == 0 && temp1 == 0) break;

		p = make_pair(temp0, temp1);

		vec.emplace_back(p);
	}

	for (auto&& v : vec) {
		int bigger, smaller;
		if (v.second > v.first) {
			bigger = v.second;
			smaller = v.first;
		}
		else {
			bigger = v.first;
			smaller = v.second;
		}
		cout << smaller << " " << bigger << "\n";
	}

	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

constexpr ll mod = 1e9+7;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    ll t = 0;
    rep(i, 0, N-1){
        rep(j, i+1, N){
            if(A[i] > A[j]){
                t++;
                t %= mod;
            }
        }
    }
    ll ans = t * K;
    ans %= mod;
    ll cnt = 0;
    rep(i, 0, N){
        rep(j, 0, N){
            if(A[i] < A[j]){
                cnt++;
                cnt %= mod;
            }
        }
    }
    ans += ((K * (K-1)/ 2) % mod) * cnt;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <cmath>
using namespace std;

int N, H, W, i, j, A, B;

int main(void) {
    cin >> N >> H >> W;
    
    int ans = 0;
    for (i=0; i<N; i++) {
        cin >> A >> B;
        if (A >= H && B >= W) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    vector<string> t;
    t.emplace_back("KIHBR");
    t.emplace_back("KIHBRA");
    t.emplace_back("KIHBAR");
    t.emplace_back("KIHBARA");
    t.emplace_back("KIHABR");
    t.emplace_back("KIHABRA");
    t.emplace_back("KIHABAR");
    t.emplace_back("KIHABARA");
    t.emplace_back("AKIHBR");
    t.emplace_back("AKIHBRA");
    t.emplace_back("AKIHBAR");
    t.emplace_back("AKIHBARA");
    t.emplace_back("AKIHABR");
    t.emplace_back("AKIHABRA");
    t.emplace_back("AKIHABAR");
    t.emplace_back("AKIHABARA");
    bool ans = false;
    for(auto &m: t) if(m == s) ans = true;
    ans ? YES() : NO();
}

Measured memory_bytes: 3688
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> ret;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main(void)
{
    ll n;
    cin >> n;
    int i;

    map<ll, ll> m = prime_factor(n);

    ll ans = 0;

    for (auto x : m)
    {
        for (i = 1; i < 500; i++)
        {
            if (x.second < i * (i + 1) / 2)
            {
                break;
            }
        }

        ans += i - 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;

# define INF ((int)(1<<30))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12

template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int dir(pii a, pii b)
{
	if (a.second < b.second)return 0;
	if (a.first < b.first)return 1;
	if (a.second > b.second)return 2;
	if (a.first > b.first)return 3;
}
int dis(pii a, pii b)
{
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int main()
{
	int n;
	while (cin >> n&&n)
	{
		vector<pii> o[100];
		REP(j, n + 1)
		{
			int m;
			cin >> m;
			REP(i, m)
			{
				pii p;
				cin >> p.first >> p.second;
				o[j].push_back(p);
			}
		}

		vector<pii> a[2][100];
		REP(j, n + 1)
		{
			REP(k, 2)
			{
				int b = dir(o[j][0], o[j][1]);
				int d[4][4] = { {0,1,0,-1},{-1,0,1,0},{0,-1,0,1},{1,0,-1,0} };
				REP(i, o[j].size() - 1)
				{
					pii next;
					next.first = d[b][dir(o[j][i], o[j][i + 1])];
					next.second = dis(o[j][i], o[j][i + 1]);
					b = dir(o[j][i], o[j][i + 1]);
					a[k][j].push_back(next);
				}
				reverse(ALL(o[j]));
			}
		}
		for (int i = 1; i <= n; i++)
		{
			if (a[0][0] == a[0][i] || a[0][0] == a[1][i])
				cout << i << endl;
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 3112
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

digitSum = sum . map digitToInt . show

main = do
    n <- getInteger
    let len = length $ show n
    let base = replicate (len - 1) '9'
    let list = filter (<=n) [readInteger (i : base) | i <- "0123456789"]
    print $ maximum $ map digitSum list

Measured memory_bytes: 636
if __name__ == '__main__':
    sx,sy,tx,ty=list(map(int,input().split()))
    dif_x=tx-sx
    dif_y=ty-sy
    path=[]

    path.append("R"*abs(dif_x))
    path.append("U"*abs(dif_y))
    path.append("L"*abs(dif_x))
    path.append("D"*abs(dif_y))
    path.append("D")
    path.append("R" * (abs(dif_x) + 1))
    path.append("U" * (abs(dif_y) + 1))
    path.append("L")
    path.append("U")
    path.append("L" * (abs(dif_x) + 1))
    path.append("D" * (abs(dif_y) + 1))
    path.append("R")
    print("".join(path))








Measured memory_bytes: 3064
#include <iostream>

int main()
{
    int w;
    while (std::cin >> w) {
        bool top = true;
        for (int i = 1; i <= 512; i <<= 1) {
            if (w & i) {
                if (top) top = false;
                else std::cout << " ";
                std::cout << (w & i);
            }
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 1160
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a, b = map(int, input().split())
    c, d = map(int, input().split())

    print(a*b - (a*d + b*c-c*d) )



Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<vector<int>> S(N,vector<int>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin>>S[i][j];
    }
  }
  int L=0; int Ans=0;
  for(int i=0; i<N; i++){
    if(S[i][0]==S[i][1]){
      L++;
    if(L==3){
      Ans++;
    }
    }
    else L=0;
  }
  if(Ans!=0)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
n = int(input())
a_list = list(map(int, input().split()))
a_map = {}
for i in range(n):
    a_map[i + 1] = a_list[i]
ans = sorted(a_map.items(), key=lambda x:x[1])
for i in range(n-1):
    print(str(ans[i][0]), end=" ")
print(ans[n-1][0])

Measured memory_bytes: 26296
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::vec_deque::VecDeque;

fn main() {
    input! {
        h: usize,
        w: usize,
        n: usize,
        aa: [usize;n]
    }
    let mut q = VecDeque::new();
    for (i,a) in aa.iter().enumerate() {
        for _ in 0..*a {
            q.push_back(i+1);
        }
    }
    let mut b = true;
    let mut vv = vec![vec![0;w];h];
    for i in 0..h {
        for j in 0..w {
            let k = if b {j} else {w-j-1};
            vv[i][k] = q.pop_front().unwrap();
        }
        b = !b;
    }
    for v in vv {
        for x in v {
            print!("{} ", x);
        }
        println!();
    }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,w; scanf("%d%d",&n,&w);
    vector<int> x(n),y(n),z(n);
    rep(i,0,n)scanf("%d%d%d",&x[i],&y[i],&z[i]);
    int dp[10010]={},idx[10010],deq[10010];
    rep(i,0,n)rep(a,0,y[i]){
        int s=0,t=0;
        for(int j=0;j*y[i]+a<=w;j++){
            int val=dp[j*y[i]+a]-j*x[i];
            while(s<t&&deq[t-1]<=val)t--;
            idx[t]=j; deq[t++]=val;
            dp[j*y[i]+a]=deq[s]+j*x[i];
            if(idx[s]==j-z[i])s++;
        }
    }
    printf("%d\n",dp[w]);
    return 0;
}


Measured memory_bytes: 3332
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}


vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

//mapで書き換えるか。値と個数のペアだ。
//それか大きい順に適用してみよう

struct my_pair {
	int b, c;
	bool operator<(my_pair p) {
		return c < p.c;
	}
};
int main() {
	int n, m;
	cin >> n >> m;
	auto vs = vector<long long>(n);
	long long sum = 0;
	for (size_t i = 0; i < n; i++) {
		cin >> vs[i];
		sum += vs[i];
	}
	sort(vs.begin(), vs.end());
	int b, c;
	auto pairs = vector<my_pair>(m);
	for (size_t i = 0; i < m; i++) {
		cin >> b >> c;
		pairs[i] = { b,c };
	}
	sort(pairs.begin(), pairs.end());
	for (size_t i = 0; i < m; i++) {
		for (size_t j = 0; j < pairs[m - 1 - i].b; j++) {
			if (vs[0] >= pairs[m - 1 - i].c) {
				cout << sum << endl;
				return 0;
			}
			sum += pairs[m - 1 - i].c - vs[0];
			vs.erase(vs.begin());
			if (vs.size() == 0) {
				cout << sum << endl;
				return 0;
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 1920
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

#define all(x)                          \
(x).begin(), (x).end()

#define rall(x)                         \
(x).rbegin(), (x).rend()

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

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    int x, y; cin >> x >> y;
    cout << x + y / 2 << endl;

return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    if (s == "SUN") cout << 7 << endl;
    else if (s == "MON") cout << 6 << endl;
    else if (s == "TUE") cout << 5 << endl;
    else if (s == "WED") cout << 4 << endl;
    else if (s == "THU") cout << 3 << endl;
    else if (s == "FRI") cout << 2 << endl;
    else if (s == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,m,q,pfs[2001][2001][5]={};
string mp[2001]={};
bool isV(int y,int x) {return y>=0&&y<n&&x>=0&&x<m;}
void dfs(int y,int x,int py,int px)
{
	pfs[y+1][x+1][0] = 1;
	if (isV(y+1,x))
	{
		if ((y+1!=py||x!=px)&&mp[y+1][x]=='1') {pfs[y+2][x+1][1] = 1;dfs(y+1,x,y,x);}
	}
	if (isV(y,x+1))
	{
		if ((y!=py||x+1!=px)&&mp[y][x+1]=='1') {pfs[y+1][x+2][2] = 1;dfs(y,x+1,y,x);}
	}
	if (isV(y-1,x))
	{
		if ((y-1!=py||x!=px)&&mp[y-1][x]=='1') {pfs[y][x+1][3] = 1;dfs(y-1,x,y,x);}
	}
	if (isV(y,x-1))
	{
		if ((y!=py||x-1!=px)&&mp[y][x-1]=='1') {pfs[y+1][x][4] = 1;dfs(y,x-1,y,x);}
	}
}
int gtsm(int y1,int x1,int y2,int x2,int t)
{
	if (x2<x1||y2<y1) {return 0;}
	else {return pfs[y2][x2][t] - pfs[y1-1][x2][t] - pfs[y2][x1-1][t] + pfs[y1-1][x1-1][t];}
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m>>q;
	for (int i=0;i<n;i++) {cin>>mp[i];}
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++) 
		{
			if (mp[i][j]=='1'&&pfs[i+1][j+1][0]==0) {dfs(i,j,-1,-1);}
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			for (int k=0;k<5;k++) {pfs[i][j][k] += pfs[i-1][j][k] + pfs[i][j-1][k] - pfs[i-1][j-1][k];}
		}
	}
	for (int i=0;i<q;i++)
	{
		int x1,y1,x2,y2;
		cin>>y1>>x1>>y2>>x2;
		cout<<gtsm(y1,x1,y2,x2,0) - gtsm(y1+1,x1,y2,x2,1) - gtsm(y1,x1+1,y2,x2,2) - gtsm(y1,x1,y2-1,x2,3) - gtsm(y1,x1,y2,x2-1,4)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 85504
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(u64);

    let m = (1..).take_while(|&i| 2u64.pow(i) - 1 <= n).last().unwrap();
    let mut n = n - (2u64.pow(m) - 1);
    let mut ins = Vec::new();
    for i in (0..m).rev() {
        if n >= 2u64.pow(i) {
            n -= 2u64.pow(i);
            ins.push(i);
        }
    }


    let mut ans = Vec::new();

    let mut l = m + ins.len() as u32;
    let ll = m + ins.len() as u32;


    for i in 0..m {
        if !ins.is_empty() && ins.last().cloned().unwrap() == i {
            ans.push(l);
            l -= 1;
            ins.pop();
        }
        ans.push(i + 1);
    }

    for i in 0..ll {
        ans.push(i + 1);
    }

    println!("{}", ans.len());
    println!(
        "{}",
        ans.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(
            " ",
        )
    );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N; cin >> N;
  vector<int> vec(N+2);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);}
  vec.at(N)=0; vec.at(N+1);
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int Alice=0, Bob=0;
  for(int j=0;j<N/2+1;j++){
    Alice += vec.at(2*j);
    Bob += vec.at(2*j+1);
  }
  
  cout << Alice-Bob << endl;  
}    

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
main(){
  int n, i;
  int A[MAX+1];
  scanf("%d", &n);
  for ( i =1; i <= n; i++ ) scanf("%d", &A[i]);

  for ( i = 1; i <= n; i++ ) {
    printf("node %d: key = %d, ", i, A[i]);
    if ( i / 2 >= 1 ){
printf("parent key = %d, ", A[i/2]);
}
    if ( 2*i <= n ) {
printf("left key = %d, ", A[2*i]);
}
    if ( 2*i+1 <= n ) {
printf("right key = %d, ", A[i*2+1]);
}
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;

ll pow(ll n, ll r) {
    if (r == 0) return 1;
    if (r % 2) return n * pow(n, r - 1);
    ll temp = pow(n, r / 2);
    return temp * temp;
}

ll comb(ll n, ll r) {
    if (r > n - r) return comb(n, n - r);
    ll deno = 1, nume = 1;
    for (ll i = 0; i < r; ++i) {
        nume *= n - i;
        deno *= i + 1;
    }
    return nume / deno;
}

int main() {
    ll n, p, a, ans = 0;
    vector<int> d(2);
    cin >> n >> p;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        ++d.at(a % 2);
    }
    for (int i = p; i <= d.at(1); i += 2) ans += comb(d.at(1), i);
    ans *= pow(2, d.at(0));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        Deque<String> words = new ArrayDeque<>();
        words.add("a");
        
        while(true){
            if(words.getFirst().length() == N) break;
            String word = words.removeFirst();
            String[] charArr = word.split("");
            Set<String> usedChar = new HashSet<>();
            for (String string : charArr) usedChar.add(string);
            String firstUnused = "";
            for(char c='a'; c-'a'<26; c++){
                if(usedChar.contains(String.valueOf(c))){
                    continue;
                }
                firstUnused = String.valueOf(c);
                break;
            }
            for (String string : usedChar) {
                words.addLast(word+string);
            }
            words.addLast(word+firstUnused);
        }
        for (String string : words) {
            System.out.println(string);
        }
    }
}

Measured memory_bytes: 66916
N = gets.chomp.to_i
str1 = gets.split
H = []

for x in 0...N
  H[x] = str1[x].to_i
end

answer = 1
high = H[0]

for x in 1...N
  if H[x] >= high
    answer += 1
    high = H[x]
  end
end

puts answer

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    string S;
    cin >> S;

    string T("");

    while (S.size()) {
        T += S.back();
        S.pop_back();

        // not match
        if (T.size() >= 8) break;
        // reset if match
        if (T == "maerd" || T == "esare" || T == "remaerd" || T == "resare") {
            T = "";
        }
    }

    if (!T.size()) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }


    return 0;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    cout<<(a+b)/2<<endl;
  }else{
    cout<<(a+b)/2+1<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, c, k;
  cin >> n >> c >> k;
  vector<ll> t(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  sort(all(t));
  ll cnt = 0;
  ll tlim = -1;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if(cnt < c && t[i] <= tlim) {
      cnt++;
    } else {
      ans++;
      cnt = 1;
      tlim = t[i] + k;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int w,n;
	cin>>w>>n;
	int a[30],b[30],c[30];
	char d;
	for(int i=1;i<=w;i++){
		a[i]=i;
	}
	for(int i=1;i<=n;i++){
		cin>>b[i]>>d>>c[i];
	}
	for(int i=1;i<=n;i++){
		swap(a[b[i]],a[c[i]]);
	}
	for(int i=1;i<=w;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}				


Measured memory_bytes: 3084
import java.util.*;
import java.math.*;
 
public class Main {
  static int mod = (int) 1e9 + 7;
    static int n;
    static long k;
    static long a[];
  public static void main(String[] args) {
    	Scanner fs = new Scanner(System.in);
    	n = fs.nextInt();
        k = fs.nextLong();
    	a = new long[n];
        for(int i = 0; i < n; ++i) {
          a[i] = fs.nextLong();
        }
        Arrays.sort(a);
        long INF = (long)(1e18)+1;
        long l = -INF;
        long r = INF - 1;
        while(l <= r) {
            long c = (l+r)/2;
            if(check(c))l = c + 1;
            else r = c - 1;
        }
        System.out.println(Math.max(-INF, l - 1));
    }

    static boolean check(long x) {
        long tot = 0;
        for(int i=0;i<n;i++) {
            long now = a[i];
            int l = 0, r = n - 1;
            if(now >= 0) {
                while(l <= r) {
                    int c = (l+r)/2;
                    if(now * a[c] < x) l = c + 1;
                    else r = c - 1;
                }
                tot += l;
            }
            else {
                while(l <= r) {
                    int c = (l+r)/2;
                    if(now * a[c] >= x) l = c+1;
                    else r = c - 1;
                }
                tot += (n - l);
            }
            if((long)a[i] * a[i]<x)tot--;
        }
        if(tot/2 < k) return true;
        else return false;
    }
}

Measured memory_bytes: 69408
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	map<string,int> mp;
	rep(i,0,n)
	{
		string str;
		cin >> str;
		mp[str]++;
	}	
	cout << "AC "<<"x" <<" "<< mp["AC"] <<"\n";
	cout << "WA "<<"x" <<" "<< mp["WA"] <<"\n";
	cout << "TLE "<<"x" <<" "<< mp["TLE"] <<"\n";
	cout << "RE "<<"x" <<" "<< mp["RE"] <<"\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3664
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[0 for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if h[a]>h[b]:
        l[b]+=1
    elif h[a]<h[b]:
        l[a]+=1
    else:
        l[a]+=1
        l[b]+=1
print(l.count(0))


Measured memory_bytes: 84928
#include<bits/stdc++.h>
					
					#define F first
					#define S second
					#define N 222222
					#define M 1000000007
					#define pb push_back
					#define cend(s) return cout << s, 0
					using namespace std;
					typedef long long ll;
					typedef vector<int> vi;
					
					int main()
					{
						int q, k, t = 0;
						cin >> q >> k;
						while(q--)
						{
							ll x, y;
							cin >> x >> y;
							double d = sqrt(x*x*1.0 + y*y*1.0);
							if(d <= k)
								t++;
						}
						cend(t);
					}

Measured memory_bytes: 3616
use std::str::FromStr;
use std::cmp::max;
use std::cmp::min;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i64> = get_vec();
    println!("{}", v[1] * (v[1]-1).pow((v[0] - 1) as u32));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    vi a(n + 2), ps(n + 2);
    FOR(i, 1, n) {
        cin >> a[i];
        ps[i] = ps[i - 1] ^ a[i];
    }
    FOR(i, 1, n)
        cout << (ps[n] ^ a[i]) << ' ';
    cout << '\n';
}

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

const int MAX_N = 103;
int F[MAX_N][12];
ll P[MAX_N][12];
int D[11];
int cnt[MAX_N];
int N;
ll mx = -1e9 - 5;

ll check() {
    fill(cnt, cnt + N, 0);
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 10; ++j) 
            if(D[j] && F[i][j]) ++cnt[i];
    }
    ll res = 0;
    for(int i = 0; i < N; ++i) res += P[i][cnt[i]];
    bool flg = false;
    for(int i = 0; i < 10; ++i) 
        if(D[i] == 1) { flg = true; break; }
    if(flg) return res;
    else return -1e9 - 10;
}

void tansaku(int cur) {
    if(cur >= 10) { mx = max(mx, check()); return ;}
    D[cur] = 1;
    tansaku(cur + 1);
    D[cur] = 0;
    tansaku(cur + 1);
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 10; ++j) 
            cin >> F[i][j];
    }
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 11; ++j) 
            cin >> P[i][j];
    }

    tansaku(0);
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256