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

#define SIZE 1024

int main(void){
  int n, i;
  double vecx[SIZE] = {0}, vecy[SIZE] = {0};
  double D[4] = {0};

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%lf", &vecx[i]);
  for (i = 0; i < n; i++)
    scanf("%lf", &vecy[i]);

  // calculate D1
  D[0] = 0;
  for (i = 0; i < n; i++)
    D[0] += abs(vecx[i] - vecy[i]);

  // calculate D2
  D[1] = 0;
  for (i = 0; i < n; i++)
    D[1] += pow(abs(vecx[i] - vecy[i]), 2);
  D[1] = sqrt(D[1]);

  // calculate D3
  D[2] = 0;
  for (i = 0; i < n; i++)
    D[2] += pow(abs(vecx[i] - vecy[i]), 3);
  D[2] = cbrt(D[2]);

  // calculate D_infinity
  D[3] = 0;
  for (i = 0; i < n; i++) {
  if (D[3] < abs(vecx[i] - vecy[i]))
    D[3] = abs(vecx[i] - vecy[i]);
  }

  for (i = 0; i < 4; i++)
    printf("%lf\n", D[i]);
  return 0;
}

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

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

  ll max =0;
  ll min =0;
  ll maxc=0;
  ll minc=0;

 for(ll i=n;i>=n-k+1;i--){
     max += i;
     maxc =i;
 }

 for(ll i=0;i<=k-1;i++){
     min += i;
     minc=i;
 }

 ll ans =0;

 for(ll i=1;i<=n-k+2;i++){
     ans += max - min +1;

     maxc--;
     minc++;


     max+=maxc;
     min+=minc;

 }

 cout << ans % (1000000000 +7) << endl;


}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int A, B;
  std::cin >> A >> B;
  std::cout << (A + B)  % 24 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char a[4],b[4];
    int i,j;

    scanf("%s %s",a,b);
    
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double型変数));printf("%f",(double型変数));"
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

struct unionfind{
	vector<int> par,rk;

	unionfind(const int n){
		par.resize(n);
		rk.resize(n);
		for(int i=0;i<n;++i) par[i]=i;
		fill(rk.begin(),rk.end(),0);
	}

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

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

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

int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	map<int,int> m;
	for(int i=0;i<n;++i){
		int a;
		scanf("%d",&a);
		++m[a];
	}
	vector<int> v;
	for(map<int,int>::iterator it=m.begin();it!=m.end();++it) v.pb(it->sc);
	sort(v.begin(),v.end());
	int ans=0;
	if(v.size()<=k){
		printf("0\n");
		return 0;
	}
	for(int i=0;i<v.size()-k;++i) ans+=v[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10748
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    cin >> str;
    if (str.size() % 2)
    {
        cout << "No\n";
        return 0;
    }
    for (int i = 0; i < str.size(); i += 2)
    {
        if (str.substr(i, 2) != "hi")
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;

int main() {
  ll X, Y;
  scanf("%lld %lld\n", &X, &Y)+1;
  
  int ans = 0;
  
  while (X <= Y) {
    X <<= 1;
    ans++;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int X; cin >> X;
  int d = X / 100;
  int r = X % 100;
  int result = 1;
  REPR(i, 5) {
    int rd = r / i;
    r %= i;
    if (rd <= d) {
      d -= rd;
    } else {
      result = 0;
      break;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		int S = Integer.parseInt(input);
		int hour = 0;
		int minutes = 0;
		int second = 0;

		if (S >= 0 && S <= 86400) {
			if (S >= 60) {
				minutes = S / 60;
				second = S % 60;
			} else {
				second = S;
			}

			if (minutes >= 60) {
				hour = minutes / 60;
				minutes = minutes % 60;
			}
		}
		System.out.println(hour + ":" + minutes + ":" + second);
	}

}



Measured memory_bytes: 26356
import sys
import numpy as np
from numba import njit
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
@njit('(i8[::1],)', cache=True)
def update(A):
    N = len(A)
    B = np.zeros_like(A)
    for i, x in enumerate(A):
        l = max(0, i - x)
        r = min(N - 1, i + x)
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1
    B = np.cumsum(B)
    return B
 
N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)
 
K = min(K, 100)
for _ in range(K):
    A = update(A)
print(' '.join(A.astype(str)))

Measured memory_bytes: 147276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    int k = sqrt(2 * n) + 3;
    vector<int> f(n + 1);
    for (int x = 1; x < k; x++) {
        for (int y = 1; y < k; y++) {
            for (int z = 1; z < k; z++) {
                int w = x * x + y * y + z * z + x * y + y * z + z * x;
                if (w <= n) f[w]++;
            }
        }
    }
    rep(i, n) cout << f[i + 1] << endl;
}

Measured memory_bytes: 3680
#coding:utf-8
import math

data = raw_input()
len_data = len(data)
split_point = []
range_max = 2**(len_data-1)
for i in xrange(range_max):
	split_point.append(format(i,"0"+str(int(math.log(range_max,2)))+"b"))
# for spoint in split_point:
#     for i in xrange(len(spoint)):
#         if spoint[i] == "1":
#             split_end = i+1
#             result.append(data[split_start:split_end])
#             split_start = split_end
#     for i in result:
#         tmp = tmp + int(i)
#     sum = sum + tmp
#     split_start = 0
#     result = []
#     tmp = 0
# print sum
result = 0
bias = 0
for bit_str in split_point:
	origin = data
	for i in xrange(len(bit_str)):
		if bit_str[i] == "1":
			origin = origin[:i+1+bias] + "+" + origin[i+1+bias:]
			bias = bias+1
	result = result + eval(origin)
	bias = 0
print result

Measured memory_bytes: 2692
#include<stdio.h>
int main(void){
	int tan[9],i,sou,kyu;

	while(1){
		scanf("%d",&sou);
		if(!sou)break;
		kyu=0;
		for(i=0;i<9;i++){
			scanf("%d",&tan[i]);
			kyu+=tan[i];
		}
		printf("%d\n",sou-kyu);
	}
	return 0;
}

Measured memory_bytes: 600
n=int(input())
l0=2
l1=1
l2=0
ans=0

if n==1:
  print(1)
  
else:
  for i in range(1,n):
    if i%3==1:
      l2=l0+l1
      ans=l2
  
    elif i%3==2:
      l0=l1+l2
      ans=l0
    
    else:
      l1=l0+l2
      ans=l1
    
  print(ans)

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int r;
	cin >> r;

	cout << r*r*3;

    return 0;
}


Measured memory_bytes: 256
import math
mod = 10**9 + 7
n = int(input())
d = {}
d0 = 0
for _ in range(n):
    a, b = map(int, input().split())
    g = math.gcd(a, b)
    if g == 0:
        d0 += 1
    else:
        a //= g
        b //= g
        if a < 0:
            a = -a
            b = -b
        elif a == 0 and b < 0:
            b = -b
        if (a,b) in d:
            d[(a,b)] += 1
        else:
            d[(a,b)] = 1
ans = 1
for (a,b) in d.keys():
    if d[(a,b)] > 0:
        t = 2**d[(a,b)]
        if b <= 0:
            a = -a
            b = -b
        if (b,-a) in d:
            t += 2**d[(b,-a)] - 1
            d[(b,-a)] = 0
        ans *= t
        ans %= mod
print((ans+d0-1)%mod)

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

int main() {
    long long H;
    cin >> H;

    int cnt = 0;
    while (H / 2) {
        cnt++;
        H /= 2;
    }

    long long res = 0;
    for (long long i = 0; i <= cnt; i++) {
        res += (long long)pow(2, i);
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif
int N, A, B, C;
vector<int> L;

int dfs(int a, int b, int c, int now) {
    int res = MOD;
    if (now == N) {
        if (a != 0 && b != 0 && c!=0) {
            return abs(A - a) + abs(B - b) + abs(C - c);
        }
    } else {
        res = min(res, dfs(a + L[now], b, c, now + 1) + (a == 0 ? 0 : 10));
        res = min(res, dfs(a, b + L[now], c, now + 1) + (b == 0 ? 0 : 10));
        res = min(res, dfs(a, b, c + L[now], now + 1) + (c == 0 ? 0 : 10));
        res = min(res, dfs(a, b, c, now + 1));
    }
    return res;
}

void Main() {
    cin >> N >> A >> B >> C;
    L.resize(N, 0);
    rep(i, N) cin >> L[i];
    int ans = dfs(0, 0, 0, 0);
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int T,k,n,a[100000 + 10],delta[100000 + 10];
int main(){
	cin >> T ;
	for (int t = 0; t < T ; ++t){
		cin >> n >> k ;
		for (int i = 0; i < n ; ++i )cin >> a[i];
		if(n>k){
			for (int l = 0 ; l + 1 < n  ; ++l ) delta[l] = a[l+1] - a[l];
			sort(delta,delta+n-1);
			int length = a[n-1] - a[0];
			for(int m = 0 ; m + 1 < k ; ++m)length = length - delta[n-m-2];
			cout << length << endl;
		}
		else cout << 0 << endl;
	}
return 0;
}

Measured memory_bytes: 1956
#include <iostream>
using namespace std;
class Dice{
public:
    int n1,n2,n3,n4,n5,n6;
      
    void East(){
        int t = n1;
        n1 = n4;
        n4 = n6;
        n6 = n3;
        n3 = t;
    }
    void West(){
        int t = n1;
        n1 = n3;
        n3 = n6;
        n6 = n4;
        n4 = t;
    }
    void South(){
        int t=n1;
        n1 = n5;
        n5 = n6;
        n6 = n2;
        n2 = t;
    }
    void North(){
        int t=n1;
        n1 = n2;
        n2 = n6;
        n6 = n5;
        n5 = t;
    }
    void Rotation(){
        int t=n2;
        n2 = n3;
        n3 = n5;
        n5 = n4;
        n4 = t;
    }
};
  
int main(){
    Dice d[100];
    int n;
      
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>d[i].n1>>d[i].n2>>d[i].n3>>d[i].n4>>d[i].n5>>d[i].n6;
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j==i)continue;
            for(int k=0; k<6; k++){
                if(k==4){
                    d[i].East();
                }
                if(k==5){
                d[i].East();
                d[i].East();
                }
                for(int l=0; l<4; l++){
                    d[i].Rotation();
                    if(d[i].n1==d[j].n1 && d[i].n2==d[j].n2 && d[i].n3==d[j].n3 &&
                       d[i].n4==d[j].n4 && d[i].n5==d[j].n5 && d[i].n6==d[j].n6){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }
              
        }
          
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3116
/*---------------Go Code GO---------------*/

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

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a


int main()
{
    long long i,j,k,l,m,n,o,p,q,tst,csin=0;

    cin>>n;
    vector<long long> vc;
    while(n--)
    {
        cin>>k;
        vc.push_back(k);
    }

    n=vc[0];
    l=0;
    for(auto k:vc)
    {
        if(k<=n)
        {
            l++;
            n=k;
        }
    }
    cout<<l<<endl;




    //main();
    return 0;
}




Measured memory_bytes: 3444
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2050;

int n, k, qn;
int a[MAXN];
int b[MAXN];
int ans = 1000 * 1000 * 1000;

bool ok(int mn, int mx) {
  int can = 0;
  set < pair<int, int> > st;  
  set < int > st2;
  for (int i = 0; i < n; i++) {
    if (a[i] < mn) {
      st.clear();
      st2.clear();
      continue;
    }
    if (sz(st) == k) {
      int idx = *st2.begin();
      st2.erase(st2.begin());
      st.erase({a[idx], idx});
    }
    st.insert({a[i], i});
    st2.insert(i);
    if (sz(st) == k && (*(st.begin())).first <= mx) {
      can++;
      st2.erase((*st.begin()).second);
      st.erase(st.begin());
    }
  }
  // cerr << mn << " " << mx << " " << can << endl;
  return can >= qn;
}

int main() { 

  scanf("%d %d %d", &n, &k, &qn);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }

  sort(b, b + n);
  /* for (int i = 0; i < n; i++) {
    cout << lower_bound(b, b + n, a[i]) - b << endl;
  } */

  int r = 0;
  for (int i = 0; i < n; i++) {
    int mn = b[i];
    if (r < i) {
      r = i;
    }
    while (r < n && !ok(mn, b[r])) {
      r++;
    }
    if (r < n) {
      // cerr << i << " " << l << " " << b[l] - mn << " " << mn << " " << b[l] << endl;
      ans = min(ans, b[r] - mn);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	vector<int>v(3e5);
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		v[a + b]++;
	}
	for (int i = 0; i < 2e5 + 10000; ++i) {
		v[i + 1] += v[i] / 2;
		v[i] %= 2;
	}
	for (int i = 0; i < 2e5 + 10000; ++i) {
		if (v[i]) {
			cout << i << " " << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3888
n,m,c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
ans = 0
for i in 0..n-1 do
  product = 0
  a = gets.split.map(&:to_i)
  for j in 0..m-1 do
    product += a[j] * b[j]
  end
  
  ans += 1 if product + c > 0
end
p ans

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

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

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

    int count = 0;
    for (int i = 0; i < n - 2; i++){
        if (data.at(i) > data.at(i + 1) && data.at(i + 1) >= data.at(i + 2)){
            count++;
        }
        else if (data.at(i + 2) > data.at(i + 1) && data.at(i + 1) >= data.at(i)){
            count++;
        }
    }

    cout << count << endl;
}


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

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// conversion
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

// math
template <class T>
inline T sqr(T x) { return x * x; }

// typedef
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

// constant
const double EPS = 1e-10;
const double PI = acos(-1.0);

// debug
#define dump(x) cerr << #x << " = " << x << endl;
#define debug(x) cerr << #x << " = " << x << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

int main(int argc, char const *argv[])
{
    int N, T;
    int ans = 1001;
    CIN(N), CIN(T);
    VI c(N), t(N);
    REP(i, N)
    {
        CIN(c.at(i)), CIN(t.at(i));
    }

    for (int j = 0; j < N; j++)
    {
        if (t.at(j) <= T)
        {
            ans = min(ans, c.at(j));
        }
    }

    if(ans == 1001) {
        COUT("TLE");
    }
    else
    {
        COUT(ans);
    }

    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 8;
int N;

vector<string> vec;
string tmp;
bool used[MAX_N];

void make(int pos) {
  if(pos == N) {
    vec.push_back(tmp);
    return;
  } else {
    REP(n,N){
      if(!used[n]) {
        used[n] = true;
        tmp += (char)('1' + n);
        make(pos+1);
        tmp.pop_back();
        used[n] = false;
      }
    } 
  }
}

int P[MAX_N], Q[MAX_N];
string pstr, qstr;

signed main()
{
  cin >> N;
  make(0);
  sort(begin(vec), end(vec));

  REP(n,N) {
    cin >> P[n];
    pstr += (char)('0' + P[n]);
  }

  REP(n,N) {
    cin >> Q[n];
    qstr += (char)('0' + Q[n]);
  }

  int p = -1, q = -1;
  REP(n,vec.size()) {
    if(pstr == vec[n]) p = n;
    if(qstr == vec[n]) q = n;
  } 

  cout << abs(p-q) << endl;

  return 0;
}


Measured memory_bytes: 2424
local N = io.read("*n")
io.read("*l")
local S = io.read("*l")

local S_bytes = {S:byte(1, N)}
local R_count, G_count, B_count = 0LL, 0LL, 0LL
local R, G, B = string.byte("RGB", 1, 3)

for i = 1, N do
    if S_bytes[i] == R then
        R_count = R_count + 1
    elseif S_bytes[i] == G then
        G_count = G_count + 1
    else
        B_count = B_count + 1
    end
end

local minus_count = 0LL
for i = 1, math.modf(N/2) do
    for j = 1, N - i * 2 do
        if S_bytes[j] ~= S_bytes[j + i]
        and S_bytes[j + i] ~= S_bytes[j + 2 * i]
        and S_bytes[j] ~= S_bytes[j + 2 * i] then
            minus_count = minus_count + 1
        end
    end
end

print(tostring(R_count * G_count * B_count - minus_count):sub(1, -3))

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

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

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}


void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

string str ;

int main(){

   cin >> str ;
   int n = sz( str ) ;
   forn( int , i , 0 , n - 1 ){
      if( str[ i ] == str[ i + 1 ] ){
         cout << "Bad\n" ;
         return 0 ;
      }
   }

   cout << "Good\n" ;

   return 0 ;
}


Measured memory_bytes: 256
n = int(input())
#n, m = map(int, input().split())
#xl = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
a=1
ans=len(str(n))
while a**2<=n:
    if n%a==0:
        b=n//a
        ans=min(ans, max(len(str(a)),len(str(b))))
    a+=1
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}




int main() {
	int n;
	int t0=0, y0 = 0, x0 = 0; 
	int t, x, y;
	cin >> n;
	string ans = "Yes";
	REP(i, 0, n){
		cin >> t >> x >> y;
		int d = (abs(x-x0)+abs(y-y0));
		int t1 = t-t0;
		if(t1%2 != d%2 || d > t1){
			ans = "No";
			break;
		}
		t0 = t;
		x0 = x;
		y0 = y;
	} 
	cout << ans;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
        int a,b;
        cin >> a >> b;
        if (a == b)
                for (int i = 1; i <= a; i++)
                        cout << a;
        else if (a < b)
                for (int i = 1; i <= b; i++)
                        cout << a;
        else
                for (int i = 1; i <=a; i++)
                        cout << b;
        cout << endl;
        return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input())-1 for i in range(N)]
used = [False] * N
a = 0
ans = 0
f = False

while True:
    if used[a]: 
        f = True
        break
    if a == 1: break
    used[a] = True
    ans += 1

    a = A[a]

if f: ans = -1
print(ans)

Measured memory_bytes: 7852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NC = ReadInts();
            var p = ReadInts();
            var cake_sum = p.Sum();
            var ans = cake_sum / (NC[0] + 1);
            if (cake_sum % (NC[0] + 1) != 0)
            {
                ans++;
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 18260
function Main(input){
	input = input.split(' ');
  	const [a,b,n] = input;
  	
  	const x = Math.min(b-1, n);
  
	const ans = Math.floor(a*x/b) - a * Math.floor(x/b);
  	console.log(ans);
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());

	if (n == 1)
	{
	    WriteLine("Hello World");
	}
	else
	{
	    int a = int.Parse(ReadLine());
	    int b = int.Parse(ReadLine());
	    WriteLine(a+b);
	}
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
    string s;
    cin >> s;
	if(s == "ARC") puts("ABC");
  else puts("ARC");
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3612
N, M = map(int, input().split())

AC = [0] * N 
WA = [0] * N

for m in range(M):
  p, S = input().split()
  p = int(p)
  
  if S == 'AC' and AC[p-1] == 0:
    AC[p-1] = 1
  elif S == 'WA' and AC[p-1] == 0:
    WA[p-1] += 1

penalty = 0
for i in range(N):
  if AC[i] == 1:
    penalty += WA[i]
    
print(sum(AC), penalty)

Measured memory_bytes: 4596
#include<stdio.h>
int main()
{
    int N,M;
    scanf("%d %d",&N,&M);
    if(N==M){
    printf("Yes\n");}
    else if(N>M){
    printf("No\n");}
    else if(N<M){
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.*;


public class Main {
    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str=br.readLine();
        
        int suuti=Integer.parseInt(str);
	
	int zkn = suuti / 3600;
	int hun = (suuti % 3600 ) / 60;
	int byo = suuti % 60;
       
        System.out.println(zkn+ ":" +hun+ ":" +byo);
    }
}

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


int main(){
  int n,a[101],minj,tmp,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n-1;i++){
    minj=i;
    for(int j=i;j<n;j++)if(a[j]<a[minj])minj=j;
    	tmp=a[i];
	a[i]=a[minj];
	a[minj]=tmp;
	if(i!=minj)cnt++;
  }
  for(int i=0;i<n-1;i++)cout<<a[i]<<" ";
  cout<<a[n-1]<<endl<<cnt<<endl;
  
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int main() {
  Bint A,B;
  cin >> A >> B;
  if(A>B){
    cout << "GREATER";
  }
  if(A<B){
    cout << "LESS";
  }
  if(A==B){
    cout << "EQUAL";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3648
// by team3
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <complex>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;
const int Maxn=105;
const int dx[4]={0,-1,1,0};
const int dy[4]={-1,0,0,1};

int N,Cntx,Cnty;
int X[Maxn],Y[Maxn],Idx[Maxn],Idy[Maxn];
long long Map[Maxn][Maxn];
bool f[Maxn][Maxn];

int Cmpx(const int &i,const int &j)
{
    return X[i]<X[j];
}

int Cmpy(const int &i,const int &j)
{
    return Y[i]<Y[j];
}

void dfs(int x,int y)
{
    f[x][y]=1;
    for(int i=0;i<4;++i)
    {
        int nx=x+dx[i],ny=y+dy[i];
        if(nx<0||nx>Cntx) continue;
        if(ny<0||ny>Cnty) continue;
        if(Map[x][y]!=Map[nx][ny]) continue;
        if(!f[nx][ny]) dfs(nx,ny);
    }
}

int main()
{
    while(scanf("%d",&N)!=EOF&&N!=0)
    {
        for(int i=0;i<N;++i) scanf("%d%d%d%d",&X[i],&Y[i+N],&X[i+N],&Y[i]);
        for(int i=0;i<2*N;++i) Idx[i]=Idy[i]=i;
        sort(Idx,Idx+2*N,Cmpx);
        Cntx=0,Cnty=0;
        int last;
        for(int i=0;i<2*N;++i)
        {
            if(i==0) ++Cntx,last=X[Idx[0]];
            else if(X[Idx[i]]!=last) ++Cntx,last=X[Idx[i]];
            X[Idx[i]]=Cntx;
        }
        sort(Idy,Idy+2*N,Cmpy);
        for(int i=0;i<2*N;++i)
        {
            if(i==0) ++Cnty,last=Y[Idy[0]];
            else if(Y[Idy[i]]!=last) ++Cnty,last=Y[Idy[i]];
            Y[Idy[i]]=Cnty;
        }
        for(int i=0;i<=Cntx;++i)
            for(int j=0;j<=Cnty;++j)
                Map[i][j]=0;
        // rep(i,N) cout << X[i] << " " << X[N+i] << " ";
        // cout << endl;
        // rep(i,N) cout << Y[i] << " " << Y[N+i] << " ";
        // cout << endl;
        for(int i=0;i<N;++i)
            for(int j=X[i];j<X[i+N];++j)
                    for(int k=Y[i];k<Y[i+N];++k)
                        Map[j][k]|=(1ll<<i);
        // For(i,0,Cntx) {
        //     For(j,0,Cnty) cout << Map[i][j] << " ";
        //     cout << endl;
        // }
        for(int i=0;i<=Cntx;++i)
            for(int j=0;j<=Cnty;++j)
                    f[i][j]=0;
        int Ans=0;
        for(int i=0;i<=Cntx;++i)
            for(int j=0;j<=Cnty;++j)
                if(!f[i][j])
                {
                    dfs(i,j);
                    ++Ans;
                }
        printf("%d\n",Ans);
    }
    return 0;
}

Measured memory_bytes: 1932
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, s):
    return len(s.split('ABC')) - 1


if __name__ == "__main__":

    N = int(input())
    s = input()
    ans = solv(N, s)

    print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main{
  static long[] memo;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    memo = new long[N+1];
    memo[0] = 2;
    memo[1] = 1;
    System.out.println(func(N));
  }
  public static long func(int N){
    if(memo[N] > 0){
      return memo[N];
    }
    
    return memo[N] = func(N-1) + func(N-2);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,m;
inline int read()
{
    int s=0,w=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(ch<='9'&&ch>='0')s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
    return s*w;
}
int main()
{
    n=read();m=read();
    printf("%d\n",max(0,n-2*m));
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
# = int(input())
# = input()
p = list(map(int, input().split()))

exp = []
for i in range(n):
	exp.append((p[i]+1)/2)

fir = 0
nex = k
num = sum(exp[:nex])
ma = 0
while nex <= n:
	if ma < num:
		ma = num
	if nex < n:
		num -= exp[fir]
		num += exp[nex]
		fir += 1
		nex += 1
	else:
		break
print(ma)

Measured memory_bytes: 24548
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int a,b,c;
  string ans;
  cin>>a>>b>>c;

  (a+b)<c ? ans="No" : ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    if(a == b){
        cout << a+b << endl; 
    }else if(a < b){
        cout << b+b-1 << endl;
    }else{
        cout << a+a-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
MIN = 10 ** 10
for i in range(N-K+1):
    if x[i+K-1] <= 0:
        MIN = min(MIN, -1 * x[i])
    elif 0 <= x[i]:
        MIN = min(MIN, x[i+K-1])
    else:
        MIN = min(MIN, -1 * x[i] + x[i+K-1] + min(-1 * x[i], x[i+K-1]))
print(MIN)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll a,b;
  cin>>a>>b;
  ll ans=0,ans2=0,sum=0;
  for(ll i=0;i<b;i++)
  ans=ans*10+a;
  for(ll i=0;i<a;i++)
  {
    ans2=ans2*10+b;
  }
  cout<<max(ans,ans2);
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N,0);
  for(int i=1;i<N;i++){
    int A;
    cin >> A;
    a.at(A-1)++;
  }
  for(int i=0;i<N;i++){
    cout << a.at(i) << endl;
  }
}


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

int main() {
    int N, M, X, tmp=0, ans;   
    cin >> N >>M>>X;
    vector<int> A(M);
    
    for(int i=0; i<M ; i++){
	cin >> A[i];
	if(X>A[i])
	    tmp++;
    }

    ans = min(tmp, M-tmp);
    cout << ans<< endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace FunProCon
{
    class FunProConSummer
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = s[0];
            int b = s[1];
            WriteLine(
                Max(a + b, Max(a - b, a * b))
                );
        }

    }
}


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

int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << setprecision(10);
	cout << h / 2.0 * w << " " << ((x == w / 2.0 && y == h / 2.0) ? 1 : 0) << endl;

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func toInt(value string) int {
	num, _ := strconv.Atoi(value)
	return num
}

func splitWithInt(value string) []int {
	vals := strings.Split(value, " ")
	nums := make([]int, len(vals))
	for index, elem := range vals {
		nums[index] = toInt(elem)
	}
	return nums
}

func main() {
	x := toInt(gets())
	fmt.Println(x * x * x)
}



Measured memory_bytes: 1116
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[100001], tmp[100001];
	int i, j, pos, slen, len;
	int flag;
	char str[4][10] = {"dream", "dreamer", "erase", "eraser"};
	
	scanf("%s", s);
	
	// str[i]の文字を反転
	for (i = 0; i < 4; i++) {
		len = strlen(str[i]); // str[i]の文字数を取得
		for (j = 0; j < len; j++) tmp[j] = str[i][len - 1 - j];
		tmp[len] = '\0';
		strcpy(str[i], tmp);
	}
	
	slen = strlen(s); // sの文字数を取得
	for (i = 0; i < slen; i++) tmp[i] = s[slen - 1 - i];
	strcpy(s, tmp);
	
	pos = 0;
	while (1) {
		flag = 1;
		
		for (i = 0; i < 4; i++) {
			len = strlen(str[i]);
			if (slen - pos < len) continue; // 配列のオーバーアクセスを防ぐ
			
			// str[i]のどれかと一致すれば
			if (strncmp(&s[pos], str[i], len) == 0) {
				pos += len;
				flag = 0;
			}
		}
		
		if (flag) break;
	}
	
	if (pos == slen) puts("YES");
	else puts("NO");
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)


double calc(int x1,int y1,int x2,int y2)
{
    int a = (abs(x1 - x2)*abs(x1 - x2));
    int b = (abs(y1 - y2)*abs(y1 - y2));
    return pow((a + b),0.5);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int,pair<int,int>> mp;
    
    vi perm(n);
    ffor(i,n)
    {
        cin >> mp[i].ff >> mp[i].ss;
        perm[i] = i;
    }
    double num;
    do
    {
        for(int i = 0;i < n - 1; ++i)
        {
            num += calc(mp[perm[i]].ff,mp[perm[i]].ss,mp[perm[i + 1]].ff,mp[perm[i + 1]].ss);
        }
    } while (next_permutation(all(perm)));
    
    int den = n;
    while(n != 1)
    {
        --n;
        den *= n;
    }
    cout << fixed << setprecision(12) << (num/(den*1.0));
}

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

int main() {
  int N,K,num;
  cin >> N;
  cin >> K;
  num = 1;
  
  rep(i,N){
  
  if (num < K)
    num *= 2;
  else
    num += K;
  }
  cout << num << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

void solve(){
	int n,d;
	cin>>n>>d;
	long double a[n][d];
	rep(i,0,n){
		rep(j,0,d){
			cin>>a[i][j];
		}
	}
	int cnt=0;
	long double sum=0;
	rep(i,0,n){
		rep(j,i+1,n){
			sum=0;
			rep(k,0,d){
				int p=a[i][k]-a[j][k];
				sum=sum+pow(abs(p),2);
			//	cout<<sum<<" "<<pow(abs(p),2);
			}
		//	cout<<endl;
		//	cout<<int(sqrt(sum))<<" "<<sqrt(sum)<<endl;
			if(int(sqrt(sum))==sqrt(sum))cnt++;	
		}
	}
	cout<<cnt<<endl;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


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

using namespace std;


int main()
{
	int n;
	cin >> n;
	int a[n]; 
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a, a+n, greater<int>());
	int c = 0;
	for (int i = 0; i < n; ++i)
	{
		if (i%2)
			c -= a[i];
		else 
			c += a[i];
	}
	cout << c << endl;
}



Measured memory_bytes: 3608
n,m=map(int,input().split())
a=[i for i in range(n+1)]
b=[0]*(n+1)
def f(x):
    if a[x]==x:
        return x
    x=a[x]
    return(f(x))
def s(x,y):
    x=f(x)
    y=f(y)
    if x!=y:
        if b[x]<b[y]:
            a[x]=y
            b[y]+=1
        else:
            a[y]=x
            b[x]+=1
for i in range(m):
    c,d=map(int,input().split())
    s(c,d)
for i in range(1,n+1):
    a[i]=f(i)
d=a.count(a[2])
s=a.count(a[1])
print(max(((n-d)*(n-d-1)//2)-m+(d*(d-1)//2),((n-s)*(n-s-1)//2)-m+(s*(s-1)//2)))

Measured memory_bytes: 85152
#include <iostream>
#include<bits/stdc++.h>
#define  ll long long
 using namespace std;
priority_queue<double,vector<double>,greater<double> >q;
int main()
{
   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       double x;
       cin>>x;
       q.push(x);
   }
    while(q.size()>1)
    {
        double x,y;
        x=q.top();q.pop();
        y=q.top();q.pop();
        q.push((x+y)/2);
    }printf("%.6f\n",q.top());
return 0;
}


Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#include <unordered_map>
#include <math.h>
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 2e5 + 1;
const long long MNN = 1e6 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

#define PI 3.14159265358979323846

void istxt(bool yes){
    freopen("/Users/mac/Desktop/input.txt", "r", stdin);
    freopen("/Users/mac/Desktop/output.txt", "w", stdout);
}

int main () {
//    ios;
//    istxt(0);
//
//    int t;
    
//    cin >> t;
    
    int n;
    
    cin >> n;
    
    string s = to_string(n);
    
    if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) {
        cout << "pon" << endl;
    } else if (n%10 == 3) {
        cout << "bon" << endl;
    } else {
        cout << "hon" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> mypair;




int main(){
int v,e;
cin>>v>>e;
vector<vector<mypair> >  g(v);
for(int i=0;i<e;i++){
int s,t,d;
cin>>s>>t>>d;
g[s].push_back(mypair(t,d));
}
/*for(int i=0;i<v;i++){
	for(int j=0;j<g[i].size();j++){
	cout<<g[i][j].first<<' ';
	}
	cout<<endl;
}*/
vector<vector<int> > dp((1<<v),vector<int> (v,(int)1e8));
dp[0][0]=0;
for(int i=0;i<(1<<v);i++){
	for(int j=0;j<v;j++){
	//	if(!((1<<j)&i)){
		if(dp[i][j]!=(int)1e8){	

			for(int k=0;k<g[j].size();k++){
				if(!(i&(1<<g[j][k].first))){
					int tmp=i|(1<<g[j][k].first);
					dp[tmp][g[j][k].first] = min(dp[tmp][g[j][k].first],dp[i][j]+g[j][k].second);
				}
			}
		}

	//	}
	}
}
int ans = dp[(1<<v)-1][0];
cout<< (ans==1e8 ? -1:ans)<<endl;
return 0;

}



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

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

    int ans = 0;
    int A, B;

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

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)

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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i <= N-3;i++){
        if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        string s, t;
        cin >> s;
        if(s == ".") break;
        cin >> t;
        int i = 0, j = 0, cnt = 0;
        while(i < s.size() && j < t.size()){
            if(s[i] != t[j]){
                cnt = 114514;
                break;
            }
            if(s[i] == '"'){
                ++i;
                ++j;
                while(i < s.size() && j < t.size()){
                    if(s[i] != t[j]){
                        ++cnt;
                        while(s[i] != '"'){++i;}
                        while(t[j] != '"'){++j;}
                        break;
                    }
                    if(s[i] == '"') break;
                    ++i;
                    ++j;
                }
            }
            ++i;
            ++j;
        }
        if(i != s.size() || j != t.size()) cnt = 114514;
        cout << (cnt == 0 ? "IDENTICAL" : cnt == 1 ? "CLOSE": "DIFFERENT") << "\n";
    }
    return 0;
}


Measured memory_bytes: 3228
def solve():
  N, C, K = map(int, input().split())
  T = [int(input()) for _ in range(N)]
  T.sort()
  cnt = 0
  ans = 1
  for i in range(N-1):
    if i==0:
      t = T[0]
    cnt += 1
    if T[i+1]>t+K or cnt>=C:
      ans += 1
      cnt = 0
      t = T[i+1]
  return ans
print(solve())

Measured memory_bytes: 13180