akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


//! All A's are dividable with n when:
//!   SUM(A) is dividable with n
//!   and the number of required operations is less than or equal to K
//!  
//! When r = Ai % n,
//!   if (r < n-r) r times decr operations are required on Ai
//!           else (n-r) times incr operations are required
//!  
//! Supporse we need I times of incr operations and D times of decr operations are required,
//!   k times of incr opertaions is equivalent to (n-k) times of decr operations. vice versa.
//!   We can balance I and D and the number would be (I+D)/2

void factorize(int x, vector< pair<int, int> >& factors)
{
    for (int f = 2; 1 < x; ++f) {
        int p = 0;
        while (x % f == 0) {
            ++p;
            x /= f;
        }
        if (0 < p) {
            factors.push_back(make_pair(f, p));
        }
    }
}

void getDivisorsAux(int base, int index, const vector< pair<int, int> >& factors, vector<int>& divisors)
{
    if (0 <= index && index < factors.size()) {
        int f = factors[index].first;
        int p = factors[index].second;
        for (int i = 0; i <= p; ++i, base *= f) {
            getDivisorsAux(base, index+1, factors, divisors);
        }
    } else if (1 < base) {
        divisors.push_back(base);
    }
}

void getDivisors(int x, vector<int>& divisors) 
{
    vector< pair<int, int> > factors; //! first: f, second: p
    factorize(x, factors);
    getDivisorsAux(1, 0, factors, divisors);
}

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }

    vector<int> divisors;
    getDivisors(sum, divisors);
    sort(divisors.rbegin(), divisors.rend());

    int ans = 1;
    for (int d : divisors) {
        vector<int> rs;
        for (int a : A) {
            int r = a % d;
            if (r) {
                rs.push_back(r);
            }
        }
        sort(rs.begin(), rs.end());

        int decOps = 0;
        int incOps = 0;
        int decIndex = 0;
        int incIndex = rs.size()-1;
 
        while (decIndex <= incIndex) {
            if (decOps < incOps) {
                decOps += rs[decIndex];
                ++decIndex;        
            } else if (incOps < decOps) {
                incOps += (d-rs[incIndex]);
                --incIndex;        
            } else {
                if (rs[decIndex] < d-rs[incIndex]) {
                  incOps += (d-rs[incIndex]);
                  --incIndex;        
                } else {
                  decOps += rs[decIndex];
                  ++decIndex;        
                }
            }
        }

        if (decOps <= K) {
            ans = d;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    double r;
    cin >> r;
    cout << 2.0 * PI * r ;
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define Mod 1000000007
#define M 100005
#define ll long long
using namespace std;
int n,K,to[M<<1],pr[M<<1],la[M],tot,sz[M],fa[M];
ll ans,P[M];
void add(int x,int y) {
	to[++tot]=y,pr[tot]=la[x],la[x]=tot;
}
void dfs(int x,int f) {
	sz[x]=0,fa[x]=f;
	for(int i=la[x]; i; i=pr[i]) {
		int y=to[i];
		if(y==f)continue;
		sz[x]++,dfs(y,x);
	}
}
ll mul(ll x,int y) {
	ll res=1;
	while(y) {
		if(y&1)res=res*x%Mod;
		x=x*x%Mod;
		y>>=1;
	}
	return res;
}
ll calc(int x,int y) {
	return P[x]*mul(P[y]*P[x-y]%Mod,Mod-2)%Mod;
}
int main() {
	scanf("%d%d",&n,&K);
	P[0]=1;
	for(int i=1; i<=K; i++)P[i]=P[i-1]*i%Mod;
	for(int i=1; i<n; i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	ll ans=K;
	dfs(1,0);
	for(int i=1; i<=n; i++) { //剩下 x个数 分 z个颜色
		int now=K-1-(fa[i]!=0);
		if(now<sz[i]) {
			ans=0;
			break;
		}
		ans=ans*calc(now,sz[i])%Mod*P[sz[i]]%Mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int a,b,c,d, A[100], B[100], C[100][100], D[100][100][100];
string s, t, r;




int main(){
	cin >> a;
	int e;
	b = a%10;
	c = a/10%10;
	d = a/100%10;
	e = a/1000;
	if((b == c && c == d) || (c == d && d == e)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  int n, m;
  vector<int> a, b;

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

  cin >> m;
  b.resize(m);
  for (int i = 0; i < m; ++i)
    cin >> b[i];

  bool gt = false;
  for (int i = 0; i < n; ++i) {
    if (i == m)
      break;
    if (a[i] > b[i])
      break;
    if (a[i] < b[i]) {
      gt = true;
      break;
    }
    if (i == n - 1 && n < m)
      gt = true;
  }

  if (gt)
    puts("1");
  else
    puts("0");
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
typedef long long ll;typedef unsigned long long ull;const int M6 = 1e6+5 , M5 = 1e5+5;
#define out2d(n,m,s,v) for(int i=s;i<n;i++){for(int k=s;k<m;k++)cout<<v[i][k]<<" ";cout<<endl;}
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second);}
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 }; int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
#define loop(i,n,s) for(int i=s;i<n;i++)
#define mim(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define szz(x) ll(x.size())
#define stop exit(0);
using namespace std;
#define endl '\n'
/**************/


int main(){FAST

    string s ;
    cin >> s ;
    ll b = 0 , ans = 0 ;

    for(int i = 0 ; i < szz(s);i++){
        if(s[i]=='B')b++;
        else ans+=b;
    }
    cout << ans << endl;



}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    int n,k,i;
    cin>>n>>k;
    vector<int> p(n);
    for(i=0;i<n;i++) cin>>p[i];
    sort(p.begin(),p.end());
    int ans=0;
    for(i=0;i<k;i++) ans+=p[i];
    cout<<ans;


    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b)
	c = calc_multi(a, b)
	fmt.Println(c)
}

func calc_multi(a, b int) int {
	if a > 9 || b > 9 {
		return -1
	}
	return a * b
}

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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll a[100];
ll x,y;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>x>>y;
		ll flag = 0;
		for(ll i=0;i<=x;i++)
		{
			ll x1= i;ll x2 = x - i;
			if(x1*4+x2*2==y){flag = 1;cout<<"Yes";break;}
		}
		if(!flag)cout<<"No"<<endl;



}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

   
}

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

using namespace std;

typedef long long ll;

const int N = 1e5 + 10, M = 1e6 + 10;
const int mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;

int t;

map<string, int> mp;

string s[N * 2];

vector<string> v;

int main()
{
    int n;
    cin >> n;
    int maxn = 0;
    for(int i  =0; i < n; i++)
    {
        cin >> s[i];
        mp[s[i]]++;
        maxn = max(maxn, mp[s[i]]);
    }
    for(int i  =0; i < n; i++)
    {
        if(mp[s[i]] == maxn)
        {
            v.push_back(s[i]);
            mp[s[i]]--;
        }
    }
    sort(v.begin(), v.end());
    for(auto i : v)
        cout << i << endl;
    return 0;
}


Measured memory_bytes: 28404
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int r,g;

int main() {
  cin>>r>>g;
  cout << 2*g-r << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,i,t,a,ma,mi;
	while(cin>>n,n){
		t=ma=0,mi=1000;
		for(i=0;i<n;i++)cin>>a,t+=a,ma=max(ma,a),mi=min(mi,a);
		cout<<(t-ma-mi)/(n-2)<<endl;
	}
}

Measured memory_bytes: 3004
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, C;
	cin >> N >> C;

	vector<Int> x(N);
	vector<Int> v(N);
	for (Int i = 0; i < N; i++) {
		cin >> x[i] >> v[i];
	}

	vector<vector<Int>> s_t(N, vector<Int>(2));//そこまでのmax、そこまでの単純和（時計回り）
	s_t[0][0] = s_t[0][1] = v[0] - x[0];

	for (Int i = 1; i < N; i++) {
		s_t[i][1] = s_t[i - 1][1] + v[i] - (x[i] - x[i - 1]);//単純和
		s_t[i][0] = max(s_t[i][1], s_t[i - 1][0]);//max
	}

	vector<vector<Int>> s_h(N, vector<Int>(2));//そこまでのmax、そこまでの単純和（反時計回り）
	s_h[N - 1][0] = s_h[N - 1][1] = v[N - 1] - (C - x[N - 1]);

	for (Int i = N-2; i >= 0; i--) {
		s_h[i][1] = s_h[i + 1][1] + v[i] - (x[i+1] - x[i]);
		s_h[i][0] = max(s_h[i][1], s_h[i + 1][0]);
	}

	DMP(s_t,s_h);

	Int ans = -INF;
	//時計回り→反時計回り
	for (Int i = 0; i < N; i++) {
		ans = max(ans, s_t[i][1]);//時計回りのみ
		if (i + 1 < N) {
			ans = max(ans, s_t[i][1] - x[i] + s_h[i + 1][0]);
		}
	}

	//最初に反時計回り
	for (Int i = N-1; i >=0; i--) {
		ans = max(ans, s_h[i][1]);//反時計回りのみ
		if (i - 1 >= 0) {
			ans = max(ans, s_h[i][1] - (C - x[i]) + s_t[i - 1][0]);
		}
	}

	if (ans >= 0) {
		cout << ans << "\n";
	}
	else {
		cout << 0 << "\n";
	}
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N,M;
    cin >> N >> M;
    priority_queue<int> que;
    REP(i,N){
        int tmp;
        cin >> tmp;
        que.push(tmp);
    }
    REP(i,M){
        int tmp = que.top();
        tmp /= 2;
        que.pop();
        que.push(tmp);
    }
    ll total = 0;
    REP(i,N){
        total += que.top();
        que.pop();
    }
    cout <<total<< "\n";
}

Measured memory_bytes: 892
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[3000];
int e[3000];
int dp[3001][3001];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++){
		scanf("%d%d",d+i,e+i);
	}
	for(int i=0;i<3001;i++)
		for(int j=0;j<3001;j++)
			dp[i][j]=-99999999;
	dp[0][0]=0;
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
			dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
			if(i+e[j]<=b&&!(i<c&&c<i+e[j]))dp[i+e[j]][j+1]=max(dp[i+e[j]][j+1],dp[i][j]+d[j]);
		}
	}
	int ret=0;
	for(int i=0;i<=b;i++)
		for(int j=0;j<=a;j++)
			ret=max(ret,dp[i][j]);
	printf("%d\n",ret);
}

Measured memory_bytes: 0
#include <stdio.h>
     
    int main(void){
      int n;
      scanf("%d", &n);
     
      int p[n];
      for (int i = 0; i < n; i++) {
        scanf("%d", &p[i]);
      }
     
      int ans = 0;
      for (int i = 1; i < n-1; i++) {
        if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        if(p[i+1] < p[i] && p[i] < p[i-1]) ans++;
      }
     
      printf("%d\n", ans);
     
      return 0;
    }

Measured memory_bytes: 128
#include<iostream>
#include<string>
typedef long long ll;
using namespace std;
int main() {
	string S;
	cin >> S;
	ll N = S.size();
	ll x = S[0] - '0' + (N - 1) * 9;
	if (N == 1)cout << S << endl;
	else {
		for (ll i = 1; i < N; i++) {
			if (S[i] != '9')
				x = (N - 1) * 9 + (S[0] - '1');
		}
      cout<<x<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return(t*t);
    else
        return(t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
    }
    return true;
}

bool cmp(const pair<int , int> &a , const pair<int , int> &b){
    return (a.first < b.first);
}

ll lcm(ll a,ll b){
    return ( a*b/__gcd(a,b));
}

ll ans;
map<ll,ll>m;
int main()
{
    weewoo;
    ll n;
    cin >> n;
    vector<ll>a;
    for(int i=0;i<n;i++){
        ll x;
        cin >> x;
        a.push_back(x);
        m[x]++;
    }
    for(auto i : m){
        ll c = i.se;
        ans+=(c*(c-1))/2;
    }
    for(ll i=0;i<n;i++){
        ll cur = ans - ((m[a[i]]*(m[a[i]]-1))/2) + (((m[a[i]]-1)*(m[a[i]]-2))/2);
        cout << cur << endl;
    }
    return 0;
}


Measured memory_bytes: 12912
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

bool palindrome(string s) {
    string tmp = s;
    reverse(all(tmp));
    return s == tmp;
}

int main() {
    string s; cin >> s;
    if (s.back() == '1' || s.front() == '0' || !palindrome(s.substr(0,s.size()-1))) {
        cout << -1 << endl;
        return 0;
    }
    int root = 1;
    rep(i,s.size()-1) {
        if (s[i] == '1') {
            cout << root << " " << i + 2 << endl;
            root = i + 2;
        } else {
            cout << root << " " << i + 2 << endl;
        }
    }
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
    int N;
    vector<int> A;
    cin >> N;
    vector<long long> S(N + 2, 0);
    A.push_back(0);
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    A.push_back(0);
    rep(i, N + 2) if (i) S[i] += S[i - 1] + abs(A[i] - A[i - 1]);
    // S[N] = S[N - 1] + abs(A[N - 1]);
    // rep(i, N + 2) cout << i << ": " << S[i] << endl;

    rep(i, N + 1) if (i) {
        long long ans = 0;
        ans += S[i - 1];
        ans += abs(A[i - 1] - A[i + 1]);
        ans += S[N + 1] - S[i + 1];
        cout << ans << endl;
    }

    return 0;
}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

int n, q;
vector<vector<int>> tree(202020);
vector<int> parent(202020);
vector<ll> counter(202020);
vector<ll> add(202020);

int main() {
    string s;
    cin >> s;
    if(s.at(5) == '1') cout << "TBD" <<endl;
    else {
        int n = stoi(s.substr(6));
        if(n <= 4) cout << "Heisei" << endl;
        else cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 8960
import sys
sys.setrecursionlimit(10**9)

n = int(input())
dic = {}
for i in range(n+1):
    if i <= 1: continue
    ai = int(input())
    if ai in dic:
        dic[ai].append(i)
    else:
        dic[ai] = [i]

def dfs(node):
    lst = []
    if node in dic:
        while dic[node] != []:
            child = dic[node].pop()
            tempmax = dfs(child)
            lst.append(tempmax)
    else:
        return 0
    lst.sort(reverse=True)
    for i in range(len(lst)):
        lst[i] += i+1
    return max(lst)

ans = dfs(1)
print(ans)

Measured memory_bytes: 114076
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> b(n + 1); rep(i, n)cin >> b[i + 1];
	for (int i = 1; i <= n; ++i)
	{
		if (i < b[i])
		{
			cout << -1 << endl;
			return 0;
		}
	}
	vector<int> res(n);
	for (int i = n - 1; i >= 0; --i)
	{
		for (int j = b.size() - 1; j > 0; --j)
		{
			if (j == b[j])
			{
				res[i] = j;
				b.erase(b.begin() + j);
				break;
			}
		}
	}
	rep(i, n)cout << res[i] << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n == 0){
                break;
            }
            int max = Integer.MIN_VALUE;
            int total = 0;
            while(0 < n--){
                total += sc.nextInt();
                max = Math.max(max, total);
                if(total < 0){
                    total = 0;
                }
            }
            System.out.println(max);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 26328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N, K;
cin >> N >> K;
vector<long long> dice(N);
vector<long long> ruisekiwa(N+1, 0);

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

for(int i = 0; i < N; ++i){
   ruisekiwa[i+1] = dice[i] + ruisekiwa[i];
}
long long res = 0;
for(int i = 0; i+K <= N; ++i){
res = max(res, ruisekiwa[i+K] - ruisekiwa[i]);

}
cout << fixed << setprecision(10) << (double)(res)/2 << endl;


} 

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int a,b,c;
int main(){
        cin >> a >> b >> c;
        if((a+b)>=c) cout << "Yes" << endl;
        else if(a==c) cout << "Yes" << endl;
        else if(b==c) cout << "Yes" << endl;
        else cout << "No" << endl;
}


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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    int count = 0;
    vector<pair<int, int>> d(n + 1);
    for(int i = 1; i <= n; i++){
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        d[i] = make_pair(tmp1, tmp2);
    }
    for(int i = 1; i <= n; i++){
        if(count != 3){
            if(d[i].first == d[i].second){
                count += 1;
            }
            else{
                count = 0;
            }
        }
        else{
            break;
        }
    }
    
    if(count == 3){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
  int main(){
      lint H,W,N;
      string s;
      cin>>H>>W>>N;
      lint x=max(H,W);
      lint ans=N/x;
      if(N%x!=0)ans++;
      cout<<ans;
    
  }
  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>    // for pair
using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (int i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

signed main()
{
    int N, X; cin >> N >> X;
    vector<int> L(N); rep(i, N) cin >> L[i];

    int ans = 1;
    int D = 0;
    rep(i, N){
        D += L[i];
        if (D > X) break;
        ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<map>

using namespace std;
typedef pair<int,int> pp;

class UF {
    public:
    int par[300000]={};
    UF(int n) {
        for(int i=0; i<n; i++)
            par[i] = i;
    }
    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        par[x] = y;
    }
};

int main(void) {
    int n,k,l;
    scanf("%d%d%d",&n,&k,&l);
    UF road(250000), rail(250000);
    for(int i=0; i<k; i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        x--, y--;
        road.unite(x,y);
    }
    for(int i=0; i<l; i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        x--, y--;
        rail.unite(x,y);
    }

    map<pp,int> res;
    for(int i=0; i<n; i++)
        res[pp(road.find(i),rail.find(i))]++;

    for(int i=0; i<n; i++) {
        printf("%d%c", res[pp(road.find(i),rail.find(i))], i==n-1 ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
 
int main(){
  int h,w,k;
  cin >> h >> w >> k;
  char c[h][w];
  rep(i,h){
    rep(j,w)
      cin >> c[i][j];
  }
  int black=0;
  rep(i,h){
    rep(j,w)
      if(c[i][j]=='#') black++;
  }
  //int all = 1<<(h+w);
  int allh = 1<<h; //分けた方が分かりやすいかも。実際最初h*wにミスったし。もっといい感じの名前が欲しい
  int allw = 1<<w; //h/w,i/jの組み合わせにR/Cも追加されて逆に分かりづらいかも。意味分かれば解決しそうだけど
  int count=0;
  //if(black<k) cout << 0 << endl; //if文いらないわ。組み合わせなければ勝手に0にしてくれるし
  //else{
    //rep(mask,all){ //分けたからfor文は2個に増えた
    rep(maskR,allh){ //なんでRかは分からない
      rep(maskC,allw){ //なんでCかは分からない
      	black=0;
      	rep(i,h){
          rep(j,w){          
          	/*1&1の時だけ1になる。&0に最初してた時if分入らなかったのそれはそうって感じ。0&0で1になるイメージだった。左右一致してれば1みたいな*/
          	/*選んでない、を1と見立てた形。選ばない/選ぶ、の二択だから0/1逆にしても動きは大丈夫だけど非直感的*/
          	//if((mask>>i&1)&&(mask>>(h+j)&1)){
          
          	/*こっちの方が直感的。0の時を判定してるから。結果1にしなきゃいけないとかじゃなくて==0にすれば問題ない*/
          	/*&1にするのはそのままで、左0なら0で通り、左1なら1になって弾かれる*/
          	/*&0だと左に何がきても0になって判定出来ないから注意*/
            if( (maskR>>i&1) == 0 && (maskC>>j&1) == 0 ) //jになって分かりやすい。変え忘れ注意。CとRもつけ忘れ注意
              if(c[i][j]=='#') black++;
          }
        }
        if(black==k) count++; //場所の変え忘れ注意
      }
    }
    cout << count << endl;
  //} 消し忘れ注意
}

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

int main()
{
	double get ;
	double high ;

	while( cin >> get )
	{
		high = 4.9 *(get/9.8)*(get/9.8) ;

		int i ;
		for( i = 0 ; ; i ++ )
		{
			double tmp = high ;
			tmp -= i*5 ;

			if( tmp < 5 )
			{
				break ;
			}
		}

		cout << i+2 << endl ;
	}

	return 0 ;
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    std::iota(v.begin(), v.end(), 1);

    do {
        for (int i = 0; i < v.size(); ++i) {
            std::cout << v[i] << " \n"[i == v.size() - 1];
        }
    } while (std::next_permutation(v.begin(), v.end()));
}


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

int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(b>a+w){
    cout << b-a-w << endl;
  }
  if(b<=a+w && b+w>=a){
    cout << 0 << endl;
    return 0;
  }
  if(b<a+w)
    cout << a-b-w << endl;
  return 0;
}

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

vector<int> card(200);
int m, n, k;

void shuffle(){
    vector<int> temp(card);
    if(k == 0){
        for(int i = 0;i<n;i++){
            card[2*i] = temp[i];
        }
        for(int i = n;i<2*n;i++){
            card[2*(i-n)+1] = temp[i];
        }
    }
    else{
        for(int i = 0;i<2*n;i++){
            card[(2*n+i-k)%(2*n)] = temp[i];
        }
    }
    return;
}

int main(){
    for(int i = 0;i<200;i++){
        card[i] = i+1;
    }
    cin >> n >> m;
    for(int i = 0;i<m;i++){
        cin >> k;
        shuffle();
    }
    for(int i = 0;i<2*n;i++){
        cout << card[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u8,
        m: u8,
        x: u32,
        v: [[u32; m + 1]; n]
    }

    let mut ans = std::u32::MAX;

    for bit in 0..2u16.pow(n as u32) {
        let mut score = Vec::with_capacity(m as usize);
        let mut cost = 0;
        for _i in 0..m {
            score.push(0);
        }
        for i in 0..n {
            if bit & (1 << i) > 0 {
                for j in 1..m + 1 {
                    score[j as usize - 1] += v[i as usize][j as usize]; // reverse?
                }
                cost += v[i as usize][0];
                if cost >= ans {
                    break;
                }
            }
            if score.iter().all(|&s| s >= x) {
                if cost < ans {
                    ans = cost;
                }
            }
        }
    }
    if ans == std::u32::MAX {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


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

long f(long a,long b){
  if (a==b)return a;
  if (a%2==1){
    return a^f(a+1,b);
  }
  if (b%2==1){
    return (((b-a+1)/2)%2==0)? 0:1;
  }
  return ((((b-a+1)/2)%2==0)? 0:1) ^ b;

}

long ff(long a,long b){
  if (a==b)return a;
  return a^ff(a+1,b);
}


int main(){
  long a,b;cin >> a >> b;
 
  //cout << f(a,b) << endl;
  cout << f(a,b) << endl;

  return 0;
}


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

int main () {
    int N, tmp;
    int sum_max = 0;
    vector<int> B;

    cin >> N;
    for (int i = 0; i < N-1; i++) {
        cin >> tmp;
        B.push_back(tmp);
    }

    for (int i = 0; i < N; i++) {
        if (i == 0) {
            sum_max += B[i];
        } else if (i == (N-1)) {
            sum_max += B[i-1];
        } else {
            if (B[i] >= B[i-1]) {sum_max += B[i-1];}
            else                {sum_max += B[i];}
        }
    }

    cout << sum_max << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

def main():
    direction=[[1,0],[0,1],[-1,0],[0,-1]]


    h,w=map(int,input().split())
    c=tuple(map(int,input().split()))
    d=tuple(map(int,input().split()))
    s=[input() for i in range(h)]

    itta=[[-1]*w for i in range(h)]
    itta[c[0]-1][c[1]-1]=0
    de=deque([(c[0]-1,c[1]-1)])
    # print(d)
    cnt=0
    while de:
        lst=[]
        while de:
            now=de.popleft()
            flag=0
            for i in range(4):
                nh,nw=now[0]+direction[i][0],now[1]+direction[i][1]
                if 0<=nh<h and 0<=nw<w:
                    if itta[nh][nw]==-1 and s[nh][nw]==".":
                        itta[nh][nw]=cnt
                        de.append((nh,nw))
                    elif s[nh][nw]=="#" and flag==0:
                        flag=1
                        lst.append(now)
        # print(lst)
        for i in range(len(lst)):
            for j in range(5):
                for k in range(5):
                    nh,nw=lst[i][0]-2+j,lst[i][1]-2+k
                    if 0<=nh<h and 0<=nw<w and s[nh][nw]=="." and itta[nh][nw]==-1:
                        itta[nh][nw]=cnt+1
                        de.append((nh,nw,cnt+1))
        cnt+=1
    print(itta[d[0]-1][d[1]-1])

main()

Measured memory_bytes: 108076
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		String S = String.valueOf(N);
		if (N < 357) {
			System.out.println(0);
			return;
		}
		long ans = 0;
		long foo = 0;
		foo += check("3", N);
		foo += check("5", N);
		foo += check("7", N);
		ans += foo;
		System.out.println(ans);
	}

	public static long check(String num, int max) {
		long tmp = Long.parseLong(num);
		long ret = 0;
		if (tmp <= max) {
			String S = num;
			boolean three = false;
			boolean five = false;
			boolean seven = false;
			for (int i = 0; i < S.length(); i++) {
				if (S.charAt(i) == '3') {
					three = true;
				} else if (S.charAt(i) == '5') {
					five = true;
				} else if (S.charAt(i) == '7') {
					seven = true;
				}
			}
			if (three && five && seven) {
				// System.out.println("o " + tmp);
				ret++;
			} else {
				// System.out.println("x " + tmp);
				// return 0;
			}
		} else {
			// System.out.println("x " + tmp);
			return 0;
		}
		ret += check(num + "3", max);
		ret += check(num + "5", max);
		ret += check(num + "7", max);
		return ret;
	}
}

Measured memory_bytes: 37176
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B, long C, long D, long E) {
    auto times = [A, B, C, D, E];
    auto ans = times.map!(a => a / 10 * 10 + (a % 10 > 0 ? 10 : 0)).sum;
    auto x = times.map!"a % 10".filter!"a > 0";
    if (x.count > 0)
        ans -= 10 - x.reduce!min;

    return ans;
}

void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    long C;
    C = input.front.to!long;
    input.popFront;

    long D;
    D = input.front.to!long;
    input.popFront;

    long E;
    E = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B, C, D, E);
    else
        solve(A, B, C, D, E).writeln;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;
const int MAX_H = 110, MAX_W = 10;


int main(int argc, char const *argv[])
{
	int H, W, K;
	cin >> H >> W >> K;
	K--;
	ll dp[MAX_H][MAX_W];
	fill(dp[0], dp[H+1], 0);

	dp[0][0] = 1;

	for (int h = 0; h < H; ++h) {
		for (int b = 0; b < (1 << (W-1)); ++b) {
			bool adjacent = false;
			for (int i = 0; i < W-2; ++i){
				if ((b >> i)%4 == 3) adjacent = true;
			}

			if (adjacent) continue;

			int to[MAX_W];
			for (int i = 0; i < W; ++i) to[i] = i;

			for (int i = 0; i < W-1; ++i) {
				if ((b>>i)&1) swap(to[i], to[i+1]);
			}
			for (int i = 0; i < W; ++i) {
				dp[h+1][to[i]] += dp[h][i];
				dp[h+1][to[i]] %= MOD;
			}
		}
	}

	cout << dp[H][K] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> e[100010];
int in[100010], d[100010], l[100010];
void dfs(int v) {
	d[v] = 1;
	for (int i = 0; i < e[v].size(); i++) {
		int w = e[v][i];
		if (!d[w]) dfs(w);
		l[v] = max(l[w] + 1, l[v]);
	}
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		--u; --v;
		e[u].push_back(v);
	}
	for (int i = 0; i < n; i++) {
		if (!d[i]) dfs(i);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, l[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8576
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    string s; cin>>s;
    ll ans=0;
    int l=s.length();
    
    for(int i=0;i<(1<<(l-1));i++){
        ll n=s[0]-'0';
        for(int j=0;j<l-1;j++){
            if(i&(1<<j)){
                ans+=n;
                n=0;
            }
            n=n*10+s[j+1]-'0';
        }
        ans+=n;
    }
    cout<<ans<<endl;
}

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

const ll int INF = 1e18 + 5;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n;
    cin>>n;
    ll int a[n];
    for(ll int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll int dp[n+5][n+5] = {0};
    for(ll int l=n;l>=0;l--){
    	for(ll int r=l;r<n;r++){
    		if(l == r)
    			dp[l][r] = a[l];
    		else{
    			dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
    		}
    		// cout<<dp[l][r]<<" "<<l<<" "<<r<<endl;
    	}
    }
    cout<<dp[0][n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 70912
#include <stdio.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, x, i, d, cnt, l[100];
	
	scanf("%d %d", &n, &x);
	lop(i, n){
		scanf("%d", &l[i]);
	}
	
	d=0; cnt=1;
	
	for(i=1; i<n+1; i++){
		d=d+l[i-1];
		if(d>x)break;
		cnt++;
	}
	
	printf("%d", cnt);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int d,n,i,count=0;
    scanf("%d%d",&d,&n);
    if(d==0)
    {
        for(i=1;i<=101;i++)
        {
            if(i!=100)
            {
                count++;
            }
            if(count==n)
            {
                printf("%d",i);
                break;
            }
        }
    }
    else if(d==1)
    {
        for(i=100;i<=(100*101);i=i+100)
        {
            if(i!=10000)
            {
            count++;
            }
            if(count==n)
            {
                printf("%d",i);
                break;
            }
        }
    }
    else
    {
        for(i=10000;i<=(10000*101);i=i+10000)
        {
            if(i!=1000000)
            {
            count++;
            }
            if(count==n)
            {
                printf("%d",i);
                break;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

lldo l;

int main() {
	cout << setprecision(10);
	cin >> l;
	cout << pow(l / 3, 3) << endl;
	return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    vl a(n);
    rep(i, n) cin >> a[i];

    vl x(n);
    vl y(n);
    vl h1(2 * n + 1, 0);
    vl h2(2 * n + 1, 0);
    rep(i, n) {
        x[i] = i - a[i];
        if (x[i] <= n && x[i] >= -n) h1[x[i] + n]++;
        y[i] = i + a[i];
        if (y[i] <= n && y[i] >= -n) h2[y[i] + n]++;
    }

    ll cnt = 0;

    rep(i, n) {
        ll t;
        t = i + a[i];
        if (t <= n && t >= -n) cnt += h1[t + n];
        t = i - a[i];
        if (t <= n && t >= -n) cnt += h2[t + n];
    }

    cout << cnt / 2 << endl;

    return 0;
}


Measured memory_bytes: 14348
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<lldo>&ar,lldo in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<lldo>&ar,lldo in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint root(llint in){
	llint st=0,ue=mod;
	while(ue-st>1){
		llint gen=(st+ue)/2;
		if(gen*gen<=in){st=gen;}
		else{ue=gen;}
	}
	return st;
}
int main(void){
	int Q;cin>>Q;
	while(Q--){
		llint a,b;cin>>a>>b;
		if(a>b){swap(a,b);}
		if(a==b){cout<<a+b-2<<endl;continue;}
		llint st=root(a*b-1);
		llint ue=st;
		if(st*(st+1)<a*b){ue=st+1;}
		cout<<st+ue-2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 3e3 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;

ll n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    if (n >= 30) cout<< "Yes";
    else cout<<"No";
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    ll n, k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i], a[i]--;

    int T = 0, d = 0;
    vl depth(n,-1);
    while (depth[T] == -1) {
        depth[T] = d++;
        T = a[T];
    }

    int now = T, N = 0;
    vl ans;
    while (true) {
        ans.push_back(now);
        now = a[now];
        N++;
        if (now == T) break;
    }

    if (k <= depth[T]) {
        rep(i,n) {
            if (depth[i] != k) continue;
            cout << i+1 << endl;
            return 0;
        }
    }
    k -= depth[T];
    cout << ans[k%N]+1 << endl;
    return 0;
}


Measured memory_bytes: 8476
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int dy[4]={ 1, 0,-1, 0};
int dx[4]={ 0, 1, 0,-1};

int main() {
  int H,W,Ch,Cw,Dh,Dw; cin>>H>>W>>Ch>>Cw>>Dh>>Dw; Ch--,Cw--,Dh--,Dw--;
  char S[H][W];
  int dist[H][W];
  for(int y=0;y<H;y++) for(int x=0;x<W;x++) cin>>S[y][x],dist[y][x]=0;
  
  queue<P> que,warpFrom;
  que.emplace(P(Ch,Cw));\
  S[Ch][Cw]='x';
  
  while(!que.empty()){
    P p=que.front(); que.pop();
    int y=p.first,x=p.second;
    if(y==Dh&&x==Dw){cout<<dist[y][x]; return 0;}
    warpFrom.push(P(y,x));
    for(int i=0;i<4;i++){
      int ny=y+dy[i],nx=x+dx[i];
      if(ny<0||H<=ny||nx<0||W<=nx||S[ny][nx]!='.') continue;
      que.push(P(ny,nx));
      S[ny][nx]='x';
      dist[ny][nx]=dist[y][x];
    }

    if(que.empty()){
      while(!warpFrom.empty()){
        P p=warpFrom.front(); warpFrom.pop();
        int y=p.first,x=p.second;
        if(y==Dh&&x==Dw){cout<<dist[y][x]; return 0;}
        for(int wy=-2;wy<=2;wy++){
          for(int wx=-2;wx<=2;wx++){
            int ny=y+wy,nx=x+wx;
            if(ny<0||H<=ny||nx<0||W<=nx||S[ny][nx]!='.') continue;
            que.push(P(ny,nx));
            S[ny][nx]='x';
            dist[ny][nx]=dist[y][x]+1;
          }
        }
      }
    }
  }
  cout<<-1;
}

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

using namespace std;

int to_int(string s)
{
  return atoi(s.c_str());
}

int main()
{
  string s;
  cin >> s;

  int u = s[0] == '0' ? to_int(s.substr(1, 1)) : to_int(s.substr(0, 2));
  int d = s[2] == '0' ? to_int(s.substr(3, 1)) : to_int(s.substr(2, 2));

  bool uism = 1 <= u && u <= 12;
  bool dism = 1 <= d && d <= 12;

  if (uism && dism)
  {
    cout << "AMBIGUOUS" << endl;
  }
  else if (uism)
  {
    cout << "MMYY" << endl;
  }
  else if (dism)
  {
    cout << "YYMM" << endl;
  }
  else
  {
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256