akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


void get_permutation(vector<vs>& perm, vs a){
    sort(a.begin(), a.end());
    do {
        vs t;
        for (string s : a) t.push_back(s);
        perm.push_back(t);
    } while (next_permutation(a.begin(), a.end()));
}

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

  int N; cin>>N;
  vi x(N),y(N); REP(i,N) cin>>x[i]>>y[i];

  vs a;
  REP(i,N) a.push_back(to_string(i));

  vector<vs> pm;
  get_permutation(pm, a);

  double sum = 0;
  for(vs p : pm) {
    double dist = 0;
    for(int i = 1; i<N; i++) {
      int s = stoi(p[i-1]);
      int t = stoi(p[i]);
      dist += sqrt((x[t]-x[s])*(x[t]-x[s]) + (y[t]-y[s])*(y[t]-y[s]));      
    }
    sum += dist;
  }

  double ans = sum / pm.size();
  printf("%.10f\n", ans);
  
  return 0;
}


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

using namespace std;

int main() {
  string s;
  int K;
  cin >> s >> K;
  vector<string> ss;
  for (int i = 0; i < (int)s.size(); ++i) {
    for (int j = 1; j <= K; ++j) {
      ss.push_back(s.substr(i, j));
    }
  }
  sort(ss.begin(), ss.end());
  ss.erase(unique(ss.begin(), ss.end()), ss.end());
  
  cout << ss[K - 1] << endl;
  return 0;
}



Measured memory_bytes: 1660
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#define EVAL 1
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 1048576
#define PI 3.1415926535
int main() {
	long long a;
	cin >> a;
	a++;
	string s = to_string(a);
	long long ans = (s.length() - 1) * 9 + s[0] - '1';
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int N, K;
int a[5009];
bool dp[5009][5009]; // dp[i][j] : 1からi番目までのカードのみでjがつくれるかどうか

bool need(int m) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= K; j++) dp[i][j] = false;
	}

	dp[0][0] = true;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {

			if (dp[i][j]) {
				dp[i + 1][j] = true;
				// a[m]は使ってはいけない
				if (i+1 != m && j + a[i + 1] < K) dp[i + 1][j + a[i + 1]] = true;
			}
		}
	}

	// dp[N][K-a[n]]～dp[N][K-1]がすべてfalseなら不要
	bool flag = false;
	for (int i = max(0,K - a[m]); i < K && !flag; i++) {
		if (dp[N][i]) flag = true;
	}

	return flag;
}

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

	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> a[i];
	sort(a + 1, a + N + 1);

	// right以上のものは必要
	// left以下のものは不要
	int left = 0;
	int right = N + 1;

	while (left != right - 1) {
		int mid = (left + right) / 2;
		if (need(mid)) right = mid;
		else left = mid;
	}

	cout << left << endl;

	return 0;
}

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


const long long MAX = 1000003;
const long long MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main (){
	long long dp[2005][2005]={0};
	int i,j,x,n,k;
	cin >> n >> k;
	COMinit();
	for(i=1;i<=k;i++){
		if(i>(n+1)/2){
			cout << "0" << endl;
		} else if(i==1) {
			cout << n-k+1 << endl;
		} else {
			long long ans;
			ans=COM(k-1,i-1)*(((COM(n-k-1,i-2)+2*COM(n-k-1,i-1))%MOD+COM(n-k-1,i))%MOD)%MOD;
			cout << ans << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 23680
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


using namespace std;



int n,m;
bool visited[200000];
vector<int> edge[200000];


void dfs(int u){
	if (visited[u])return;
	visited[u]=true;
	for (int v:edge[u]){
		dfs(v);
	}
}


int main(){
	cin>>n>>m;
	rep(i,n){
		int k;
		cin>>k;
		rep(j,k){
			int L;
			cin>>L;
			L--;
			edge[i].push_back(n+L);
			edge[n + L].push_back(i);
		}
	}
	dfs(0);
	cout << (all_of(visited, visited + n, [](bool f){return f;})?"YES":"NO")<<endl;

	return 0;
}

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


int main(){
  int n;
  cin >> n;
  vector<vector<int>> x(n), y(n);
  REP(i, n) {
    int a;
    cin >> a;
    x[i].resize(a);
    y[i].resize(a);
    REP(j, a){
      cin >> x[i][j] >> y[i][j];
      --x[i][j];
    }
  }
  int ans = 0;
  for (int i = 1;i < 1 << n;i++){
    vector<bool> honest(n);
    REP(j, n) honest[j] = i >> j & 1;
    bool ok = true;
    REP(j, n) if (honest[j]){
      int a = x[j].size();
      REP(k, a){
	if (y[j][k] == 0 && honest[x[j][k]]) ok = false;
	if (y[j][k] == 1 && !honest[x[j][k]]) ok = false;
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int main() {
    int N,M;
    string S;
    cin >> N >> M >> S;
    int now = N;
    vector<int> ans;
    while (now > 0){
        bool flag = true;
        for (int step=M;step>0;step--){
            if (!flag) continue; 
            if (now - step < 0 || S[now - step] == '1') continue;
            ans.push_back(step);
            now -= step;
            flag = false;
        }
        if (flag == true) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i=ans.size()-1;i>=0;i--){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1144
s=input()
sl=len(s)
a=[]
count=1
for i in range(sl-1):
    if s[i+1]==s[i]:
        count+=1
    else:
        a.append(count)
        count=1
a.append(count)
ans=0
al=len(a)
if s[0]=="<":
    for i in range(0,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==1:
        ans+=a[-1]*(a[-1]+1)/2
elif s[0]==">":
    ans+=a[0]*(a[0]+1)/2
    for i in range(1,al-1,2):
        m,n=max(a[i],a[i+1]),min(a[i],a[i+1])
        ans+=(m*(m+1)+n*(n-1))/2
    if al%2==0:
        ans+=a[-1]*(a[-1]+1)/2
print(int(ans))

Measured memory_bytes: 11992
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    ll a[n+1];
    ll l = 1, ans = 1;
    rep(i, n)
    {
        cin >> a[i+1];
    }
    for(ll i = 2; i <= n; i++){
        if(a[i] <= a[i-1]){
            l++; ans = max(l, ans);
        }
        else l = 1;
    }
    cout << ans-1;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%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);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
	void scan(int edcount, bool oindexed, bool w) {
		REP(i, edcount) {
			int a, b, c = 1;
			scanf("%d %d", &a, &b);
			if (w)scanf("%d", &c);
			con(a - oindexed, b - oindexed, c);
		}
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
signed main() {
	int n;
	cin >> n;
	set<int> al;
	REP(i, n) {
		int a;
		scanf("%d", &a);
		if (al.count(a))
			al.erase(a);
		else
			al.insert(a);

	}
	cout << al.size();
	return 0;
}

Measured memory_bytes: 4864
#import"bits/stdc++.h"
#define r(n) for(i=0;i<n;i++)
using namespace std;main(int N){cin>>N;int A[2*N],c[N+1]={},n,t,i;r(2*N)cin>>A[i];r(2*N)c[A[i]]++;if(*max_element(c,c+N+1)>N)cout<<"No";else{cout<<"Yes ";queue<int>s;r(N)if(A[i]==A[N+i])s.push(i);while(s.size()){n=s.front(),t=N+rand()%N;s.pop();if(A[n]!=A[t]&A[t-N]!=A[n+N])swap(A[n+N],A[t]);else s.push(n);}r(N)cout<<A[i+N]<<" ";}}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  ll mi = 0, mc = 0, adsum = 0;
  vector<int> add;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<int> b(n);
  rep(i, n) cin >> b.at(i);
  rep(i, n){
    if(a.at(i) > b.at(i)){
      adsum += a.at(i)-b.at(i);
      add.push_back(a.at(i)-b.at(i));
    }
    if(a.at(i) < b.at(i)){
      mi += b.at(i)-a.at(i);
      mc++;
    }
  }
  if(adsum < mi){
    cout << -1 << endl;
    return 0;
  }

  sort(add.rbegin(), add.rend());
  int ans = mc;
  // cerr << ans << endl;
  for(int i : add){
    if(mi <= 0) break;
    ans++;
    mi -= i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4380
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n{};
    cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    
    vector<vector<int>> dp(3,vector<int>(n));
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for(int i=1;i<n;i++)
    {
        dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1],dp[1][i-1]);
    }
    int ans = max(dp[0][n-1], max(dp[1][n-1],dp[2][n-1]));
    cout<<ans;
    return 0;
}

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

int main() {
  int n,m,a;
  long long ans=1;
  cin>>n>>m;
  vector<int> state(n+1,0);
  rep(i,m){
    cin>>a;
    state.at(a)=1;
  }
  
  long long dp[n+2];
  dp[0]=1;dp[-1]=0;
  for(int i=1; i<=n; i++){
    if(state[i]){
      dp[i]=0;
      continue;
    }
    dp[i]=(dp[i-1]+dp[i-2])%1000000007;
    
  }
  cout<<dp[n]<<endl;
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

int main(void) {
    int A, P;
    cin >> A >> P;

    int ans;
    ans = ((A*3) + P) / 2;

    cout << ans;

    return (0);
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll l,r,d;
    cin >> l >> r >> d;

    ll total = r/d - l/d;
    if(l%d==0){
        total++;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef unsigned long long ll;
using namespace std;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    ll n,i,j,ans=0;
    cin>>n;
    vector<ll>a(n+2),b(n+1);
    for(i=1;i<=n+1;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    ll t=0;
    for(i=1;i<=n;i++)
    {
        ans+=min(b[i],a[i]);
        t=a[i];
        a[i]-=min(b[i],t);
        b[i]-=min(b[i],t);
        ans+=min(b[i],a[i+1]);
        t=a[i+1];
        a[i+1]-=min(b[i],t);
        b[i]-=min(b[i],t);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;

int n , m , q , ans = 0;
int a[52] , b[52] , c[52] , d[52];
void rec(int idx ,int prev , vector<int> v) {
    for(int i = prev ; i <= m ; i ++) {
        v[idx] = i;
        if(idx == n - 1) {
            int temp = 0 ;
            for(int j = 0 ; j < q ; j ++) {
                if(v[b[j]] - v[a[j]] == c[j]) temp += d[j];
            }
            ans = max(ans , temp);
        }
        else rec(idx + 1, i , v );
    }
}

void solve(int z) {
    
    cin >> n >> m >> q;
    for(int i = 0 , t ; i < q ; i ++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i] -- , b[i] --;
    }
    vector<int> v(n);
    rec( 0 , 1 , v);
    cout << ans;
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



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

const int C = (int)1e5 + 1;
int N, M, K;

vector<int> graph(C, -1);

vector<vector<int>> g_frens(C);
vector<vector<int>> g_block(C);

int root(int n) {
    return graph[n] == -1 ? n : root(graph[n]);
}

void merge(int a, int b) {
    int root1 = root(a);
    int root2 = root(b);
    if (root1 == root2) return;
    if (root1 > root2) graph[root1] = root2;
    else graph[root2] = root1;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr); 
    
    cin >> N >> M >> K;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        g_frens[a].push_back(b);
        g_frens[b].push_back(a);
        merge(a, b);
    }
    for (int i = 0; i < K; ++i) {
        int c, d;
        cin >> c >> d;
        g_block[c].push_back(d);
        g_block[d].push_back(c);
    }

    int cntArr[N + 1];
    fill(cntArr, cntArr + N + 1, 0);
    for (int i = 1; i <= N; ++i) {
        int r = root(i);
        cntArr[r]++;
    }
    
    for (int i = 1; i <= N; ++i) {
        int r1 = root(i);
        int cnt = cntArr[r1] - g_frens[i].size() - 1;
        for (int j = 0; j < g_block[i].size(); ++j) {
            int r2 = root(g_block[i][j]);
            if (r1 == r2) cnt--;
        }
        cout << cnt << " ";
    }
}


Measured memory_bytes: 12664
//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


void solve()
{ 

        int n;
        cin >> n;
        
        vii v(n);
        
        uom<int,int>h;

        fo(i,0,n-1)
        {
          cin >> v[i];

          if(h.count(v[i])) h[v[i]]++;
          else h[v[i]] = 1;
        } 

        int tot = 0, cnt = 0,other;

        fo(i,0,n-1)
        {
          cnt = n;

          fo(j,1,sqrt(v[i]))
          {
            if(!(v[i]%j) and h.count(j)) cnt -= h[j];

            other = v[i]/j;

            if(other == j) continue;

            if(!(v[i]%other) and h.count(other))
            {
              cnt -= h[other];
            } 
          }

          if(cnt == n-1) tot++;
        }

        cout << tot << endl;
    
       
}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
 //   cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 12148
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

int main() {
  i64 H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  rep(i,0,H) {
    cin >> s[i];
  }

  vector<vector<i64>> ans(H, vector<i64>(W, -1));
  i64 now = 1;
  queue<i64> que;
  rep(i,0,H) {
    if(count(all(s[i]), '#') == 0) {
      que.push(i);
      continue;
    }
    rep(j,0,W) {
      ans[i][j] = now;
      if(s[i][j] == '#') now++;
    }
    if(now > 1) {
      rep(j,0,W) {
        if(ans[i][j] == now) {
          ans[i][j] = now - 1;
        }
      }
    }

    while(!que.empty()) {
      i64 v = que.front();
      que.pop();
      rep(j,0,W) {
        ans[v][j] = ans[i][j];
      }
    }
  }
  while(!que.empty()) {
    i64 v = que.front();
    que.pop();
    rep(j,0,W) {
      ans[v][j] = ans[v - 1][j];
    }
  }
  rep(i,0,H) {
    rep(j,0,W) {
      cout << ans[i][j] << " \n"[j + 1 == W];
    }
  }
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

bool is_prime(const long long n) {
    for (int p = 2; p * p <= n; ++p) {
        if (n % p == 0) {
            return false;
        }
    }
    return true;
}

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

    li x;
    cin >> x;

    while (!is_prime(x)) {
        x++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

int gcd(int a, int b);

int main()
{
  int N, X;
  std::cin >> N >> X;
  std::vector<int> x(N);
  for (int i = 0; i < N; i++)
  {
    std::cin >> x.at(i);
    x.at(i) = std::abs(x.at(i) - X);
  }
  int ans = x.at(0);
  for (int i = 1; i < N; i++)
  {
    ans = gcd(ans, x.at(i));
  }
  std::cout << ans << std::endl;
}

/* ++++++++++ function ++++++++++*/
int gcd(int a, int b)
{
  while (true)
  {
    if (a < b) std::swap(a, b);
    if (!b) break;
    a %= b;
  }
  return a;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n;
string a,b,c;

int main(void){
    cin >> n;
    cin >> a >> b;
	
  	//cout << a[1] << endl;
    for(int i = 0; i < n; i++){
        c += a[i];
    	c += b[i];
    }
  	
  	cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,a[20005],b[20005],c[20005],d[20005];
int main(){
	n=read();
	for(int i=0;i<n;i++)
		c[i]=read(),d[c[i]-1]=i;
	for(int i=0;i<n;i++)
		a[i]=25000*(i+1),b[i]=d[i]+25000*(n-i);
	for(int i=0;i<n;i++)
		printf("%d ",a[i]);
	puts("");
	for(int i=0;i<n;i++)
		printf("%d ",b[i]);
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    if (S.length() < 4) {
        cout << "No" << endl;
    } else if (S.substr(0, 4) == "YAKI") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main() {
  long long X, K, D;
  cin >> X >> K >> D;
  
  X = abs(X);
  long long min_ = 0;
  min_ = abs(X - K * D);
  if ((X / D) % 2 == 0){
    if (K % 2 == 0){
      if (X / D <= K) min_ = min(min_, X - (X / D) * D);
    }
    if (K % 2 == 1){
      if (X / D + 1 <= K) min_ = min(min_, abs(X - (X / D + 1) * D));
    }
  }
  if ((X / D) % 2 == 1){
    if (K % 2 == 1){
      if (X / D <= K) min_ = min(min_, X - (X / D) * D);
    }
    if (K % 2 == 0){
      if (X / D + 1 <= K) min_ = min(min_, abs(X - (X / D + 1) * D));
    }
  }
  cout << min_ << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

const ll INF = 5e15;
const ll MOD = 1e9 + 7;

ll dp1[50][50][63];
ll dp2[50][50][64];
ll N, K;
vector<vector<ll>> A;

int main(){
    cin >> N >> K;
    for(ll i = 0; i < N; i++){
        vector<ll> tmp(N);
        for(ll &t : tmp) cin >> t;
        A.push_back(tmp);
    }
    for(ll i = 0; i < N; i++) for(ll j = 0; j < N; j++) dp1[i][j][0] = A[i][j] == 1;
    for(ll dig = 1; dig < 63; dig++) for(ll k = 0; k < N; k++) for(ll i = 0; i < N; i++) for(ll j = 0; j < N; j++) (dp1[i][j][dig] += dp1[i][k][dig - 1] * dp1[k][j][dig - 1] % MOD) %= MOD;
    for(ll i = 0; i < N; i++) dp2[i][i][0] = 1;
    for(ll dig = 1; dig <= 64; dig++) for(ll k = 0; k < N; k++) for(ll i = 0; i < N; i++) for(ll j = 0; j < N; j++){
        if((1ll << (dig - 1)) & K) (dp2[i][j][dig] += dp2[i][k][dig - 1] * dp1[k][j][dig - 1] % MOD) %= MOD;
        else dp2[i][j][dig] = dp2[i][j][dig - 1];
    }
    ll ans = 0;
    for(ll i = 0; i < N; i++) for(ll j = 0; j < N; j++) (ans += dp2[i][j][63]) %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2688
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
using namespace std;
//typedef __int64 ll;

int const Max_N = 1e6+5;
int main()
{
 	int N;
	int A,B;
	cin >> A>> B;
	if(A%3==0||B%3==0||(A+B)%3==0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;  

	return 0;
}
	//freopen("in.txt","r",stdin);
//std::ios::sync_with_stdio(false);



Measured memory_bytes: 256
N,M = (int(i) for i in input().split())

drinkinfo = []  #prices and numbers of drinks

#get input data
for i in range(N):
    A,B = (int(k) for k in input().split())
    drinkinfo.append([A,B])

#sort drinks in price
sorteddrink = sorted(drinkinfo, key = lambda x:(x[0]), reverse = False)

price = 0 #answer
numdrink = 0 #number of drinks

#perform greedy algorithm
for i in range(N):
    if sorteddrink[i][1] <= (M - numdrink):
        price += sorteddrink[i][1] * sorteddrink[i][0]
        numdrink += sorteddrink[i][1]
    else:
        price += sorteddrink[i][0] * (M - numdrink)
        numdrink += (M - numdrink)

    if numdrink == M:
        break

print(price)        

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 1000001
#define mod 1000000007

int n;
vector<int> v;
int prime[MAXN];
unordered_map<int, int> max_map;

int modpow(int x, int y)
{
  int z = 1;
  while (y)
  {
    if (y & 1)
      z = (z * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return z;
}
void crivo()
{
  prime[0] = prime[1] = 1;
  for (int i = 2; i < MAXN; i++)
  {
    if (!prime[i])
    {
      for (int j = i * 2; j < MAXN; j += i)
        if (!prime[j])
          prime[j] = i;
      prime[i] = i;
    }
  }
}
int getlcm(vector<int> v)
{
  for (int i = 0; i < n; i++)
  {
    int num = v[i];
    unordered_map<int, int> temp;
    while (num > 1)
    {
      int factor = prime[num];
      temp[factor]++;
      num /= factor;
    }
    for (auto it : temp)
      max_map[it.first] = max(max_map[it.first], it.second);
  }
  int ans = 1;
  for (auto it : max_map)
    ans = (ans * modpow(it.fir, it.sec)) % mod;
  return ans;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  crivo();
  int prod = v[0];
  for (int i = 1; i < n; i++)
    prod = (v[i] * prod) % mod;
  if (getlcm(v) == prod)
  {
    cout << "pairwise coprime\n";
    return 0;
  }
  int gcdd = v[0];
  for (int i = 0; i < n; i++)
    gcdd = __gcd(gcdd, v[i]);
  if (gcdd != 1)
    cout << "not coprime\n";
  else
    cout << "setwise coprime\n";
  return 0;
}


Measured memory_bytes: 29940
fun main(args : Array<String>) {
    val (m, d) = readLine()!!.split(" ").map{it.toInt()}

    var cnt = 0
    for (i in 4..m) {
        for (j in 22..d) {
            val d1 = j % 10
            val d2 = j / 10
            if (d1 >= 2 && d1 * d2 == i) cnt++
        }
    }

    println(cnt)
}

Measured memory_bytes: 37772
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;

	if (n / 10 == 9 ||
		n % 10 == 9)
		cout << "Yes\n";
	else
		cout << "No\n";

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static final long MOD = 1000000007;
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}

	static long modinv(long n){
		return modpow(n , MOD - 2);
	}
	static long comb(int N , int R, long fact[]){
		long ret = fact[N];
		ret = (ret * modinv(fact[R])) % MOD;
		ret = (ret * modinv(fact[N - R])) % MOD;
		return ret;
	}

	static long solve2(int N , int i, long fact[]){
		int M = N - 3 * i;
		long ret = comb(M + i - 1, i - 1, fact);
		return ret;
	}
	static long solve(int N , long fact[]){
		if(N <= 2){
			return 0;
		}
		long ret = 0;
		for(int i = 1 ; i <= N / 3 ; ++i){			
			long r = solve2(N , i, fact);
//			System.out.println(i+" "+r);
			ret = (ret + r) % MOD;
		}
		return ret;
	}
	private static long[] calcFactorial(int N) {
		long fact[] = new long[N + 1];
		fact[0] = 1;
		fact[1] = 1;
		for(int i = 2 ; i < fact.length; ++i){
			fact[i] = (i * fact[i - 1]) % MOD;
		}
		return fact;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long fact[] = calcFactorial(6001);
		int N = sc.nextInt();
		long ret = solve(N, fact);
		System.out.println(ret);
	}
}


Measured memory_bytes: 35696
#include<stdio.h>
int main(void)
{
	int a[5],i,n;
	n=0;
	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
		if(a[i]<40){
			a[i]=40;
		}
	}
	n=(a[0]+a[1]+a[2]+a[3]+a[4])/5;
	printf("%d\n",n);
	return 0;
}



Measured memory_bytes: 2048
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<Long,Integer>map=new TreeMap<>();
		int n=sc.nextInt();int m=sc.nextInt();

		for(int i=0;i<n;i++) {
		long a=sc.nextLong(); int b=sc.nextInt();
		map.put(a,map.containsKey(a)?b+map.get(a):b);
		}
		long ans=0;
		for(long i:map.keySet()) {
			if(m<=map.get(i)) {
				ans+=i*m;
				break;
			}else {
				m-=map.get(i);
				ans+=i*map.get(i);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 98360
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
using namespace std;

int main(){
    string s;
    while(cin>>s&&s!="-"){
        int n;
        cin>>n;
        for(int i=0; i<n; i++){
            int num;
            cin>>num;
            s.insert(s.size(), s.substr(0,num));
            s.erase(0,num);
        }
        cout<<s<<endl;
    }
}



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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

class item
{
public:
	int w, v;
	bool operator < (item& rhs){
		if(rhs.v == v)
			return rhs.w > w;
		return rhs.v < v;
	}
};

int N, W;
VI A, B, C, D;
LL minwt;
const int MAXN = 101;
vector<vector<VVI>> cache;
int MPV(int a, int b, int c, int d)
{
	if(a < 0 || b < 0 || c < 0 || d < 0)
		return 0;

	int& dp = cache[a][b][c][d];
	if(dp != -1)
		return dp;

	int ret = 0;
	LL sum = a * minwt + b * (minwt + 1) + c * (minwt + 2) + d * (minwt + 3);
	if(sum > W)
	{
		ret = max(ret, MPV(a - 1, b, c, d));
		ret = max(ret, MPV(a, b - 1, c, d));
		ret = max(ret, MPV(a, b, c - 1, d));
		ret = max(ret, MPV(a, b, c, d - 1));
	}
	else
	{
		if(a > 0) ret += A[a - 1];
		if(b > 0) ret += B[b - 1];
		if(c > 0) ret += C[c - 1];
		if(d > 0) ret += D[d - 1];
	}
	return dp = ret;
}

int knapsack()
{
	vector<item> items(N);

	 minwt = LLONG_MAX;
	 REP(i, 0, N){
	 	cin >> items[i].w >> items[i].v;
		minwt = min(minwt, (LL)items[i].w);
	 }
	 REP(i, 0, N)
	 {
		 int wt = items[i].w, val = items[i].v;
		 if(wt - minwt == 0)
		 	A.push_back(val);
		 else if(wt - minwt == 1)
		 	B.push_back(val);
		 else if(wt - minwt == 2)
		 	C.push_back(val);
		else
			D.push_back(val);
	 }	

	 sort(ALL(A), greater<int>());
	 sort(ALL(B), greater<int>());
	 sort(ALL(C), greater<int>());
	 sort(ALL(D), greater<int>());

	 partial_sum(ALL(A), A.begin());
	 partial_sum(ALL(B), B.begin());
	 partial_sum(ALL(C), C.begin());
	 partial_sum(ALL(D), D.begin());

	 int a = sz(A), b = sz(B), c = sz(C), d = sz(D);
	 cache.assign(a + 1, vector<VVI>(b + 1, VVI(c + 1, VI(d + 1, -1))));
	
	 return MPV(a, b, c, d);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> N >> W;

	cout << knapsack() << endl;	 

	return 0;
}

Measured memory_bytes: 2944
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 1e10 + 5;

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, k, c;
        string s;
        cin >> n >> k >> c >> s;

        int dl[n + 5] = {}, dr[n + 5] = {}, lt = -INF;
        for(int i = 1; i <= n; i++) {
            if(s[i - 1] == 'o' && lt + c < i) {
                lt = i;
                dl[i] = dl[i - 1] + 1;
            }
            else 
                dl[i] = dl[i - 1];
        }
        lt = -INF;
        for(int i = 1; i <= n; i++) {
            if(s[n - i] == 'o' && lt + c < i) {
                lt = i;
                dr[i] = dr[i - 1] + 1;
            }
            else 
                dr[i] = dr[i - 1];
        }


        // for(int i = 0; i <= n; ++i) 
        //     cout << dl[i] << ' ' << dr[i] << '\n';

        for (int i = 0; i < n; i++) {
            int l = i;
            int r = n - 1 - i;
            if(s[i] == 'o' && dl[l] + dr[r] < k) 
                cout << i + 1 << '\n';
        }


    }
    
    return 0;
}

Measured memory_bytes: 6848
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

// O(N^(1/2))
// ref. https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2020-06-27abc-172#toc4
int main(void) {
    int N;
    cin >> N;

    auto f = [](const ll n) {
        return n * (n + 1) / 2;
    };

    ll ans = 0;
    for (int i = 1; i * i <= N; i++) {
        // x == y
        ans += i * i;

        // x < y or x > y
        ans += 2 * i * (f(N / i) - f(i));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3540
from bisect import bisect_left
N, Q = map(int, input().split())
consts = []
for _ in range(N):
    s,t,x = map(int, input().split())
    consts.append((x,s,t))
consts.sort()
D=[int(input()) for _ in range(Q)]
ans=[-1]*Q
jump=[-1]*Q
for x,s,t in consts:
    left=bisect_left(D,s-x)
    right=bisect_left(D,t-x)
    while left<right:
        if jump[left]==-1:
            ans[left]=x
            jump[left]=right
            left += 1
        else:
            left=jump[left]
print(*ans, sep='\n')

Measured memory_bytes: 57628
n = int(input())
 
digit = len(str(n))
 
if digit < 4:
    answer = 1000 - n
else:
    three_digits = str(n)[-3:]
    if three_digits == '000':
        answer = 0
    else:
        answer = 1000 - int(three_digits)
print(answer)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<ll>t(n, 0);
    REP(i, n) {
        cin >> t[i];   
    }
    sort(ALL(t));

    ll curr = 0;
    ll ans = 0;

    while(curr < n){
        ll firstPassenger = curr;
        bool ok = true;
        ll on = 1;
        curr++;

        while (ok){
            if (t[curr] <= t[firstPassenger]+k) on++;
            else {
                ok = false;
                continue;
            }

            if (on > c) {
                ok = false;
                continue;
            }

            curr++;
        }
        ans++;
    }
    cout << ans << endl;
    
}

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

int main(){
    int a[200],n,flag=0,cnt=0;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    while(flag!=1){
        for(int i=0;i<n;i++){
            if(a[i]%2!=0){
                flag=1;
                break;
            }
            else
                a[i]/=2;
        }
        if(flag==0)
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	int N,M,K;
	cin >> N >> M >> K;

	bool ans = false;

	rep(i,N+1){
		rep(j,M+1){
			int kazu = i * M + j * N - 2 * i * j;
			if(kazu == K) ans = true; 
		}
	}

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3664
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		double[][] point = new double[N][D];
		double[][] y = new double[N][D];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < D; j++) {
				point[i][j] = sc.nextDouble();
			}
		}
		int count = 0;
		for(int i = 0; i < N - 1; i++) {
			for(int j = i + 1; j < N; j++) {
				double dist = 0;
				for(int k = 0; k < D; k++) {
					dist += Math.pow((point[i][k] - point[j][k]), 2);
				}
				dist = Math.sqrt(dist);
				if(dist == Math.floor(dist))count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll a,b,c;
int main(){ //srand((unsigned)time(NULL));
  cin >> a >> b >> c;
  cout << (a < b && b < c ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
using namespace std;



int main(void){
  int N,Q;
  string S;
  int I,i,l,q;
  char c;
  set<int> counter[26];
  vector<int> ans;
  cin >> N >> S >> Q;
  for(int j = 0; j < S.size();j++) counter[S[j] - 'a'].insert(j);

  for(int j = 0; j < Q;j++){
    cin >> I;
    if(I == 1){
      cin >> i >> c;
      counter[S[i-1] - 'a'].erase(i-1);
      S[i-1] = c;
      counter[S[i-1] - 'a'].insert(i-1);
    }
    else{
      cin >> l >> q;
      int cnt = 0;
      for(int j = 0; j < 26;j++){
        set<int>::iterator end = counter[j].end();
        set<int>::iterator it = counter[j].lower_bound(l-1);
        if(it != end){
          if(*it <= q-1) cnt++;
        } 
      }
      ans.push_back(cnt);
    }
  }
  for(int a : ans){
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 24452
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    int N;
    cin >> N;
    vector<LL>  a(N+1);
    for(int i = 1;i <= N;i++)    cin >> a[i];
    sort(a.begin(), a.end());
    int rem = 0;
    LL sum = 0;
    for(int i = 1;i < N;i++){
        sum += a[i];
        if(sum*2 < a[i+1])  rem = i;
    }
    cout << N-rem << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename ID_TYPE = uint64_t>
class UnionFindTreeBase
{
private:
  std::vector<ID_TYPE> root, rank;

public:
  UnionFindTreeBase(ID_TYPE N)
  {
    root = std::vector<ID_TYPE>(N);
    for (ID_TYPE n = 0; n < N; ++n) { root[n] = n; }
    rank = std::vector<ID_TYPE>(N, 0);
  }

  ID_TYPE find(ID_TYPE x)
  {
    if (root[x] == x) { return x; }

    root[x] = find(root[x]);

    return root[x];
  }

  void unite(ID_TYPE x, ID_TYPE y)
  {
    ID_TYPE x_root = find(x), y_root = find(y);

    if (rank[x_root] > rank[y_root]) {
      root[y_root] = x_root;
    } else if (rank[x_root] < rank[y_root]) {
      root[x_root] = y_root;
    } else if (x_root != y_root) {
      root[y_root] = x_root;
      ++rank[x_root]; 
    }
  }

  bool is_same(ID_TYPE x, ID_TYPE y)
  {
    return find(x) == find(y);
  }

  ID_TYPE operator[](ID_TYPE x) {
    return find(x);
  }
};

typedef UnionFindTreeBase<uint64_t> UnionFindTree;

using namespace std;

int main()
{
  uint64_t N, M;
  cin >> N >> M;

  UnionFindTree uf_tree(N);
  N_TIMES(m, M) {
    uint64_t A, B;
    cin >> A >> B;
    --A; --B;

    uf_tree.unite(A, B);
  }

  uint64_t counter = 0;
  N_TIMES(n, N) {
    if (uf_tree.find(n) == n) {
      ++counter;
    }
  }
  cout << (counter - 1) << endl;

  return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,h; cin>>n>>h;
  vi b(n);
  int ma=0;
  rep(i,n){
    int a; cin>>a>>b[i];
    if(ma<a) chmax(ma,a);
  }
  sort(b.rbegin(),b.rend());
  int s=0, ans=0;
  bool flg=false;
  rep(i,n){
    if(ma<b[i]){
      s+=b[i];
      ans++;
      if(s>=h){
        cout<<ans<<endl;
        return 0;
      }
    }else break;
  }
  ans+=(h-s+ma-1)/ma;
  cout<<ans<<endl;
}

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

#define int long long

using namespace std;

int sz[100001];
int a[100001];

 main () {
    int n, m;
    cin >> n;
    int ans = 0;
    for (int i = 1;i <= n;i ++) cin >> a[i];
    for (int i = 1;i <= n;i ++) {
    	int qwe = min (a[i], a[i + 1]);
    	if ((a[i] - qwe) % 2 && qwe != 0) qwe --;	
    	ans += qwe;
    	a[i] -= qwe;
    	a[i + 1] -= qwe;
    	ans += a[i] / 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024