akhauriyash/Code-Regression huggingface dataset:
import sys

EPS = 1e-12

def main():
    n,k,t,u,v,l = map(int, sys.stdin.readline().split())
    carrots = [0] * 10001
    for i in range(n):
        carrots[ int(sys.stdin.readline()) ] = 1

    remain_time  = 0
    carrot_count = 0
    ans = 0
    for i in range(0,l):
        #print("kyori:{}\tremain_time:{}\tcarrot_count:{}\tans:{}".format(i,remain_time,carrot_count,ans))
        # ???????????????????????????????????????
        if carrots[i] == 1:
            carrot_count += 1
        # ?????????????¶?????????????????????????
        if carrot_count > k:
            remain_time = t
            carrot_count -= 1

        if remain_time > 0 + EPS:
            # ????????????????????£???????????¶???
            if remain_time * v >= 1.0:
                ans += 1 / v
                remain_time -= 1 / v
            else:
                if carrot_count > 0:
                    ans += 1 / v
                    carrot_count -= 1
                    remain_time = t - (1 - (remain_time * v)) / v
                else:
                    ans += remain_time
                    ans += (1 - (remain_time * v)) / u
                    remain_time = 0
        else:
            remain_time = 0
            # ????????????????????£???????????¶???
            if carrot_count > 0:
                ans += 1 / v
                carrot_count -= 1
                remain_time = t - 1 / v
            else:
                ans += 1 / u

    print("{:.9f}".format(ans))



if __name__ == '__main__':
    main()

Measured memory_bytes: 7800
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

int main() {
int N;
cin >> N;
vector <int> a;
map <int, int> m;
int min_n = 100000, max_n = -1;
for (int i = 0; i < N; i++) {
int num;
cin >> num;
a.push_back(num);
m[num]++;
}

int max_c = 0;
int pp_num =  - 20, pp_count = 0;
int p_num =  - 10, p_count = 0;
for (auto it = m.begin(); it != m.end(); it++) {
int count = it->second;
  int num = it->first;
  if (abs(num - p_num) <= 1) count += p_count;
  if (abs(p_num - pp_num) <= 1) count += pp_count;
  if (count > max_c) max_c = count;
  pp_count = p_count;
  p_count = it->second;
  pp_num = p_num;
  p_num = num;
}

cout << max_c << endl;
return 0;
}

Measured memory_bytes: 3576
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;in(n);
	int a[n];
	for(int i=0;i<n;i++) in(a[i]);
	
	int cnt = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			for(int k=j+1;k<n;k++) {
				if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && (a[i]+a[j] > a[k] && a[j]+a[k] > a[i] && a[i] +a[k] > a[j]))
				{cnt++;}
			}
		}
	}
	cout<<cnt<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long a,b,k;
	cin >> a >> b >> k;
	long long aa=max(0LL,a-k);
	long long nk=max(0LL,k-a);
	long long bb=b-nk;
	if(bb<=0) bb=0;
	cout << aa << " " << bb << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string X){
    ll N = X.length();
    ll num_s = 0, cnt=0;
    for(auto x:X){
        if(x=='S'){
            num_s++;
        }
        if(x=='T'){
            if(num_s>0){
                num_s--;
                cnt++;
            }
        }
    }
    cout<<N - 2*cnt<<endl;

}

int main(){
    std::string X;
    std::cin >> X;
    solve(X);
    return 0;
}


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

int main()
{
	int number;
	int score[100];
	int sum, max, min;
	
	while(true)
	{
		cin >> number;
		if(!number) return 0;
		sum = 0, max = 0, min = 1000;
		for(int i = 0; i < number; ++i)
		{
			cin >> score[i];
			sum += score[i];
			if(score[i] > max) max = score[i];
			if(score[i] < min) min = score[i];
		}
		cout << (sum - max - min) / (number - 2) << endl;
	}
}

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

int main(){
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> S(H);
  for(auto& s: S){
    cin >> s;
  }

  // dp[h][w] := white_cnt in [0, h) * [0, w)
  // dp[h][w] = dp[h - 1][w] + dp[h][w - 1] - dp[h - 1][w - 1] + (0|1)
  vector<vector<int>> dp(H + 1, vector<int>(W + 1));
  for(int h = 1; h <= H; h++){
    for(int w = 1; w <= W; w++){
      dp[h][w] = dp[h - 1][w] + dp[h][w - 1] - dp[h - 1][w - 1];
      if(S[h - 1][w - 1] == '1'){
        dp[h][w]++;
      }
    }
  }
  /*
  for(int h = 0; h <= H; h++){
    for(int w = 0; w <= W; w++){
      cout << dp[h][w] << ' ';
    }cout << endl;
  }
  */
  
  int ans = 1e9;
  for(int separate_bit = 0; separate_bit < (1 << (H - 1)); separate_bit++){
    vector<int> h_sep; // start of h, plus banpei H
    h_sep.push_back(0);
    for(int i = 0; i < H - 1; i++){
      if((separate_bit >> i) & 1){
        h_sep.push_back(i + 1);
      }
    }
    h_sep.push_back(H);

    int ans_tmp = h_sep.size() - 2;

    int w_start = 0;
    for(int w_end = 1; w_end <= W; w_end++){
      bool should_update = false;
      for(int i = 0; i + 1 < h_sep.size(); i++){
        int h_start = h_sep[i], h_end = h_sep[i + 1];
        int area_white_cnt = dp[h_end][w_end] - dp[h_end][w_start] - dp[h_start][w_end] + dp[h_start][w_start];
        if(area_white_cnt > K){
          should_update = true;
          break;
        }
      }
      if(should_update && w_end - w_start == 1){
        ans_tmp = 1e9;
        break;
      }
      if(should_update){
        // cout << "***" << endl;
        ans_tmp++;
        if(ans_tmp > ans){
          break;
        }
        w_start = w_end - 1;
        w_end--;
      }
    }

    ans = min(ans, ans_tmp);
  }
  cout << ans << endl;
}


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

int main(void) {
    int n, m, r;
    cin >> n >> m >> r;

    vector<int> rs(r);
    for(auto &x: rs) cin >> x, x--;

    vector<vector<pair<int,int>>> G(n);
    for(int i=0; i<m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back(pair<int,int>(b,c));
        G[b].push_back(pair<int,int>(a,c));
    }

    vector<vector<int>> dis(n, vector<int>(n, 1e9));

    for(int i=0; i<n; i++) {
        dis[i][i] = 0;
        for(auto &r: G[i])
            dis[i][r.first] = min(dis[i][r.first], r.second);
    }

    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);

    sort(rs.begin(), rs.end());

    long res = 1e18;
    do {
        long t = 0;
        for(int i=0; i<r-1; i++)
            t += dis[rs[i]][rs[i+1]];
        res = min(res, t);
    } while(next_permutation(rs.begin(), rs.end()));

    cout << res << endl;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int n;
vector<int> prime(110);  // prime[i]...n!を素因数分解したときにiで何回割れるか
vector< pair<ll, ll> > prime_factorize(ll n) {  // 素因数分解アルゴリズム
    vector< pair<ll, ll> > res;
    for(ll a = 2; a*a <= n; ++a) {
        if(n % a != 0) continue;
        ll ex = 0;
        while(n % a == 0) {
            ++ex;
            n /= a;
        }
        res.push_back({a, ex});
    }
    if(n != 1) res.push_back({n, 1});
    return res;
}

int main() {
    cin >> n;
    rp(i, 2, n+1) {
        vector<pair<ll, ll>> pf = prime_factorize(i);
        for(auto x: pf) {
            prime.at(x.first) += x.second;
        }
    }
    vector<int> a(5);  // a[0]...n!を2回割れる素数の数 a[1]:4 a[2]:14 a[3]:24 a[4]:74
    vector<int> b = {2, 4, 14, 24, 74};
    rp(i, 2, 105) {
        rp(j, 0, 5) {
            if(prime[i] >= b[j]) a[j] ++;
        }
    }
    // rp(i, 0, 5) {
    //     cout << "a[" << i << "] = " << a[i] << endl;
    // }
    int res = 0;
    res += a[4] + a[3] * (a[0] - 1) + a[2] * (a[1] - 1) + a[1] * (a[1] - 1) * (a[0] - 2) / 2;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  var N = sc.nextInt()
  var result = false;
  do {
    result |= N % 10 == 7
    N /= 10
  } while (N > 0)
  println(if (result) "Yes" else "No")
}


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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var p = new int[n];
            var q = new Queue<int>();
            foreach (var x in Enumerable.Range(0, n)) q.Enqueue(x);
            var s = Console.ReadLine().Trim();
           var ba =  Play(q, p, s);
            Array.Sort(p);
            foreach (var x in p) Console.Write("{0} ", x);
            Console.WriteLine(ba);
        }
    }
    public static int Play(Queue<int> q, int[] p, string s)
    {
        var ba = 0;
        int n;
        for (int i = 0; i < s.Length; i++)
        {
            n = q.Dequeue(); q.Enqueue(n);
            switch (s[i])
            {
                case 'M':
                    p[n]++;
                    break;
                case 'S':
                    ba += p[n] + 1;
                    p[n] = 0;
                    break;
                case 'L':
                    p[n] += ba + 1;
                    ba = 0;
                    break;
            }
        }
        return ba;
    }
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
using namespace std;
vector<ll> v[200000+5];
bool vis[200000+5];
ll tick;
void dfs(ll n)
{
    vis[n]=1;
    tick++;
    for(auto x:v[n])
    {
        if(vis[x]==0)
            dfs(x);
    }
}
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m,ans=0;
        cin>>n>>m;
        ll p,q,i;
        map<pair<ll,ll> ,ll> z;
        for(i=0;i<m;i++)
        {
            cin>>p>>q;
            if(z[{p,q}]==0){
            v[p].push_back(q);
            v[q].push_back(p);
            }
            z[{p,q}]=1;
        }
        for(i=1;i<=n;i++)
        {
            if(vis[i]==0)
            {
                tick=0;
                dfs(i);
                ans=max(ans,tick);
            }
        }
        cout<<ans;

    }
    return 0;
}


Measured memory_bytes: 33496
// ITP1_7_C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int h,w;
    cin>>h>>w;
    vector<vector<int>> info(h,vector<int>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int num;
            cin>>num;
            info[i][j]=num;
        }
    }
    vector<int> yoko(h);
    vector<int> tate(w);
    int total=0;
    for(int i=0;i<h;i++){
        int num=0;
        for(int j=0;j<w;j++){
            num+=info[i][j];
        }
        yoko[i]=num;
        total+=num;
    }
     for(int i=0;i<w;i++){
        int num=0;
        for(int j=0;j<h;j++){
            num+=info[j][i];
        }
        tate[i]=num;
    }
     for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<info[i][j]<<" ";
        }
        cout<<yoko[i]<<endl;
    }
    for(int i=0;i<w;i++){
        cout<<tate[i]<<" ";
    }
    cout<<total<<endl;
    return 0;
}


Measured memory_bytes: 3152
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] line = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();
            int W = line[0];
            int H = line[1];
            int x = line[2];
            int y = line[3];
            int r = line[4];

            string result = "No";
            if (0 <= (x - r) && (x + r) <= W &&
                    0 <= (y - r) && (y + r) <= H) {
                result = "Yes";
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 18436
#include<iostream> 
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
struct FenwickTree{ 
	vector<ll> bit; 
	int n;
	FenwickTree(int n){ 
		this->n=n;
		bit.assign(n,0);
	}
	ll getmax(int r){
		ll ret=0;
		ll val;
		for(;r>=0;r=(r&(r+1))-1){
			ret=max(ret,bit[r]);
		}
		return ret; 
	}

	void update(int idx,ll val){ 
		for(; idx <n;idx=idx|(idx+1)){
			bit[idx]=max(bit[idx],val);
		}
	}
};



int main(){ 
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int N;
	cin>>N;
	vector<int> a(N);
	vector<pii> h(N);
	for(int i=0;i<N;i++){ 
		h[i].second=i;
		cin>>h[i].first;
	}
	for(int i=0;i<N;i++){ 
		cin>>a[i];
	}
	sort(h.begin(),h.end());
	FenwickTree tree=FenwickTree(N); 
	for(pii v: h){ 
		int idx=v.second;
		tree.update(idx,tree.getmax(idx)+a[idx]);
	}
	cout<<tree.getmax(N-1);



		
	
	return 0;
} 



Measured memory_bytes: 4736
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
X = gets.chomp.to_i

output = 0

(0..A).each do |a|
  (0..B).each do |b|
    (0..C).each do |c|
      if (500 * a + 100 * b + 50 * c) == X
        output += 1
      end
    end
  end
end

puts output


Measured memory_bytes: 1788
#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 llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

llong gcd(llong a, llong b) {
  if(a < b) gcd(b, a);
  llong r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
	llong N;
    cin >>N;
    llong ans =1;
    LV A(N);
    LV before_r(N),after_r(N),before_l(N),after_l(N);
    REP(i,N){
        cin >> A[i];
    }
    after_r[N-1]=before_r[N-1]=A[N-1];


    REPR(i,N-2){
        before_r[i]=after_r[i+1];
        after_r[i]=gcd(A[i],before_r[i]);
    }
    before_l[0]=after_l[0]=A[0];
    FOR(i,1,N){
        before_l[i]=after_l[i-1];
        after_l[i]=gcd(before_l[i],A[i]);
    }

    llong ngcd = after_r[0];
    llong min_notg = INF;
    // REP(i,N){
    //     cout << before_l[i] << " ";
    // }
    // cout << "e" << endl;
    // REP(i,N){
    //     cout << before_r[i] << " ";
    // }
    LV notme(N);
    FOR(i,1,N-1){
        notme[i]=gcd(before_l[i],before_r[i]);
    }
    notme[0]=before_r[0];
    notme[N-1]=before_l[N-1];
    sort(notme.begin(),notme.end());
    ans = notme[0];
    REPR(i,N-1){
        if(notme[i] != ans){
            ans = notme[i];
            break;
        }
    }





    cout << ans << endl;





}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 800002;

int s[MAX_N];
int dp[MAX_N][11];

int main()
{
    while(1){
        string bf;
        cin >> bf;
        if(bf=="0"){
            break;
        }
        rep(i,bf.length()){
            s[i] = (int)(bf[i]-'0');
        }
        rep(i,bf.length()){
            rep(j,11){
                dp[i][j] = 0;
            }
        }
        dp[0][s[0]]++;
        for(int i=1;i<bf.length();i++){
            if(s[i] != 0){
                dp[i][s[i]]++;
            }
            rep(k,11){
                dp[i][(k*10+s[i])%11] += dp[i-1][k];
            }
        }
        int res = 0;
        rep(i,bf.length()){
            res += dp[i][0];
        }
        printf("%d\n",res);
    }
	return 0;
}

Measured memory_bytes: 7080
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	L := float64(nextInt())

	fmt.Println(L * L * L / 27)
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

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

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

  vector<P> pairs;
  VI list;

  auto pf = prime_factor(n);
  if (pf.size() == 0) {
    ANS(0);
    return 0;
  }

  int ans = 0;
  for (auto p : pf) {
    int cnt = p.second;
    int i = 1;
    while (true) {
      int sum = i * (i + 1) / 2;
      if (cnt < sum) {
        ans += i - 1;
        break;
      }
      i++;
    }
  }
  ANS(ans);

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll N, K, L, R, a[45];

void build(ll bg, ll en, vector<P> &v){
    ll m = en - bg;
    for(int i=0; i<(1<<m); i++){
        ll k=0, sum=0;
        for(int j=0; j<m; j++){
            if((i>>j)&1){
                sum += a[j+bg];
                k++;
            }
        }
        if(k>K)continue;
        if(sum>R)continue;
        v.push_back(P(k,sum));
    }
}

int main() {
    ll cnt = 0;
    vector<P> s1, s2;
    cin >> N >> K >> L >> R;
    REP(i,N) cin >> a[i];

    build(0, N/2, s1);
    build(N/2, N, s2);

    SORT(s2);
    for(auto p1 : s1){
        ll k1 = p1.first, a1 = p1.second;
        cnt += upper_bound(ALL(s2),P(K-k1,R-a1))-lower_bound(ALL(s2),P(K-k1,L-a1));
    }

    cout << cnt << endl;

    return 0;
}



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

int main(void){
  int n;
  int a[1000]={};
  int min=1000000;
  cin>>n;
  while(n!=0){
    min=1000000;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i!=j){
	  int sa;
	  if(0>(a[i]-a[j])){
	    sa=a[j]-a[i];
	  }else{
	    sa=a[i]-a[j];
	  }
	  //  cout<<sa<<" "<<min<<endl;
	  if(sa<min)min=sa;
	  //  cout<<sa<<" "<<min<<endl;
	}
      }
    }
    cout<<min<<endl;
    cin>>n;
  }
}

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

struct info{
    long long i, a, m;
    double key;
    info(long long i, long long a, long long m, double key):i(i),a(a),m(m),key(key){}
    info(){}
    bool operator<(const info& aa) const{ return key < aa.key; }
    bool operator>(const info& aa) const{ return key > aa.key; }
};

int main(){

    int n; cin >> n;
    long long rh, ra, rd, rs; cin >> rh >> ra >> rd >> rs;
    long long H = rh;
    vector<info> array(n);

    long long sum_a = 0LL;
    for(int i = 0; i < n; i++){
        long long h, a, d, s; cin >> h >> a >> d >> s;
        if(s > rs) rh -= max(0LL, a - rd);
        //cout << ra - d << endl;
        if(ra - d <= 0 && a - rd > 0){

            for(int j = i + 1; j < n; j++) cin >> h >> a >> d >> s;
          	//cout << "hoge" << endl;

            cout << -1 << endl;
            return 0;
        }

        if(ra - d > 0) array[i] = info(i, max(0LL, a - rd), (h + (ra - d) - 1) / (ra - d), 1);
        else array[i] = info(i, 0, 0, 0);
        sum_a += array[i].a;
    }

    for(int i = 0; i < n; i++){
		if(array[i].key == 0) continue;
        array[i].key = (double)array[i].a / array[i].m;
    }

    sort(array.begin(), array.end());
    reverse(array.begin(), array.end());
    
    for(int i = 0; i < n; i++){
		//cout << "i= " << i << "rh= " << rh << " array[i].a = " << array[i].a << " array[i].m = " << array[i].m << " array[i].key = " << array[i].key << endl;
        rh -= (array[i].m - 1) * sum_a;
        if(rh < 0){
			//cout << "huhuhuhga" << endl;
            cout << -1 << endl;
            return 0;
        }

        sum_a -= array[i].a;
        rh -= sum_a;
    }

    //cout << rh << endl;
    if(rh <= 0){
		//cout << "piyo" << endl;
        cout << -1 << endl;
        return 0;
    }else{
        cout << H - rh << endl;
    }
    return 0;
}



Measured memory_bytes: 4140
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    double R;
    cin >> R;
    cout << 2 * M_PI * R << endl;

    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

const int INF = 1e9;

struct edge {
	int to, cost;
	edge(int t, int c) : to(t), cost(c) {}
	bool operator<(const edge& that) const {
		return cost > that.cost;
	}
};

using edges = vector<edge>;
using graph = vector<edges>;

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	graph G(N);
	for (int i = 0; i < M; i++) {
		int a, b, l;
		cin >> a >> b >> l; a--, b--;
		G[a].emplace_back(b, l);
		G[b].emplace_back(a, l);
	}
	vector<int> used(N);
	vector<int> d(N, INF);
	priority_queue<edge> pq;
	for (int i = 0; i < K; i++) {
		int s;
		cin >> s; s--;
		d[s] = 0;
		pq.emplace(s, 0);
	}
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		int v = p.to;
		if (used[v]) continue;
		used[v] = 1;
		for (auto& e : G[v]) if (d[e.to] > d[v] + e.cost) {
			d[e.to] = d[v] + e.cost;
			pq.emplace(e.to, d[v] + e.cost);
		}
	}
	ld res = *max_element(d.begin(), d.end());
	for (int i = 0; i < N; i++) {
		for (auto& e : G[i]) {
			if (abs(d[i] - d[e.to]) == e.cost) continue;
			ld mi = min(d[i], d[e.to]), ma = max(d[i], d[e.to]), l = e.cost;
			res = max(res, ma + (l - (ma - mi)) / 2.0);
		}
	}
	cout << (int)round(res) << endl;
	return 0;
}



Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    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);
}
int N;
int a[MAXN];
vector<pii > op;
void Init() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
}
void Solve() {
    int t = 1;
    for(int i = 2 ; i <= N ; ++i) {
	if(abs(a[i]) > abs(a[t])) t = i;
    }
    for(int i = 1 ; i <= N ; ++i) {
	if(i != t) {
	    op.pb(mp(t,i));
	    a[i] += a[t];
	}
    }
    if(a[t] < 0) {
	for(int i = N - 1 ; i >= 1 ; --i) {
	    a[i] += a[i + 1];
	    op.pb(mp(i + 1,i));
	}
    }
    else {
	for(int i = 2 ; i <= N ; ++i) {
	    a[i] += a[i - 1];
	    op.pb(mp(i - 1,i));
	}
    }
    out(op.size());enter;
    for(auto k : op) {
	out(k.fi);space;out(k.se);enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = (1 << 18) + 5;
int n, q, v[MX], w[MX], mem[20][MX], col[20][MX], act[20], l[MX], res[MX];
vi pos[MX];

int dp (int u, int k) {
	if (k < 0) return -1e9;
	if (u < 0) return 0;

	int &res = mem[u][k];
	if (col[u][k] == act[u]) return res;
	col[u][k] = act[u];

	return res = max(
		dp(u - 1, k),
		dp(u - 1, k - w[act[u]]) + v[act[u]]
	);
}

void dfs (int u, int lvl) {
	if (u > n) return;
	act[lvl] = u;

	for (int j : pos[u])
		res[j] = dp(lvl, l[j]);

	dfs(2 * u, lvl + 1);
	dfs(2 * u + 1, lvl + 1);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(col, -1, sizeof(col));

	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> v[i] >> w[i];

	cin >> q;
	forn (i, q) {
		int v;
		cin >> v >> l[i];
		pos[v].pb(i);
	}

	dfs(1, 0);

	forn (i, q)
		cout << res[i] << endl;

	return 0;
}


Measured memory_bytes: 42784
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int64_t N;
  cin>>N;
  int64_t ans=0;
  for(int64_t i=1;i*i<=N;i++){
    if(N%i==0){
      int64_t m=N/i-1;
      if(m>0&&N/m==N%m){ans+=m;}
      if(i>1&&N/i==N%i){ans+=i-1;}
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
 
int  n,u,A[100][100],C[100],d[100];
 
int main(){
  int i,j,mincost,sum = 0;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
      if(A[i][j] == -1)A[i][j] = 2001;
    }
  }
  
  for(i=0;i<n;i++){
    d[i] = 2001;
    C[i] =0;
  }
  d[0]=0;
 
  while (1){
    mincost = 2001;    
for(i=0;i<n;i++){
      if (C[i] != 1 && d[i] < mincost){
    mincost = d[i];
    u = i;
      }
    }
 if (mincost == 2001){
   break;
 }
    C[u] = 1;
    for (i=0;i<n;i++){
      if (C[i] != 1 && A[u][i] < d[i]){
    d[i] = A[u][i];
      }
    }
  }
  for (i=0;i<n;i++){
    sum+=d[i];
  }
  printf("%d\n",sum);
  return 0;
}

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


int main() {
  const double pi = acos(-1);
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double hour_angle = (h * 60 + m) / 720 * 2 * pi;
  double minute_angle = m / 60 * 2 * pi;

  double x1 = a * cos(hour_angle);
  double y1 = a * sin(hour_angle);
  double x2 = b * cos(minute_angle);
  double y2 = b * sin(minute_angle);

  cout << fixed << setprecision(12) << hypot(x1 - x2, y1 - y2) << endl;
}


Measured memory_bytes: 4108
s = input()
flag = 0

if (len(s))%2 == 1:
    print('No')
else:
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == 'h':
                pass
            else:
                flag = 1
        else:
            if s[i] == 'i':
                pass
            else:
                flag = 1

    if flag == 0:
        print('Yes')
    else:
        print('No')

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

int main() {
	int h, w;
	cin >> h >> w;
	string *arry = new string[h];
	bool flg = true;
	for (int i = 0; i < h; i++) {
		cin >> arry[i];
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (arry[i][j] == '#') {

				if ((i - 1 < 0 || arry[i - 1][j] != '#') && (i + 1 >= h || arry[i + 1][j] != '#')
					&& (j - 1 < 0 || arry[i][j - 1] != '#') && (j + 1 >= w || arry[i][j + 1] != '#')) {
					flg = false;
				}

			}
		}
	}
	if (flg) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
info = [[[[0] * 13 for i in range(11)] for j in range(11)] for k in range(11)]
memo = [0 for i in range(13)]
memo2 = [0 for i in range(13)]
memo2[0] = 1
memo3 = [0 for i in range(13)]
memo3[0] = 1

s = input()
if len(s) % 3 > 0:
  s = "0" * (3 - len(s) % 3) + s

for i in range(10):
  for j in range(10):
    for k in range(10):
      info[i][j][k][(i * 100 + j * 10 + k) % 13] = 1

for i in range(10):
  for j in range(10):
    for k in range(10):
      for l in range(13):
        info[10][j][k][l] += info[i][j][k][l]

for i in range(11):
  for j in range(10):
    for k in range(10):
      for l in range(13):
        info[i][10][k][l] += info[i][j][k][l]

for i in range(11):
  for j in range(11):
    for k in range(10):
      for l in range(13):
        info[i][j][10][l] += info[i][j][k][l]

v = [s[i: i+3] for i in range(0, len(s), 3)]
v.reverse()

for i in range(len(v)):
  for j in range(13):
    memo[j] = info[10 if v[i][0] == "?" else int(v[i][0])][10 if v[i][1] == "?" else int(v[i][1])][10 if v[i][2] == "?" else int(v[i][2])][j]
    memo2[j] = 0
  for j in range(13):
    for k in range(13):
      if i % 2 == 1:
        memo2[(j - k) % 13] += memo3[j] * memo[k]
      else:
        memo2[(j + k) % 13] += memo3[j] * memo[k]
  for j in range(13):
    memo2[j] = memo3[j] = (memo2[j]) % (10 ** 9 + 7)

print(memo2[5])

Measured memory_bytes: 52716
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}

int main() {
	string s;
	cin >> s;
	if (s.back() == 's') s += "es";
	else s += 's';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &i:a)cin >> i;
	vector<int> cnt(1000001);

	for(int i = 0;i<n;i++)
	{
		cnt[a[i]]++;
	}
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		auto fac = divisor(a[i]);
		cnt[a[i]]--;
		bool is = true;
		for(int j = 0;j<fac.size();j++)
		{
			if(cnt[fac[j]]>0)
			{
				is = false;
				break;
			}
		}
		cnt[a[i]]++;
		if(is)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 7932
# abc077_c.py
'''
多分あとは、Bで重複がある場合は探索しないで個数かけていくとかにしないといけない。
'''
def is_okC(idx,key,target):
########## wirte criteria here ##########
    if target[idx] > key:
        return True
    return False

def meguru_bisectC(key,target):
    left = -1
    length = len(target)
    right = length
    while (abs(right - left) > 1):
        mid = left + (right - left) // 2
        if is_okC(mid,key,target):
            right = mid
        else:
            left = mid
    return length-right


def is_okA(idx,key,target):
########## wirte criteria here ##########
    if target[idx] >= key:
        return True
    return False

def meguru_bisectA(key,target):
    left = -1
    length = len(target)
    right = length
    while (abs(right - left) > 1):
        mid = left + (right - left) // 2
#        print("mid : " , mid)
        if is_okA(mid,key,target):
            right = mid
        else:
            left = mid
    return right

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
a = 0
c = 0
ans = 0
#print(A)
#print(B)
#print(C)
for i in B:
    a = meguru_bisectA(i,A)
#    print(A[:a] )
#    print("i : ",i)
    c = meguru_bisectC(i,C)
#    print(C[c:])
    ans += a*c
#    print()

print(ans)

Measured memory_bytes: 23328
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>Pre,In,Post;
int pos,n,x;
void Rebuild(int l,int r)
{
    if(l>=r)return ;
    int root=Pre[pos++];
   // int m=distance(In.begin(),find(In.begin(),In.end(),root));
    int m=find(In.begin(),In.end(),root)-In.begin();
    Rebuild(l,m);
    Rebuild(m+1,r);
    Post.push_back(root);
}
void Solve()
{
    pos=0;
    Rebuild(0,n);
    for(int i=0;i<n;i++)
    {
        if(i)cout<<' ';
        cout<<Post[i];
    }
    cout<<endl;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>x,Pre.push_back(x);
    for(int i=0;i<n;i++)cin>>x,In.push_back(x);
    Solve();
    return 0;
}



Measured memory_bytes: 3140
if __name__ == '__main__':
  val = input()
  input_num = val.split(' ')
  
  a,b,t = input_num
  cuccki = 0
  
  for i in range(10000):
    if int(a)*(i+1) < (float(t)+0.5):
	    cuccki += int(b)
    else:
      break
      
  print(cuccki)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) vi x(n); forn(i,0,n) scanf("%d", &x[i])

#define pb push_back
#define mp make_pair
const int MAXN = 100000;
vector<int> lst[MAXN];
int parent[MAXN];
vi pos;

void make_set (int v) {
    lst[v] = vector<int> (1, v);
    parent[v] = v;
}

int find_set (int v) {
    return parent[v];
}

bool union_sets (int a, int b, int d) {
    int sb = pos[a] - pos[b] + d;
    a = find_set (a);
    b = find_set (b);
    if(a == b) {
        if(sb!=0) return false;
    }
    if (a != b) {
        if (lst[a].size() < lst[b].size()) {
            swap (a, b);
            sb = -sb;
        }
        while (!lst[b].empty()) {
            int v = lst[b].back();
            pos[v] += sb;
            lst[b].pop_back();
            parent[v] = a;
            lst[a].push_back (v);
        }
        
    }
    return true;
}



int main()
{

    int n, m;
    scanf("%d %d", &n, &m);
    pos = vi(n, 0);
    forn(i,0,n) make_set(i);
    forn(i,0,m) {
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);
        l--;
        r--;
        if(!union_sets(l, r, d)) {
            cout<<"No";
            return 0;
        }
//        forn(i,0,n) cout<<pos[i]<<' '; cout<<endl;
    }
    cout<<"Yes";
    
    
}


Measured memory_bytes: 10236
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N;
  string S;
  cin >> N >> S;
  int k = 0;
  REP(i, S.size()) {
    if (S[i] == ')') {
      if (0 == k) {
        S.insert(S.begin(), '(');
        k++;
        i++;
      }
      k--;

    } else {
      k++;
    }
  }
  k = 0;
  for (int i = S.size()-1; i >= 0; i--) {
    if (S[i] == '(') {
      if (0 == k) {
        S.push_back(')');
        k++;
      }
      k--;
    } else {
      k++;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  std::vector<int> t(D);
  for(int i = 0; i < D; ++i) t[i] = i%26;
  std::set<int> last[26];
  for(auto& li: last) li.insert(-1); // sentinel
  int ans = 0;
  for(int d = 0; d < D; ++d) {
    int t1 = t[d];
    ans += s[d][t1];
    last[t1].insert(d);
    for(int i = 0; i < 26; ++i) {
      ans -= c[i]*(d - *last[i].rbegin());
    }
  }
  for(auto& li: last) li.insert(D); // sentinel
  
  // additional score when t[d] = i compare to t[d] = -1
  auto sum_up = [](int d) { return d*(d-1)/2; };
  auto score = [&](int d, int i)->int {
    int res = s[d][i];
    auto it = last[i].lower_bound(d);
    int nd = *it;
    int pd = *--it;
    int diff = sum_up(d-pd) + sum_up(nd-d) - sum_up(nd-pd);
    res -= c[i]*diff;
    return res;
  };
  
  // hill climbing
  int lm = 0;
  int sc[26];
  for(;;) {
    if((xor64()>>25)&1) {
      int d = xor64()%D;
      int pi = t[d];
      last[pi].erase(d);
      for(int i = 0; i < 26; ++i) sc[i] = score(d, i);
      int mi = std::max_element(sc, sc+26) - sc;
      t[d] = mi;
      last[mi].insert(d);
      if(mi != pi) lm = 0; else ++lm;
    } else {
      int d1 = xor64()%D, d2 = xor64()%D;
      while(d1 < d2-16 || d2 < d1-16 || t[d1] == t[d2]) {
        d1 = xor64()%D; d2 = xor64()%D;
      }
      int pi1 = t[d1], pi2 = t[d2];
      last[pi1].erase(d1);
      int diff = score(d1, pi2) - score(d1, pi1);
      last[pi2].insert(d1);
      last[pi2].erase(d2);
      diff += score(d2, pi1) - score(d2, pi2);
      if(diff > 0) {
        last[pi1].insert(d2);
        t[d1] = pi2;
        t[d2] = pi1;
        lm = 0;
      } else {
        last[pi2].insert(d2);
        last[pi2].erase(d1);
        last[pi1].insert(d1);
        ++lm;
      }
    }
    if(lm >= 10000) break;
  }
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) << endl
 
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = (1<<20);
const ll inf = 1e9+7;
const ll VAL = 20;
int main() {
	fastio;
	 ll n,k;
	 cin>>n>>k;
	 ll a[n];
  	f(i,0,n)cin>>a[i];
  	f(i,0,n-k){ 
  		if(a[i]<a[i+k]) cout<<"Yes\n";
  		else cout<<"No\n";
  	}
	return 0;
}

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

const int MOD = 1000000007;

vector<ll> fact;
vector<ll> invFact;

ll binary_pow(ll n, ll p)
{
    return p ? binary_pow(n * n % MOD, p >> 1) * (p & 1 ? n : 1) % MOD : 1;
}

void init_fact(int n)
{
    fact.resize(n + 10);
    invFact.resize(n + 10);
    fact[0] = 1;
    invFact[0] = 1;
    rep (i, n)
    {
        fact[i + 1] = fact[i] * (i + 1) % MOD;
        invFact[i + 1] = invFact[i] * binary_pow(i + 1, MOD - 2) % MOD;
    }
}

ll combination(ll n, ll r)
{
    ll ret = 1;
    ret = ret * fact[n];
    ret = ret * invFact[r] % MOD;
    ret = ret * invFact[n - r] % MOD;
    return ret;
}

ll divide(ll x, ll y)
{
    if (x < y || y < 1)
        return 0;
    if (x == 0 && y == 0)
        return 1;
    ll ret;
    ret = combination((x - y) + y - 1, y - 1);
    return ret;
}

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

    init_fact(n + k);

    ll ans;
    for (int i = 1; i <= k; i++)
    {
        ll temp = 0;
        ans = divide(k, i);
        temp += divide(n - k, i - 1) % MOD;
        temp += divide(n - k, i) * 2 % MOD;
        temp += divide(n - k, i + 1) % MOD;
        ans = ans * temp % MOD;
        if (i == 1 && ans == 0)
            cout << 1 << endl;
        else
            cout << ans << endl;
    }
    return 0;
}

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

int	main()
{
  string s, t;

  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if (s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return (0);
}

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

int main(){
  constexpr int Nbit= 1e5;
  int N,M;
  cin >> N >> M;

  bitset<Nbit> filter;
  for(int i=0; i<N; i++){
    filter.set(i);
  }
  
  vector<int> data(N, 1);
  bitset<Nbit> plausible;
  plausible.set(0);
  int from,to;
  for(int j=0; j<M; j++){
    cin >> from >> to;
    from--; to--; // 1-indexed -> 0-indexed
    data.at(from)--;
    data.at(to)++;
    if(plausible.test(from)){
      plausible.set(to);
    }
    if(data.at(from)==0){
      plausible.reset(from);
    }
  }

  int ans= (plausible & filter).count();

  cout << ans << endl;
}

Measured memory_bytes: 3768
import numpy as np
N =int(input())
A =[]
B =[]
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
index = np.argsort(B)
time = 0
f = 0
for i in index:
    time += A[i]
    if time>B[i]:
        f = 1
        break
if f == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 29704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    int i,j;
    vector<int> v(31,1);
    for(i=0;i<28;i++){
        int x;
        cin>>x;
        v[x]--;
    }
    for(i=1;i<=30;i++){
        if(v[i]) cout<<i<<endl;
    }

}


Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

ll S,ji,x,y;

ll doko(ll num){
    ll l=1;
    ll r=1e10;
    ll mid;
    ll a,b;
    while(true){
        mid=(l+r)/2;
        a=mid*mid;
        b=(mid+1)*(mid+1);
        if(a<num&&b>=num){
            return mid+1;
        }
        else if(b<num){
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
    return mid+1;
}

int main(){
    cin>>S;
    cout<<0<<" "<<0<<" ";
    ji=doko(S);
    ll sa=ji*ji-S;
    // for(ll i=sqrt(sa)+1;i>=1;i--){
    //     if(sa%i==0){
    //         x=i;
    //         y=sa/i;
    //         break;
    //     }
    // }
    cout<<ji<<" "<<1<<" "<<sa<<" "<<ji<<endl;
    // repi(i,1,sqrt(sa)+1){
    //     if(sa%i==0){
    //         x=i;
    //         y=sa/i;
    //     }
    // }
    // cout<<ji<<" "<<y<<" "<<x<<" "<<ji<<endl;


    
    
}


Measured memory_bytes: 256