akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    int h,a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> a(N);rep(i,N)cin >> a[i];
    int ans = 0;
    int tmp = 1;
    rep(i,N){
        if(i == 0)continue;
        if(i == N-1){
            if(a[i] == a[i-1]){
                tmp++;
                ans += (tmp/2);
                break;
            }
            else{
                ans += (tmp/2);
                break;
            }
        }
        if(a[i] == a[i-1])tmp++;
        else{
            ans += (tmp/2);
            tmp = 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	
	int K;
	int odd[100];
	int par[100];
	int oddcount = 0;
	int parcount= 0;
	scanf("%d", &K);
	
	for (int i = 1; i <= K; i++){
		
		if(i % 2 != 0){
			odd[oddcount] = i;
			oddcount++;
		}
		else{
			par[parcount] = i;
			parcount++;
		}
	}
	
	printf("%d", (parcount*oddcount));
	
	
	
	
	
	
	
	return 0;
}

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

using namespace std;

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

  string s;
  cin >> s;

  int p = 0;
  for (char c : s)
    if (c == 'p') ++p;
  cout << s.size() / 2 - p << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
ll N,A,B;
vector<ll> h;
bool C(int x){
    ll cnt=0;
    for(int i=0;i<N;++i){
        ll tmp=h[i]-B*x;
        if(tmp>0) cnt+=(tmp+A-B-1)/(A-B);
    }
    if(cnt<=x) return true;
    else return false;
}
int main(){
    cin>>N>>A>>B;
    h.resize(N);
    for(int i=0;i<N;++i) cin>>h[i];
    int l=0,r=1e9;
    while(r-l>1){
        int m=(l+r)/2;
        if(C(m)) r=m;
        else l=m;
    }
    cout<<r<<endl;
    return 0;
}

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

#define MOD 1000000007

// C function for extended Euclidean Algorithm (used to 
// find modular inverse. 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; // To store results of recursive call 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
  
// Function to find modulo inverse of b. It returns 
// -1 when inverse doesn't 
ll modInverse(ll b, ll m) 
{ 
    ll x, y; // used in extended GCD algorithm 
    ll g = gcdExtended(b, m, &x, &y); 
  
    // Return -1 if b and m are not co-prime 
    if (g != 1) 
        return -1; 
  
    // m is added to handle negative x 
    return (x%m + m) % m; 
} 
  
// Function to compute a/b under modlo m 
ll modDivide(ll a, ll b, ll m) 
{ 
    a = a % m; 
    int inv = modInverse(b, m); 
    if (inv == -1){
    	cout << "masuk" << endl;
       return a; 
    }
    else {
    	// cout << inv << " " << a << " " << m << endl;
       return (inv * a) % m; 
    }
} 
  

int main() {
	int n;
	cin >> n;
	ll data[n + 5];
	ll cnt = 0;
	for(int i = 0; i < n; i++) {
		cin >> data[i];
		cnt += data[i];
		cnt %= MOD;
	}
	
	cnt = (cnt * cnt);
	
	
	ll res = 0;
	for(int i = 0; i < n; i++) {
		res += (data[i] * data[i]);
		res %= MOD;
	}
	
	cout << modDivide((cnt - res) % MOD, 2, MOD) << endl;
	return 0;
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max(a*b,c*d) << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

int n[201][5]={};
int x;

scanf("%d",&x);
for(int i=0;i<x;i++)
scanf("%d %d %d",&n[i][0],&n[i][1],&n[i][2]);

for(int j=0;j<3;j++)
for(int i=0;i<x;i++)
{int c=0;
for(int k=0;k<x;k++){
if(n[i][j]==n[k][j])c++;
}
if(c==1)n[i][3]+=n[i][j];
}
for(int i=0;i<x;i++)
printf("%d\n",n[i][3]);

return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

double dis(int n, int x[], int y[], int p) {
	double absolute = 0;
	for (int i = 0; i < n; i++) {
		absolute += abs(pow((x[i] - y[i]), p));
	}

	return pow(absolute, 1.0 / p);
}

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

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

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

	printf("%.5f\n", dis(n, x, y, 1));
	printf("%.5f\n", dis(n, x, y, 2));
	printf("%.5f\n", dis(n, x, y, 3));

	double p_inf = 0;
	for (int i = 0; i < n; i++) {
		if (p_inf < abs(x[i] - y[i])) {
			p_inf = abs(x[i] - y[i]);
		}
	}

	printf("%.5f\n", p_inf);

	return 0;
}

Measured memory_bytes: 1256
#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;
  cin >> n;
  vector<int> data(n);
  rep(i,n){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  cout << data.at(n/2)-data.at(n/2-1) << endl; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> g(N);
	REP(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	
	vector<int> ans(N), d(N, INF);
	queue<int> que;
	d[0] = 0;
	que.push(0);
	
	while (!que.empty()) {
		int v = que.front(); que.pop();
		
		for (int u : g[v]) {
			if (chmin(d[u], d[v] + 1)) {
				que.push(u);
				ans[u] = v;
			}
		}
	}
	
	puts("Yes");
	FOR(i, 1, N) printf("%d\n", ans[i] + 1);
	return 0;
}


Measured memory_bytes: 10712
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		
		int C = s.lastIndexOf('C');
		int F = s.lastIndexOf('F');
		if (C == -1 || F == -1 || C > F) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	vector<double> v(n);
	vector<double> dp(n + 1, 0);
	vector<double> prevDp(n + 1, 0);
	prevDp[0] = 1;
	rep(i, 0, n)
	{
		cin >> v[i];
	}
	rep(i, 0, n)
	{
		dp[0] = (1 - v[i]) * prevDp[0];
		rep(j, 1, i + 2)
		{
			dp[j] = (1 - v[i]) * prevDp[j] + (v[i]) * prevDp[j - 1];
		}
		prevDp = dp;
	}
	double ans = 0;
	rep(i, (n + 2) / 2, n + 1)
	{
		ans += dp[i];
	}
	cout << setprecision(20) << ans << endl;
	return 0;
}


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

int main(){
    ll N; cin >> N;
    if(N % 2 == 1){
        cout << 0 << endl;
        return 0;
    }
    N /= 2;
    ll ans = 0;
    while(N > 0){
        N /= 5;
        ans += N;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# 入力の取得
S = input()

# 入力内容から次の天気を予測
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
elif S == "Rainy":
    print("Sunny")
else:
    print("入力内容が間違っています。")

Measured memory_bytes: 8884
#pragma warning (disable:4996)
#include"bits/stdc++.h"
#include<cassert>
#define int long long
#define MRE assert(0);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long mod = 1000000007;
const long long inf = 1e17;
typedef pair<int, int> P;
int n; 
int h[105];
int dp1[105][105], dp2[105][105];
int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod;
		x >>= 1;
	}
	return res;
}

void memo(int l, int r) {
	if (dp1[l][r] != -1)return;
	vector<P>V;

	int idx = l, mn = inf;
	for (int i = l; i <= r; i++)mn = min(mn, h[i]);
	int idx2 = l;

	while (1) {
		while (idx2<=r&&h[idx2] == mn)idx2++;
		if (idx2 > r)break;
		int idx3 = idx2;
		while (idx3<=r&&h[idx3] != mn)idx3++;
		V.push_back(P(idx2, idx3-1));
		idx2 = idx3 + 1;
	}

	if (V.size()) {//適切なマージ
		vector<P>V2;
		rep(j, V.size()) {
			memo(V[j].first, V[j].second);
			V2.push_back(P(dp1[V[j].first][V[j].second], dp2[V[j].first][V[j].second]));
		}
		int m = 0;
		for(int i=l;i<=r;i++)if (h[i] == mn)m++;
		int sum = 1, sum2 = 2;
		int H = h[r + 1];
		if (l)H = max(H, h[l - 1]);
		H = mn - H;
		rep(i, V2.size()) {
			sum *= V2[i].first + 2 * V2[i].second;
			sum %= mod;
			sum2 *= V2[i].second;
			sum2 %= mod;
		}
		sum = sum*modpow(2, m) % mod;
		int T = (sum + mod - sum2) % mod;
		sum2 = sum2*modpow(2, H-1) % mod;
		dp1[l][r] = T;
		dp2[l][r] = sum2;
	}
	else {
		int H = h[r + 1];
		if (l)H = max(H, h[l - 1]);
		int t = (modpow(2, r - l + 1) + mod - 2) % mod;
		int u = modpow(2, h[l]-H);
		dp1[l][r] = t;
		dp2[l][r] = u;
	}
}


signed main() {
	cin >> n;
	rep(i, n)cin >> h[i];
	rep(i, n)rep(j, n)dp1[i][j] = dp2[i][j]= -1;
	memo(0, n - 1);
	cout << (dp1[0][n - 1] + dp2[0][n - 1])%mod << endl;
}

Measured memory_bytes: 384
package main

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

func nextFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	r := nextFloat64(sc)

	fmt.Printf("%6f %6f", r*r*math.Pi, 2*r*math.Pi)
}



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

int main(){
    int n;
    cin >> n;
    vector<ll> p(n);
    rep(i,n) cin >> p[i];
    ll min_p=p[0], cnt=1, i;

    for(i=1; i<n ; i++){
        min_p = min(min_p,p[i]);
        if(min_p == p[i]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var x = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        long n = long.Parse(Console.ReadLine());
        for(int p = 0; p < n; p++)
        {
            if(x[0] >= x[1])
            {
                x[1] *= 2;
            }
            else
            {
                x[2] *= 2;
            }
        }
        if(x[0]<x[1] && x[1]<x[2])
        {
            Console.Write("Yes");
        }
        else
        {
            Console.Write("No");
        }
    }
}

Measured memory_bytes: 28168
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;

typedef pair<long long, string> pls;


#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, k, a, b, c, d, e,H, W,Q;
long long A[200000]= {};
long long B[200005] = {};
long long C[20][200] = {};
bool f;
bool ff;
string S[200];
set <long long>sll;
pl buf;
pls bufls;
vector <long long>vl;
vector <pl>vpl;
vector <pls>vpls;
vector <string> vs;

struct ST
{
	long long hajime;
	long long owari;
	long long zahyou;
	int bangou;

	bool operator<(const ST& another) const
	{
		return hajime < another.hajime;//年齢を比較
	};

};



vector <ST> vst;
ST st[200005];

int main() {

	cin >> N>>M;

	a = 0;

	a = (N - 2) * (M - 2);

	if (N == 1) {
		a = M - 2;
	}

	if (M == 1) {
		a = N - 2;
	}

	if (N == 1 && M == 1) {
		a = 1;
	}
	cout << a << endl;

	return 0;

}


Measured memory_bytes: 2304
#include <stdio.h>

int main()
{
    int n,a,bucket[200000] = {0};

    int i;

    scanf("%d",&n);
    for (i = 1; i < n; i++)
    {
        scanf("%d",&a);
        bucket[a - 1]++; 
    }

    for (i = 0; i < n; i++)
    {
       printf("%d\n", bucket[i]);
    }
    
}


Measured memory_bytes: 2512
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
int A[100010];
long long sum[100010];
int suc[100010];

void solve()
{
	int i;
	sort(A, A+N);
	sum[0] = A[0];
	for(i=1; i<N; i++)
		sum[i] = sum[i-1] + A[i];
	suc[N-1] = 1;
	int res = 1;
	for(i=N-2; i>=0; i--){
		if(sum[i]*2 >= A[i+1] && suc[i+1]==1){
			suc[i] = 1;
			res ++;
		}
		else
			suc[i] = 0;
	}
	printf("%d\n", res);
}

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

Measured memory_bytes: 1664
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class edge{
public:
	int t,c;
	edge(){}
	edge(int tt,int cc){
		t=tt;
		c=cc;
	}
};

class data{
public:
	int v,c;
	data(){}
	data(int vv,int cc){
		v=vv;
		c=cc;
	}
	bool operator<(const data &d)const{
		return d.c<c;
	}
};

int n,m,r,q;
vector<edge> G[100001];
int dp[10][100001];

void dijkstra(int rest){
	for(int i=1;i<=n;i++){
		if(i%r!=rest)dp[rest][i]=INF;
		else dp[rest][i]=0;
	}
	priority_queue<data> que;
	for(int i=rest;i<=n;i+=r){
		if(i>0)que.push(data(i,0));
	}
	while(que.size()){
		data q=que.top();
		que.pop();
		for(int i=0;i<G[q.v].size();i++){
			edge e=G[q.v][i];
			if(dp[rest][e.t]>dp[rest][q.v]+e.c){
				dp[rest][e.t]=dp[rest][q.v]+e.c;
				que.push(data(e.t,dp[rest][e.t]));
			}
		}
	}
}

int main(void){
	scanf("%d%d%d%d",&n,&m,&r,&q);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		G[b].push_back(edge(a,c));
	}
	for(int i=0;i<r;i++){
		dijkstra(i);
	}
	ll res=0;
	for(int i=0;i<q;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		int plus=0;
		for(int j=0;j<r;j++){
			plus=max(plus,z-dp[j][x]-dp[j][y]);
		}
		res=(ll)res+plus;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 12608
n = int(input())
w = list(map(int, input().split()))


ans = []
for t in range(1, n):
    s1 = 0
    s2 = 0
    for i in range(len(w)):
        if i < t:
            s1 += w[i]
        else:
            s2 += w[i]
        #print(w[i], w[-(i+1)])
    #print(i)
    ans.append(abs(s1-s2))
    #print(t, s1, s2)
print(min(ans))

Measured memory_bytes: 3060
import java.util.*;

class Main {
  public static void main(String[] args) { 
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int total = 0;
    int res[] = new int[n];
    for(int i =0; i < n; i++) {
      a[i] = sc.nextInt();
      total ^= a[i];
    }
    
    for(int i = 0; i < n; i++) {
      res[i] = a[i]^total;
      System.out.print(res[i]+" ");
    }
    
  }
}


Measured memory_bytes: 64360
#include<bits/stdc++.h>
#define rint register int
#define ll long long 
using namespace std;
struct node{
	int to,next;
}e[1011000];
int fa[1010100],tot,h[1010100],n,k,ans,dep[1011000];
inline void add(int from,int to){e[++tot].next=h[from];h[from]=tot;e[tot].to=to;}
inline void DFS(int now) {
	int Max=-1;
	for(rint i=h[now];i;i=e[i].next){
		int to=e[i].to;DFS(to);
		Max=max(Max,dep[to]);
	}
	dep[now]=Max+1;
	if(now==1) return ;
	if(dep[now]>=k-1&&fa[now]!=1) ans++,dep[now]=-1;
}
int main(){
	cin>>n>>k;
	for(rint i=1;i<=n;++i) cin>>fa[i];
	if(fa[1]!=1) ans++;
	for(rint i=2;i<=n;++i) add(fa[i],i);
	DFS(1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 13412
class Node(object):
  def __init__(self, num, prv = None, next = None):
    self.num = num
    self.prv = prv
    self.next = next

class DoublyLinkedList(object):
  def __init__(self):
    self.start = self.last = None

  def insert(self, num):
    new_element = Node(num)

    if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

  def delete(self, target):
    it = self.start
    while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

  def deleteFirst(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

  def deleteLast(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = None
      self.last = self.last.prv

  def contentToArray(self):
    n_list = []
    it  = self.start
    while it is not None:
      n_list.append(it.num)
      it = it.next
    return ' '.join(n_list)

def main():
  from sys import stdin
  N = int(input())

  linkedList = DoublyLinkedList() # インスタンス作成

  for i in range(N):
    command = stdin.readline().rstrip().split()
    if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

  print(linkedList.contentToArray())

if __name__ == "__main__":
  main()


Measured memory_bytes: 227600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String T = in.next();
            int N = T.length();
            int K = in.nextInt();

            int[][][] dp = new int[N][N][K + 1];

            for (int right = 0; right < N; right++) {
                for (int left = right; left >= 0; left--) {
                    if (left == right) {
                        dp[left][right][0] = 1;
                    } else {
                        for (int k = 0; k <= K; k++) {
                            dp[left][right][k] = Math.max(dp[left + 1][right][k], dp[left][right - 1][k]);
                            if (T.charAt(left) == T.charAt(right)) {
                                dp[left][right][k] = Math.max(dp[left][right][k], 2 + dp[left + 1][right - 1][k]);
                            } else if (k > 0) {
                                dp[left][right][k] = Math.max(dp[left][right][k], 2 + dp[left + 1][right - 1][k - 1]);
                            }
                        }
                    }
                }
            }
            int best = 0;
            for (int k = 0; k <= K; k++) {
                best = Math.max(best, dp[0][N - 1][k]);
            }
            out.println(best);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main (void){
	long long int n,i,m,x,ans=0;
	cin >> n;
	for(i=1;i<=sqrt(n);i++){
		if(n%i==0&&i<n/i-1) ans+=n/i-1;
	}
	cout << ans << endl;
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char t[100][100];
bool visited[100][100];
bool a,b;
int h,w,cnt;
void rec(int y,int x){
  if(t[y][x]=='B')a=true;
  if(t[y][x]=='W')b=true;
  if(t[y][x]!='.')return;
  if(visited[y][x])return;
  visited[y][x]=true;
  cnt++;
  if(y>0)rec(y-1,x);
  if(y+1<h)rec(y+1,x);
  if(x>0)rec(y,x-1);
  if(x+1<w)rec(y,x+1);
}
int main(){
  while(1){
    cin>>w>>h;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>t[i][j],visited[i][j]=false;
    int suma=0,sumb=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(visited[i][j])continue;
	if(t[i][j]!='.')continue;
	a=b=cnt=false;
	rec(i,j);
	if(a&&!b)suma+=cnt;
	else if(!a&&b)sumb+=cnt;
      }
    }
    cout<<suma<<' '<<sumb<<endl;
  }
}

Measured memory_bytes: 1284
from numba import njit
@njit("i8(i8)")

def solve(n):
  l=[1]*(n+1)
  ans=1
  for i in range(2,n+1):
    j=i
    while(j<=n):
      l[j-1]+=1
      j+=i
    ans+=(i*l[i-1])
  return ans

n=int(input())
print(solve(n))



Measured memory_bytes: 187800
def main():
    N = int(input())

    times, start, interval = [], [], []
    for i in range(N-1):
        t, s, i = list(map(int, input().split()))
        times.append(t)
        start.append(s)
        interval.append(i)

    for src_station_idx in range(N-1):
        current_total_time = start[src_station_idx] + times[src_station_idx]

        for via_station_idx in range(src_station_idx+1, N-1):
            moving_time = times[via_station_idx]

            # 次に来る電車までの待ち時間を計測する
            if current_total_time <= start[via_station_idx]:
                waiting_time = start[via_station_idx] - current_total_time
            else:
                passed_time_from_start = current_total_time - start[via_station_idx]
                passed_time_from_before = passed_time_from_start % interval[via_station_idx]

                if passed_time_from_before == 0:
                    waiting_time = 0
                else:
                    waiting_time = interval[via_station_idx] - passed_time_from_before

            current_total_time += waiting_time + moving_time

        print(current_total_time)

    print(0)

main()


Measured memory_bytes: 3188
s = input()
k = int(input())

l = sorted(set(list(s)))
r = []
for first in l[:min(len(l),k)]:
    #print(first)
    for i in range(len(s)):
        if s[i]==first:
            for j in range(1,6):
                r.append(s[i:i+j])
r = sorted(set(r))
print(r[k-1])


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

lint f(lint b, lint n) {
  if (b < 2) return -1;
  lint ret = 0;
  while (n) {
    ret += n % b;
    n /= b;
  }
  return ret;
}

signed main() {
  lint n, s;
  cin >> n >> s;

  lint po = sqrt(n) + 1;

  if (n == s) {
    cout << n + 1 << endl;
    return 0;
  }

  for (lint i = 2; i <= po; ++i) {
    if (f(i, n) == s) {
      cout << i << endl;
      return 0;
    }
  }

  for (lint i = po; i >= 1; --i) {
    lint b = (n - s) / i + 1;
    if (f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}


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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // 526607076 9

    srand(time(NULL));
    // for (int tc = 0; tc < 50; tc++) {
    int n, k, temp = 0;
    vector<int> div;
    cin >> n >> k;
    // n = (ll(rand() + 1) * ll(rand() + 1)) % 1000000000 + 1;
    // k = rand() % 99 + 2;
    // cout << n << " " << k << endl;
    stack<int> s;
    div.clear();

    div.push_back(0);
    for (int i = 1; i * i <= n; i++) {
        if (n / i != temp) {
            div.push_back(i);
            s.push(n / i);
            temp = n / i;
        }
    }
    //debug
    // cout << "d: ";
    // for (int a : d) cout << a << " ";
    // cout << endl;
    // cout << "s.top = " << s.top() << ", d.back = " << d.back() << endl;

    while (!s.empty() && s.top() == div.back()) {
        // cout << s.top() << " poped, ";
        s.pop();
    }
    // cout << endl;

    while (!s.empty()) {
        int t = s.top();
        // cout << t << " popped, " << endl;
        div.push_back(t);
        s.pop();
    }
    // cout << endl;
    int D = div.size();

    vector<vector<int> > dp(k + 1, vector<int>(D, 0));

    for (int j = 1; j < D; j++) {
        dp[1][j] = div[j];
    }
    for (int i = 2; i <= k; i++) {
        for (int j = 1; j < D; j++) {
            dp[i][j] = dp[i][j - 1];
            ll temp = ((ll)(div[j] - div[j - 1]) * (ll)dp[i - 1][D - j]) % MOD;
            dp[i][j] = (temp + dp[i][j]) % MOD;
        }
    }

    //debug
    // cout << "divisors ";
    // for (int a : d) cout << a << " ";
    // cout << endl;

    cout << dp[k][D - 1] << endl;
    // }
    return 0;
}

Measured memory_bytes: 25980
#include <iostream>
using namespace std;
  
int main()
{
    int n=0;
    cin >> n;
    int y = 0;
    for (int i = 1; i <= n; i++)
    {
        int x = i;
        if (x % 3 == 0)//i???3??????????°???????¨???i?????????
        {
            cout << ' ' <<i;
            continue;
        }
        while (x) {
            if (x % 10 == 3)
            {
                cout << ' ' << i;
                break;
            }
            x /= 10;
        }
    }
	cout << endl;
    return 0;
}

Measured memory_bytes: 3084
fun main(array: Array<String>) {
    val num = readLine()!!
    val a = num[0].toInt() - 48
    val b = num[1].toInt() - 48
    val c = num[2].toInt() - 48
    val d = num[3].toInt() - 48
    var ans = a + b + c + d
    if(ans == 7) {
        print("$a+$b+$c+$d=7")
        return
    }
    ans = a + b + c - d
    if(ans == 7) {
        print("$a+$b+$c-$d=7")
        return
    }
    ans = a + b - c + d
    if(ans == 7) {
        print("$a+$b-$c+$d=7")
        return
    }
    ans = a + b - c - d
    if(ans == 7) {
        print("$a+$b-$c-$d=7")
        return
    }
    ans = a - b + c + d
    if(ans == 7) {
        print("$a-$b+$c+$d=7")
        return
    }
    ans = a - b + c - d
    if(ans == 7) {
        print("$a-$b+$c-$d=7")
        return
    }
    ans = a - b - c + d
    if(ans == 7) {
        print("$a-$b-$c+$d=7")
        return
    }
    ans = a - b - c - d
    if(ans == 7) {
        print("$a-$b-$c-$d=7")
        return
    }

}

Measured memory_bytes: 34488
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.Math;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    int N = Integer.parseInt(strs[0]);
    int I = Integer.parseInt(strs[1]);
    
    System.out.println(N - I + 1);
  }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
  if (c=='a')
   cout << "vowel" << endl;
 else if (c=='i')
   cout << "vowel"<< endl;
  else if (c=='u')
   cout << "vowel" << endl;
   else if (c=='e')
   cout << "vowel" << endl;
    else if (c=='o')
   cout << "vowel" << endl;
   else cout << "consonant" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;

typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 4e5 + 100;
const ll inf = 1e9;
const ll mod = 1e9+7;

ll n,dp[MAX],sum[MAX],sz[MAX];
vii adj[MAX];

vi aux;

void centroid(ll u,ll f){
	sz[u] = 1;
	bool go = true;
	for(ii it:adj[u]){
		ll v = it.ff;
		if(v == f) continue;
		centroid(v,u);
		sz[u] += sz[v];
		if(sz[v] > n/2) go = false;
	}
	if( n - sz[u] > n/2) go = false;
	if(go) aux.push_back(u);
}


void dfs(ll u,ll f){
	sz[u] = 1;
	dp[u] = 0;
	for(ii it:adj[u]){
		ll v = it.ff;
		if(v == f) continue;
		dfs(v,u);
		dp[u] += dp[v] + it.ss * sz[v];
		sz[u] += sz[v];
	}
}

ll solve(ll cen){
	if(cen == -1) return 0;
	dfs(cen,0);
	ll ans = 0,mini = inf,heavy = -1;
	for(ii it:adj[cen]){
		ll v = it.ff,w = it.ss;
		if( (n%2 == 0 && sz[v] == n/2) )
			heavy = w; 
		mini = min(mini,w);
		ans += 2*dp[v];
		ans += 2*w*sz[v];
	}
	if(heavy > 0) mini = heavy;
	return 2*dp[cen] - mini;
}

int main(){
	fastio;
	ll u,v,w;
	cin >> n;
	f(i,1,n){
		cin >> u >> v >> w;
		adj[u].push_back({v,w});
		adj[v].push_back({u,w});
	}
	centroid(1,0);
	aux.push_back(-1);
	cout << max(solve(aux[0]),solve(aux[1])) << endl;
	return 0;
}

Measured memory_bytes: 26304
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }

    public static void main(String[] args) throws Exception {
        int num = Integer.parseInt(br.readLine().trim());
        int[] arr = inputval();
        int[] counter = new int[num];
        for(int i=0; i<num; i++) counter[i] = 0;
        for(int i=0; i<num; i++){
            while(arr[i]%2 != 1){
                arr[i] /= 2;
                counter[i]++;
            }
        }
        int minnum=Integer.MAX_VALUE;
        for(int i=0; i<num; i++){
            if(counter[i]<minnum) minnum = counter[i];
        }
        System.out.println(minnum);
    }
}

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

int max(const void *a, const void *b){
  return *(double*)a - *(double*)b;
}

int main(){
  int N;
  cin >> N; cin.ignore();
  double v[N];
  for(int i=0;i<N;i++) cin >> v[i];
  qsort(v, N, sizeof(double), max);
  double ans = v[0];
  for(int i=1;i<N;i++) ans = (ans+v[i])/2.0;
  cout << ans << endl;
}

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

using namespace std;

int main() {
    long long n;
    set <long long> s;
    cin >> n;

    s.insert(n);

    long long x = n - 1;

    if (x >= 2)
        s.insert(x);

    for (long long i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            s.insert(i);
            if (x / i != i)
                s.insert(x / i);
        }
    }

    for (long long i = 2; i * i <= n; i++) {
        long long y = n;
        while (y % i == 0){
            y /= i;
        }
        if ((y - 1) % i == 0)
            s.insert(i);
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 764
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let mut s: Vec<char> = input::<String>().chars().collect();
    s.sort();
    println!(
        "{}",
        if s[0] == s[1] && s[1] != s[2] && s[2] == s[3] {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;


signed main() {
	int n;
	
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream> 
#include<vector> 
#include<iomanip>
using namespace std; 
#define lld long long int
#define X 1000000007
#define fast();  ios_base::sync_with_stdio(false); cin.tie(0);
# define rec(i,n) for(int i=0;i<n;i++) 
#define w(t) int t; cin>>t; while(t--)
int main()
{
    fast(); 
     double  r; 
     cin>>r; 
     r=2*r; 
     r=r*(3.1415926); 
     cout<<fixed<<setprecision(5)<<r<<endl; 
	return 0;
}

Measured memory_bytes: 3796
#include<cstdio>
#include<cstring>

int main(){
    char str[1001];
    
    while(1){
        scanf("%s",str);
        if (str[0]=='0')break;
        int sum =0;
        for (int i=0; i<strlen(str);i++){
            sum +=(str[i]-'0');
        }
        printf("%d\n",sum);
        
    }
    return 0;
}


Measured memory_bytes: 2732
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <atcoder/fenwicktree>

using namespace std;
using namespace atcoder;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 998244353;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int n,q,t,u,v;
 cin>>n>>q;
 fenwick_tree<ll> ftree(n);
 rep(i, n) {
   cin>>u;
   ftree.add(i, u);
 }
 rep(i,q) {
   cin>>t>>u>>v;
   if(t == 0) ftree.add(u, v);
   else cout<<ftree.sum(u, v)<<endl;
 }

 return 0;
}


Measured memory_bytes: 8240
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
struct shop{
	ll int Money;
	ll int count;
	bool operator<(const shop& x) { return Money < x.Money; }
};
shop Shop[100010];
int main(void)
{
	long long int N, M;
	long long int ans=0,count=0;
	scanf("%lld%lld", &N, &M);
	
	for (int i = 0; i < N; i++) {
		scanf("%lld%lld", &Shop[i].Money, &Shop[i].count);
	}
	sort(Shop, Shop + N);
	for (int i = 0; i < N; i++) {
		if (M > count + Shop[i].count) {
			ans += Shop[i].count * Shop[i].Money;
			count += Shop[i].count;
		}
		else {
			ans += (M - count) * Shop[i].Money;
			printf("%lld", ans);
			return 0;
		}
	}

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
    long n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    long x,y;
    x=min({a,b,c,d,e});
    y=5+n/x;
    if(n%x==0){
      y=y-1;
    }
  cout<<y<<endl;
}


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

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final Seat left = new Seat(0);
        if (left.status == Status.Vacant) {
            return;
        }

        final Seat right = new Seat(n - 1);
        if (right.status == Status.Vacant) {
            return;
        }

        binarySearch(left, right);
    }

    private static void binarySearch(final Seat left, final Seat right) {
        if (right.number - left.number == 1) {
            System.out.println(right.number);
            return;
        }

        final Seat mid = new Seat((left.number + right.number) / 2);
        if (mid.status == Status.Vacant) {
            return;
        }

        if ((mid.number - left.number) % 2 == 0 && left.status == mid.status
            || (mid.number - left.number) % 2 == 1 && left.status != mid.status) {
            binarySearch(mid, right);
        } else {
            binarySearch(left, new Seat(mid.number - 1, Status.Dummy));
        }
    }

    private static class Seat {
        private final int number;
        private final Status status;

        private static final FastScanner scanner = new FastScanner(System.in);

        Seat(final int number) {
            this.number = number;
            printAndFlush(number);
            this.status = Status.valueOf(scanner.next());
        }

        Seat(final int number, final Status status) {
            this.number = number;
            this.status = status;
        }

        private static void printAndFlush(final int number) {
            System.out.println(number);
            System.out.flush();
        }
    }

    private enum Status {
        Vacant, Male, Female, Dummy
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 32916
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define dump(x) cerr << #x << " = " << (x) << endl

typedef long long LL;

using namespace std;

int N;

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

    cin >> N;
    vector<int> a(N), b(N);
    REP(i, N)
    {
        cin >> a[i];
    }
    REP(i, N)
    {
        cin >> b[i];
    }

    string ans = "";
    REP(k, 29)
    {
        int T = pow(2, k);
        vector<int> a_k(N), b_k(N);
        REP(i, N)
        {
            a_k[i] = a[i] % (2 * T);
            b_k[i] = b[i] % (2 * T);
        }
        sort(b_k.begin(), b_k.end());

        LL cnt[3] = {0, 0, 0};
        REP(i, N)
        {
            REP(j, 3)
            {
                auto it = lower_bound(b_k.begin(), b_k.end(), (j + 1) * T - a_k[i]) - b_k.begin();
                cnt[j] += N - it;
            }
        }

        auto n = (cnt[0] - cnt[1]) + cnt[2];
        ans = to_string(n % 2) + ans;
    }
    cout << stoi(ans, nullptr, 2) << endl;

    return 0;
}


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

int main() {
    string S ;
    cin >> S ; //Each character of S is A or B.|S|=3 
    if (S[0] == S[1] && S[1] == S[2]) cout << "No" <<endl;
    else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll N;
		cin>>N;
		string s="";
		while(N){
			//s+=(char)('a'+(N%26));
			s+=(char)('a'+((N-1)%26));
			N--;
			N/=26;
		}
		for(ll i=s.size()-1;i>=0;i--){
			cout<<s[i];
		}
	}
}

Measured memory_bytes: 3652