akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int A[100000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( key == A[mid] ) return 1; /* keyを発見 */
    if ( key > A[mid] ) left = mid + 1; /* 後半を探索 */
    else if ( key < A[mid] ) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
  }
  
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);
  
  return 0;
}


Measured memory_bytes: 2132
N = int(input())
S = input()

dw = [0]*N
de = [0]*N

for i in range(N):
  dw[i]= (dw[i-1] if i>0 else 0 )+ (1 if (S[i]=="W") else 0 )
for i in range(N-1,-1,-1):
  de[i]= (de[i+1] if i<N-1 else 0 )+ (1 if (S[i]=="E") else 0 )

#print ( dw )
#print ( de )

m = 100000000000000
for i in range(N):
  dm = 0
  if (i>0):
    dm += dw[i-1]
  if (i<N-1):
    dm += de[i+1]
  m = min(m,dm)
print ( m ) 

Measured memory_bytes: 47320
#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() {
    int n, x, y; cin >> n >> x >> y;
    int ans[2005] = {0};
    rep(i, n) ans[i+1] = n - 1 - i;
    for(int i=1;i<n;i++) {
        for(int j=i+1;j<=n;j++) {
            if(j < x || i > y) continue;
            if(j-i>=abs(x-i)+1+abs(y-j)) {
                ans[j-i]--;
                ans[abs(x-i)+1+abs(y-j)]++;
            }
        }
    }
    rep(i, n-1) {
        cout << ans[i+1] << endl;
    }
}


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

int main() {
  int N, P;
  string S;
  cin >> N;
  vector<tuple<string, int, int>> vec;
  for (int i = 0; i < N; i++) {
    cin >> S >> P;
    P = 100 - P;
    vec.push_back(make_tuple(S, P, i + 1));
  }

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

  int ans;
  for (int i = 0; i < N; i++) {
    tie(ignore, ignore, ans) = vec.at(i);
    cout << ans << endl;
  }
}


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

int main(){
  int n,i,j,k;
  cin>>n;
  int t[n];
  for(i=0;i<n;i++){
    t[i]=i+1;
  }
  string s[n];
  int p[n];
  for(i=0;i<n;i++){
    cin>>s[i]>>p[i];
  }
  int q1;
  string q2;
  for(i=0;i<101;i++){
    for(j=0;j<n;j++){
      for(k=0;k<j;k++){
        if(s[j]<s[k] || (s[j]==s[k] && p[j]>p[k])){
          q1=p[j];
          p[j]=p[k];
          p[k]=q1;
          q2=s[j];
          s[j]=s[k];
          s[k]=q2;
          q1=t[j];
          t[j]=t[k];
          t[k]=q1;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    cout<<t[i]<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

char c[110];
int k,m,n,a[110],tot=0;
signed main(){
	scanf("%s",c+1);n=strlen(c+1);k=read();
	for(register int i=1;i<=n;i++){
		if(c[i]!=c[i-1])a[++tot]=1;
		else a[tot]++;
	}
	if(tot==1){
		printf("%lld ",n*k/2);
		return 0;
	}
	int ans=0;
	if(c[1]==c[n]){
		for(register int i=2;i<tot;i++){
			ans+=a[i]/2*k;
		}
		ans+=a[1]/2+a[tot]/2+(a[1]+a[tot])/2*(k-1);
		printf("%lld ",ans);
		return 0;
	}
	for(register int i=1;i<=tot;i++)ans+=a[i]/2*k;
	printf("%lld ",ans);
	return 0;
}

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

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int a = 0;
  int b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') a++;
    if (s.at(i) == '1') b++;
  }
  cout << min(a, b) * 2 << endl;
}


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

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    if(a+b>=c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
hl = LI()
ans = 0
tmp = 0
for i in range(N-1):
    if hl[i] >= hl[i+1]:
        tmp += 1
        ans = max(ans, tmp)
    else:
        tmp = 0
print(ans)

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n, m;
int dp[100050], no[100050];
const int mod = 1e9+7;

int main()
{
	IOS;
	cin >> n >> m;
	while (m--) {
		int e;
		cin >> e;
		no[e] = 1;
	}
	dp[0] = 1, dp[1] = !no[1];
	for (int i = 2; i <= n; i++) {
		if (!no[i]) {
			dp[i] = dp[i-1] + dp[i-2];
			dp[i] = dp[i] % mod;
		}
	}
	/*
	for (int i = 0; i <= n; i++) {
		cout << dp[i] << ' ';

	}*/
	cout << dp[n] << endl;
	return 0;
}



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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());
    vector<pair<int, int>> g;
    rep(i,M) {
        int a,b;
        cin >> a >> b;
        g.emplace_back(b, a);
    }
    sort(g.begin(),g.end(), greater<pair<int,int>>());
    int i = 0;
    for (auto m : g) {
        for (int j = 0; j < m.second; j++) {
            if (a[i] >= m.first)
                break;
            a[i] = m.first;
            i++;
        }
    }
    ll ans = 0;
    rep(i, N) ans += a[i];
    cout << ans << endl;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  int h,w,k;
  cin>>h>>w>>k;
  char x[h][w];
  char m[h][w];
  rep(i,h){
    rep(j,w){
      cin>>x[i][j];
    }
  }
  int ans=0;

  rep(biti,(1LL<<h)){
    rep(bitj,(1LL<<w)){
      int count=0;
      rep(i,h){
        rep(j,w){
          if(x[i][j]=='#'){
            if(biti&(1LL<<i) || bitj&(1LL<<j) ){

            }
            else{
              count++;
            }
          }
        }
      }
      if(count==k) ans++;
    }
  }
  
  cout<<ans<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7768
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back

int32_t main(){
IOS;
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int ans = 0;
for(int i=60;i>=0;i--)
{
    int o=0,z=0;
    for(int j=0;j<n;j++)
    {
        if((a[j] >> i) & 1)
        o++;
        else
        {
            z++;
        }
    }
    ans += ((o*z)%1000000007)*((int)pow(2 , i)%1000000007);
    ans %= (1000000007);
}
cout<<ans<<endl;
return 0;
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n, d[100001];
	cin >> n;
	rep(i, n) cin >> d[i];
	sort(d, d + n);
	cout << d[n/2] - d[n/2-1] << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
const ll MOD = 1e9+7;
const vi dx = {1, 0, -1, 0, 1, -1, -1, 1};
const vi dy = {0, 1, 0, -1, 1, 1, -1, -1};


int main() {
    int X,Y,Z; cin>>X>>Y>>Z;
    cout<<Z<< " " << X<< " " <<Y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <ctype.h>
#define N 100000
using namespace std;

void down(string *);

int main(){
	string w,s;
	cin>>w;
	int c=0;
	down(&w);
	while(cin>>s,s!="END_OF_TEXT"){
		down(&s);
		if(w==s) c++;
	}
	cout<<c<<endl;
	return 0;
}

void down(string *w){
	for(int i=0;i<(*w).size();i++){
		if('A'<=(*w)[i] &&(*w)[i]<='Z') (*w)[i]+='a'-'A';
	}
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3


//modつき演算
ll mod_add(ll a, ll b) {
	return (a + b) % MOD;
}

ll mod_sub(ll a, ll b) {
	return (a - b + MOD) % MOD;
}

ll mod_mul(ll a, ll b) {
	return a*b % MOD;
}

ll fact[100100];

ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	ll res = mod_pow(x*x%MOD, n / 2);
	if (n & 1)res = res*x%MOD;
	return res;
}

ll factorial() {
	REP(i, 100100) {
		if (i == 0)fact[0] = 1;
		else fact[i] = fact[i - 1] * i%MOD;
	}
}

ll nCk(ll n, ll k) {
	return fact[n] * mod_pow(fact[k], MOD - 2) % MOD*mod_pow(fact[n - k], MOD - 2) % MOD;
}
int n;
set<int> si;
int lb = 0, ub = 0;
int pos[100100];

int main() {
	factorial();
	cin >> n;
	REP(i, n + 1) {
		int a;
		cin >> a;
		if (si.find(a) != si.end()) {
			ub = i;
			lb = pos[a];
		}
		pos[a] = i;
		si.insert(a);
	}
	FOR(i, 1, n + 2) {
		if (lb + n - ub-(i - 1) >= 0)cout << mod_sub(nCk(n + 1, i), nCk(lb + n - ub, i - 1)) << endl;
		else cout << nCk(n + 1, i) << endl;
	}

}

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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n;
string s;

int main(){
  cin>>n>>s;
  int min_ = n;
  int pre = 0;
  FOR(i,1,n)
    if(s[i] == 'E') pre++;
  min_ = pre;
  FOR(i,1,n){
    if(s[i-1] == 'W')
      pre++;
    if(s[i] == 'E')
      pre--;
    min_ = min(min_,pre);
  }
  cout<<min_<<endl;
  return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+5],q;
	memset(a,0,sizeof(a));
	while(cin>>q)
	{
		if(getchar()=='\n')
		{
			a[q]++;
			break;
		}
		
		a[q]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 4404
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

void solve() {
	string s; cin >> s;
	int le = stoi(s.substr(0, 2));
	int ri = stoi(s.substr(2, 2));
	bool f = false, g = false;
	if (1 <= le && le <= 12)f = true;
	if (1 <= ri && ri <= 12)g = true;
	if (f&&g) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (f) {
		cout << "MMYY" << endl;
	}
	else if(g){
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

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

Measured memory_bytes: 256
import math
from functools import lru_cache
from operator import mul
from functools import reduce


def resolve():
    import sys
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()
    B = A[::-1]

    @lru_cache(maxsize=None)
    def combinations_count__(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    @lru_cache(maxsize=None)
    def combinations_count____(n, r):
        r = min(r, n - r)
        numer = reduce(mul, range(n, n - r, -1), 1)
        denom = reduce(mul, range(1, r + 1), 1)
        return numer // denom

    def combinations_count_(n, r):
        if n - r < r: r = n - r
        if r == 0: return 1
        if r == 1: return n

        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]

        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot

        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])

        return result

    def modinv(a, mod=10**9+7):
        return pow(a, mod-2, mod)

    def combinations_count(n, r, mod=10**9+7):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n-r)
        return fact[n] * factinv[r] * factinv[n-r] % mod
    
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    sum = 0
    for i in range(K-1, N):
        sum += combinations_count(i, K-1) * A[i] % MOD - combinations_count(i, K-1) * B[i] % MOD

    print(sum % MOD)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 74536
n=int(input())
card=[] 
all_=[[0]*13 for i in range(4)]
#print(all_)
case=["S","H","C","D"]
for i in range(n):
    a,b=input().split()
    all_[case.index(a)][int(b)-1]=1
#print(all_)
for i in range(4):
    for j in range(13):
        if all_[i][j]==0:
            print(case[i]+" "+str(j+1))


Measured memory_bytes: 5600
n = input()
a,b,c,d = map(int,list(n))
op =[1,1,1]
v = ["?","+","-"]
ans = 0
for i in range(-1,2,2):
    for j in range(-1,2,2):
        for k in range(-1,2,2):
            op[0] = i
            op[1] = j
            op[2] = k
            if a+b*op[0]+c*op[1]+d*op[2] == 7:
                print("{}{}{}{}{}{}{}=7".format(a,v[op[0]],b,v[op[1]],c,v[op[2]],d))
                break
        else:
            continue
        break
    else:continue
    break


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
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(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC161 D - Lunlun Number
// 2020.06.24

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll K; cin >> K;
  queue<ll> q;
  for(ll i = 1; i <= 9; i++){
    q.push(i);
  }
  ll cnt = 1;
  while(1){
    ll cur = q.front(); q.pop();
    if(cur%10 != 0) q.push(cur*10+((cur%10)-1));
    q.push(cur*10+(cur%10));
    if(cur%10 != 9) q.push(cur*10+((cur%10)+1));
    if(cnt == K){
      cout << cur << endl;
      return 0;
    }
    cnt++;
  }
}

Measured memory_bytes: 4756
N, K = map(int, input().split())
if K % 2 != 0:
    print(pow(int(N / K), 3))
else:
    cnt = 0
    cnt1 = 0
    cnt2 = 0
    for i in range(1, N + 1):
        if i % K == 0:
            cnt1 += 1
        elif i % K == K / 2:
            cnt2 += 1
    cnt = pow(cnt1, 3) + pow(cnt2, 3)
    print(cnt)
    


Measured memory_bytes: 3060
n, t = list(map(int, input().split()))
ct = []
for i in range(n):
    ct.append(list(map(int, input().split())))

cost = 2000
for cn, tn in ct:
    if cn <= cost and tn <= t:
        cost = cn
if cost == 2000:
    print("TLE")
else:
    print(cost)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n", min(b / a, c));
    return 0;
}



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

int LIMIT = 200000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    string t;
    cin >> s;
    cin >> t;
    unordered_map<char, vector<int>> m;
    for (int i = 0; i < s.length(); i++) {
        m[s[i]].push_back(i + 1);
    }
    // にぶたんで配列外参照を起こさないように
    for (char i = 'a'; i <= 'z'; i++) {
        m[i].push_back(LIMIT);
    }

    long long ans = 0;
    int p = 0;
    for (auto i : t) {
        if (m[i][0] == LIMIT) {
            cout << -1 << endl;
            return 0;
        }
        int c = *lower_bound(m[i].begin(), m[i].end(), p + 1);
        c = c == LIMIT ? m[i][0] : c;
        if (c <= p) {
            ans += s.length() - p;
            p = 0;
        }
        ans += (c - p);
        p = c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S; // 入力
  string A = "ACGT";
  int ans = 0;	// S中のACGT文字列の最大長
  int now = 0;	// 今判定しているACGT文字列の最大長
  for (int i = 0; i < S.size(); i++) {
  	bool isACGT = false;
    for (int j = 0; j < A.size(); j++) {
    	if (S[i] == A[j]) {
          isACGT = true;
        }
    }
    if (!isACGT) {
      now = 0; 
    }else {
      now++;
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int main() {
	ll n;

	scanf("%lld", &n);

	ll ans = 1e18;

	for(ll i = 1; i*i <= n; i++) {
		if(n%i == 0) {
			ans = min(ans, i-1 + n/i - 1);
		}
	}

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 256
while True:
    S = input()
    if S == ".":
        break
    
    brackets = []
    closed = True
    for c in S:
        if c in "([":
            brackets.append(c)
        elif c == ")":
            if not brackets or brackets[-1] != "(":
                closed = False
                break
            else:
                brackets.pop()
        elif c == "]":
            if not brackets or brackets[-1] != "[":
                closed = False
                break
            else:
                brackets.pop()
    
    if brackets:
        closed = False
        
    if closed:
        print("yes")
    else:
        print("no")


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> w(n); rep(i, n) cin >> w[i];

	int ans = 100 * 100;
	rep(i, n - 1) {
		int sum1 = 0, sum2 = 0;
		rep(j, n) {
			if (j <= i) sum1 += w[j];
			else sum2 += w[j];
		}
		ans = min(ans, abs(sum1 - sum2));
	}
	printf("%d\n", ans);
	return 0;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define FOR(i, a, b) for (int i = a; i <= (int)(b); i++)
#define FORD(i, a, b) for (int i = a; i >= (int)(b); i--)

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
using Lint = long long;
#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define PB push_back
#define MP make_pair
using P=pair<int, int>;
using V=vector<int>;
using M=map<int, int>;
using S=set<int>;

#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
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;}
/* vector<T>のイテレータはvector<T>::iterator型
vector<int>::iterator it = vc.begin();  // begin()はvectorの最初の要素を指すイテレータを返す
vector<int>::iterator endIt = vc.end(); // end()はvectorの終端位置を指すイテレータを返す
while (it != endIt)
{
  cout << *it << '\n'; // イテレータの指す要素は、ポインタのように*演算子でアクセス
  it++;                // インクリメントすることで次の要素を指します。
}
}*/
int main(){
int a,sum;
cin >> a;
  sum=a+a*a+a*a*a;
    COUT(sum); 
}


Measured memory_bytes: 3632
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back 
#define MP make_pair
typedef long long ll;
const ll INF=1<<28;
const ll LINF=1ll<<61;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
char s[100111];
int n;
bool ans[100111];
void solve()
{
	for(int i=2;i<n+2;i++)
	{
		if(ans[i-1]^(s[i-1]=='o'))ans[i]=ans[i-2]^1;
		else ans[i]=ans[i-2];
	}
//	for(int i=0;i<n+2;i++)putchar(ans[i]?'S':'W');puts("");
	if(ans[n]==ans[0]&&ans[n+1]==ans[1])
	{
		for(int i=0;i<n;i++)putchar(ans[i]?'S':'W');
		exit(0);
	}
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	s[n]=s[0];
	s[n+1]=s[1];
	for(int i=0;i<4;i++)
	{
		ans[0]=i&1;
		ans[1]=(i>>1)&1;
		solve();
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 512
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  long a, b, c, d;
  
  readf("%s %s %s %s\n", &a, &b, &c, &d);

  auto res = b - a + 1;

	res -= b / c - (a-1) / c;
  res -= b / d - (a-1) / d;
  auto lcm = c * d / gcd(c, d);
  res += b / lcm - (a-1) / lcm;
  res.writeln;
}


Measured memory_bytes: 256
program cm
   implicit none
   integer::N,M,Q
   integer,allocatable,dimension(:)::a,b,c,d
   integer,allocatable,dimension(:)::X

   integer::i
   integer::ans=0
   read*,N,M,Q
   allocate(a(Q),b(Q),c(Q),d(Q))
   do i=1,Q
      read*,a(i),b(i),c(i),d(i)
   end do

   allocate(X(0:N))
   X(0)=1
   call DFS(1)
   print"(I0)",ans
contains
recursive subroutine DFS(K)
   integer::K
   integer::tmp
   integer::i
   if(K==N+1)then
      tmp=0
      do i=1,Q
         if(X( B(i) )-X( A(i) )==c(i))tmp=tmp+d(i)
      end do
      ans=max(ans,tmp)
      return
   endif
   do i=X(K-1),M
      X(K)=i
      call DFS(K+1)
   end do
end subroutine
end program cm

Measured memory_bytes: 2936
#include<iostream>
#include<vector>
#include<map>

using namespace std;

#define Max(a, b) ((a) > (b) ? (a) : (b))

struct Circle
{
	int x, y, radius, color;
	bool overlap(const Circle& other) const
	{
		int dis_x = x - other.x;
		int dis_y = y - other.y;
		int dis = radius + other.radius;

		return dis * dis > dis_x * dis_x + dis_y * dis_y;
	}
};

map<int, int> dp;
vector<Circle> circles;


int next_circle(int state, int index)
{
	for(int i = index - 1; i >= 0; --i)
	{
		if(state & (1 << i))return i;
	}
	return -1;
}

bool isTop(int state, int index)
{
	bool ret = true;
	int on_index = index;
	
	while(true)
	{
		on_index = next_circle(state, on_index);
		if(on_index < 0)break;

		ret &= !circles[index].overlap(circles[on_index]);
	}
	return ret;
}

bool removable(int state, int i, int j)
{
	const auto& now = circles[i];
	const auto& other = circles[j];
	if(now.color != other.color)return false;

	return isTop(state, i) && isTop(state, j) && !now.overlap(other);
}

int dfs(int state)
{
	if(dp.find(state) != dp.end())
	{
		if(dp[state] > 0)return dp[state];
	}
	int ret = 0;

	for(int i = 0; i < circles.size(); ++i)
	{
		//?????§??????????????????????????????
		if(!(state & (1 << i)))continue;

		for(int j = i - 1; j >= 0; --j)
		{
			//?????§??????????????????????????????
			if(!(state & (1 << j)))continue;

			if(removable(state, i, j))
			{
				int removed_circle = ((1 << i) | (1 << j));
				int new_state = state & (~removed_circle);

				ret = Max(dfs(new_state) + 2, ret);
			}
		}
	}
	return dp[state]= ret;
}

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

		dp.clear();
		dp[(1 << n) - 1] = 0;

		circles.clear();
		circles.reserve(n);

		for(auto i = 0; i < n; ++i)
		{
			int x, y, radius, color;
			cin >> x >> y >> radius >> color;

			Circle c = Circle{x, y, radius, color};
			circles.push_back(c);
		}

		cout << dfs((1 << n) - 1) << endl;

	}


	return 0;	
}

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


int main()
{	
	int n,k; cin >> n >> k;
	std::vector<int> h(n);
	int count = 0;
	rep(i,n) {
		cin >> h[i];
		if(h[i] >= k) count++;
	}

	cout << count << endl;

   
    return 0;
}

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    n--;
    cout<<n*(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const int INF=1e9;
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; }

int ac(string t){
  int cnt=0;
  for(int i=0; i<t.size(); i++){
    if(t[i]=='A' && t[i+1]=='C') cnt++;
  }
  return cnt;
}


int main(int argc, char const *argv[]) {
  string s;
  int n,Q;
  int l[100010],r[100010];
  std::cin >> n >> Q >> s;
  rep(i,Q) {
    std::cin >> l[i] >> r[i];
    l[i]--,r[i]--;
  }
  int cnt=0,memo[200010]={};
  for(int i=1; i<n; i++){
    if(s[i]=='C' && s[i-1]=='A'){
      cnt++;
      memo[i]=cnt;
    }
    else memo[i]=cnt;
  }
  //rep(i,n) std::cout << memo[i] << '\n';

  for(int i=0; i<Q; i++){
    std::cout << memo[r[i]]-memo[l[i]] << '\n';
  }



  return 0;
}


Measured memory_bytes: 2688
a,b = map(int, input().split())
poker = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if poker.index(a) == poker.index(b):
    print("Draw")
elif poker.index(a) > poker.index(b):
    print("Alice")
else:
    print("Bob")

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

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

	int dp[n+1];
	dp[1]=0;
	dp[2] = abs(h[1]-h[2]);

	for(int i=3;i<=n;i++){
		dp[i] = min( dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2])  );
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 4328
#include <stdio.h>

char a[100][100];

int main(){
	int H,W;
	scanf("%d %d",&H,&W);
	int i,j;
	for(i = 0;i<H;i++){
		for(j = 0;j<W;j++){
			scanf(" %c",&a[i][j]);
		}
	}

	for(i = 0;i<H+2;i++){
		for(j = 0;j<W+2;j++){
			if(i == 0 || i == (H+1)){
				printf("#");
			}else{
				if(j == 0 || j == (W+1)){
					printf("#");
				}else{
					printf("%c",a[i-1][j-1]);
				}
			}
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
string s;
int al[26];
ll ans=1;
int main(){
	cin>>n;
	cin>>s;
	for(int i=0;i<s.size();i++){
		al[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		ans*=(al[i]+1);
		ans%=MOD;
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;

ll N, Q;
string s;
vector<char> t, d;

void input() {
    cin >> N >> Q >> s;
    t.resize(Q);
    d.resize(Q);
    for (ll i = 0; i < Q; i++) {
        cin >> t[i] >> d[i];
    }
}

ll goal(ll p) {
    for (ll i = 0; i < Q; i++) {
        if (s[p] == t[i]) {
            if (d[i] == 'L')
                p--;
            else
                p++;
        }
        if (p < 0 or p >= N)
            return p;
    }
    return p;
}

ll solve() {
    vector<ll> spos[0xff];
    for (ll i = 0; i < N; i++) {
        spos[ll(s[i])].push_back(i);
    }
    ll dels = 0;
    ll l = 0, r = N-1;
    ll c = (l + r)/2;
    while (l <= r) {
        if (goal(c) < 0) {
            dels += c-l+1;
            l = c+1;
        } else {
            r = c-1;
        }
        c = (l+r)/2;
    }
    l = 0, r = N-1;
    while (l <= r) {
        if (goal(c) >= N) {
            dels += r-c+1;
            r = c-1;
        } else {
            l = c+1;
        }
        c = (l+r)/2;
    }
    
    return N - dels;
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



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

int main() {
	int N , a[10] , ng = 1 , all = 1;
	cin >> N;
	for(int i = 0;i < N;i++){
		cin >> a[i];
	}
	for(int i = 0;i < N;i++){
		all *= 3;
		if(a[i] % 2 == 0) ng *= 2;
	}
	cout << all - ng << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	// ?´?
	static int paper[][] = new int[10][10];
	// 1???????????????
	static int deepCell = 0;
	// ??????????????????????????????
	static int clearCell = 0;

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

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String str;

		while (true) {
			str = br.readLine();
			if (str == null || str.isEmpty()) {
				break;
			}

			// ??\???????????????
			String[] input = str.split(",");

			// ??????????????????????????°??????????????????
			int x = Integer.parseInt(input[0]);
			int y = Integer.parseInt(input[1]);
			int size = Integer.parseInt(input[2]);

			// size?????§??????????????£???????????????????????????????????????
			switch (size) {
			case 1:
				small(x, y);
				break;
			case 2:
				medium(x, y);
				break;
			case 3:
				large(x, y);
				break;
			}
		}
		printClearCell();
		printDeepCell();
	}

	// ?????????????????????????????????????????????
	private static void printClearCell() {
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				if (paper[i][j] == 0) {
					clearCell++;
				}
			}
		}
		System.out.println(clearCell);
	}

	// ?????????????????????????????????
	private static void printDeepCell() {
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				if (deepCell < paper[i][j]) {
					deepCell = paper[i][j];
				}
			}
		}
		System.out.println(deepCell);
	}

	private static void small(int x, int y) {
		// ???????????´??????????????¨???
		paper[x][y]++;
		// ??????????????????????????¨
		if (y != 0) {
			paper[x][y - 1]++;
		}
		// ??????????????????????????¨
		if (y != 9) {
			paper[x][y + 1]++;
		}
		// ??????????????????????????¨
		if (x != 0) {
			paper[x - 1][y]++;
		}
		// ??????????????????????????¨
		if (x != 9) {
			paper[x + 1][y]++;
		}
	}

	private static void medium(int x, int y) {
		small(x, y);
		// ???????????????????????????
		if (x >= 1 && y >= 1) {
			paper[x - 1][y - 1]++;
		}
		// ???????????????????????????
		if (x <= 8 && y >= 1) {
			paper[x + 1][y - 1]++;
		}
		// ???????????????????????????
		if (x >= 1 && y <= 8) {
			paper[x - 1][y + 1]++;
		}
		// ???????????????????????????
		if (x <= 8 && y <= 8) {
			paper[x + 1][y + 1]++;
		}
	}

	private static void large(int x, int y) {
		medium(x, y);
		// ???????????´???2??????
		if (x >= 2) {
			paper[x - 2][y]++;
		}
		// ???????????´???2??????
		if (x <= 7) {
			paper[x + 2][y]++;
		}
		// ???????????´???2??????
		if (y >= 2) {
			paper[x][y - 2]++;
		}
		// ???????????´???2??????
		if (y <= 7) {
			paper[x][y + 2]++;
		}
	}
}

Measured memory_bytes: 24200
//
//  main.cpp
//  programming
//
//  Created by 安波暢道 on 2020/03/28.
//  Copyright © 2020年 安波暢道. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

vector<bool> ans(3,false);

void check(vector<int> &data, vector<bool> &temp,int i, int p)
{
    if(temp[i])
    {
        p += data[i+1];
    }
    else
    {
            p -= data[i+1];
    }
    
    if(i == 2)
    {
        if(p==7)
        {
            ans = temp;
        }
    }
    else
    {
        check(data,temp,i+1,p);
        temp[i+1] = true;
        check(data,temp,i+1,p);
        temp[i+1] = false;
    }
    return;
}

int main()
{
    string S;
    cin >> S;
    
    vector<int> data(4);
    
    for(int i=0;i<4;i++)
    {
        data[i] = S[i] - '0';
    }
    
    vector<bool> temp(3,false);

    check(data,temp,0,data[0]);
    temp[0] = true;
    check(data,temp,0,data[0]);
    
    cout << data[0];
    for(int i=0;i<3;i++)
    {
        if(ans[i])
        {
            cout << "+";
        }
        else
        {
            cout << "-";
        }
        
        cout << data[i+1];
    }
    cout << "=7"<<endl;
    
    
    //cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int d = a / b, r = a % b;
    double f = 1.*a / b;
    printf("%d %d %.5f\n", d, r, f);
    return 0;

}




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


typedef int value_type;
value_type med3(value_type x, value_type y, value_type z) {
    if (x < y) {
        if (y < z) return y; else if (z < x) return x; else return z;
    } else {
        if (z < y) return y; else if (x < z) return x; else return z;
    }
}

void quicksort(value_type a[], int left, int right) {
    
    if (left < right) {

        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]);

        while (1) {
            while (a[i] < pivot) i++;
            while (pivot < a[j]) j--;
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp;
            i++; j--;
        }

        quicksort(a, left, i - 1);
        quicksort(a, j + 1, right);

    }
}


int main(){
    int ans=0,n,k,MIN=1000000001;
    cin >>n>>k;
    int data[n];
    for (int i = 0; i < n; i++){
        cin >> data[i];
    }
    quicksort(data,0,n-1);

    for (int i = 0; i <= n-k; i++){
        MIN =min(MIN,data[k+i-1]-data[i]);
    }
    
    cout << MIN <<endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }
string str[12];

void f(int x,int y){
	str[y][x]='0';
	if(0<x&&str[y][x-1]=='1')f(x-1,y);
	if(x<11&&str[y][x+1]=='1')f(x+1,y);
	if(0<y&&str[y-1][x]=='1')f(x,y-1);
	if(y<11&&str[y+1][x]=='1')f(x,y+1);
}

int main() {
	while(cin>>str[0]){
		int i;
		for(i=1;i<12;i++)cin>>str[i];
		int x,y,res=0;
		for(y=0;y<12;y++){
			for(x=0;x<12;x++){
				if(str[y][x]=='1'){
					res++;
					f(x,y);
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222

ll dp[MAX][22][10], x[4] = { 0,3,5,7 };


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

  cin >> s;
  n = s.length();


  dp[0][0][0] = 1;
  rep(i, n) rep(j, 2) rep(mask, 8) {
    tmp = s[i] - '0';
    if (j) tmp = 9;
    for (ll z = 0; x[z] <= tmp && z < 4; z++) {
      if (z == 0&&mask) continue;
      ll y = z != 0 ? 1LL << (z - 1) : 0;
      dp[i + 1][j || x[z] < tmp][mask | y] += dp[i][j][mask];
    }
  }

  cout << dp[n][1][7]+ dp[n][0][7]<< endl;


  return 0;
}


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

int main() {
  string str1, str2, str3;
  cin >> str1 >> str2 >> str3;
  char a,b,c;
  a = str1.at(0);
  b = str2.at(0);
  c = str3.at(0);
  cout << a << b << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	string S, T;
	cin >> S >> T;
	ll ans = 0;
	rep(i, S.size()) {
		if (S[i] != T[i]) { ans++; }
	}

	cout << ans << endl;
}

Measured memory_bytes: 3920
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
// use std::cmp; // cmp::max,cmp::min

// Rustメモ: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

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

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

////////////////////////////////////////////////

fn prime_board(n:i64)->Vec<bool>{
    let mut ret = vec![true;(n+1) as usize];

    ret[0]=false;
    ret[1]=false;
    for i in 2..(n+1){
        if ret[i as usize] {
            let mut j = 2*i;

            while j < n+1{
                ret[j as usize]=false;
                j +=i;
            }
        }
    }

    ret
}

fn main(){
    let n : usize = 100009;
    let board = prime_board(n as i64);
    let mut total = 0;
    let mut arr = vec![0 as i32;n/2];

    // for i in 0..100 {
    //     if board[i]{
    //         println!("{},",i);
    //     }
    // }

    for i in 0..n/2{
        let m1 = i * 2 + 1;
        let m2 = (m1+1)/2;
        let flag = board[m1] && board[m2];

        arr[i] = total;

        if flag {
            total += 1;
        }
    }

    let q = read_int();

    for _ in 0..q{
        let input = read_ints();
        let (l,r) = (input[0],input[1]);

        let l_idx = (l-1)/2;
        let r_idx = (r-1)/2;

        let ans0 = arr[r_idx as usize+1]-arr[l_idx as usize];
        println!("{}",ans0);
    }
}

Measured memory_bytes: 4732
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(void){
	int h,w,i,j;
	char a[100][101];
	cin>>h>>w;
	for(i=0;i<h;i++)cin>>a[i];
	for(i=0;i<w+2;i++) cout<<"#";
	cout<<endl;
	for(i=0;i<h;i++) cout<<"#"<<a[i]<<"#"<<endl;
	for(i=0;i<w+2;i++) cout<<"#";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define LL long long

 
 int main(){
 	LL x, ans;
 	cin >> x;
 	ans = 2*(x/(6+5));
 	if(11*ans/2 < x && 11*ans/2 + 6 >= x) ans++;
 	else if(11*ans/2 + 6 < x ) ans+=2;
 	cout << ans << endl;
 }

Measured memory_bytes: 384