akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int a,b,c,k;
    cin >> a >> b >> c >>k;
    ll ans = min(a,k);
    k-=a;
    if(k>0){
    k-=b;
    if(k>0){
        ans+=min(c,k)*-1;
    }
    }
    cout<< ans << endl;
}
    



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;
  cout<<A*B<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SIZE 200005
#define INF 100000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

ll burger[51];
ll pati[51];


void init(){
    burger[0]=1;
    pati[0]=1;
    for(int i = 1;i <= 50;i++){
        burger[i] = burger[i-1]*2+3;
        pati[i] = pati[i-1]*2+1;
    }
}

ll dfs(ll level,ll X){//patiの数
    if(X==burger[level])
        return pati[level];
    if(X<0||X>burger[level]){
        return 0;
    }
    ll ret = 0;
    if(X>=1){
        X--;
    }else{return 0;}
    if(X>=burger[level-1]){
        X-=burger[level-1];
        ret += pati[level-1];
    }else{
        ret += dfs(level-1,X);
        return ret;
    }
    if(X>=1){
        X--;
        ret++;
    }else{
        return ret;
    }
    if(X>=burger[level-1]){
        X-=burger[level-1];
        ret += pati[level-1];
    }else{
        ret += dfs(level-1,X);
        return ret;
    }
    return ret;
}


int main(){
    ll N,X;
    cin>>N>>X;
    init();
    cout<<dfs(N,X)<<endl;
}


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

int main() {
	
	int n, m, tmp;
	ll sum = 0;
	cin >> n >> m;
	priority_queue<int> a;
	rep(i, n){
		cin >> tmp;
		a.push(tmp);
	}
	
	rep(i, m){
		tmp = a.top();
		a.pop();
		a.push(tmp/2);
	}
	
	while(!a.empty()){
		sum += a.top();
		a.pop();
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    long l;
    cin >> l;
    long r;
    for (r=1;r<=19;++r) {
        if (l < pow(2,r)) {
            break;
        }
    }
    --r;
    vector<vector<long>> ans;
    for (long i=1;i<=r;++i) {
        ans.push_back({i,i+1,0});
        ans.push_back({i,i+1,static_cast<long>(pow(2,i-1))});
    }
    for (long i=r;i>=1;--i) {
        if (l - pow(2,i-1) >= pow(2,r)) {
            ans.push_back({i,r+1,l-static_cast<long>(pow(2,i-1))});
            l -= pow(2,i-1);
        }
    }
    cout << r+1 << ' ' << ans.size() << "\n";
    for (auto each_ans : ans) {
        cout << each_ans[0] << ' ' << each_ans[1] << ' ' << each_ans[2] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (i=a;i<n;i++)
#define per(i,a,n) for (i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE 1000001
#define ONLINE_JUDGE
#define rd
#define PI acos(-1)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
auto clk=clock(); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;

int main(){
	cout<<fixed<<setprecision(2);
	int r;
	cin>>r;
	cout<<2*PI*r;
	return 0;
}

Measured memory_bytes: 3764
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
  string s;cin>>s;
  vvll dp(s.size()+1,vll(13,0));
  dp[0][0]=1;
  rep(i,0,s.size()){
    rep(k,0,10){
      if(s[i]!='?'&&s[i]-'0'!=k)continue;
      rep(j,0,13){
        dp[i+1][(j*10+k)%13]+=dp[i][j];
        dp[i+1][(j*10+k)%13]%=MOD;
      }
    }
  }
  cout<<dp[s.size()][5]<<endl;
}




Measured memory_bytes: 13696
#include<cstdio>
#include<cstring>
using namespace std;
typedef long int ll;

char S[222222];
int memo1[222222];

int main(){
	scanf("%s", S);
	ll res = 0LL;
	for(int i = 0; i < strlen(S); i++){
		if(S[i] == 'B') memo1[i + 1] = memo1[i] + 1;
		if(S[i] == 'W'){
			res += memo1[i];
			memo1[i + 1] = memo1[i];
		}
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 1152
def solve(an,n):
  ret = 0
  nxt = 1
  while ret <= n+1:
    nxt = an[nxt-1]
    ret += 1
    if nxt == 2:
      return ret
  return -1


if __name__ == "__main__":
  n = int(input())
  An = [0 for i in range(n)]
  for i in range(n):
    An[i] = int(input())
  print(solve(An,n))


Measured memory_bytes: 7080
function main()
  
  (N,A,B) = map(x -> parse(Int,x), split(readline()))
  
  if N % (A+B) > A
    println(div(N,A+B)*A+A)
  else
    println(div(N,A+B)*A+(N % (A+B)))
  end
  
end

main()

Measured memory_bytes: 110476
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
int D, G;
int p[maxn], c[maxn];
 
 
int solve(int mask) {
    int score = 0;
    int solved = 0;
    for (int i=0; i<D; i++) {
	if (mask>>i&1) {
	    solved += p[i];
	    score += (i+1)*100*p[i];
	    score += c[i];
	}
    }
 
    for (int i=D-1; i>=0 && score<G; i--) {
	if (mask>>i&1) continue;
	for (int j=0; j<p[i] && score<G; j++) {
	    solved++;
	    score+=(i+1)*100;
	}
	score+=c[i];
    }
 
    return solved;
}
 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
 
    cin>>D>>G;
    for (int i=0; i<D; i++) {
	cin>>p[i]>>c[i];
    }
 
 
    int res = 1e9;
    for (int mask=0; mask<(1<<D); mask++) {
	res = min(res, solve(mask));
    }
 
 
    cout<<res<<endl;
    return 0 ;
}

 


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n,k;
        cin>>n>>k;
        int val=(n+1)/2;
        if(k<=val) cout<<"YES\n"; else cout<<"NO\n";
        return 0;
}
/**

**/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using pii = pair<pi,pi>;
int main()
{
  int n; cin >> n;
  vector<pii> p;
  while(n-- > 0) {
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(a == c) {
      if(b > d) swap(b, d);
      p.push_back({{a, 1}, {b, d}});
    }
    else {
      if(a > c) swap(a, c);
      p.push_back({{a, 0},{b, 0}});
      p.push_back({{c, 2},{b, 0}});      
    }
  }

  sort(p.begin(), p.end());
  multiset<int> st;
  int res = 0;
  rep(i,(int)p.size()) {
    pii q = p[i];
    if(q.F.S == 0) st.insert(q.S.F);
    else if(q.F.S == 1) {
      auto it = st.lower_bound(q.S.F);
      int cnt = 0;
      while(it != st.end() && *it <= q.S.S) {
	it++;
	cnt++;
      }
      res += cnt;
    }
    else if(q.F.S == 2) {
      auto it = st.find(q.S.F); 
      st.erase(it);
    }
  }
  cout << res << "\n";
  return 0;
}



Measured memory_bytes: 8644
#include <iostream>
#include <cstdlib>
#define ll long long
#define ar array
using namespace std;
const int W = 1e5;
int weight[105];
int value[105];
ll dp[105][W+5];

int main(){
    ios_base::sync_with_stdio(0);
    int n, w;
    cin>>n>>w;
    for(int i=1; i<=n; i++)
        cin>>weight[i]>>value[i];

    for(int i=1; i<=n; i++){
        for(int j=1; j<=w; j++){
            if(weight[i]>j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i]]+value[i]);
        }
    }

    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 81284
import sys
input = sys.stdin.readline

N, M = map(int,input().split())

yakusu = []

for i in range(1,int(M**0.5)+1):
    if M%i==0:
        yakusu.append(i)
        if M//i!=i:
            yakusu.append(M//i)
    
yakusu.sort()
for i in yakusu:
    if i>=N:
        print(M//i)
        break




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

int main()
{
	int n, s, as = 0;
	cin >> n;
	while (n != 0)
	{
		s = n % 10;
		if (s == 2) as++;
		n /= 10;
	}
	cout << as << endl;
	return 0;
}


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

int main() {
    string a; cin>>a;
    bool found=0;
    for(int i=0;i<a.size();i++) if(a[i]=='7') {found=1; break;} 
    if(found) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3596
# include <iostream>
# include <algorithm>
# include <vector>
# include <functional>
# include <string>
using namespace std;

int main() {
	int N, K, memo, max=0;
	vector<int> l;

	cin >> N >> K;
	for (int i = 0;i<N; ++i) {
		cin >> memo;
		l.push_back(memo);
	}

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

	for (int i = 0;i<K; ++i) {
		max += l[l.size() - 1 - i];
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
	 int x, i, j,t;
	 x = A[r];
	 i = p - 1;
	 for(j=p; j<r; j++){
	 	if(A[j] <= x){
	 		i++;
	 		t = A[i];
	 		A[i] = A[j]; 
	 		A[j] = t;
	 	}
	 }
	 t = A[i + 1]; 
	 A[i + 1] = A[r];
	 A[r]= t;
	 return i + 1;
}

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



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int cnt;
string s;
stack<int> stk;
int main(){
	cin >> s;
	for(int i=0;s[i];i++){
		if(s[i]=='S'){
			stk.push('S');
		}else{
			if(stk.size()==0){
				++cnt;
			}else{
				stk.pop();
			}
		}
	}
	printf("%d",cnt+stk.size());
}

Measured memory_bytes: 900
using System;
class aoj
{
    static void Main()
    {
        int z = 65;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            string[] b = a.Split(',');
            int[] c = new int[2];
            for (int i = 0; i < 2; i++)
            {
                char[] h = new char[10];
                h = b[i].ToCharArray();
                c[i] = (int)h[0];
            }
            int d = 1;
            for (int i = 0; i < 2; i++)
            { 
                if (c[i] == z)
                {
                    z = c[d];
                    break;
                }
                d--;
            }
        }
        char g = (char)z;
        Console.WriteLine(g);
    }
}

Measured memory_bytes: 8776
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
        int num[],c,i,n,w;
        w = sc.nextInt();
        n = sc.nextInt();

        num = new int[30];

        for(i=0;i<w;i++) num[i] = i + 1;

        for (i=0;i<n;i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            c = num[a];
            num[a] = num[b];
            num[b] = c;
	}

        for(i=0;i<w;i++) System.out.printf("%d\n",num[i]);

    }
}

Measured memory_bytes: 17228
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> X(N, 0);
    rep(i, N) cin >> X[i];
    int m = INT_MAX;
    rep(i, 1, 100) {
        int cost = 0;
        rep(j, N) { cost += (i - X[j]) * (i - X[j]); }
        chmin(m, cost);
    }
    cout << m << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define second sec
#define first fir
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	string s;
	cin >> s;
	rep(i, s.size()) cout << "x";
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

long long int fact(long long int k) {
	long long int sum = 1;
	for (long long int i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long int pow_mod(int a, int b) {
	long long int  ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}


int main()
{
	long long int n, num, cnt = 0;

	cin >> n;
	
	vector<long long int> a(n);

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

	num = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == num)
			num++;
		else
			cnt++;
	}

	if(num == 1)
		cout << -1 << endl;
	else
		cout << cnt << endl;




	return 0;
}

Measured memory_bytes: 1792
/*
aoj 0514
2016/06/08 21:39
*/

#include<stdio.h>

struct DATA{
	int a,b,c;
}data[1000];

int main(){
	int i,j,n,num,ans,a,b,c,s;
	int t[301]={0};

	while(scanf("%d%d%d",&a,&b,&c),a+b+c){
		s = a+b+c;
		scanf("%d",&n);
		for(i=0;i<301;i++)t[i]=2;
		for(i = j = 0;i < n;i++){
			scanf("%d%d%d%d",&a,&b,&c,&num);
			if(num){
				t[a] = t[b] = t[c] = 1;
			}else{
				data[j].a = a;
				data[j].b = b;
				data[j++].c = c;
			}
		}
		for(i = 0;i < j;i++){
			if(t[data[i].a]==1 && t[data[i].b]==1){
				t[data[i].c] = 0;
			}else if(t[data[i].b]==1 && t[data[i].c]==1){
				t[data[i].a] = 0;
			}else if(t[data[i].c]==1 && t[data[i].a]==1){
				t[data[i].b] = 0;
			}else{
				if(t[data[i].a])
					t[data[i].a] = 2 - (t[data[i].a]==1);
				if(t[data[i].b])
					t[data[i].b] = 2 - (t[data[i].b]==1);
				if(t[data[i].c])
					t[data[i].c] = 2 - (t[data[i].c]==1);
			}
		}
		for(i = 1;i <= s;i++){
			printf("%d\n",t[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 612
import numpy

L, R = map(int, input().split())
l, r = L % 2019, R % 2019

if l > r or (R - L) >= 2019:
    print(0)
else:
    print(numpy.min([(i * j) % 2019 for i in range(l, r) for j in range(i + 1, r + 1)]))

Measured memory_bytes: 100468
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int i,j=0;
  string s;
  vector<string> a(3);
  cin>>s;
  rep(i,0,10){
    if(s.at(i)=='/'){
      ++j;
      continue;
    }
    a.at(j)+=s.at(i);
  }
  //cout<<a.at(0)<<' '<<a.at(1)<<' '<<a.at(2);
  if(stoi(a.at(0))<=2019&&stoi(a.at(1))<=04&&stoi(a.at(2))<=30)ou("Heisei");
  else ou("TBD");
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;
#define ll unsigned long long 

int main(){
	map<int,int> table;
	int graph[1011];
	table[0] = 1;
	table[1] = 2;
	graph[1] = 0;
	for(int x=2;x<=1010;++x){
		table[x] = (table[x-1] + table[x-2])%1001;
		graph[x] = 0;
	}
	int v,d;
	while(scanf("%d %d",&v,&d)==2){
		int tot = 0;
		int fibo[v+2];
		fibo[0] = -1;
		for(int x=1;x<=v+1;++x)fibo[x]=table[x];
		sort(fibo,fibo+v+1);
		for(int x=1;x<=v;++x){
			for(int y=x+1;y<=v;++y){
				if(abs(fibo[x]-fibo[y])<d){
					graph[y] = x;
				}
			}
		}
		for(int x=1;x<=v;++x){
			if(graph[x]==0)tot++;
			graph[x] = 0;
		}	
		cout<<tot<<endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<0||b<0) return 0;
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}


void solve(){
	int n , m , k ;
	cin >> n >> m >> k ;
	int ans = 0 ;
	for(int i = n-1-k ; i <= n-1 ; i++){
		int c = choose(n-1,i) ;
		rmult(c,m) ;
		int d = modpow(m-1,i) ;
		radd(ans,mult(c,d)) ;
	}
	cout << ans ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
	init(N) ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 12700
#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];
        a[i]-=1;
    }
    int x=0,ans=0;
    bool y=false;
    for(int i=0;i<N;i++){
        x=a[x];
        ans++;
        if(x==1){
            y=true;
            break;
        }
    }
    if(y)
        cout<<ans<<endl;
    else cout<<-1<<endl;
}


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

int main()
{
  ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
  return 0;
}
                   

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

struct node{
	LL h,p;
}s[5005];
bool cmp(node x,node y){
	return x.h + x.p < y.h + y.p;
}

LL n;
LL dp[5005];

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> s[i].h >> s[i].p;
	sort(s + 1,s + 1 + n,cmp);
	
	memset(dp,INF,sizeof(dp)); dp[0] = 0;
	for(LL i = 1;i <= n;i ++){
		for(LL j = i;j >= 1;j --){
			if(dp[j - 1] <= s[i].h) dp[j] = min(dp[j],dp[j - 1] + s[i].p);
		}
	}
	for(LL i = n;i >= 0;i --){
		if(dp[i] < INF){
			cout << i << endl;
			break;
		}
	}
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Rof(a, b, c) for(int a = b; a >= c; --a)
#define Fv(a, b) for(auto &a : b)
#define int long long
#define ll long long
#define ull unsigned long long
#define db double
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define vt vector<int>
#define vii vector<ii>
#define sz(x) (int)(x.size())
#define I_love_Nguyen_Hai_Binh ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define task "kplank"
#define two(x) (1 << x)
#define bit(x, i) (x >> i & 1ll)
#define onbit(x, i) (x | (1ll << i))
#define offbit(x, i) (x & (~(1ll << i)))

int h, w, a, b;

main() {
    cin >> h >> w >> a >> b;
    swap(a, b);
    For(i, 1, h) {
        For(j, 1, w) {
            if(i <= a && j <= b) cout << '0';
            else if(i > a&& j <= b) cout << '1';
            else if(i <= a && j > b) cout << '1';
            else if(i > a && j > b) cout << '0';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
}


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

int main() {
  long long int N, M, L;
  string S, T;
  cin >> N >> M >> S >> T;
  L = N * M / __gcd(N, M);
  for (long long int i = 0; i < __gcd(N, M); i++) {
    long long int x = N * i / __gcd(N, M), y = M * i / __gcd(N, M);
    if (S.at(x) != T.at(y)) {
      L = -1;
      break;
    }
  }
  cout << L << endl;
}

Measured memory_bytes: 3652
from heapq import heappop, heappush

H, W = map(int, input().split())
c =  [list(map(int, input().split())) for _ in range(10)]

# Dijkstra法で1からの距離を求める
INF = 10**12
q = [(0,1)] # 始点のコストとindex
d = [INF] * 10
d[1] = 0

while len(q) > 0:
    cost, u = heappop(q)
    #print(u,c[u])
    for v in range(10):
        if v == u: continue
        #print(i,v)
        tmp = d[u] + c[v][u]
        #print(v,tmp)
        if tmp < d[v]:
            d[v] = tmp
            heappush(q, (d[v], v))
    #print(d)

A =  [0]*10
for i in range(H):
    tmp = list(map(int, input().split()))
    for j in range(W):
        if tmp[j] >= 0:
            A[tmp[j]] += 1

ans = 0
for i in range(10):
    ans += A[i]*d[i]
print(ans)

Measured memory_bytes: 73524
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
            count += 1

print(count)

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.14159265358979323846264338327950L
int main()
{
	ll a,b,h,m;
	cin>>a>>b>>h>>m;
	
	ld rad=2*pi*((ld)h/12.0+((ld)m/60.0)/12.0-((ld)m/60.0));
	ld res=a*a+b*b-2*a*b*cosl(rad);
	cout<<fixed<<setprecision(20)<<sqrt(res)<<"\n";
	return 0;
}


Measured memory_bytes: 4164
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]

for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag = True
        for k in range(m):
            for l in range(m):
                if b[k][l] != a[k + i][l + j]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3060
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{int p, l, r;};
struct Node T[MAX];
int n;

void preParse(int u){
	if(u == NIL) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u == NIL) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

void postParse(int u){
	if(u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}

int main(){
	
	int i, v, l, r, root;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		T[i].p = NIL;
	}
	
	for(i = 0; i < n; i++){
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if(l != NIL) T[l].p = v;
		if(r != NIL) T[r].p = v;
	}
	
	for(i = 0; i < n; i++) if(T[i].p == NIL) root = i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}



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


//c++ templte for help............................................................................................................................................
typedef long long ll;

//template<typename... T>
//void print1(T... t){
	//((cout<<t<<" "),...);
//}

//template<typename... T>
//void print2(T... t){
		//vector<vector<ll>> ans={t...};
		//for(ll i=0;i<(ll)ans.size();i++){
			//if(i!=0) cout<<"\t\t";
			//else cout<<"\t";
			//for(ll j=0;j<(ll)ans[i].size();j++){
				//cout<<ans[i][j]<<" ";
			//}
			//if(i!=(ll)ans.size()-1)
			//cout<<endl;
		//}
//}	
//#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
//#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 1000000007
//const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}
 
 
 
//c++ template for help...........................................................................................................................................


ll solve(){
	ll x,n;
	cin>>x>>n;
	vector<ll> vec(n);
	map<ll,ll> mp;
	for(int i=0;i<n;i++){
		cin>>vec[i];
		mp[vec[i]]++;
	}
	
	ll ans=INT_MAX;
	ll ans1=0;
	for(ll i=-100000;i<=100000;i++){
		if(mp.find(i)==mp.end() and abs(x-i)<ans){
			ans=abs(x-i);
			ans1=i;
		}
	}
	
	return ans1;
}

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(50);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 

	 
	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	return 0;
}


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

using namespace std;


int a,b,c;

typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<double> vdb;
typedef vector<bool> vbol;
typedef vector<string> vstr;

#define vvll(a,b,c) vector<vector<long long>> c(a,vector<long long>(b,0))
#define vvit(a,b,c) vector<vector<int>> c(a,vector<int>(b,0))
#define vvstr(a,b,c) vector<vector<string>> c(a,vector<string>(b,0))
#define vvbol(a,b,c) vector<vector<bool>> c(a,vector<bool>(b,0))
#define vvdb(a,b,c) vector<vector<double>> c(a,vector<double>(b,0))
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=0;i<=b;i++)
#define f_j(a,b) for(int j=0;j<=b;j++)


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double d,t,s;
    cin >> d >> t>>s;
    if((d/s)<=t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    return(0);
}

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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextInt();
		long array[] = new long [n];
		for(int i = 0; i<n;i++){
			array[i] = sc.nextLong();
		}
		Arrays.sort(array);
		long sum = 0;
		for(int i = 0; i<n-k;i++){
			sum += array[i];
		}
System.out.println(sum);
	}
}

Measured memory_bytes: 67060
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size()
using namespace std;
typedef unsigned long long ll;

int gcd(int x,int y){
	if(x < y) swap(x, y);
	if(y == 0) return x;
	else return gcd(x % y, y);
}
int gcdary(vector<int> &a, int n){
  int ans;
  ans = gcd(a[0], a[1]);
  for(int i = 2; i < n; i++){
    ans = gcd(ans, a[i]);
  }
  return ans;
}

int main(void){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	cout << gcdary(a, n) << endl;

	return 0;
}


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


int main() {
string s;
cin>>s;
vector<long> a(3);
for(int i=0;i<s.size();i++){
  a[(s[i]-'a')]++;
}
//for(int i=0;i<3;i++) cout<<a[i]<<endl;
sort(a.begin(),a.end());
a[2]-=a[0];
a[1]-=a[0];
a[0]=0;
if(a[1]<=1&&a[2]<=1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, X, Y);
  ll ans = 0;
  while (X <= Y) {
    ans++;
    X *= 2;
  }
  print(ans);
}


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

int main(){
	int N;
	cin >> N;
	vector<int> B(N);

	rep(i,N-1){ int t; cin >> t; B[t-1]++; }
	for(int u : B){cout << u << endl; }
}


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

ll A,B,N;

int main(){
	cin>>A>>B>>N;
	cout<<(A*min(B-1,N))/B-A*(min(B-1,N)/B)<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
ll n;
string s;
ll sm[2*100000+5];
ll sn[2*100000+5];

int main(){
	cin >> n >> s;
	if(s[0] == '#') sm[0] = 1;
	
	FOR(i,1,n-1){
		if(s[i] == '#') sm[i] = sm[i-1] + 1;
		else sm[i] = sm[i-1];
	}
	for(int i=n-1;i>=0;--i){
		if(s[i+1] == '.') sn[i] = sn[i+1] + 1;
		else sn[i] = sn[i+1];
	}

	FOR(i,0,n-1) sm[i] += sn[i];
	ll mx = INF;
	FOR(i,0,n-1){
		chmin(mx, sm[i]);
	}
	
	ll sm0 = sn[0] + (s[0] == '.'? 1:0);
	chmin(mx, sm0);
	cout << mx;
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  vector<ll> sum(n), sumr(n);
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    sum[i] = i + (i > 0 ? sum[i-1] : 0);
  }

  for (int i = n - 1; i >= 0; --i) {
    sumr[i] = i + (i < n ? sumr[i+1] : 0);
  }
  reverse(sumr.begin(), sumr.end());
  for (int i = k-1; i < n; ++i) {
    ans += sumr[i] - sum[i] + 1;
    ans %= mod;
  }
  cout << ans << endl;
}

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


int main(){
	int N ;
	cin >> N ;
	double a[1005] , sum = 0 ;
	for( int i = 0 ; i < N ; i++ ){
		cin >> a[i] ;
		sum += (1/a[i]);
	}
	double ans = 1.00/sum ;
	printf("%lf\n",ans);



	return 0 ;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << 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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
ll n;
vector<ll> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n*3; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(ALL(a));
    ll ans=0;
    for(int i=n;i<3*n;i+=2){
        ans+=a[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 6256
a = sorted(list(map(int, input().split())))
a = [a[2] - a[0], a[2] -  a[1], a[2] - a[2]]
if (a[0] - a[1])%2==0:
    print((a[0] - a[1])//2 + a[1])
else:
    print((a[0] - a[1])//2 + a[1] + 2)

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

stack<char> A;
string s;
int sum=0;

int main(){
  cin >> s;
  //Step 1: Take in input, Step 2: Compare with Previous
  //C1: If idential continue else C2: remove and increment by one
  A.push(s[0]);
  
  for (int i=1;i<s.size();i++){
    if (A.empty() || A.top() == s[i]){
      A.push(s[i]);
    }
    else{
      if (A.empty()==false){
        A.pop();
      }
      sum += 1;
    }
  } 
  cout << sum*2; 
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 vector<ll> a(n,0);
 for(ll i=0;i<n-1;i++){
  ll b;
  cin>>b;
  b--;
  a[b]++;
 }
 for(auto i:a)cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 4804
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string S=in<string>(),T=in<string>();
	int N=S.size();
	vector<int> U(26,-1),V(26,-1),SA(N,-1),SB(N,-1);
	int index=0;
	REP(i,N){
		if(U[S[i]-'a']==-1) U[S[i]-'a'] = index++;
		SA[i] = U[S[i]-'a'];
	}
	index=0;
	REP(i,N){
		if(V[T[i]-'a']==-1) V[T[i]-'a'] = index++;
		SB[i] = V[T[i]-'a'];
	}
	
	REP(i,N){
		if(SA[i]!=SB[i]){
			out("No");
			return 0;
		}
	}
	out("Yes");
	return 0;
}


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



// // 二分探索(最小値を出す問題は疑う)
// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < N; ++i){
// 		res += max(0ll, A[i]-x/F[i]);
//     }
//     return res <= K;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }



int main() {
  ll A, B;
  cin >> A >> B;
  int K;
  cin >> K;

  REP(i, K){
    if(i % 2 == 0){
      if(A % 2 != 0) A--;
      A /= 2;
      B += A;
    }else if(i % 2 != 0){
      if(B % 2 != 0) B--;
      B /= 2;
      A += B;      
    }
  }

cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
n, c, k = map(int, input().split(" "))
t = []
 
for i in range(0, n):
    t.append(int(input()))

t = sorted(t)

p = 0 # バスに乗っている人数
f = 0 # 最初にバスに乗った人の時間
b = 0 # バスの台数

for i in t:
    if f == 0:
        f = i
    elif f + k < i or c <= p:
        b += 1
        f = i
        p = 0
    p += 1

b += 1

print(b)


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

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

Measured memory_bytes: 3104
#include <stdio.h>

#define arr_print_d0dn(a, n) for(int i=0;i<(n);++i)printf(i==(n)-1?"%d\n":"%d ",(a)[i])

void insertionSort(int *A, const int N) {
    arr_print_d0dn(A, N);
    for(int i = 1; i < N; ++i) {
        int tmp = A[i];
        int j = i - 1;
        // rotate right to left
        while(j >= 0 && A[j] > tmp) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = tmp;
        arr_print_d0dn(A, N);
    }
}

int main() {
    int N;
    scanf("%d", &N);
    int A[N];
    for(int i = 0; i < N; ++i) {
        scanf("%d", A + i);
    }
    // solve
    insertionSort(A, N);

    return 0;
}



Measured memory_bytes: 2140
#include <iostream>
using namespace std;
long long gcd(long long a, long long b){
  int r = 0;
  while(true){
    /*a = abs(a);
    b = abs(b);*/
    r = a % b;
    a = b;
    b = r;
    if(r == 0){break;}
  }
  return a;
}
long long lcm(long long a, long long b){
  int L = 0;
  int G = gcd(a,b);
  L = a / G * b;
  return L;
}
int main(){
  long long N, Input;
  long long anslcm = 1;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> Input;
    anslcm = lcm(anslcm,Input);
  }
  cout << anslcm << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    int m = atoi(s.substr(5, 2).c_str());
    int d = atoi(s.substr(8, 2).c_str());
    bool before = false;
    if (m < 4) {
        before = true;
    }
    else if (m == 4 && d <= 30) {
        before = true;
    }
    if (before) {
        println("Heisei");
    }
    else {
        println("TBD");
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,m;
vector<int>P[N];
int in[N];
int dfn[N],dfr[N],dftt;
void dfs(int p,int lastt){
	dfn[p]=++dftt;
	for(int i=0;i<P[p].size();i++){
		int y=P[p][i];
		if(y==lastt)continue;
		dfs(y,p);
	}
	dfr[p]=dftt;
}
int A[N];
void solve(){
	scanf("%d %d",&n,&m);
	for(int a,b,i=1;i<n;i++){
		scanf("%d %d",&a,&b);
		P[a].push_back(b);
		P[b].push_back(a);
	}
	dfs(1,0);
	for(int a,b,i=1;i<=m;i++){
		scanf("%d %d",&a,&b);
		A[dfn[a]]+=b,A[dfr[a]+1]-=b;
	}
	for(int i=1;i<=n;i++)
		A[i]+=A[i-1];
	for(int i=1;i<=n;i++){
		printf("%d ",A[dfn[i]]);
	}puts("");
}
int main(){
	solve();
	return 0;
}

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

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

    int n;
    while (cin >> n) {
        cout << n + n * n + n * n * n << '\n';
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	int count = 0;

	for (int i = a; i <= b; i++)
	{
		if (c % i == 0)
		{
			count ++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3108