akhauriyash/Code-Regression huggingface dataset:
def _3():
    from collections import defaultdict

    def can_pair(s1, s2):
        l = []
        for c1, c2 in zip(s1, s2):
            c = sorted([c1, c2])
            if c in l:
                l.remove(c)
            else:
                l.append(c)

        if len(s1) % 2 == 0:
            return len(l) == 0
        else:
            return len(l) == 1 and l[0][0] == l[0][1]

    def pair_graph(s1, s2):
        N = len(s1)
        G = np.zeros([N, N])
        for i in range(N):
            for j in range(i+1, N):
                if s1[i] == s2[j] and s1[j] == s2[i]:
                    G[i, j] = 1
                    G[j, i] = 1
        return G

    import numpy as np
    H, W = list(map(int, input().split(' ')))
    S = []
    d = defaultdict(list)

    for h in range(H):
        s = input()
        S.append(s)
        d[''.join(sorted(S))].append(h)

    already_paired = np.zeros(H)

    Gs = []

    for i in range(H):
        if already_paired[i]:
            continue

        for j in range(i+1, H):
            if already_paired[j]:
                continue

            if can_pair(S[i], S[j]):
                already_paired[i] = 1
                already_paired[j] = 1
                G = pair_graph(S[i], S[j])
                Gs.append(G)
                break

    if already_paired.sum() < H - 1:
        print('NO')
        exit()

    elif already_paired.sum() == H - 1:
        for i in range(H):
            if already_paired[i] == 0:
                G = pair_graph(S[i], S[i])
                Gs.append(G)
                break

    G = np.array(Gs).sum(axis=0) // len(Gs)

    def is_perfect_matching(G):
        N = len(G)
        if N == 1:
            return True

        for i in range(N):
            for j in range(i+1, N):
                if G[i, j] == 1:
                    l = list(range(N))
                    l.remove(i)
                    l.remove(j)
                    if len(l) == 0:
                        return True
                    if is_perfect_matching(G[l][:, l]):
                        return True
        return False

    if is_perfect_matching(G):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    _3()

Measured memory_bytes: 21564
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int i,j,k,N;

int main()
{
  cin>>N;
  
  i=1000-(N%1000);
  if(i==1000) i=0;
  cout<<i;
}

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

using namespace std;


long long gcd(long a, long b){
	if(a%b) return gcd(b,a%b);
	else return b;
}

int main (){
	long long  a,b;
	cin >> a >> b;
	long long g;
	if(a>b){g = gcd(a,b);}else{g = gcd(b,a);}
	int count =1;

	for (long long i = 2; i*i<=g;i++){
		if(g%i==0){
			count ++;
			while(g%i==0) g /= i;
		}
	}

	if ( g != 1) count++;
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0;
  string s;
  std::cin >> s;
  rep(i,s.size()){
    if(s[i]!=s[s.size()-1-i]){
      std::cout << "No" << '\n';
      return 0;
    }
  }
  rep(i,(s.size()-1)/2){
    if(s[i]!=s[(s.size()-1)/2-1-i]){
      std::cout << "No" << '\n';
      return 0;
    }
  }
  repo(i,(s.size()+3)/2-1,s.size()){
    if(s[i]!=s[s.size()-1-i]){
      std::cout << "No" << '\n';
      return 0;
    }
  }
  std::cout << "Yes" << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int a, b;
		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();

		if(a > b) System.out.println("a > b");
		else if(a < b) System.out.println("a < b");
		else System.out.println("a == b");
	}
}


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

#define ll long long
#define ar array

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, A;
    cin >> n >> A;
    vector<ll> wt(n);
    vector<ll> val(n);
    for (int i = 0; i < n; i++) {
        cin >> wt[i] >> val[i];
    }
    vector<vector<ll>> knapsack(n + 1, vector<ll>(A + 1));
    for (int i = 1; i < n + 1; i++) {
        for (int j = 1; j < A + 1; j++) {
            if (wt[i - 1] > j) {
                knapsack[i][j] = knapsack[i - 1][j];
            } else {
                knapsack[i][j] = max(knapsack[i - 1][j], knapsack[i - 1][j - wt[i - 1]] + val[i - 1]);
            }
        }
    }

    cout << knapsack[n][A] << "\n";
}


Measured memory_bytes: 80256
#include <stdio.h>



int main() {
	int A, B;

	scanf("%d %d", &A, &B);

	if (A > 12) {
		printf("%d\n", B);
	}
	else if (A <= 12 && A >= 6) {
		printf("%d\n", B / 2);
	}
	else {
		printf("%d\n", 0);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
    int s = a * 60 + b;
    int t = c * 60 + d;
    cout << t - s - e << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt = 0;
  rep(i, n) {
    cin >> a[i];
    if (a[i] < 0) cnt++;
  }

  ll ans = 0;
  rep(i, n) ans += abs(a[i]);
  if (cnt % 2 != 0) {
    int min_v = 1001001001;
    rep(i, n) min_v = min(min_v, abs(a[i]));
    ans -= 2 * min_v;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3680
using System;

namespace ABC157C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nms = Console.ReadLine().Split();
            int n = int.Parse(nms[0]);
            int m = int.Parse(nms[1]);
            string scs;
            int[] s = new int[m];
            int[] c = new int[m];
            int[] a = new int[n];
            for(int i = 0; i < n; i++)
            {
                a[i] = -1;
            }
            int ans = 0;
            for(int i = 0; i < m; i++)
            {
                scs = Console.ReadLine();
                string[] sc = scs.Split();
                s[i] = int.Parse(sc[0]);
                c[i] = int.Parse(sc[1]);
            }
            for(int i = 0; i < m; i++)
            {
                if((a[s[i] - 1] != -1 && a[s[i] - 1] != c[i]) || (s[i] == 1 && c[i] == 0 && n != 1))
                {
                    for(int j = 0; j < n; j++)
                    {
                        a[j] = -1;
                    }
                    break;
                }
                a[s[i] - 1] = c[i];
            }
            bool isErr = true;
            bool left = true;
            for(int i = 0; i < n; i++)
            {
                if (a[i] != -1)
                {
                    ans += a[i] * (int)Math.Pow(10, n - i - 1);
                    left = false;
                    isErr = false;
                }
                else if (left)
                {
                    ans += 1 * (int)Math.Pow(10, n - i - 1);
                    left = false;
                }
            }
            if (isErr)
            {
                ans = -1;
            }
            if(m == 0)
            {
                switch (n)
                {
                    case 1:
                        ans = 0;
                        break;
                    case 2:
                        ans = 10;
                        break;
                    case 3:
                        ans = 100;
                        break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a, b;
string s;

inline bool check() {
    if (s[a] != '-') {
        return false;
    }
    rep(i, sz(s)) {
        if (i == a)continue;
        if (s[i] < '0' || s[i] > '9') {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> a >> b;
    cin >> s;
    cout << (check() ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n,k;
	cin>> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int sum = 0;
	for(int i = 0; i < n; i++){
	    if(a[i] >= k){
	        sum++;
	    }
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    string s;
    cin>>s;
    int n=s.size();
    int cnt=0;
    int ans=0;
    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++;
            ans=max(ans,cnt);
        }
        else{
            cnt=0;
        }
    }

    cout<<ans<<endl;







    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
mean = sum(A)/N

ans = 0
abs_value = abs(A[0] - mean)

for i in range(1, N):
    if abs(A[i] - mean) < abs_value:
        ans = i
        abs_value = abs(A[i] - mean)
    
print(ans)

Measured memory_bytes: 3060
N,M=gets.chomp.split(" ").map { |e| e.to_i   }
a=gets.chomp.split(" ").map { |e| e.to_i  }.map { |e| e%M  }

b=Array.new(N,0)

b[0] = a[0]

for i in 1..N-1
  b[i] = b[i-1] + a[i]
end

b=b.map { |e| e%M  }.sort

def conb(n,m)
  return n*(n-1)/2
end

const = 0
j=0

N.times do |i|
  if b[i] != b[j]
    const += conb(i-j,2)
    j=i
  end

  if b[i] == 0
    const +=1
  end
end

const += conb(N-j,2)

puts const

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

int main(){
  string S;
  cin >> S;
  if (S.at(1) == 'B')
    cout << "ARC"<< endl;
  else
    cout << "ABC"<< endl;
}

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

int main() {
	int x, n;
	cin >> x >> n;
	map<int, bool> mp;
	for (int i = 0, y; i < n; ++i) {
		cin >> y;
		mp[y] = true;
	}
	
	int ans = 101;
	
	for (int i = 101; i >= -1; --i) {
		if (!mp[i] && abs(x-i) <= abs(x-ans)) {
			ans = i;
		}
	}
	
	cout << ans << "\n";
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define two ios_base::sync_with_stdio(0)
#define powerofn cin.tie(0)
using namespace std;

ll const MOD = 998244353;

int const max_n = 1e6 + 10;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll a[max_n];

void solve(){

    int n;
    cin >> n;

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

    sort(a+1, a+n+1);
    reverse(a+1, a+n+1);

    ll sum = 0;
    sum += a[1];
    n -= 2;

    int id = 2;

    while( 1 ){
            if( n <= 0 ) break;
        sum += a[id];
        n--;
        //cout << a[id] << ' ';
        if( n <= 0 ) break;

        sum += a[id];
        n--;
        if( n <= 0 ) break;

        //cout << a[id] << ' ';

        id++;
    }


    cout << sum;


}

int main(){
    two;
    powerofn;

    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 5184
#!/usr/bin/env python3
#AGC9 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(sys.stdin.readline())
a,b = [],[]
for _ in range(n):
    x,y = map(int,sys.stdin.readline().split())
    a.append(x)
    b.append(y)
ans = 0
for i in range(n)[::-1]:
    x = -(a[i] + ans) % b[i]
    ans += x
print(ans)


Measured memory_bytes: 52316
# ans

N = int(input())
H = list(map(int, input().split()))

if H == 1:
  print('Yes')
  exit()

for i in range(1, N):
  if H[i-1] == H[i]:
    pass
  elif H[i-1] < H[i]:
    H[i] -= 1
  else:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int m = 0;
	int k,n,a;
	cin >> k >> n >> a;
	int pa = a;
	for(int i = 1; i<n;i++){
		int an;
		cin >> an;
		if(m < (an-pa)) m = (an-pa);
		pa = an;
	}
	int l = (k-pa) + a;
	if(l > m) m = l;
	cout << k - m << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	int counter = 0;
	for (int i = a; i <= b; i++) {
		if (c % i == 0) counter++;
	}
	cout << counter << endl;
	return 0;
}


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

int main() {
    int ss;
    cin >> ss;
    int h,m,s;
    h = ss/3600;
    ss %= 3600;
    m = ss/60;
    ss %= 60;
    s = ss;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "NO" << endl;return 0
#define MM <<" "<<
#define Endl endl

vector<int> topological(vector<pair<int,int>> S){
    int V=0,E=S.size();
    for(int i=0;i<E;i++){
        V=max(V,S[i].first+1);
        V=max(V,S[i].second+1);
    }
    queue<int> Q;
    vector<vector<int>> G(V);
    vector<int> L;
    vector<int> H(V,0);
    
    for(int i=0;i<E;i++){
        G[S[i].first].push_back(S[i].second);
        H[S[i].second]++;
    }
    for(int i=0;i<V;i++){
        if(H[i]==0){
            Q.push(i);
        }
    }
    while(!Q.empty()){
        int u=Q.front();Q.pop();
        int v=G[u].size();
        L.push_back(u);
        for(int i=0;i<v;i++){
            H[G[u][i]]--;
            if(H[G[u][i]]==0){
                Q.push(G[u][i]);
            }
        }
    }
    return L;
}
 
signed main(void){
    int N,M;
    vector<pair<int,int>> Z;
    int x,y;
    
    cin >> N >> M;
    REP(i,M){
        cin >> x >> y;
        x--;y--;
        Z.push_back({x,y});
    }
    vector<int> R=topological(Z);
    
    vector<vector<int>> G(N);
    for(int i=0;i<M;i++){
        G[Z[i].first].push_back(Z[i].second);
    }
    
    int dp[114514]={};
    REP(i,N-1){
        REP(j,(G[R[i]].size())){
            dp[G[R[i]][j]]=max(dp[G[R[i]][j]],dp[R[i]]+1);
        }
    }
    int Ans=0;
    REP(i,N){
        Ans=max(Ans,dp[i]);
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 11376
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  cout << fixed << ((double)((int)(n+1)/2)/n) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a, prev, ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (i == 0)
        {
            prev = a;
        }
        else
        {
            if (a < prev)
            {
                ans += prev - a;
            }
            else
                prev = a;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define int long long
#define MAX_N (300005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;

signed main() {
    int a,b,t;
    cin >> a >> b >> t;

    cout << (t/a)*b << endl;

}

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

int main(){
    int N;  cin >> N;
    vector<bool> prime(N+1, true);
    prime[0] = false; prime[1] = false; prime[2] = true;
    for(int i=3; i<=N; i++) for(int j=2; j<i; j++) if(i%j==0){
        prime[i] = false;
        break;
    }

    vector<int> a(N+1,0);
    for(int i=2; i<=N; i++){
        int n = i;
        for(int j=2; j<=N; j++){
            if(prime[j]){
                while(n%j==0){n/=j;  a[j]++;}
            }
        }
    }
    sort(a.begin(), a.end());
    int ans = 0;
    ans += a.end() - lower_bound(a.begin(), a.end(), 74);
    ans += (a.end() - lower_bound(a.begin(), a.end(), 24))*(a.end() - lower_bound(a.begin(), a.end(), 2) - 1);
    ans += (a.end() - lower_bound(a.begin(), a.end(), 14))*(a.end() - lower_bound(a.begin(), a.end(), 4) - 1);
    ans += (a.end() - lower_bound(a.begin(), a.end(), 4))*(a.end() - lower_bound(a.begin(), a.end(), 4) - 1) / 2 * (a.end() - lower_bound(a.begin(), a.end(), 2) - 2);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

#define MAX_N 111
ll d[MAX_N][MAX_N];
void warshall_floyd(int n) {
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            for(int k=0;k<n;k++)
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
}
signed main() {
    REP(i,MAX_N) REP(j,MAX_N) d[i][j]=INFLL;
    REP(i,MAX_N) d[i][i]=0;
    int N,M;
    cin>>N>>M;
    vector<pair<pii,int>> e;
    REP(i,M) {
        int a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        e.push_back({{a,b},c});
        d[a][b]=c;
        d[b][a]=c;
    }
    warshall_floyd(N);

    int ans=0;
    REP(i,M) {
        int a=e[i].first.first;
        int b=e[i].first.second;
        int c=e[i].second;
        bool f=false;
        REP(j,N) {
            if(d[b][j]==INFLL || d[a][j]==INFLL || j==a) continue;
            if(d[a][j]==d[b][j]+c) {
                f=true;
            }
        }
        if(!f) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
typedef long long ll;
const ll inf = 1e18; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	ll ans=1,temp;
	int flag=0;
	for(int i=0;i<n;i++)
	{
		cin>>temp;
		if(temp==0)
		{
			cout<<0<<endl;
			return 0;
		}
		if(inf/temp<ans)
			flag=1;
		else
			ans*=temp;
	}
	if(flag)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n, d;
  cin>>n>>d;
  int x[n][d];
  for (int i=0; i<n; i++) {
    for (int j=0; j<d; j++) {
      cin>>x[i][j];
    }
  }

  int ans = 0;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      long dist = 0;
      for (int k=0; k<d; k++) {
        long dd = (x[i][k]-x[j][k]);
        dist += dd * dd;
      }
      for (int k=1; k*k <= dist; k++) {
        if (k*k == dist) {
          ++ans;
        }
      }
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (auto&& e : a) {
    cin >> e;
    --e;
  }
  a.push_back(0);
  for (int i = n - 1; i >= 0; --i) {
    a[i] += a[i + 1];
    a[i] %= k;
  }
  long long res = 0;
  map<int, int> mp;
  for (int r = 0; r <= n; ++r) {
    if (r - k >= 0) {
      --mp[a[r - k]];
    }
    res += mp[a[r]]++;
  }
  cout << res << '\n';
}


Measured memory_bytes: 12516
import java.util.Scanner;
public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			char[] w = sc.next().toCharArray();
			int[] c = new int[26];
			for(int i = 0; i < w.length; i++) {
				c[w[i] - 'a']++;
			}
			boolean ans = true;
			for(int i = 0; i < 26; i++) {
				if(c[i] % 2 == 1) {
					ans = false;
					break;
				}
			}
			System.out.println((ans?"Yes":"No"));
		}

		

}


Measured memory_bytes: 9940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N,Q;
   cin >> N >> Q;
   vector<pair<int,int>> v1;
   vector<pair<int,int>> v2;
   for(int i=0;i<N;i++){
      int S,T,X;
      cin >> S >> T >> X;
      v1.push_back(make_pair(S-X, X));
      v2.push_back(make_pair(T-X, X));
   }
   sort(v1.begin(),v1.end());
   sort(v2.begin(),v2.end());
   vector<pair<int,int>> D;
   for(int i =0; i<Q; i++){
      int d;
      cin >> d;
      D.push_back(make_pair(d,i));
   }
   sort(D.begin(),D.end());
   multiset<int> S;
   int ind1=0;
   int ind2=0;
   long long ans[Q];
   for(int i=0; i < Q; i++){
      int d = D[i].first;
      //cout <<"D"<<i<<endl;
      while(ind1 < (int)v1.size() && v1[ind1].first <= d){
         //cout << "insert"<< v1[ind1].second<< endl;
         S.insert(v1[ind1].second);
         ind1++;
      }
      while(ind2 < (int) v2.size() && v2[ind2].first <= d){
         //cout << "erase"<< v2[ind2].second<< endl;
         S.erase(S.find(v2[ind2].second));
         ind2++;
      }
      if(S.empty()){
         ans[D[i].second]=-1;
      }
      else{
         ans[D[i].second] = *S.begin();
      }
   }
   for(int i=0;i<Q;i++){
      cout << ans[i] << endl;
   }
   return 0;
}


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

int main(){
    int n,x,num = 0;
    cin >> n >> x;
    int m[n];
    for(int i = 0; i < n; i++) cin >> m[i];
    int min = m[0];
    for(int i = 0; i < n; i++){
        x -= m[i]; num++;
        if(min > m[i]) min = m[i];
    }
    while(x >= min){
        num++; x-= min;
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main(void){
    int lp;
    cin >> lp;
    int* ary =(int*)malloc(sizeof(int)*lp);
    for(int i=0;i<lp;i++) {
        cin >> ary[i]; 
    }
    int count =0;    
    for(int i=0;i<lp;i++) {
        for(int j=0;j<lp-i-1;j++) {
            if(ary[j] > ary[j+1]) {
                int tmp=ary[j];
                ary[j] = ary[j+1];
                ary[j+1] = tmp;
                count++;
            }
        }
    }
    for(int i=0;i<lp;i++) {
        if(i==lp-1)
            printf("%d\n",ary[i]);
        else
            printf("%d ",ary[i]);
    }
    printf("%d\n",count);
    free(ary);
    return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  
  int i;
  int m,b;
  
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  }
  
}



Measured memory_bytes: 3148
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
		}
		Arrays.parallelSort(a);

		int result = 0;
		int temp;
		for (int i = 0; n - 1 - i >= k - 1; i++) {
			temp = (int) ((long) (a[n - 1 - i] - a[i]) * comb(n - 1 - i, k - 1) % MOD);
			result = (result + temp) % MOD;
		}

		while (result < 0)
			result += MOD;
		System.out.println(result);

	}

	static final int MOD = 1000000007;
	static final int FACT_MAX = 100000;
	static int[] FACT = new int[FACT_MAX + 1];
	static {
		FACT[0] = 1;
		for (int i = 1; i <= FACT_MAX; i++) {
			FACT[i] = (int) ((long) FACT[i - 1] * i % MOD);
		}

	}

	static int comb(int n, int k) {
		return (int) ((long) FACT[n] * inverse((int) ((long) FACT[k] * FACT[n - k] % MOD)) % MOD);
	}

	static int inverse(int denom) {
		return power(denom, MOD - 2);
	}

	static int power(int b, int p) {//b^p
		long res = 1;
		for (long a = b % MOD; p > 0; a = a * a % MOD, p >>= 1)
			if ((p & 1) > 0)
				res = res * a % MOD;
		return (int) res;
	}
}


Measured memory_bytes: 50712
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#include<sstream>
#define endl '\n'
#define ll long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		if(arr[i]<arr[i-1])
		{
			ans+= arr[i-1]-arr[i];
			arr[i]=arr[i-1];
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 5176
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/26/20 20:43:51
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;

int op(int a, int b) {
  return max(a,b);
}
int unit() {
  return 0;
}
constexpr int MAX = 3e5;

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

  int n,k; cin>>n>>k;
  vector<int> A(n); for(auto& a:A) cin>>a;
  atcoder::segtree<int, op, unit> rmq(MAX+1);
  for (int i = 0; i < n; i++) {
    rmq.set(A[i], rmq.prod(max(A[i]-k, 0), min(A[i]+k+1, MAX+1))+1);
  }
  cout << rmq.all_prod() << endl;

  return 0;
}


Measured memory_bytes: 9828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i*27/25==n){
			cout<<i<<endl;
			return 0;
		}
	}
	puts(":(");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

typedef long long ll;

priority_queue<ll> q;
ll N,M;

int main(){
    cin >> N >> M;
    ll a;
    for(int i=0;i<N;i++){
        cin >> a;
        q.push(a);
    }
    for(int i=0;i<M;i++){
        a = q.top();
        q.pop();
        a /= 2;
        q.push(a);
    }
    ll sum = 0;
    for(int i=0;i<N;i++){
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, K;
int x[100], y[100];

bool check(int top, int bottom, int right, int left) {
  int cnt = 0;
  rep(k, 0, N) {
    int cx = x[k];
    int cy = y[k];
    if (left <= cx && cx <= right && bottom <= cy && cy <= top) {
      ++cnt;
    }
  }

  return cnt >= K;
}

int dummy[1000000];

int main() {
  cin >> N >> K;
  rep(i, 0, N) { cin >> x[i] >> y[i]; }

  for (ll i = 0; i <= 315000000; ++i) {
    dummy[i % 1000000] = i;
  }

  ll ans = numeric_limits<ll>::max();
  rep(i, 0, N) {
    rep(j, i, N) {
      rep(k, j, N) {
        rep(l, k, N) {
          ll top = max(y[i], max(y[j], max(y[k], y[l])));
          ll bottom = min(y[i], min(y[j], min(y[k], y[l])));
          ll left = min(x[i], min(x[j], min(x[k], x[l])));
          ll right = max(x[i], max(x[j], max(x[k], x[l])));

          if (check(top, bottom, right, left)) {
            chmin(ans, (top - bottom) * (right - left));
          }
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 7524
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, long long Q, std::vector<long long> A){
  auto AA = A;
  sort(AA.begin(),AA.end());
  set<ll> a(A.begin(),A.end());
  ll ans=AA[Q-1]-AA[0];
  for(auto x:a){
    vector<vector<ll>::iterator> tmp;
    For(j,A.size()){
      if(A[j]<=x){
        tmp.push_back(A.begin()+j);
      }
    }
    tmp.push_back(A.end());
    vector<ll> prob;
    auto itr=A.begin();
    For(j,tmp.size()){
      vector<ll> t(itr,tmp[j]);
      ll tt=max(0LL,(ll)t.size()-K+1);
      if(tt!=0){
        sort(t.begin(),t.end());
        For(k,tt){
          prob.push_back(t[k]);
        }
      }
      if(tmp[j]!=A.end())
        itr=next(tmp[j]);
    }
    if(prob.size()>=Q){
      sort(prob.begin(),prob.end());
      ans=min(ans,prob[Q-1]-prob[0]);
    }else{
      break;
    }
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    static int n;
    static List<int[]>[] to;
    static List<Integer> path;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        // ans: m個のパスが、いずれもどこかの辺が黒く塗られているパターン数
        long ans = 0;
        
        // 辺の全探索だとO(2^50)
        // -> 包除原理で分けて考える
        
        // 条件を満たさない = どの辺も白く塗る
        // -> 各「条件を満たさない」を全て満たさないならどの条件も満たすことになる
        // -> ans = 集合AにもBにもCにも...属さない集合
        // -> = 全体 - (全集合の和集合)
        // -> = 全体 - (f(A)+f(B)+...) + (f(A,B)+f(A,C)+...) - (f(A,B,C)+f(A,B,D)+...) + ... - ...
        // -> = f()の中が偶数なら足し、奇数なら引くを全てのパターンする
        
        // to: 隣接リスト(無向)
        // 辺のidも記録する
        to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<int[]>();
        }
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            int id = i;
            to[p].add(new int[]{q, id});
            to[q].add(new int[]{p, id});
        }
        
        // bitset[i]: i番目の制約
        // ex. 1100101 -> 辺id0,2,5,6を白く塗る
        int m = sc.nextInt();
        long[] bitset = new long[m];
        for (int i = 0; i < m; i++) {
            int start = sc.nextInt() - 1;
            int end = sc.nextInt() - 1;
            
            path = new ArrayList<Integer>();
            dfs(start, end, -1);
            for (Integer id : path) {
                // (id)bit目を立てる
                bitset[i] |= 1L<<id;
            }
        }
        
        // 制約のパターン(上の集合の組み合わせ)をbit全探索
        // [00000]～[11111]
        for (int bit = 0; bit < 1<<(m); bit++) {
            // mask: どの辺を白く塗るか
            long mask = 0;
            
            // bitの各桁をなめる
            for (int d = 0; d < m; d++) {
                // 1の桁はmaskに採用
                if ((bit & (1<<d)) != 0) {
                    mask |= bitset[d];
                }
            }
            
            // count1ofmask: 白く塗る辺の数
            // count1ofbit: 制約の数
            int count1ofmask = Long.bitCount(mask);
            int count1ofbit = Integer.bitCount(bit);
            
            if (count1ofbit % 2 == 0) {
                ans += (long)Math.pow(2, (n-1) - count1ofmask);
            } else {
                ans -= (long)Math.pow(2, (n-1) - count1ofmask);
            }
            // System.out.println(count1ofmask + " " + ans);
        }
        System.out.println(ans);
    }
    
    // 最短経路を得る
    public static boolean dfs(int p, int end, int par) {
        // 終了条件
        if (p == end) {
            return true;
        }
        
        for (int[] qData : to[p]) {
            int q = qData[0];
            int id = qData[1];
            if (q == par) continue;
            
            if (dfs(q, end, p)) {
                path.add(id);
                return true;
            }
        }
        
        return false;
    }
}

Measured memory_bytes: 24684
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

#define P pair<long long int, long long int> 

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

	vector<long long int> x(n);
	vector<long long int> y(n);

	vector<P> dot(n);

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		dot[i] = P(x[i], y[i]);
	}

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	long long int MIN = (x[n - 1] - x[0])*(y[n - 1] - y[0]);

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = 0; k < n; k++) {
				for (int l = k + 1; l < n; l++) {
					int cc = 0;
					for (int r = 0; r < n; r++) {
						if (x[i] <= dot[r].first && dot[r].first <= x[j] && y[k] <= dot[r].second && dot[r].second <= y[l]) {
							cc++;
						}
					}
					if (cc >= K) {
						MIN = min(MIN, (x[j] - x[i])*(y[l] - y[k]));
					}
				}
			}
		}
	}

	cout << MIN << endl;

	return 0;
}

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

int main() {
    string s;
    cin>>s;
    // Sunny, Cloudy, or Rainy
    if(s=="Cloudy")
    {
        cout<<"Rainy";
    }
    else if(s=="Sunny")
    {
        cout<<"Cloudy";
    }
    else if(s=="Rainy")
    {
        cout<<"Sunny";
    }
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;

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

  ll sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += s[i] - '0';
  }

  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
bool dp[100009];
int x;
bool f(int i){
    if (i==x)
        return 1;
    if (dp[i])
        return 1;
    dp[i]=1;
    bool h=0;
    for (int j=100;j<=105;j++){
        if (i+j<=x&&!dp[i+j])
            h|=f(i+j);
    }
    return h;

}
int main()
{
    FASTINOUT;
    cin>>x;
    if (f(0))
        cout<<1;
    else
        cout<<0;
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAXV = 100001;

pair<int, int> cnteven[MAXV], cntodd[MAXV];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int v[n];
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=0;i<=MAXV;i++){
        cnteven[i] = make_pair(0, i);
        cntodd[i] = make_pair(0, i);
    }
    for(int i=0;i<n;i++){
        if(i %2 == 0){
            cnteven[v[i]].first++;
        }else{
            cntodd[v[i]].first++;
        }
    }
    sort(cnteven, cnteven + MAXV, greater<pair<int, int> >());
    sort(cntodd, cntodd + MAXV, greater<pair<int, int> >());
    int ans;
    if(cnteven[0].second == cntodd[0].second){
        ans = min(n - cntodd[1].first - cnteven[0].first, n - cntodd[0].first - cnteven[1].first);
    }else{
        ans = n - cnteven[0].first - cntodd[0].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
S = [0]*2020

n = int(input())
X = [int(a) for a in input().split()]
for a in X:
  S[a] = 1

m = int(input())
M = [int(a) for a in input().split()]
for i in M:
  i = i - 1
  if X[i]+1 != 2020:
    if S[X[i]+1] == 0:
      S[X[i]+1] = 1
      S[X[i]] = 0
      X[i] = X[i]+1

for i in range(2020):
  if S[i] == 1:
    print(i)


Measured memory_bytes: 5628