akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
const int MAX=50;
//???????????§???????????¬
int main(){
	int N,M,r;
	cin>>N>>M>>r;
	//???????????±
	vll s,t,c;
	//???????????¢
	vll dist;
	//???????????¢??????????????????
	//????????????INF?????\???????????¨????§??????????0???
	for(int i=0;i<N;i++){
		dist.pb(INFLL);
	}
	dist[r]=0;
	for(int i=0;i<M;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		//x--,y--;
		s.pb(x);
		t.pb(y);
		c.pb(z);
	}
	//???????????¢?????´??°???N-1?????????
	for(int loop=0;loop<N-1;loop++){
		for(int i=0;i<M;i++){
			if(dist[s[i]]==INFLL)
				continue;
			if(dist[t[i]]>dist[s[i]]+c[i]){
				dist[t[i]]=dist[s[i]]+c[i];
			}
		}
	}
	//??????????????????????????????????????????
	vector<bool> negative;
	for(int i=0;i<N;i++){
		negative.pb(0);
	}
	//???????????¢?????´??°???N?????°?????????
	//????????§??´??°???????????¨???????????¨????????????????????¨???????????¨?????????
	//??´??°??????????????????negative???true???
	for(int loop=0;loop<N;loop++){
		for(int i=0;i<M;i++){
			if(dist[s[i]]==INFLL)
				continue;
			if(dist[t[i]]>dist[s[i]]+c[i]){
				dist[t[i]]=dist[s[i]]+c[i];
				negative[t[i]]=1;
			}
			if(negative[s[i]]==1){
				negative[t[i]]=1;
			}
		}
	}

	for(int i=0;i<N;i++)
		if(negative[i]==1){
			cout<<"NEGATIVE CYCLE"<<endl;
			return 0;
		}
	for(int i=0;i<N;i++){
		if(dist[i]==INFLL)
			cout<<"INF"<<endl;
		else
			cout<<dist[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3216
#include <iostream>

using namespace std;
int main()
{
    int k,a,b;
    cin >> k >> a >>b;
    int rem = a % k;
    if(rem == 0){
        cout << "OK" << endl;
    }
    else if((a - rem + k) >= a && (a - rem + k) <= b){
        cout << " OK" << endl;
    }else
    {
        cout << "NG" << endl;
    }
     
    return 0;
}

Measured memory_bytes: 3052
#include <iostream>
int main(){
  using namespace std;
  int a,b,x;
  cin >> a >> b;
  x = a+b;
  if(x%2==0){
    x = x/2;
  }else{
    x = (x+1)/2;
  }
  cout << x << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  sort(ALL(v));
  ll res = 0;
  rep(i,k)res += v[i];
  cout << res << endl;


  



  return 0;
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

long long int d[114514] = {};

int main() {

    long long int n;
    cin >> n;

    long long int k;
    long long int ma = 0;
    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        d[in]++;
        if ( i == 0 ) k = in;
        ma = max( ma, in );
    }
    if ( k != 0 || d[0] != 1 ) {
        cout << 0 << endl;
        return 0;
    }

    long long int ans = 1;
    for ( long long int i = 1; i <= ma; i++ ) {
        for ( long long int j = 0; j < d[i]; j++ ) {
            ans *= d[i-1];
            ans %= 998244353;
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1024
/* https://atcoder.jp/contests/abc076/tasks/abc076_c */

#include <iostream>
#include <vector>

/* {{{ Variables */
std::string S, T;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> S >> T;
  /* }}} */

  /* {{{ Output */
  for (int i = S.length()-T.length(); i >= 0; --i) {
    std::string sub_S = S.substr(i, (int)T.length());

    for (int j = 0; j < (int)sub_S.length(); ++j) {
      char s = sub_S.at(j);
      char t = T.at(j);

      if (!(s == t || s == '?')) {
        break;
      }

      if (j == (int)sub_S.length()-1) {
        std::string SS = "";

        for (int k = 0; k < (int)S.length(); ++k) {
          char ss = S.at(k);

          if (ss != '?') {
            SS += ss;
            continue;
          }

          int sub_head_idx = i;
          int sub_tail_idx = i + j;

          if (k >= sub_head_idx && k <= sub_tail_idx) {
            SS += T.at(k-sub_head_idx);
          } else {
            SS += "a";
          }
        }

        std::cout << SS << std::endl;
        return 0;
      }
    }
  }

  std::cout << "UNRESTORABLE" << std::endl;
  /* }}} */

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>;
#define vi vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false);
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always

int main() {
    ios
    
    int n, m; cin >> n >> m;
    //最大でもn * m個?
    //lcm
    int num = lcm(n, m) / m;
    int a[n]; rep(i, n) cin >> a[i];
    
    int ans = 0;
    int now = 0;
    rep(i, num) {
        int l = -inf, s = inf;
        rep(j, m) {
            chmax(l, a[now]);
            chmin(s, a[now]);
            (now += 1) %= n;
        }
        ans += l - s;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3224
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal


from numba import jit

@jit
def run_dp(MAP, dp, Rs, Cs):
    for i in range(1, len(Rs)+1):
        for j in range(1, len(Cs)+1):
            for k in range(4):
                dp[i,j,0] = max(dp[i,j,0], dp[i-1,j,k])
                if MAP[i,j]:
                    dp[i,j,1] = max(dp[i,j,1], dp[i-1,j,k]+MAP[i,j])

                dp[i,j,k] = max(dp[i,j,k], dp[i,j-1,k])
                if MAP[i][j] and k < 3:
                    dp[i,j,k+1] = max(dp[i,j,k+1], dp[i,j-1,k] + MAP[i,j])
    return dp[len(Rs), len(Cs)].max()

def run():
    R,C,K = map(int, sysread().split())
    Rs = set()
    Cs = set()
    vals = []
    for i in range(K):
        r, c, v = map(int, sysread().split())
        vals.append((r, c, v))
        Rs.add(r)
        Cs.add(c)
    #Rs = sorted(list(Rs))
    Rs = np.array(sorted(list(Rs)))
    #Cs = sorted(list(Cs))
    Cs = np.array(sorted(list(Cs)))
    r_idx = {r:i+1 for i, r in enumerate(Rs)}
    c_idx = {c:i+1 for i, c in enumerate(Cs)}
    #MAP = [[0] * (len(Cs)+1) for _ in range(len(Rs)+1)]
    MAP = np.zeros((len(Rs)+1, len(Cs)+1), dtype= np.int64)
    for r,c,v in vals:
        rn = r_idx[r]
        cn = c_idx[c]
        MAP[rn][cn] = v

    #dp = [[[0] * 4 for _ in range(len(Cs)+1)] for i in range(len(Rs)+1)]
    dp = np.zeros((len(Rs)+1, len(Cs)+1, 4), dtype= np.int64)

    run_dp(MAP, dp, Rs, Cs)

    #print(dp)
    #for m in MAP:
    #   print(m)
    ans= run_dp(MAP, dp, Rs, Cs)

    print(ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 501808
N = int(input())
ss = list(input() for _ in range(N))
ans = 0
a_end = 0
b_start = 0
both = 0
for si in ss:
    ans += si.count("AB")
    if si[0]=="B" and si[-1]=="A":
        both += 1
    elif si[0]=="B":
        b_start += 1
    elif si[-1]=="A":
        a_end += 1

if both > 0:
    ans += both - 1
    if max(a_end, b_start)>0:
        ans += 1
ans += min(a_end, b_start)
print(ans)


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

int n,m,z;
bool p[1001];
int main(void){
	while(1){
		memset(p,true,sizeof(p));
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		z=n;
		int c=0,d=0;
		while(1){
			if(p[d]==false)d++;
			else if(m==c){
				p[d]=false;
				z--;
				//printf("%d\n",d);
				if(z==1)break;
				c=1;
				d++;
			}else{
				d++;
				c++;
			}
			if(d==n+1)d=1;
		}
		for(int i=1;i<=n;i++)if(p[i]==true)printf("%d\n",i);
	}
    return 0;
}

Measured memory_bytes: 0
require 'prime'
N = 500

primes = Prime.each(10000).to_a
ans = Array.new(N+1){Array.new(N+1, 1)}

N.times do |i|
    N.times do |j|
        if (i+j)%2 == 0
            ans[i][j] *= primes[(i+j)/2] * primes[(i-j+N-1)/2+N]
        end
    end
end

N.times do |i|
    N.times do |j|
        if (i+j)%2 == 1
            [[i+1, j], [i-1, j], [i, j-1], [i, j+1]].each do |x, y|
                ans[i][j] = ans[i][j].lcm(ans[x][y])
            end
            ans[i][j] += 1
        end
    end
end

n = gets.to_i
n.times do |i|
    puts ans[i][0, n].join(' ')
end

Measured memory_bytes: 7420
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int func(int n) {
    if (n % 2 == 0) {
        return n / 2;
    } else {
        return (3 * n + 1);
    }
}
int main() {
    int s, count = 1;
    cin >> s;
    set<int> num;
    num.insert(s);
    while (true) {
        int out = func(s);
        // cout << s << endl;
        count++;
        if (num.count(out) == 1) {
            cout << count << endl;
            return 0;
        }
        num.insert(out);
        s = out;
    }
    return 0;
}

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

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

ll n;
pair<P,P> PP[100];

pair<P,P> multiple(pair<P,P> A,pair<P,P> B)
{
	pair<P,P> C;
	P p = A.first,q = A.second;
	P r = B.first,s = B.second;
	C.first = P((p.first*r.first+p.second*s.first),(p.first*r.second+p.second*s.second));
	C.second = P((q.first*r.first+q.second*s.first),(q.first*r.second+q.second*s.second));
	return C;
}

int main()
{
	int cnt=0;
	scanf("%lld",&n);
	if(n==0){
		printf("1\n");
		return 0;
	}else if(n==1){
		printf("1\n");
		return 0;
	}
	n;
	ll buff = n;
	while(buff != 1){
		buff /= 2;
		cnt++;
	}
	PP[0].first = P(0,1);
	PP[0].second = P(1,1);
	rep(i,cnt){
		PP[i+1] = multiple(PP[i],PP[i]);
	}
	pair<P,P> res;
	res.first = P(1,0);
	res.second = P(0,1);
	rep(i,cnt+1){
		if(n & (1 << i)){
			res = multiple(res,PP[i]);
		}
	}
	printf("%d\n",res.second.second);
	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

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

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	ll a,b,n;
    	cin>>a>>b>>n;
    	ll max=INT_MIN;
    	if(b==1)
    	{
    		cout<<0<<endl;
    		return 0;
    	}
    	if(b<=n)
    	{
    		ll value;
    		// deb(value);
    		 value=((a*(b-1))/b)-(a*((b-1)/(b)));
    		 cout<<value<<endl;
    		 // continue;
    		return 0;
    	}
    	ll value=((a*(n))/b)-(a*((n)/(b)));
    	cout<<value<<endl;

    	
    	
    }
    return 0;
}

Measured memory_bytes: 3652
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def divisor_pairs(n):
    res = set()
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            a,b = i,n//i
            res.add((a,b))
    res = list(res)
    res.sort()
    return res

def main():
    """ main """
    N = int(input())
    pairs = divisor_pairs(N)
    ans = float('inf')
    for x,y in pairs:
        ans = min(ans,abs(x-1)+abs(y-1))

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4540
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    int d=0;
    int cnt=1;
    for(int i=0; i<=n-1; i++){
        d = d+L[i];
        if(d<=x) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 888
#include <array>
#include <iostream>
#include <vector>

uint64_t merge_sort(uint32_t start, uint32_t end, std::vector<uint32_t>& A) {
  uint64_t ans = 0;
  if (end - start == 1) return ans;
  uint32_t mid = (end + start + 1) / 2;

  ans += merge_sort(start, mid, A);
  ans += merge_sort(mid, end, A);

  std::vector<uint32_t> L(mid - start + 1);
  std::vector<uint32_t> R(end - mid + 1);
  for (uint32_t i = 0; i < mid - start; i++) L[i] = A[start + i];
  for (uint32_t i = 0; i < end - mid; i++) R[i] = A[mid + i];
  L.back() = -1;
  R.back() = -1;

  auto iter_L = L.begin(), iter_R = R.begin();
  for (uint32_t i = 0; i < end - start; i++) {
    if (*iter_L <= *iter_R) {
      A[start + i] = *iter_L;
      iter_L++;
    } else {
      A[start + i] = *iter_R;
      iter_R++;
      ans += std::distance(iter_L, L.end() - 1);
    }
  }

  return ans;
}

int main() {
  uint32_t n = 0;
  std::cin >> n;
  std::vector<uint32_t> A(n);
  for (uint32_t i = 0; i < n; i++) std::cin >> A[i];

  std::cout << merge_sort(0, n, A) << std::endl;

  return 0;
}


Measured memory_bytes: 4284
while True:
    try:
        [x, y] = map(int, raw_input().split())
        if x < y:
            a = y
            b = x
        else:
            a = x
            b = y
        while a % b:
            c = a % b
            a = b
            b = c
        print "%d %d" % (b, x*y/b)
    except (EOFError):
        break

Measured memory_bytes: 6444
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

    void yes(bool fl = true){
            if(fl) cout << "YES\n";
            else cout << "Yes\n";
    }
    void no(bool fl = true){
        if(fl) cout << "NO\n";
        else cout << "No\n";
    }  

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        

        


        

        void solve(){
          cin >> n;

          ll cnt = 0;
          ll starting = 100;
          while(true){
              if(starting >= n) break;
              cnt++;
              starting += starting/100;
          }
          cout << cnt << endl;
            
        }
    
   

        int main(){
        ios_base::sync_with_stdio(false);
       

        int cases = 1;
        //cin >> cases;

        while(cases--){ 
            solve();
        }

        return 0;

        }

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

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

const int MAXN = 2e5 + 10;

int n; ll ans, tmp[MAXN], num[MAXN];
pii arr[MAXN];

struct BIT {
    ll bit[MAXN + 100];
    void chkmin(ll& a, ll b) { if (a < b) a = b; }
    BIT() { rep(i, 0, MAXN) bit[i] = -INT_MAX; }
    void clear() { rep(i, 0, MAXN) bit[i] = -INT_MAX; }
    void add(int x, ll val) { for (; x < MAXN; x += x & -x) chkmin(bit[x], val);  }
    ll query(int x) { ll ret = -INT_MAX; for (; x; x -= x & -x) chkmin(ret, bit[x]); return ret; }
    void radd(int x, ll val) { for (; x; x -= x & -x) chkmin(bit[x], val); }
    ll rquery(int x) { ll ret = -INT_MAX; for (; x < MAXN; x += x & -x) chkmin(ret, bit[x]); return ret; }
} bit1, bit2;

int main() {
    IO::read(n);
    rep(i, 1, n) IO::read(arr[i].first), IO::read(arr[i].second), tmp[i] = arr[i].second;
    sort(arr + 1, arr + n + 1), sort(tmp + 1, tmp + n + 1);
    int _n = unique(tmp + 1, tmp + n + 1) - tmp - 1;
    rep(i, 1, n) num[i] = lower_bound(tmp + 1, tmp + _n + 1, arr[i].second) - tmp;
    rep(i, 1, n) {
        if (i > 1) ans = max(ans, arr[i].first + max(arr[i].second + bit1.query(num[i]), bit2.rquery(num[i]) - arr[i].second));
        bit1.add(num[i], -(arr[i].first + arr[i].second)), bit2.radd(num[i], -arr[i].first + arr[i].second);
    }
    bit1.clear(), bit2.clear();
    per(i, n, 1) {
        if (i < n) ans = max(ans, -arr[i].first + max(arr[i].second + bit1.query(num[i]), bit2.rquery(num[i]) - arr[i].second));
        bit1.add(num[i], -(-arr[i].first + arr[i].second)), bit2.radd(num[i], arr[i].first + arr[i].second);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 13136
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    pair<string,pii> p[n];
    rep(i,n){
        p[i]={stin(),{-in(),i+1}};
    }
    sort(p,p+n);
    rep(i,n)cout<<p[i].second.second<<endl;
}

Measured memory_bytes: 256
N,Y=map(int,input().split())
for x in range(0,N+1):
    if x==N:
        x_money=10000*x
        if x_money==Y:
            print('{} {} {}'.format(x,0,0))
            exit()
    elif x<N:
        x_money=10000*x
        for y in range(0,N+1-x):
            if x+y==N:
                y_money=5000*y
                if x_money+y_money==Y:
                    print('{} {} {}'.format(x,y,0))
                    exit()     
            elif x+y<N:
                y_money=5000*y
                z=N-(x+y)
                z_money=1000*z
                if x_money+y_money+z_money==Y:
                    print('{} {} {}'.format(x,y,z))
                    exit()
print('-1 -1 -1')


Measured memory_bytes: 3064
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s, n, node):
    # 頂点が探索済みかどうかのチェック配列
    check = [False for _ in range(n)]
    check[s] = True
    # 次見る頂点を格納するキュー
    queue = deque([s])
    visited_num = 1

    # 問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color = [-1 for _ in range(n)]
    color[s] = 0

    while visited_num < n:
        # グラフが全連結ではない場合
        if len(queue) == 0:
            # 空配列を返す
            # 現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex = queue.popleft()
        # インデックスがない場合は
        for next_vertex in node[now_vertex]:

            if check[next_vertex] == True:
                continue

            queue.append(next_vertex)
            check[next_vertex] = True

            # 問題固有の計算
            color[next_vertex] = color[now_vertex]+1
            visited_num += 1

    return color


mod = 10**9+7
# n=int(input())
# n,m=list(map(int,input().split()))
# a=list(map(int,input().split()))
def ceil(x, y): return (x+y-1)//y
def input_list(): return list(map(int, input().split()))


def buy(buy_cost, sell_cost, money):
    return money % buy_cost+(money//buy_cost)*sell_cost


n = int(input())


print(10-n//200)


Measured memory_bytes: 9564
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
bool bitcheck(ll x, ll y) { return (x >> y) & 1; }

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll q;
    cin >> q;
    set<ll> s;
    REP(i, q) {
        ll a, b;
        cin >> a >> b;
        if (a == 0) {
            s.insert(b);
            cout << s.size() << endl;
        } else if (a == 1) {
            cout << s.count(b) << endl;
        } else if (a == 2) {
            s.erase(b);
        } else {
            ll r;
            cin >> r;
            s.lower_bound(b);
            auto it1 = s.lower_bound(b);
            auto it2 = s.upper_bound(r);
            for (auto it = it1; it != it2; it++) {
                cout << *it << endl;
            }
        }
    }
}


Measured memory_bytes: 12452
n=int(input())
l=list(map(int,input().split()))
count2=0
count4=0
for i in range(n):
  if l[i]%4==0:
    count4+=1
  elif l[i]%2==0:
    count2+=1
if count4*2+count2>=n or count4*2+1>=n:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main(){
  int N;
  string S;
  ll ans = 1;
  ll mod = 1e9 + 7;
  map<char, int> num;
  string al = "abcdefghijklmnopqrstuvwxyz";
  for (int i=0; i<al.size(); i++){
    num[al[i]] = 0;
  }
  cin >> N;
  cin >> S;
  for (int i=0; i<N; i++) num[S[i]]++;
  for (int i=0; i<al.size(); i++){
    ans *= (num[al[i]] + 1);
    ans = ans % mod;
  }
  
  cout << (ans != 0 ? ans - 1 : mod - 1) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K , now;
  cin >> N >> K;
  now = 1;
  
  for(int i = 0; i < N; i++){
    if(now + K < now * 2){
    	now += K;
    }
    else{
    	now *= 2;
    }
  }
  cout << now << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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

ans = 0

min_ = min(goal)
max_ = max(goal)

#最小の値はあらかじめ引いてしまい、その分だけまんべんなく水をまいたとして計上
ans += min_
goal = list(map(lambda x: x - min_, goal))


r = max_ - min_

for i in range(r):
    #連続区間を示すフラグ
    f = 0

    for j in goal:
        #今の水準より高い場合は、フラグを立てる
        if j > i:
            f = 1
        #水準の下に来たらフラグを下す。すでにフラグが立ってたら、連続区間として計上
        else:
            if f == 1:
                ans += 1 
            f = 0
            continue
    #フラグが立ったまま水準が終わった場合も連続区間として計上
    else:
        if f == 1:
            ans += 1 

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
 int main(){
 	int N , T;
 	cin >> N >> T;
 	int c[N] , t[N];
 	for(int i=0; i<N; i++){cin >> c[i] >> t[i];}
 	int answer=2000;
 	
 	 for(int i=0; i<N; i++){
 	 	if (T>=t[i]){
 	 		if(answer>c[i]){
 	 			answer=c[i];
 	 		}
 	 	}
 	 }
 	 
 	  if (answer==2000){
 	  	cout << "TLE" << endl;
 	  }else{
 	  	cout << answer << endl;
 	  }
 	  
 	 
 	 return 0 ;
 	 	
 	 	
 	 }

 

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	//input = input.split("\n");
	input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  var x1 = input[0];
  var y1 = input[1];
  var x2 = input[2];
  var y2 = input[3];
  var tmpX = y2 - y1;
  var tmpY = x2 - x1;
  var list = [];
  list.push(x2 - tmpX);
  list.push(y2 + tmpY);
  list.push(x1 - tmpX);
  list.push(y1 + tmpY);
  myout(list.join(" "));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 21192
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = input()
digit = len(N)
K = I()

# dp[i番目まで][未満かどうか][他の条件]
dp = [[[0]*(K+2) for _ in range(2)] for _ in range(digit+2)]
dp[0][0][0] = 1

for i in range(digit):
  num = int(N[i])
  for j in range(2):
    for k in range(K+2):
      for n in range(9+1 if j else num+1):
        dp[i + 1][j or (n < num)][min(K+1, k + (n != 0))] += dp[i][j][k]
print(dp[digit][0][K] + dp[digit][1][K])

Measured memory_bytes: 42352
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define MIN(a,b) ((a)<(b)?(a):(b))

typedef int node;

typedef struct segmentTreePointUpdateRangeAns{
  node *array;
  int size;
  node e;
  void (*func)(node *c,const node *a,const node *b);
} segTree;

segTree* newSegmentTree(int n,const node *e,void (*f)(node *c,const node *a,const node *b)){
  segTree *res=(segTree *)malloc(sizeof(segTree));
  int k=1;
  while(k<n) k*=2;
  res->array=(node *)malloc(sizeof(node)*2*k);
  res->size=k;
  res->e=*e;
  res->func=f;
  int i;
  for(i=1;i<2*k;i++) res->array[i]=*e;
  return res;
}

void update(segTree *seg,int index,node *v){
  node *s=seg->array;
  int k=seg->size+index;
  s[k]=*v;
  k/=2;
  while(k>=1){
    seg->func(s+k,s+2*k,s+2*k+1);
    k/=2;
  }
  return;
}

//[l,r)
void query(segTree *seg,int l,int r,node *res){
  int size=seg->size;
  node *a=seg->array;
  node s=seg->e;
  node t=seg->e;
  for(l+=size,r+=size;l<r;l/=2,r/=2){
    if(l&0x01) seg->func(&s,&s,a+l++);
    if(r&0x01) seg->func(&t,a+(--r),&t);
  }
  seg->func(res,&t,&s);
  return;
}

void func(node *c,const node *a,const node *b){
  *c=MIN(*a,*b);
  return;
}

void run(void){
  int n,x;
  scanf("%d%d",&n,&x);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int e=1000000000;
  segTree *seg=newSegmentTree(2*n,&e,func);
  for(i=0;i<2*n;i++){
    update(seg,i,a+i%n);
  }
  int64 ans=(int64)e*n;
  int k;
  for(k=0;k<n;k++){
    int64 local=(int64)k*x;
    for(i=n;i<2*n;i++){
      int t;
      query(seg,i-k,i+1,&t);
      local+=t;
    }
    ans=MIN(ans,local);
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}

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

int main()
{
    int x;
    scanf("%d",&x);
    // for (int x=1;x<=1000000000;x++) {
        bool flag=false;
        for (int i=0;i<=10000;i++) {
            for (int j=-10000;j<i;j++) {
                long long tmp=i*i*i*i*i-j*j*j*j*j;
                if (tmp==x) {
                    printf("%d %d\n",i,j);
                    flag=true;
                    break;
                }
            }
            if (flag) break;
        }
        if (!flag) puts("Very bad!!!");
    // }
    return 0;
}

Measured memory_bytes: 3760
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		s.useDelimiter("\n");
		int n = s.nextInt();
		for(;n>0;n--) {
			String p = s.next();
			p = p.replaceAll("Hoshino", "Hoshina");
			System.out.println(p);
		}
	}	
}

Measured memory_bytes: 17232
#include<stdio.h>
#include<limits.h>
int A[500005],N,c=0,i,tmp[2][250005];
void marge(int l,int m,int r)
{
	int i,j,c1=m-l,c2=r-m;
	for(i=0;i<c1;i++)tmp[0][i]=A[l+i];
	for(i=0;i<c2;i++)tmp[1][i]=A[m+i];
	tmp[0][c1]=tmp[1][c2]=INT_MAX;
	for(i=j=0;i<c1||j<c2;c++)
	{
		if(tmp[0][i]<tmp[1][j])
		{
			A[l+i+j]=tmp[0][i];
			i++;
		}
		else
		{
			A[l+i+j]=tmp[1][j];
			j++;
		}
	}
}

void margeSort(int l,int r)
{
	int m;
	if(l+1<r)
	{
		m=(l+r)/2;
		margeSort(l,m);
		margeSort(m,r);
		marge(l,m,r);
	}
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",A+i);
	margeSort(0,N);
	for(i=0;i<N;i++)
		printf("%d%c",A[i],i==N-1?'\n':' ');
	printf("%d\n",c);
	return 0;
}



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

typedef long long ll;

const ll MOD=1000000007;

int  a[1000005];

ll pow2(ll n)
{
    ll ans=1;
    for(int i=1;i<=n;i++)
    {
        ans=(2*ans)%MOD;
    }
    return ans%MOD;

}


int main()
{
    int n;
    cin>>n;
    int temp;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        a[temp]++;
    }
    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]>2)
        {
                cout<<"0"<<endl;
                return 0;
        }
        else if(a[i]==1)
        {
                cout<<"0"<<endl;
                return 0;
        }
    }
    if(n%2)
    {
        if(a[0]>1)
        {
            //cout<<__LINE__;
               cout<<"0"<<endl;
                return 0;
        }
    }
    else
    {
        if(a[0]>2)
        {
                cout<<"0"<<endl;
                return 0;
        }
    }
    cout<<pow2(n/2)<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define D(i,n) for (int i=(n); i-->0;)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream& operator<<(ostream& os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i]; return os;}
const bool debug = 1;

struct xy {
    int x,y,id;
};
xy operator-(xy a, xy b) {
    return {a.x-b.x, a.y-b.y, -1};
}
struct cmpX {bool operator()(xy a, xy b) const {
    return mt(a.x,a.y) < mt(b.x,b.y);}};
double dot(xy a, xy b) {return a.x*b.x + a.y*b.y;} // scalar product
double cross(xy a, xy b) {return a.x*b.y - a.y*b.x;} // vector product
xy read(int i) {int a,b; cin>>a>>b; return {a,b,i};}
double orient(xy a, xy b, xy c) {return cross(b-a,c-a);}
// Remove obsolete hull vertices and add p
void up(V<xy> &st, xy p) {
    while (S(st) >= 2 && orient(st.end()[-2], st.back(), p) <= 0)
        st.pop_back();
    st.pb(p);
}
V<xy> convexHull(V<xy> ps) {
    sort(ALL(ps), cmpX()); // by x then y, see 3.2
    V<xy> lo, hi; // lower and upper hulls
    F(i,S(ps)) up(lo, ps[i]);
    D(i,S(ps)) up(hi, ps[i]);
    lo.pop_back(); hi.pop_back();
    for (xy a : hi) lo.pb(a);
    return lo;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    V<xy> p(n);
    F(i,n) p[i] = read(i);
    p = convexHull(p);
    int m = S(p);
    V<double> prob(n, 0.0);
    F(i,m) {
        xy v = p[i]-p[(i-1+m)%m],
           w = p[(i+1)%m]-p[i];
        prob[p[i].id] = acos(dot(v, w) / sqrt(dot(v,v) * dot(w,w))) / 2 / M_PI;
    }
    cout << fixed << setprecision(10);
    F(i,n) {
        cout << prob[i] << "\n";
    }
}

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

const int MAXN = 1e5 + 5;

map<int,int> num;
int n, a[MAXN], ans;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
		num[a[i]]++;
	}
	for(auto i : num){
		if(i.second >= i.first){
			ans += i.second-i.first;
		}else{
			ans += i.second;
		}
	}
	printf("%d\n", ans);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n;
  cin >> n;
  if((n/10) % 10 == 7 || n % 10 == 7 || n / 100 == 7) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
func mainB() {
    let S: [Character] = .init(readLine()!)
    let T: [Character] = .init(readLine()!)

    let Scount = S.count
    let Tcount = T.count

    var results: [Int] = []
    for i in 0...Scount-Tcount {

        var count = 0
        for j in 0..<Tcount {

            if S[i + j] == T[j] {
                count += 1
            }
        }
        results.append(Tcount - count)
    }

    print(results.min()!)
}
mainB()

Measured memory_bytes: 7780
n = int(input())
a = list(map(int, input().split()))

ans1 = 0
ans2 = 0
cur1 = 0
cur2 = 0

for i in range(n):
    cun = a[i]
    # iが偶数のときプラス
    if i % 2 == 0:
        # プラスじゃないとき
        if a[i] + cur1 <= 0:
            ans1 += -(a[i] + cur1) + 1
            cun = -cur1 + 1
    # iが奇数のときマイナス
    else:
        # マイナスじゃないとき
        if a[i] + cur1 >= 0:
            ans1 += a[i] + cur1 + 1
            cun = -cur1 - 1
    cur1 += cun

for i in range(n):
    cun = a[i]
    # iが偶数のときマイナス
    if i % 2 == 0:
        # マイナスじゃないとき
        if a[i] + cur2 >= 0:
            ans2 += a[i] + cur2 + 1
            cun = -cur2 - 1
    # iが奇数のときプラス
    else:
        # プラスじゃないとき
        if a[i] + cur2 <= 0:
            ans2 += -(a[i] + cur2) + 1
            cun = -cur2 + 1
    cur2 += cun

print(min(ans1, ans2))

Measured memory_bytes: 14500
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  int a;
  cin >> a;
  vector <int> ans(a);
  for(int i = 0;i<a;i++){
      cin >> ans.at(i);
  }
  sort(ans.begin(),ans.end());
  int sum = 0;
  for(int i = 0;i<a-1;i++){
    if(ans.at(i)!=ans.at(i+1))sum++;
  }
      cout << sum+1;
}

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

char change(char c,int N){
  string Alpha={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  int x;
  rep(i,26){
    if(Alpha.at(i)==c){
      x=i;
    }
  }
  return Alpha.at((x+N)%26);
}

int main() {
  int N;
  string S;
  cin>>N>>S;
  rep(i,S.size()){
    S.at(i)=change(S.at(i),N);
    cout<<S.at(i);
  }
  cout<<endl;
}





Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int N=1010100;
int n,cnt;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        cnt^=x;
    }
    if(!cnt) puts("Yes");
    else puts("No");
    return 0;
}

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

const int cost[10] = {0,2,5,5,4,5,6,3,7,6};
const int INF = 1e8;

int main(){
  int N, M; cin >> N >> M;
  vector<pair<int,int>> A(M);
  for(int i=0; i<M; i++){
    cin >> A.at(i).first;
    A.at(i).second = cost[A.at(i).first];
  }
  
  sort(A.begin(), A.end());

  vector<int> dp(N+1);
  dp.at(0) = 0;
  
  for(int i=1; i<=N; i++){
    dp.at(i) = -INF;
    for(int j=0; j<M; j++){
      if(A.at(j).second <= i)
        dp.at(i) = max(dp.at(i), dp.at(i-A.at(j).second)+1);
    }
  }
  
  int count = N;
  while(count != 0){
    for(int i=M-1; i>=0; i--){
      if(count >= A.at(i).second && dp.at(count - A.at(i).second) == dp.at(count)-1 ){
        cout << A.at(i).first;
        count -= A.at(i).second;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 200000
long long a[MN+5];
int main()
{
	int n,x,i,j;__int128 ans=1e18,s;
	scanf("%d%d",&n,&x);
	for(i=1;i<=n;++i)scanf("%lld",&a[i]),a[i]+=a[i-1];
	for(i=1;i<=n;++i)
	{
		s=2*(a[n]-a[n-i])+1LL*(n+i)*x;
		for(j=1;i*j<=n;++j)
			s+=(__int128)(2*j+1)*(a[n-i*j+i]-a[n-i*j]);
		ans=min(ans,s+(__int128)(2*j+1)*a[n-i*j+i]);
	}
	printf("%lld",(long long)ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
const int BIT = 29;
const int mod = 1e9 + 7;
int seg[4 * N][2];
int n, d, par[N];
long long a[N][2];
vector<int> sz[N];
void update(int node, int start, int end, int idx, int typ){
    if(start > end || idx < start || end < idx) return;
    if(start == end){
        seg[node][0] = (typ ? idx : 0);
        seg[node][1] = (typ ? idx : 0);
        return;
    }
    int mid = (start + end) >> 1;
    update(node << 1, start, mid, idx, typ);
    update(node << 1 | 1, mid + 1, end, idx, typ);
    for(int typ = 0; typ < 2; typ ++){
        if(a[seg[node << 1][typ]][typ] <= a[seg[node << 1 | 1][typ]][typ]){
            seg[node][typ] = seg[node << 1][typ];
        }else{
            seg[node][typ] = seg[node << 1 | 1][typ];
        }
    }
}
int query(int node, int start, int end, int l, int r, int typ){
    if(start > end || r < start || end < l) return 0;
    if(l <= start && end <= r){
        return seg[node][typ];
    }
    int mid = (start + end) >> 1;
    int q1 = query(node << 1, start, mid, l, r, typ);
    int q2 = query(node << 1 | 1, mid + 1, end, l, r, typ);
    if(a[q1][typ] <= a[q2][typ]){
        return q1;
    }else{
        return q2;
    }
}
int main(){
    set<pair<int, int> > s;
    long long ans = 0;
    scanf("%d %d", &n, &d);
    a[0][0] = a[0][1] = 1e16;
    for(int i = 1; i <= n; i++){
        int val;
        scanf("%d", &val);
        a[i][0] = val - 1LL * i * d;
        a[i][1] = val + 1LL * i * d;
    }
    for(int i = 1; i <= n; i++){
        par[i] = i;
        sz[i].push_back(i);
        update(1, 1, n, i, 1);
        s.insert({sz[i].size(), i});
    }
    int edge = n - 1;
    while(edge--){
        int c = (s.begin()) -> second;
        for(int i : sz[c]){
            update(1, 1, n, i, 0);
        }
        long long mini = 2e16;
        int idx;
        for(int i : sz[c]){
            int q1 = query(1, 1, n, 1, i - 1, 0);
            int q2 = query(1, 1, n, i + 1, n, 1);
            long long res = a[i][1] + a[q1][0];
            if(res < mini){
                mini = res;
                idx = q1;
            } 
            res = a[i][0] + a[q2][1];
            if(res < mini){
                mini = res;
                idx = q2;
            } 
        }
        ans += mini;
        int p = par[idx];
        s.erase(s.find({sz[c].size(), c}));
        s.erase(s.find({sz[p].size(), p}));
        while(sz[c].size()){
            int i = sz[c].back();
            update(1, 1, n, i, 1);
            sz[p].push_back(i);
            par[i] = p;
            sz[c].pop_back();
        }
        s.insert({sz[p].size(), p});
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  string c;
  cin >> c;
  
 if(c=="a"||c=="i"||c=="e"||c=="o"||c=="u"){
 cout << "vowel" << endl;
 } 
  
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(void) {
	int n; cin >> n;
	vector<int> b(n-1);
	ll ans = 0;
	for (int i = 0; i < n-1; i++)
	{
		cin >> b[i];

	}
	for (int i = 0; i < n-2; i++)
	{
		ans += min(b[i], b[i + 1]);
	}
	ans += b[0] + b[n - 2];
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int a;
  cin >> a;
  int b=a%100;
  a/=100;
  if (a ==0) a=20;
  if (b==0)b=20;

  if (a > 12 and b > 12) {
    cout << "NA";
  } else if (a > 12) {
    cout << "YYMM";
  } else if (b > 12) {
    cout << "MMYY";
  } else {
    cout << "AMBIGUOUS";
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 256
s = input()
if s[3] == "9":
  if s[5] == 1:
    print("TBD")
  else:
    if int(s[5]) == 1:
      print("TBD")
    else:
      if int(s[6]) > 4:
        print("TBD")
      else:
        print("Heisei")
    
else:
  print("Heisei")

Measured memory_bytes: 3060