akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
//#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 2333
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, c;
int main() {
	n = read(), m = read(), c = read();
	m = max(n, m);
	printf("%d", (int)(ceil((D)c / (D)m)));
	return 0;
}


Measured memory_bytes: 256
import numpy as np
import copy


def main():
    # N = int(input())
    # ds = list(map(int, input().split()))
    # ds = np.array(ds, dtype=np.int)
    # ans = 0
    # for K in range(int(np.max(ds))+1):
    #     if np.sum(ds >= K) == N // 2:
    #         ans += 1
    # print(int(ans))

    N = int(input())
    ds = list(map(int, input().split()))
    ds = np.array(ds, dtype=np.int)

    ds = np.sort(ds)

    ans = ds[N//2] - ds[N//2-1]
    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23416
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))

arr = [0] * (n+1)
arr[0] = 1
for i in range(1, n+1):
    if i in a:
        arr[i] = 0
    else:
        arr[i] = (arr[i-1] + arr[i-2]) % 1000000007

print(arr[-1])


Measured memory_bytes: 58200
#include<stdio.h>

int main(void){
	int N,i,j,sum = 0,con,san;
	int A[100001];
	int sa[100001];

	A[0] = 0;
	scanf("%d",&N);
	A[N] = 0;
	for(i = 1;i <= N;i++){
		scanf("%d",&A[i]);
		sa[i] = (A[i]-A[i-1] >= 0) ? A[i]-A[i-1] : A[i-1]-A[i];
		sum = sum + sa[i];
	}
	A[N+1] = 0;
	sa[N+1] = (A[N+1]-A[N] >= 0) ? A[N+1]-A[N] : A[N]-A[N+1];
	sum = sum + sa[N+1];

	for(j = 1;j <= N;j++){
		san = (A[j+1]-A[j-1] >= 0) ? A[j+1]-A[j-1] : A[j-1]-A[j+1];
		con = sum -	sa[j] - sa[j+1] + san;
		printf("%d\n",con);
	}

	return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#define N_MAX 100000

int main()
{
    int h, n;
    int a[N_MAX];
    int tot=0;
    
    scanf("%d%d",&h,&n);
    for ( int i=0; i<n; i++ ){
        scanf("%d", &a[i]);
        tot += a[i];
    }
    
    if ( tot >= h ){
        printf("Yes\n");
    } else {
        printf("No\n");
    }

}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

Node T[MAX];
int n,D[MAX];

void print(int);
void rec(int,int);

int main() {

  int i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;

}

void print(int u) {

  int i,c,a=0;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  c = T[u].l;
  while(c!=NIL) {
    if(a>0) printf(", ");
    printf("%d",c);
    c = T[c].r;
    a++;
  }

  printf("]\n");

}

void rec(int u,int p) {
  
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
  
}


Measured memory_bytes: 6380
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<long long int,long long int> P;
int main(){
  int n;
  cin >> n;
  long long int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  vector <P> v;
  long long int d,cnt=1;
  for(int i=0;i<n-1;i++){
    if(cnt==1) d=a[i];
    if(d==a[i+1]) {
      cnt++;
      if(cnt>=2){
      if(i+1==n-1) v.push_back(make_pair(d,cnt));
    }
    }
    else{
      if(cnt>=2) v.push_back(make_pair(d,cnt));
      cnt=1;
    }
  }
    sort(v.begin(),v.end());
    int k=v.size();
    if(k==0) cout << 0 <<endl;
    else{
      for(int i=k-1;i>=0;i--){
        if(v[i].second>=4) {
          cout <<v[i].first*v[i].first<<endl;
          return 0;
        }
        else{
          cout <<v[i].first*v[i-1].first<<endl;
          return 0;
        }
      }
      }
    }


Measured memory_bytes: 2168
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int cnt=0;
  vector<int>vi;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(a>=n)
      cnt++;
    else
      vi.pb(a);
  }
  int ans=0;
  sort(vi.begin(),vi.end());
  while(cnt<m-1){
    cnt++;
    ans+=n-vi[vi.size()-1];
    vi.pop_back();
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3148
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	ll a, b, k;
	scanf("%lld%lld%lld", &a, &b, &k);
	ll tmp = a;
	a -= min(k, a);
	if (a) {
		k = 0;
	}
	else {
		k -= tmp;
	}
	b -= k;
	printf("%lld\n%lld\n", max(a, 0LL), max(b, 0LL));

	Please AC;
}


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

typedef long long ll;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //Älä käytä, jos tehtävä on interaktiivinen!
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i=0, j=n-1;
    int ans=0;
    while (true){
        while (s[i]=='R' && i<n) {
            i++;
        }
        while (s[j]=='W' && j>=0) {
            j--;
        }
        if (i<j) ans++;
        else break;
        i++;
        j--;
    }
    cout << ans << "\n";
}






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

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    int D,out=0;
    cin >> D;
    int c[26],s[D][26],t[D],l[26]={};
    for(int i=0;i<26;i++) cin >> c[i];
    for(int i=0;i<D;i++){
        for(int j=0;j<26;j++) cin >> s[i][j];
    }
    for(int i=0;i<D;i++) cin >> t[i];
    for(int i=0;i<D;i++){
        l[t[i]-1] = i+1;
        out += s[i][t[i]-1];
        for(int j=0;j<26;j++){
            out -= c[j] * (i + 1 - l[j]);
        }
        cout << out << endl;
    }

}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7;
const double PI = acos(-1);


int main (){
    int n, k;

    cin >> n >>k;

    vector<int> v(n + 1);
    vector<vector<int>> prefix(n+2, vector<int>(k + 2, 0));
    vector<vector<int>> suffix(n+2, vector<int>(k + 2, 0));
    
    prefix[0][0] = suffix[n+1][0] = 1;

    for (int i=1; i<=n; i++) cin >> v[i];
    
    for (int i=1; i<=n; i++){
        for (int j=0; j<=k; j++){
            prefix[i][j] |= prefix[i-1][j];
            if (j - v[i] >= 0 and prefix[i - 1][j - v[i]] == 1) prefix[i][j] |= 1;
            //cout << prefix[i][j] << " ";
        }
        //cout << endl;
    }

    //cout << endl;

    for (int i=n; i>=1; i--){
        for (int j=0; j<=k; j++){
            suffix[i][j] |= suffix[i+1][j];
            if (j - v[i] >= 0 and suffix[i + 1][j - v[i]]) suffix[i][j] |= 1;
            //cout << suffix[i][j] << " ";
        }
        //cout << endl;
    }

    //cout << endl;

    for (int i=1; i<=n; i++){
        for (int j=1; j<=k; j++) {
            suffix[i][j] += suffix[i][j-1];
            // cout << suffix[i][j] << " ";
        }
        // cout << endl;
    }

    int cnt = 0;

    for (int i=1; i<=n; i++){
        bool can = false;
        int l = k - v[i], r = k - 1;
        if (l < 0) continue;
        
        for (int j=0; j<=k; j++){
            if (prefix[i - 1][j] == 0) continue;
            if (l <= j and j <= r){
                can = true;
                break;
            }
            int nl = max(0, l - j), nr = r - j;
            if (nr < 0) break;
            int sub;
            if (nl == 0) sub = 0;
            else sub = suffix[i+1][nl - 1];
            if (suffix[i+1][nr] - sub > 0) {
                can = true;
                break;
            }
        }

        if (!can) {
            cnt++;
            // cout << i << " ";
        }
    }
    // cout << endl;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 196096
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    int K; cin >> K;

    int N = s.length();
    vector<int> appeared[26];
    for(int i=0; i<N; i++) {
        int c = s[i] - 'a';
        appeared[ c ].push_back(i);
    }

    for(int i=0; i<26; i++) {
        if(appeared[i].size() == 0) continue;
        int M = appeared[i].size();
        set<string> vs;

        for(auto x : appeared[i]) {
            for(int k=1; k<=5; k++) {
                int lim = x + k - 1;
                if(lim >= N) continue;
                // printf("appear = %lld, substr: %s\n", x, s.substr(x, k).c_str());
                vs.insert(s.substr(x, k));
            }
        }

        if(vs.size() >= K) {
            int itr = 0;
            for(auto x : vs) {
                itr++;
                if(itr == K) {
                    cout << x << endl;
                    return 0;
                }
            }
        }
        K -= vs.size();
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  int a,b,t;cin>>a>>b>>t;

  //caricurate
cout<<(b*(t/a))<<endl;


  //output


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

vector<int>v;  
vector<bool>vis;
vector<int>ans;


int main()
{
    int n;
    lli k;
    cin >> n >> k;
    v.resize(n);
    for(int i=0;i<n;i++)
    {
        int x;
        cin >>x;
        x-=1;
        v[i]=x;
    }
    vis.resize(n,false);
    int p=0;
    while (!vis[p])
    {
        ans.push_back(p);
        vis[p]=true;
        p=v[p];
    }
    int ind=0;
    for(int i=0;i<ans.size();i++)
    {
        if(ans[i]==p)
        {
            ind=i;
            break;
        }
    }
    // for(int i=0;i<ans.size();i++)
    //     cout << ans[i] << " ";
    // cout << endl;
    int cl=ans.size()-ind;
    if(k<ans.size())
        cout << ans[k]+1 << endl;
    else
    {
        vector<int>ans1;
        for(int i=ind;i<ans.size();i++)
            ans1.push_back(ans[i]);
        k-=ind;
        int r=k%cl;
        cout << ans1[r]+1 << endl;
    }
}

Measured memory_bytes: 5976
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, b[99], a[100];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n - 1; i++) cin >> b[i];
	a[n - 1] = b[n - 2];
	for(int i = n - 2; i >= 0; i--)
		if(i == 0) a[i] = b[i];
		else a[i] = min(b[i - 1], max(b[i], a[i + 1]));
	int sum = 0;
	for(int i = 0; i < n; i++) sum += a[i];
	cout << sum << "\n";
	return 0;
}

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const ll INF = 1e9;
const ll INFF = 1e18;
const ll MAXN = 510;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

ll frek[200010];
ll tab[200010];

ll cnt(ll x)
{
    return (x * (x - 1)) / 2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    for (ll i = 1 ; i <= n ; i++)
    {
        cin >> tab[i];
        frek[tab[i]]++;
    }
    ll tot = 0;
    for (ll i = 1 ; i <= n ; i++)
    {
        tot += cnt(frek[i]);
    }
    // cout << tot << endl;
    for (ll i = 1 ; i <= n ; i++)
    {
        ll oldVal = cnt(frek[tab[i]]);
        ll newVal = cnt(frek[tab[i]] - 1);
        ll tmp = tot;
        ll delta = newVal - oldVal;
        // cout << i << ": " << delta << endl;
        cout << tot + delta << endl;
    }
    return 0;
}

Measured memory_bytes: 6696
// C - Candles
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vector<int> X(N); rp(i,0,N) cin>>X[i];
	int ans = INT_MAX;
	rp(ir,K-1,N){
		int il = ir - (K-1), l = X[il], r = X[ir];
		if(0 < l) l = 0;
		if(r < 0) r = 0;
		l = abs(l); r = abs(r);
		if(l > r) swap(l, r); // l: small, r: large
		ans = min(ans, l*2 + r);
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int MAXN = 100500;

vector <pair <int, int> > events;
int n;

int main()
{                                                     
	ios_base::sync_with_stdio(0);
	
	cin >> n;
	events.resize(2 * n);

	for (int i = 0; i < n; i++)
	{
		int val;
		cin >> val;
		events[2 * i + 1] = {val - 1, 1};
		events[2 * i] = {val + 2, -1};
	}

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

	int ans = 0;
	int cur = 0;

	for (int i = 0; i < 2 * n; i++)
	{
		cur += events[i].second;
		ans = max(ans, cur);
	}

	cout << ans << '\n';
	
	return 0;
}


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

int main()
{
    long long int n,ar[113],i,flag = 0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    for(i=2;i<n;i++)
    {
        if((ar[i]>ar[i-1] && ar[i]<ar[i+1]) || (ar[i]>ar[i+1] && ar[i]<ar[i-1]))
        {
            flag++;
        }
    }
    cout<<flag<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int baris,kolom;
char petas[15][15];
bool sudahkol[15],sudahbar[15],ans=false;
vector <int> kiri,kanan;
bool check(){
	for(int i=0;i<baris;i++)
		sudahbar[i]=false;
	int kesempatan=(baris&1)?1:0;
	for(int i=0;i<baris;i++)
	{
		if(sudahbar[i])
			continue;
		
		sudahbar[i]=true;
		bool dapet=false;
		for(int j=i+1;j<baris;j++)
		{
			if(sudahbar[j])
				continue;
			bool bisadenganini=true;
			for(int k=0;k<kiri.size();k++)
			{
				if(petas[i][kiri[k]]!=petas[j][kanan[k]])
					bisadenganini=false;
				if(petas[i][kanan[k]]!=petas[j][kiri[k]])
					bisadenganini=false;
			}
			if(bisadenganini)
			{
				dapet=true;
				sudahbar[j]=true;
				break;
			}
		}
		
		if(!dapet)
		{
			bool bisadenganini=true;
			for(int k=0;k<kiri.size();k++)
				if(petas[i][kiri[k]]!=petas[i][kanan[k]])
					bisadenganini=false;
			if(bisadenganini&&kesempatan)
				kesempatan--;
			else
				return false;
		}
	}
	assert(kesempatan==0);
	return true;
}
void BF(int sisa){
	if(sisa&1)
	{
		for(int i=0;i<kolom;i++)
		{
			if(sudahkol[i])
				continue;
			kiri.pb(i);
			kanan.pb(i);
			sudahkol[i]=true;
			BF(sisa-1);
			if(ans)
				return;
			sudahkol[i]=false;
			kiri.pop_back();
			kanan.pop_back();
		}
	}
	else if(sisa>=2)
	{
		int terkecil=-1;
		for(int i=0;i<kolom;i++)
		{
			if(sudahkol[i])
				continue;
			if(terkecil==-1)
				terkecil=i;
			else
			{
				sudahkol[terkecil]=sudahkol[i]=true;
				
				kiri.pb(terkecil);kanan.pb(i);
				BF(sisa-2);
				if(ans)	return;
				kiri.pop_back();kanan.pop_back();
				
				sudahkol[terkecil]=sudahkol[i]=false;
			}
		}
	}
	else
	{
		if(check())
			ans=true;
	}
}
int main()
{
	memset(sudahkol,false,sizeof(sudahkol));
	memset(sudahbar,false,sizeof(sudahbar));
	
	scanf("%d%d",&baris,&kolom);
	for(int i=0;i<baris;i++)
		scanf("\n%s",&petas[i]);
	BF(kolom);
	if(ans)
		printf("YES\n");
	else
		printf("NO\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll N,C; cin >> N >> C;
  vector<vll> line(C, vll(100005));
  rep(i,N) {
    ll s,t,c; cin >> s >> t >> c;
    c--;
    line[c][s-1]++;
    line[c][t]--;
  }
  rep(i, 100003) {
    rep(c, C) {
      line[c][i+1] += line[c][i];
    }
  }
  ll ans = 0;
  rep(i, 100003) {
    ll num = 0;
    rep(c, C) {
      // if start time of one is the same as the end time of anohter, line[c][i] could be 2 and it's ok
      if (line[c][i] == 2) num--;
      num += line[c][i];
    }
    chmax(ans, num);
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 27508
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }


LL from[3030],to[3030];
LL S[3030];

const LL MOD = 1000000007;


int main() 
{
	int N;
	string s;	
	
	cin >> N >> s;
	
	rep(i, N) from[i]=1;
	
	rep(i, N-1) {
		memset(to, 0, sizeof(to));
		rep(x, N) S[x] = ((x ? S[x-1] : 0) + from[x]) % MOD;
		rep(x, N-1-i) {
			if (s[i]=='>') {
				to[x] = (S[N-1] - S[x] + MOD) % MOD;
			} else {
				to[x] = S[x];
			}
		}
		swap(from, to);
	}
	
	cout << from[0] << endl;
	return 0;
}


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

int main(){
  string N;
  cin >> N;
  bool No = true;
  
  for(int i=0; i<3 ; i++){
    
    if( N.at(i) == '7' ){
      No = false;
      cout << "Yes" << endl;
      break;}
  }
  
  if(No){
    cout << "No" << endl;}
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 2 * 1e5;

int main() {
  std::string S;
  std::cin >> S;

  static int dp[MAX_N][2] = {};
  dp[0][0] = 1;
  dp[0][1] = 1;
  for(int i = 1; i < (int)S.length(); ++i) {
    int cand1 = 0, cand2 = 0;
    if(S[i - 1] != S[i]) {
      dp[i][0] = std::max(dp[i][0], dp[i - 1][0] + 1);
    }
    if(i - 2 >= 0) {
      dp[i][0] = std::max(dp[i][0], dp[i - 2][1] + 1);
    }

    if(i + 1 < (int)S.length()) {
      dp[i][1] = std::max(dp[i][1], dp[i - 1][0] + 1);
      if(i - 2 >= 0 and S.substr(i - 2, 2) != S.substr(i, 2)) {
        dp[i][1] = std::max(dp[i][1], dp[i - 2][1] + 1);
      }
    }
  }

  int ans = dp[(int)S.length() - 1][0];
  if((int)S.length() >= 2) {
    ans = std::max(ans, dp[(int)S.length() - 2][1]);
  }
  std::cout <<  ans << '\n';
}


Measured memory_bytes: 2180
N, K = map(int, open(0).read().split())

MOD = 10 ** 9 + 7
dp = [[[0] * (K + 1) for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1

for i in range(1, N + 1):
    for j in range(N + 1):
        for k in range(K + 1):
            if k - 2 * j >= 0:
                dp[i][j][k] = (2 * j + 1) * dp[i - 1][j][k - 2 * j]
                
                if j < N:
                    dp[i][j][k] += (j + 1) ** 2 * dp[i - 1][j + 1][k - 2 * j]
                if j > 0:
                    dp[i][j][k] += dp[i - 1][j - 1][k - 2 * j]
            dp[i][j][k] %= MOD
                    
print(dp[N][0][K])

Measured memory_bytes: 95196
import sys

def main():
    def input():
        return sys.stdin.readline()[:-1]
    N = int(input())
    a = list(map(int,input().split()))
    ans = 1000000
    for k in range(-100,101):
        t = 0
        for e in a:
            t += (e-k)**2
        ans = min(ans,t)
    print(ans)
if __name__ == '__main__':
    main()


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main() {
    ll a,b,k;
    cin >>a>>b>>k;
    ll aa,ab;
    aa= max(a-k,0LL);
    k-=a;
    ab=b;
    if(k>0){
        ab=max(0LL,ab-k);
    }
    cout <<aa<<" "<<ab<<endl;
    return 0;
}



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


const int NMAX=1E5;

int main(){

    int N;
    cin >> N;
    vector<vector<int> > A (3,vector<int> (N));
    for (int i=0;i<3;i++){
        for (int j=0;j<N;j++){
            scanf("%d",&A[i][j]);
        }
        sort(A[i].begin(),A[i].end());
    }
    vector<vector<long> > acum(3,vector<long> (N));
    for (int i=0;i<N;i++) acum[2][i] = N-i;

    for (int i=1;i>=0;i--){
        int j = N-1;
        auto Cit = A[i+1].end();
        Cit = upper_bound(A[i+1].begin(),Cit,A[i][j]);
        if (Cit!=A[i+1].end())
            acum[i][j--] = acum[i+1][Cit-A[i+1].begin()];
        else
            acum[i][j--] = 0;
   //     cout << acum[i][j+1] << endl;
        while (j>=0){
            Cit = upper_bound(A[i+1].begin(),Cit,A[i][j]);
            if (Cit!=A[i+1].end())
                acum[i][j] = acum[i][j+1] + acum[i+1][Cit-A[i+1].begin()];
            else
                acum[i][j] = acum[i][j+1];
     //       cout << acum[i][j] << endl;
            j--;
        }
    }
    cout << acum[0][0];
}


Measured memory_bytes: 4600
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

A = Counter(V[0::2]).most_common(2)
B = Counter(V[1::2]).most_common(2)

A.append((0, 0))
B.append((0, 0))

a_value, a_count = A[0]
a2_value, a2_count = A[1]
b_value, b_count = B[0]
b2_value, b2_count = B[1]

if a_value != b_value:
    ans = n - a_count - b_count
else:
    ans = min(n-a_count-b2_count, n-a2_count-b_count)

print(ans)

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

int main(){
    ll n = 0;
    cin >> n;
    
    // int count = 1;
    // ll a,b = 0;
    // a = 26;
    // while(a<n || n<=b){
    //     b = a;
    //     a = (a+1)*26;
    //     count++;
    // }
    // ll m = n-b-1;
    // vector<char> v(count);
    // int ch = 0;
    // ll dummy;
    // string alphabet = "abcdefghijklmnopqrstuvwxyz";
    // rep(i,count){
    //     dummy = pow(26,count-i-1);
    //     ch = m / dummy;
    //     m = m % dummy;
    //     v[i] = alphabet[ch];
    // }
    // rep(i,count)cout << v[i];
    // cout <<endl;
    vector<char> v(15);
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    int i = 0;
    int ch =0;
    while(n > 0){
        n--;
        ch = n % 26;
        n /= 26;
        v[i] = alphabet[ch];
        i++;
    }
    rep(j,i)cout << v[i-1-j];
    cout << endl;
    
}

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

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

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

  int prev = a[0];
  int cont = 1, ans = 0;
  for (int i = 1; i < n; ++i) {
    if (prev == a[i]) ++cont;
    else {
      ans += cont / 2;
      cont = 1;
      prev = a[i];
    }
  }
  ans += cont / 2;
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define DB long double
#define LDB long double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define rint register int 
namespace IO{
	const int BS=(1<<23)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout),OS=OT;}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush();}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	inline LL read(){
		LL nm=0; bool fh=true; char cw=getchar();
		for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
		return fh?nm:-nm;
	}
} using namespace IO;
#define mod 1000000007
namespace CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
	inline void dec(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
	inline int qpow(int x,LL sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
#define M 5020
int n,a[M],m,p[M],fs[M],nt[M],to[M],tmp;
int tg[M],sz[M],ot,ans,F[M],fac[M],pw[M];
inline void link(int x,int y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
inline void dfs(int x){
	tg[x]=-1,++sz[m];
	for(int i=fs[x];i!=-1;i=nt[i]) dfs(to[i]);
}
int TIM;
inline bool fd(int x){
	++TIM;
	while(!tg[x]) tg[x]=TIM,x=p[x]; if(tg[x]!=TIM||x==-1) return false;
	return true;
}
int main(){
	n=read(),memset(fs,-1,sizeof(fs)),fac[0]=pw[0]=1;
	for(int i=1;i<=n;i++) p[i]=read(),fac[i]=mul(i,fac[i-1]),pw[i]=mul(pw[i-1],n-1);
	for(int i=1;i<=n;i++) if(p[i]!=-1) link(p[i],i);
	for(int i=1;i<=n;i++) if(p[i]==-1) ++m,dfs(i);
	for(int i=1;i<=n;i++) if(fd(i)) ++ot;
//	debug(ot)el;
	ans=mul(mns(n,ot),qpow(n-1,m)),F[0]=1;
//	debug(ans)el;
	for(int i=1;i<=m;i++) for(int k=i-1;k>=0;--k) upd(F[k+1],mul(F[k],sz[i]));
	for(int i=2;i<=m;i++) dec(ans,mul(F[i],mul(pw[m-i],fac[i-1])));
	for(int i=1;i<=m;i++) dec(ans,mul(pw[m-1],sz[i]-1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3980
#include <iostream>
#include <cstdio>
using namespace std;
const int N=1e6+10;
int a[N],n;
int binarysearch(int key)
{
    int left=0;
    int right=n;
    int mid;
    while(left<right)
    {
        mid=(left+right)/2;
        if(key==a[mid]) return 1;
        if(key>a[mid]) left=mid+1;
        else if(key<a[mid]) right=mid;
    }
    return 0;
}
int main()
{
    int i,q,key,sum=0;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    cin>>q;
    for(i=0;i<q;i++)
    {
        cin>>key;
        if(binarysearch(key))
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std; 
#define priority_queue pq
#define pu push
#define loop for(int i=0;i<n;i++)
int ar[100001];
int32_t  main()
{ 
	int n;
	int k;
	cin>>k>>n;
	int sum=0;
	loop
	{
		int a;
		cin>>a;
		sum+=a;
	}
	if(sum>k)
	cout<<"-1";
	else
	cout<<k-sum;
}


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

const int M = 1000005;

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

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

    vector<int> count(M);

    for (int x : a) {
        if (count[x] != 0) {
            count[x]++;
            continue;
        }
        for (int j = x; j < M; j += x) {
            count[j]++;
        }
    }

    int ans = 0;
    rep(i,n) {
        if (count[a[i]] == 1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7848
//g++ -std=c++17 -Wall t.cpp -o test -g -O2
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'
#define teto(a, b) (a+b-1)/(b)
 
const int MAX = 1000010;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-6;
const ld PI = acos(-1.0);

using namespace std;

// End - Template //

int main()
{sws;
    
    int m[1010];
    int n, x;
    cin >> n >> x;
    ll sum=0;
    int mm = INF;
    for(int i=0;i<n;i++){
        cin >> m[i];
        sum+=m[i];
        mm = min(mm, m[i]);
    }

    cout << n + (x-sum)/mm << endl;
    


    
    return 0;
}

Measured memory_bytes: 3668
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
#define inf 0x7fffffff
ll ans;
int main()
{
	ll a,b;
	cin>>a>>b;
	for(ll i=a;i<=b;i*=2) ans++;
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
enemies = list(map(int, input().split()))
heros = list(map(int, input().split()))

enemy = enemies[0]
count = 0
diff = 0

for i in range(n):
    enemy = enemies[i]

    kill = min(enemy, diff)
    count += kill
    enemy -= kill

    kill = min(enemy, heros[i])
    count += kill
    diff = heros[i] - kill

count += min(enemies[n], diff)
print(count)

Measured memory_bytes: 19116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll T1,T2;cin >> T1 >> T2;
  ll A1,A2;cin >> A1 >> A2;
  ll B1,B2;cin >> B1 >> B2;
  A1 *= T1;
  B1 *= T1;
  A2 *= T2;
  B2 *= T2;
  ll A = A1+A2;
  ll B = B1+B2;

  if(A == B){
    cout << "infinity" << endl;
    return 0;
  }
  if(A<B){
    swap(A,B);
    swap(A1,B1);
    swap(A2,B2);
  }
  if(A1>B1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2*((B1-A1)/(A-B));
  if((B1-A1)%(A-B) != 0) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

i = 1
K = []
while(1):
    k = i * (i+1) // 2
    if k > 10**5:
        break
    K.append(k)
    i+=1
if not N in K:
    print ('No')
    exit()
print ('Yes')
S = [[],[]]
i = 0

for n in range(1,N+1):
    S[i].append(n)
    S[-1].append(n)
    i+=1
    if n in K:
        if n==N:
            break
        i = 0
        S.append([])
print(len(S))
for s in S:
    print(str(len(s)) + ' ' + ' '.join(map(str,s)))


Measured memory_bytes: 9076
#include <iostream>
#include <cstdlib>

using namespace std;

int main (void)
{
    int n, m, *t, *ans;

    cin >> n;
    t = (int *)malloc(sizeof(int) * n);
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }

    cin >> m;
    ans = (int *)malloc(sizeof(int) * m);
    for (int i = 0; i < m; i++) {
        int p, x, sum = 0;
        cin >> p >> x;
        p--;
        for (int j = 0; j < n; j++) {
            if (j == p) {
                sum += x;
            } else {
                sum += t[j];
            }
        }
        ans[i] = sum;
    }

    for (int i = 0; i < m; i++) {
        cout << ans[i] << endl;
    }

    free(ans);
    free(t);
    return 0;
}

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

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    int X[N + 1][D];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int sum = 0;
            for (int k = 0; k < D; ++k) {
                int a = abs(X[i][k] - X[j][k]);
                sum += a * a;
            }
            double b = sqrt(sum);
            if (floor(b) == b) ans++;
        }

    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int X,Y;
  int N,M;
  int x=-1000,y=1000;
  cin >> N >> M >> X >> Y;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    x=(tmp>x ?tmp : x);
  }
  for(int i=0;i<M;i++){
    int tmp;
    cin >> tmp;
    y=(tmp<y ?tmp : y);
  }
  if(x<y && X<y && x < Y){
    cout << "No War";
    return 0;
  }
  cout << "War";
  return 0;
  
  
  
  
}

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

using namespace std;

#define ll long long

const int INF = 1e9+9999;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, sum = 0;
    cin >> n;
    vector <int> a(n);
    vector <int> b(n);
    vector <int> c(n-1);

    for (auto& elem:a)
        cin >> elem;
    for (auto& elem:b)
        cin >> elem;
    for (auto& elem:c)
        cin >> elem;

    for (int i=0; i<n; ++i) {
        int u = a[i];
        int v = 100;
        if (i+1 < n)
            v = a[i+1];
        sum += b[u-1];
        if (v == u + 1)
            sum += c[u-1];
    }

    cout << sum;

}

Measured memory_bytes: 256
/*
*/

#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 337

using namespace std;

const int INF = 1e9;
const int N = 2201231;

long long n, a;

long long temp[N];

void make_array(long long s, int n)
{
	for (int i = 1; i <= n; i++)
	{
		temp[i] = s / n;
		if (i <= s%n)
			temp[i]++;
	}
}

long long get_prod(long long r)
{
	long long res = 1;
	for (int i = 1; i <= r; i++)
	{
		if (temp[i] == 0)
			return 0;
		if (1e18 / temp[i] < res)
			return 1e18;
		res *= temp[i];
	}
	return res;
}

long long solve(long long R)
{
	long long res = R + a;

	for (int times_a = 1; times_a <= 60; times_a++)
	{
		long long l, r;
		l = 0;
		r = 1e15;
		while (l < r)
		{
			long long mid = l + r;
			mid /= 2;
			make_array(mid, times_a);
			long long P = get_prod(times_a);
			if (P >= R)
				r = mid;
			else
				l = mid + 1;
		}
		res = min(res, l + 1ll * times_a*a);
	}
	return res;
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/input.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n >> a;
	cout << solve(n) - a << endl;

	cin.get(); cin.get();
	return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

#define MAX 510000
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int 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()
{
    ll N,M;
    cin >> N >> M;
    COMinit();

    ll n = 1;
    REP(i, 1, N)
    {
        n *= COM(i+1, i);
        n %= MOD;
    }

    ll m = 1;
    REP(i, 1, M)
    {
        m *= COM(i+1, i);
        m %= MOD;
    }
    
    if( abs(N-M) > 1 ) cout << 0 << endl;
    else if( N==M ) cout << n * m * 2%MOD << endl;
    else cout << n*m%MOD << endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
int main (){
  int a,b,c,k; cin >> a>>b>>c >>k;
  int f=0;
  while (b<=a){
    f++;
    b*=2;
  }
  while (c<=b){
    f++;
    c*=2;
  }
  if (f<=k)cout << "Yes" ;
  else cout << "No";
}

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	int now = 0;
	for(int i=0; i<s.size(); i++){
		if(s.at(i) == 'I'){
			now++;
		}else{
			now--;
		}
		ans = max(ans, now);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<math.h>
#include <iomanip>
using namespace std;

int main(){
    int N;
    long Y;
    cin >> N >> Y;
    int A, B, C;
    bool frag=false;
    
    for(A=0; A<=N; A++){
        for(B=0; B<=N; B++){
            C=N-A-B;
            if(10000*A+5000*B+1000*C==Y&&C>=0){
                frag=true;
                cout << A << " " << B << " " << C << endl;
                break;
            }
        }
        if(frag==true){
            break;
        }
    }
    if(frag==false){
        cout << "-1 -1 -1" << endl;
    }
    
    
    

    return 0;
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

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

	int k;
	cin>>k;
	if (k<10){
		cout<<k<<endl;
		return 0;
	}
	queue<int> q;
	forn(i,1,10)
		q.push(i);
	int cnt=0;
	while (!q.empty()){
		int x=q.front();
		q.pop();
		cnt++;
		if (cnt==k){
			cout<<x<<endl;
			return 0;
		}
		int y=x%10;
		forn(i,y-1,y+2){
			if (i<0 || i>=10) continue;
			q.push(x*10+i);
		}
	}
	return 0;
}

Measured memory_bytes: 4764
#include <iostream>

int main(){
  int num, lim;
  int t_score = 0, h_score = 0;
  std::string t_card, h_card;

  std::cin >> num;
  for(int i=0; i<num; i++){
    std::cin >> t_card >> h_card;
    if(t_card == h_card){
      t_score += 1;
      h_score += 1;
      continue;
    }

    if(t_card.size() < h_card.size()) lim = t_card.size();
    else lim = h_card.size();

    for(int j=0; j<lim; j++){
      if(t_card[j]==h_card[j]){
        if(j == lim-1 && t_card.size() < h_card.size()) h_score += 3;
        else if(j == lim-1 && t_card.size() > h_card.size()) t_score += 3;
        else continue;
      }

      else if((int)t_card[j] > (int)h_card[j]){
        t_score += 3;
        break;
      }

      else{
        h_score += 3;
        break;
      }

    }
  }

  std::cout << t_score << ' ' << h_score << std::endl;
}



Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {

	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int N = in.nextInt();
		long min = Long.MAX_VALUE;
		long max = Long.MIN_VALUE;
		for (int i = 0; i < N; i++) {
			long A = in.nextLong();
			min = Long.min(min, A);
			max = Long.max(max, A);
		}
		System.out.println(max - min);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

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

    map<int, int> mp;

    rep(i, k)
    {
        int d;
        cin >> d;
        vector<int> a(d);
        rep(j, d) cin >> a.at(j);

        rep(j, d)
        {
            mp[a.at(j)]++;
        }
    }

    cout << n - int(mp.size()) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
 
 
 
int main() {
    int n;
    scanf("%d",&n);
    ll x;
    scanf("%lld",&x);

    // バーガーの層の枚数
    ll a[n+1] = {};
    ll aa = 1;
    a[0] = 1;
    srep(i, 1, n+1){
        a[i] = a[i-1] * 2 + 3;
    }

    // パティの層の枚数
    ll b[n+1] = {};
    ll bb = 1;
    b[0] = 1;
    srep(i, 1, n+1){
        b[i] = b[i-1] * 2 + 1;
    }   

    ll ans = 0;

    // 二分探索
    for(int i = n; i >= 0; --i){
        if(i == 0){
            ans++;
            break;
        }
        if(x == 1){
            ans += 0;
            break;
        }else if(x < 1 + a[i-1] + 1){
            x = x - 1;
        }else if(x == 1 + a[i-1] + 1){
            ans += b[i-1] + 1;
            break;
        }else if(x < a[i]){
            ans += b[i-1] + 1;
            x = x - (1 + a[i-1] + 1);
        }else if(x == a[i]){
            ans += b[i];
            break;
        }
    }

    cout << ans << endl;
   
    return 0;
}
 
 

Measured memory_bytes: 256