akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 1e9+7;
signed main(){
    string s; cin >> s;
    ll dp[s.size()+1][13];
    rep(i,s.size()+1)rep(j,13)dp[i][j]=0;
    dp[0][0]=1;
    rep(i,s.size()){
        if(s[i]=='?'){
            rep(x,10){
                //dp[i+1][x]+=1;
                rep(j,13){
                    int y=(10*j+x)%13;
                    dp[i+1][y]+=dp[i][j];
                    dp[i+1][y]%=MOD;
                }
            }
        }else{
            int x=s[i]-'0';
            //dp[i+1][x]+=1;
            rep(j,13){
                int y=(10*j+x)%13;
                dp[i+1][y]+=dp[i][j];
                dp[i+1][y]%=MOD;
            }
        }
        //cout << dp[i+1][5] << endl;
    }
    cout << dp[s.size()][5] << endl;
    //int ret=0; for(int i=0;i<100;i++){if(i%13==5)ret++;} cout<<ret<<endl;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define ld long double
int dp[2][20][1<<20];
int ok[21][20][2];
int mod=1e9+7;
int main(){
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i = 0;i<=m;i++){
        for(int j=0;j<=n;j++)
            ok[i][j][0]=ok[i][j][1]=1;
    }
    for(int i = 0;i<k;i++){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        ok[a][b-1][c^1]=0;
    }
    dp[1][0][0]=1;
    LL ans=0;
    for(int i=1;i<=m;i++){
        for(int j=0;j<n-1;j++){
            for(int k=0;k<(1<<(n-1));k++){
              //  printf("%d %d %d %d\n",i,j,k,dp[i&1][j][k]);
                if(k&(1<<j)){
                    if(ok[i][j][1])
                    dp[i&1][j+1][k]+=dp[i&1][j][k];
                    dp[i&1][j+1][k]%=mod;
                }
                else{
                    if(ok[i][j][0])
                    dp[i&1][j+1][k]+=dp[i&1][j][k];
                    dp[i&1][j+1][k]%=mod;
                    int val=k;
                    val=val&((1<<n)-(1<<j));
                    if(ok[i][j][1]){
                        dp[i&1][j+1][k+(1<<j)-(val&-val)]+=dp[i&1][j][k];
                         dp[i&1][j+1][k+(1<<j)-(val&-val)]%=mod;
                    }
                }
            }
        }
        MEM(dp[(i&1)^1]);
        for(int k=0;k<(1<<(n-1));k++){
            dp[(i&1)^1][0][k]=dp[i&1][n-1][k];
            if(i==m)
            ans+=dp[i&1][n-1][k];
        }
    }
    printf("%lld\n",ans%mod);
}

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  ll a, b, k;
  cin >> a >> b >> k;
  if (a >= k) {
    a -= k;
    k = 0;
  }
  else {
    k -= a;
    a = 0;
  }
  if (b >= k) {
    b -= k;
    k = 0;
  }
  else {
    b = 0;
  }
  cout << a << " " << b << endl;
  return 0;
  
  string s, t;
  cin >> s >> t;
  t += s;
  cout << t << endl;
  return 0;
  int x;
  cin >> x;
  for (int a = x; a <= inf; a++) {
    bool flag= true;
    for (int j = 2; j < a; j++) {
      if (a % j == 0) flag = false;
        
    }
    if (flag) {
      cout << a << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
// Coder: @SumitRaut
#include <bits/stdc++.h>
#define speedup ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
using namespace std;
#ifndef ONLINE_JUDGE
class Timer { chrono::high_resolution_clock::time_point start_t, end_t; public: Timer() { start_t=chrono::high_resolution_clock::now(); } ~Timer() { end_t = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(end_t-start_t); cerr<<"\nRunTime: "<<duration.count()<<"ms"<<'\n'; } };
template <typename T>
ostream &operator<<(ostream &cout, const vector<T> &v) {
    cout << "[";
    for (auto &it : v)
        cout << it << ' ';
    cout << "]";
    return cout;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &cout, const vector<pair<T1, T2>> &v) {
    cout << "[";
    for (auto &it : v)
        cout << "(" << it.first << ',' << it.second << ")" << ' ';
    cout << "]";
    return cout;
}
void debug() { cout << '\n'; }
template <typename T, typename... Args>
void debug(T print, Args... args) { cout << ' ' << print; debug(args...); }
#define deb(...) cout << "[" << #__VA_ARGS__ << "]" <<" --> ", debug(__VA_ARGS__)
#else
#define deb(...) ;
#endif
const int mod = 998244353;
void solve() {
    int n,k;
    cin>>n>>k;
    vector<int> dp(n+1),l(k),r(k);
    for(int i=0;i<k;++i)
        cin>>l[i]>>r[i];
    dp[1]=1;
    for(int i=2;i<=n;++i) {
        for(int j=0;j<k;++j) {
            dp[i]+=dp[max(0,i-l[j])]-dp[max(0,i-r[j]-1)];
            if(dp[i]<0)
                dp[i]+=mod;
            if(dp[i]>=mod)
                dp[i]-=mod;
        }
        dp[i]+=dp[i-1];
        if(dp[i]>=mod)
            dp[i]-=mod;
    }
    cout<<(dp[n]-dp[n-1]+mod)%mod<<'\n';
}

int main()
{
    speedup;
    #ifndef ONLINE_JUDGE
    Timer timer;
    #endif
        solve();
    return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    ll X, K, D;
    cin >> X >> K >> D;
    if(X == 0){
        if(K % 2 == 0){
            cout << 0 << endl;
        }
        else{
            cout << D << endl;
        }
    }
    else if(X > 0){
        ll a = X/D;
        ll p1 = X - a * D;
        ll ans = 1LL << 60;
        if(a >= K){
            ans = abs(X - K * D);
        }
        else{
            if((K - a) % 2 == 0){
                ans = min(ans, abs(p1));
            }
            else {
                ans = min(ans, abs(p1 - D));
            }
            ll p2 = X - (a + 1) * D;
            if((K - a - 1) % 2 == 0){
                ans = min(ans, abs(p2));
            }
            else{
                ans = min(ans, abs(p2 - D));
            }
        }
        cout << ans << endl;
    }
    else{
        ll a = -X/D;
        ll ans = 1LL<<60;
        if(a >= K){
            ans = abs(X + K * D);
        }
        else{
            ll p1 = X + a * D;
            if((K - a) % 2 == 0){
                ans = min(ans, abs(p1));
            }
            else{
                ans = min(ans, abs(p1 + D));
            }
            ll p2 = X + (a + 1) * D;
            if((K - a - 1) % 2 == 0){
                ans = min(ans, abs(p2));
            }
            else{
                ans = min(ans, abs(p2 + D));
            }
        }
        cout << ans << endl;
    }

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

    solve();
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  vector<int> P(A);
  vector<int> Q(B);
  vector<int> R(C);

  for (int i = 0; i < A; i++) {cin >> P.at(i);}
  for (int j = 0; j < B; j++) {cin >> Q.at(j);}
  for (int k = 0; k < C; k++) {cin >> R.at(k);}

  sort(P.begin(), P.end(), greater<int>());
  sort(Q.begin(), Q.end(), greater<int>());

  vector<int> PQR(X+Y+C);
  for (int i = 0; i < X; i++) {PQR[i] = P[i];}  // only keep biggest X examples from P
  for (int i = 0; i < Y; i++) {PQR[i + X] = Q[i];}  // only keep biggest X examples from Q
  for (int i = 0; i < C; i++) {PQR[i + X + Y] = R[i];}
  sort(PQR.begin(), PQR.end(), greater<int>());

  long long ans = 0;
  for (int i = 0; i < X + Y; i++) {ans += PQR[i];}
  cout << ans << endl;
}


Measured memory_bytes: 2560
module.exports=function(t){var r={};function i(n){if(r[n])return r[n].exports;var e=r[n]={i:n,l:!1,exports:{}};return t[n].call(e.exports,e,e.exports,i),e.l=!0,e.exports}return i.m=t,i.c=r,i.d=function(t,r,n){i.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,r){if(1&r&&(t=i(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var e in t)i.d(n,e,function(r){return t[r]}.bind(null,e));return n},i.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(r,"a",r),r},i.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},i.p="",i(i.s=0)}([function(t,r,i){"use strict";var n=i(1);i(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,i){"use strict";var n=i(3),e=i(5);t.exports=function(t){var r=new n(t);e(r)}},function(t,r,i){"use strict";var n=i(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,i){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,i){"use strict";var n=i(6);t.exports=function(t){for(var r=t.in(),i=t.in(),e=new Array(r),s=0;s<r;s++)e[s]=t.in();for(var o=new n(2*r+1),u=0;u<r;u++)o.unite(e[u],u+1+r);for(var a=0;a<i;a++){var c=t.in()-1,f=t.in()-1;o.unite(e[c],e[f])}for(var h=0,p=0;p<r;p++)o.isSameGroup(p+1,p+1+r)&&h++;console.log(h)}},function(t,r,i){"use strict";t.exports=class{constructor(t){this.N=t,this.par=new Array(this.N),this.rank=new Array(this.N);for(var r=0;r<this.N;r++)this.par[r]=r,this.rank[r]=0}find(t){return this.par[t]==t?t:this.par[t]=this.find(this.par[t])}unite(t,r){var i=this.find(t),n=this.find(r);i!=n&&(this.rank[i]<this.rank[n]?this.par[i]=n:(this.par[n]=i,this.rank[i]==this.rank[n]&&this.rank[i]++))}isSameGroup(t,r){return this.find(t)==this.find(r)}}}]);

Measured memory_bytes: 38980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll                dp[100005][13];

int main() {
    string s;
    cin >> s;
    s        = ' ' + s;
    dp[0][0] = 1;
    for (int i = 1; i < s.length(); i++) {
        if (s[i] == '?') {
            for (int j = 0; j < 13; j++)
                for (int k = 0; k <= 9; k++) {
                    dp[i][(10 * j + k) % 13] += dp[i - 1][j];
                }
        } else {
            for (int j = 0; j < 13; j++)
                dp[i][(10 * j + s[i] - '0') % 13] += dp[i - 1][j];
        }
        for (int j = 0; j < 13; j++)
            dp[i][j] %= 1000000007;
    }
    cout << dp[s.length() - 1][5] << endl;
}

Measured memory_bytes: 10620
#include<bits/stdc++.h>
using namespace std;
long long arr[10000];
int main()
{
	long long n,i,ans;
	ans=0;
	cin>>n;
	for (i=0;i<n-1;i++)
	{
		cin>>arr[i];
	}
	ans+=(arr[0]+arr[n-2]);
	for (i=0;i<n-2;i++)
	{
		ans+=(fmin(arr[i],arr[i+1]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
#define ll long long

int main() {
    string n;
    cin >> n;
    if(n[0] == '7' || n[1] == '7' || n[2] == '7') {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;

    int x = 0;
    int ans = 0;

    rep(i, n){

        if(s[i] == 'I'){
            x++;
        }else{
            x--;
        }

        ans = max(ans, x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    if(k == 0){
        cout << n * n << endl;
        return 0;
    }

    ll ans = 0;
    for(int i = k + 1; i <= n; i++){
        ll num = i - k;
        ll cycle = n / i;
        ans += num * cycle;
        ll rest = n % i;
        
        ans += max(0LL, rest - k + 1);

    }

    cout << ans << endl;
}

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

int main() {
    ll n;
    cin>>n;
    vector<string> s(n);
    rep(i,n){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    ll ans=0;
    ll cnt=1;
    string be=s[0];
    rep(i,n-1){
        if(s[i+1]==be){
            cnt++;
            if(i+1==n-1)ans+=cnt*(cnt-1)/2;
        }else{
            ans+=cnt*(cnt-1)/2;
            cnt=1;
        }
        be=s[i+1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int n,x;
multiset <int, greater<int> > s;
multiset <int> v;
int main()
{
    cin>>n;
    for(int i=0;i<(1<<n);i++)
    {
        cin>>x;
        s.insert(x);
    }
    v.insert(*s.begin());
    s.erase(s.begin());
    for(int i=0;i<n;i++)
    {
        vector <int> add_v;
        for(multiset <int>:: iterator it=v.begin();it!=v.end();it++)
        {
            if(s.lower_bound(*it-1)==s.end())
            {
                cout<<"No";
                return 0;
            }
            add_v.push_back(*(s.lower_bound(*it-1)));
            s.erase(s.lower_bound(*it-1));
        }
        for(int j=0;j<(int)add_v.size();j++)
            v.insert(add_v[j]);
    }
    cout<<"Yes\n";
    return 0;
}

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

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

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i]; 
    rep(i, n) cin >> b[i]; 
    rep(i, n-1) cin >> c[i]; 
    
    int score = b[a[0]-1];
    rep(i, n-1){
        if(a[i] + 1 == a[i+1]) score += c[a[i]-1];
        score += b[a[i+1]-1];
    }

    cout << score << endl;
    return 0;
}


Measured memory_bytes: 256
import collections
num_list = [int(i) for i in input().split()]
height_list = [int(i) for i in input().split()]
way_list = list(list(map(int, input().split())) for i in range(num_list[1]))

tower_list = [i for i in range(1, num_list[0]+1)]
gd_dict = dict(zip(tower_list, ['good' for i in range((len(tower_list)))]))

def change_to_bad(target_list):
    if height_list[target_list[0]-1] > height_list[target_list[1]-1]:
        gd_dict[target_list[1]] = 'bad'
    elif height_list[target_list[0]-1] == height_list[target_list[1]-1]:
        gd_dict[target_list[0]] = 'bad'
        gd_dict[target_list[1]] = 'bad'
    else:
        gd_dict[target_list[0]] = 'bad'

for i in way_list:
    change_to_bad(i)

good_val = collections.Counter(gd_dict.values())['good']

print(good_val)

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

int main() {
	int n, x;
	cin >> n >> x;
	int l[n];
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		if (i) l[i] += l[i - 1];
	}
	int ans = 1;
	for (auto e : l) if (e <= x) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int cnt = 0;
		long now = 0;
		for(int i=0;i<=N;i++){
			if(now > X) break;
			cnt++;
			if(i < N)now += L[i];
		}
		Console.WriteLine(cnt);
		
	}
	int N;
	long[] L;
	long X;
	public Sol(){
		var d = ria();
		N = d[0]; X = d[1];
		L = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
	int n,ans=0;

	cin >>n;
	int *array=new int[n];
	for(int i=0;i<n;i++)cin >>array[i];
	sort(array,array+n);
	for(int i=n-1;i>=0;i--){
		if(n%2==i%2)ans-=array[i];
		else ans+=array[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

long long n, a, b;
long long x[101010];

int main() { 
	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i) 
		cin >> x[i];

	long long ans = 0;
	for (int i = 1; i < n; ++i)
		ans += min((x[i] - x[i - 1]) * a, b);

	cout << ans << endl;
}


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll N=ii(), K=ii();
    vector<ll> P, C;
    REP(i,0,N){
        P.push_back(ii()-1);
    }
    REP(i,0,N){
        C.push_back(ii());
    }
    ll ret=LLONG_MIN;
    REP(i,0,N){
        ll all=0;
        ll n=0;
        ll c=i;
        ll k=K;
        REP(j,0,N){
            c=P[c];
            all+=C[c];
            n++;
            if(c==i) break;
        }
        ll r=0;
        if(k/n-1>0){
            if(all>0){
                r=(k/n-1)*all;
            }
            k-=(k/n-1)*n;
        }
        REP(j,0,k){
            c=P[c];
            r+=C[c];
            ret=max(ret,r);
        }
    }
    oie(ret);
    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int N;		cin >> N;
  pair<pair<string , int> , int> p[101];

  for(int i = 0 ; i < N ; i++){
	 cin >> p[i].first.first >> p[i].first.second;
	 p[i].second = i + 1;
	 p[i].first.second *= -1;
  }

  sort(p, p + N);
  for(int i = 0 ; i < N ; i++){
	 cout << p[i].second << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int n,i;
  int x,xx;
  string s;
  cin>>n>>s;
  x=xx=0;
  for(i=0;i<n;i++){
    if(s[i]=='I') x++;
    else x--;
    xx=max(x,xx);
  }
  cout<<xx<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,a,b,ans;
int main()
{
	cin>>n;
	a=n*800;
	for(int i=0;i<8;i++)
	{
		if(i*15<=n&&i*15+15>n)
		{
			b=i;	
		} 
	} 
	ans=a-b*200;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    string s;cin>>s;
    bool count = false;
    bool ans = true;
    for(char x:s){
        if(count) {
            if(x == 'i'){
                count = !count;
            }else{
                ans = false;
            }
        }else{
            if(x == 'h'){
                count = !count;
            }else{
                ans = false;
            }
        }
    }

    if(s.size()%2 == 1) ans = false;
    cout << (ans ? "Yes" : "No") <<endl;


    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 20;
const int MM = 1000000007;

ll A[MX], B[MX], S[MX], D[MX];

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	for(int i = 1; i <= N; i++){
		scanf("%lld", D+i);
		S[i] = S[i-1] + D[i];
	}
	for(int i = 1; i <= N; i++){
		A[i] = A[i-1];
		if( D[i] >= 0 ) A[i] += D[i];
	}
	for(int i = N; i >= 1; i--){
		B[i] = B[i+1];
		if( D[i] >= 0 ) B[i] += D[i];
	}
	ll ans = -1e18;
	for(int i = 1; i+K-1 <= N; i++){
		ans = max(ans, A[i-1] + (S[i+K-1] - S[i-1]) + B[i+K]);
		ans = max(ans, A[i-1] + B[i+K]);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 7168
// Aizu Vol0 0016: Treasure Hunt
// 2017.8.11

#include <stdio.h>
#include <math.h>

#define PI 3.1415926535897932384626433832795
#define M 0.01745329251994329576923690768489

#define EPS  1.0e-8
#define isZero(k) (fabs(k) <= EPS)

int main()
{
	double r, q, f;
	int d, a;
	double r2, q2, t;

	r = 0, q = 90*M, f = 0;
	while (1) {
		scanf("%d,%d", &d, &a);
		if (!d && !a) break;
		r2 = sqrt(r*r + d*d - 2*r*d*cos(PI - fabs(f)));
		if (isZero(r) || isZero(r2)) q2 = q - f, f = a*M;
		else {
			t = acos((r*r + r2*r2 - d*d) / (2 * r*r2));
			if (f >= 0) q2 = q - t, f += a*M - t;
			else        q2 = q + t, f += a*M + t;
		}
		r = r2, q = q2;
	}
	printf("%d\n%d\n", (int)(r * cos(q)), (int)(r * sin(q)));
	return 0;
}

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

int main(){
    ld a,b,c;
    cin>>a>>b>>c;
    //cout<<sqrtl(a)<<endl;
    //cout<<sqrtl(b)<<endl;
    //cout<<sqrtl(c)<<endl;
    if(a+2*sqrt(a)*sqrt(b)+b < c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;



public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] H = new long[N];
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextLong();
		}
		long result = 0;
		Arrays.sort(H);
		if(N > K) {
			for(int i = 0; i < N-K; i++) {
				result += H[i];
			}
		}
		System.out.println(result);
	}
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+111;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        string s,t;
        cin>>s>>t;
        n=s.sz;
        ll ans=0;
        for(i=0;i<n;i++){
                if(s[i]!=t[i])ans++;
        }
        cout<<ans<<endl;

        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;


int main(){
  int n;
  cin>>n;
  if(n==1) cout<<"Hello World"<<endl;
  else{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	int a1, a2, a3, a4, a5, a6;
	cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
	cout << (a1 + a2 * 5 + a3 * 10 + a4 * 50 + a5 * 100 + a6 * 500 >= 1000 ? 1 : 0) << endl;
}

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

using namespace std;

int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int st = max(a,c);
    int ed = min(b,d);
    int result = ed - st;
    if (result <= 0){
        printf("0\n");
    }
    else{
        printf("%d\n",result);
    }
    return 0;
}


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

int main() {
  string s;
  
  cin >> s;
  
  bool isgood = true;
  
  if (s[0] == s[1]) isgood = false;
  if (s[1] == s[2]) isgood = false;
  if (s[2] == s[3]) isgood = false;
    
  cout << (isgood ? "Good" : "Bad") << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    string S;
    cin >> S;
    if(S[0] == S[2]){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(auto c: S) {
        if(c == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    vector< LLP > v(n);
    rep(i, n){
        cin >> v[i].second >> v[i].first;
    }
    SORT(v);

    bool flag = true;
    lint t = 0;
    rep(i, n){
        t += v[i].second;
        if(t > v[i].first){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  rep(i, n) {
    int a;
    cin >> a;
    a--;
    if (a == cnt) cnt++;
  }
  int ans = cnt == 0 ? -1 : n - cnt;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            System.out.println(-1 + 2 * K <= N ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); int M = sc.nextInt(); int C = sc.nextInt();
		int[] B = new int[M];
		for(int i = 0;i < M;i++){
			B[i] = sc.nextInt();
		}
		int[][] A = new int[N][M];
		int cnt = 0;
		for(int i = 0;i < N;i++) {
			int sum = 0;
			for(int j = 0;j < M;j++) {
				A[i][j] = sc.nextInt();
				sum += A[i][j]*B[j];
			}
			if(sum + C > 0) {
				cnt++;
			}
		}
		sc.close();
		System.out.println(cnt);
	}
}

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

int main(void)
{
	int n;
	cin>>n;
	vector<int> a(26,100);
	for (int i = 0; i < n; i++) {
		string s;
		cin>>s;
		vector<int> cnt(26,0);
		for(auto x:s){
			cnt[x-'a']++;
		}
		for(int j=0;j<26;j++){
			a[j]=min(a[j],cnt[j]);
		}
	}
	string ret;
	int i=0;
	for(auto x:a){
		ret+=string(x,'a'+i);
		i++;
	}
	cout<<ret<<endl;
	return 0;
}


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

struct Process {
    string name;
    int time;
    int count;
};

class Queue {
    private:
        Process store[1000000];
        int head, tail;
        Process firstProcess;

    public:
        Queue() {
            head=0;
            tail=0;
        }
 
        void enqueue(string name, int time) {
            Process p;
            p.name = name;
            p.time = time;
            store[tail] = p;
            tail++;
        }

        Process dequeue() {
            firstProcess = store[head];
            head++;
            return firstProcess;
        }
};
 
int main() {
    Queue q;
    int n, rr, time, diff, total;
    string name;
    Process p;

    cin >> n >> rr;
    for (int i=0; i<n; i++) {
        cin >> name >> time;
        q.enqueue(name, time);
    }

    total = 0;
    while (n) {
        p = q.dequeue();
        diff = p.time - rr;
        if (diff >0) {
            total += rr;
            q.enqueue(p.name, diff);
        } else {
            total += p.time;
            cout << p.name << " " << total << endl;
            n--;
        }
    }
    return 0;
}


Measured memory_bytes: 21112
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>
#define PI 3.1415926535
#include <sstream>
#define MAX 100
#define swap(a,b,t) (t=a,a=b,b=t)
using namespace std;

int main()
        { 
        float A,B,T;
        int a;
        cin>>A>>B>>T;
        a=(T+0.5)/A;
        cout<<B*a;
        //system("pause");
        }
        



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

A,B,C,D = map(int,input().split())

if(B<C or D<A):
    print("0")
else:
    if(A>=C):
        begin = A
    else:
        begin = C
    if(D<=B):
        end = D
    else:
        end = B
    print(end-begin)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int waru = 1000000007;
const int INF=2000000000;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,INF))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]

int main(){
int n;cin>>n;
  vec1(a,n);
  reverse(all(a));
  vector<int> dp(n,INF);//dp[i]:=i+1文字の部分列の最後の文字の最小値
  rep(i,n) *upper_bound(all(dp),a[i])=a[i];
  cout<<lower_bound(all(dp),INF)-dp.begin()<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
class Main /*atcoder beginner contest 42*/{
	public static void main(String[] args) {
			
			Scanner s = new Scanner(System.in);
			int n = s.nextInt() , l = s.nextInt();
			int n1 = n;
			int[] pre = new int[10];
			for(int i = 0;i < l;i++){
				int dig = s.nextInt();
				pre[dig] = 1;
			}
/*
			String np = n+"";
			int[] no = new int[np.length()];
			int indx = np.length()-1;
			while(n != 0){
				int p = n%10;
				no[indx] = p;
				n/=10;
				indx--;
			}*/
/*
			for(int i = 0;i  < no.length;i++)
				System.out.print(no[i]);
			System.out.println();
*/			/*int change = 0;
			for(int i = 0;i  < no.length;i++){
				int ele = no[i];
				// System.out.println(ele);
				if(pre[ele] == 1){

					if(i == 0){
						for(int j = ele;j <= 9;j++){
							if(pre[j] != 1 ){
								no[i] = j;
								change = 1;
								break;
							}
						}
					}
					else{
						for(int j = ele;j <= 9;j++){
							if(pre[j] != 1){
								no[i] = j;
								change = 1;
								break;
							}
						}
					}

				}
			}
		*/	
			// if(change == 0)
			{
				// System.out.println("exe");
				for(int j = n1;j  <= 100000 ;j++){
					String line = j+"";
					int flag = 0;
					// System.out.println("line = "+line+" j = "+j);
					for(int i = 0;i < line.length();i++)
					{
						char p = line.charAt(i);
						int indx = Integer.parseInt(p+"");
						if(pre[indx] == 1){
							flag = 1;
							break;
						}
					}
					if(flag == 0){
						System.out.println(line);
						break;
					}
				}
			}
			/*else{

				for(int i = 0;i < no.length;i++)
					System.out.print(no[i]);
				System.out.println();
			}*/

	}
}

Measured memory_bytes: 34388
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn{
			cin >> ar[i];
		}
		int mx = 0 , ans =0;
		fn{
			mx=max(mx,ar[i]);
			ans+=mx-ar[i];
		}
		cout << ans ;
	}
	return 0;
}

Measured memory_bytes: 5152
import sys
sys.setrecursionlimit(10**7) #再帰回数の上限を変更
from collections import deque

N,K=map(int,input().split())
A=list(map(int,input().split()))

L=[]
chk=[0 for _ in range(N)]
tmp=0
while(1):
    if chk[tmp]==1:
        break
    chk[tmp]=1
    L.append(tmp)
    tmp=A[tmp]-1
#print(L)
loop_s=A[L[-1]]-1
loop_g=L[-1]
one_to_s=0
tmp=0
#print(loop_s)
#print(loop_g)

while(1):
    if tmp==loop_s:
        break
    tmp=A[tmp]-1
    #print(tmp)
    one_to_s+=1

loop_l=0
tmp=loop_s
Loop=[loop_s]
while(1):
    if tmp==loop_g:
        break
    tmp=A[tmp]-1
    Loop.append(tmp)
    loop_l+=1
loop_l+=1
#print(one_to_s)
if K<=one_to_s:
    tmp=0
    #print("ON")
    cnt=0
    while(1):
        if cnt==K:
            break
        tmp=A[tmp]-1
        cnt+=1
    ans=tmp + 1
else:
    K-=one_to_s
    num=K%loop_l
    ans=Loop[num]+1

print(ans)

Measured memory_bytes: 34404
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int sum_count = 0;
    for (int i=1; i <= N; i++) {
        if (i % 2 == 0) {
            continue;
        }

        int count = 0;
        for (int j=1; j <= N; j++) {
            if (j % 2 == 0) {
                continue;
            }

            if (i % j == 0) {
                count += 1;
            }
        }

        if (count == 8) {
            sum_count += 1;
        }
    }

    cout << sum_count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char S[3];
	
	scanf("%s",S);
	
	if ( S[1]==S[2] && S[2]==S[0] && S[0]==S[1] ){
		printf("No");
		return 0;
	}
	printf("Yes");
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int N,i,j;
  int heal = 0;
  int S[200];
  scanf("%d",&N);
  for(i=0;i<N;i++){scanf("%d",&S[i]);}
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      heal += S[i]*S[j];
    }
  }
  printf("%d",heal);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z), p;
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    rep(i, X){
        rep(j, Y){
            p.push_back(A[i] + B[j]);
        }
    }
    sort(p.begin(), p.end(), greater<ll>());

    vector<ll> tmp;
    int pp = min((ll)p.size(), K);
    rep(i, pp) tmp.push_back(p[i]);

    vector<ll> ans;
    rep(i, pp){
        rep(j, Z) ans.push_back(tmp[i]+C[j]);
    }

    sort(ans.begin(), ans.end(), greater<ll>());

    rep(i, K){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 43144
// 1D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<algorithm>
#define MAX 100000
using namespace std;

int n, A[MAX + 1], L[MAX];

int lis()
{
    L[0] = A[0];
    int length = 1;

    for (int i = 1; i < n; i++) {
        if (L[length - 1] < A[i]) {
            L[length++] = A[i];
        }
        else {
            *lower_bound(L, L + length, A[i]) = A[i];
        }

    }
    return length;
}

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

    cout << lis() << endl;

    return 0;
}


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

typedef long long ll;

int main (void) {
    const int N = (1e5) + 5;
    int n, a[N];
    int L[N];
    int R[N];
    scanf("%d", &n);

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

    for (int i = 1; i <= n; i++) {
        L[i] = __gcd(L[i - 1], a[i]);
    }

    for (int i = n; i >= 1; i--) {
        R[i] = __gcd(a[i], R[i + 1]);
    }
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, __gcd(L[i - 1], R[i + 1]));
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define range(x,l,r) (l<=x && x<r)  
using namespace std;
typedef pair<int,int> pii;

const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};
int w,h;
int g[110][110];

int dijkstra(int s, int t){
  vector<int> dis(h*w,1e8);
  dis[s] = 0;
  priority_queue< pii,vector<pii>,greater<pii> > q;
  q.push(pii(0,s));
  
  while(q.size()){
    pii cur = q.top(); q.pop();
    int y = cur.second/w, x = cur.second%w, d = cur.first;
    if(t == cur.second)return d;
    if(dis[cur.second] < d)continue;

    rep(dir,4){
      int ny = y+dy[dir], nx = x+dx[dir];
      if(range(ny,0,h) && range(nx,0,w) && g[ny][nx]!=4){
	int nxt = ny*w + nx, nd = dis[cur.second] + g[y][x];
	if(dis[nxt] > nd){
	  dis[nxt] = nd;
	  q.push(pii(nd, nxt));
	}
      }
    }
  }
  return -1;
}

int main(){
  cin >> w >> h;
  vector<string> s(h);
  rep(i,h){
    cin >> s[i];
    rep(j,w)g[i][j] = 1;
  }

  int S,G;
  vector<int> maki;
  rep(i,h)rep(j,w){
    if(s[i][j] == '#'){
      for(int ii=-2;ii<=2;ii++)for(int jj=-2;jj<=2;jj++){
	  int ni = i+ii, nj = j+jj;
	  if(range(ni,0,h) && range(nj,0,w)){
	    int dif = max(abs(ii),abs(jj));
	    g[ni][nj] = max(g[ni][nj], 4-dif);
	  }
	}
    }else if(s[i][j] == 'M')maki.push_back(i*w + j);
    else if(s[i][j] == 'S')S = i*w + j;
    else if(s[i][j] == 'G')G = i*w + j;
  }

  int K = maki.size();
  int dis[10][10];
  rep(i,K){
    dis[0][i+1] = dijkstra(S,maki[i]);
    dis[i+1][K+1] = dijkstra(maki[i],G);
    rep(j,i){
      dis[i+1][j+1] = dijkstra(maki[i], maki[j]);
      dis[j+1][i+1] = dijkstra(maki[j], maki[i]);
    }
  }

  vector<int> perm(K);
  rep(i,K)perm[i] = i+1;
  int ans = 1e8;
  do{
    int sum = dis[0][perm[0]] + dis[perm[K-1]][K+1];
    for(int i=0;i<K-1;i++)sum += dis[perm[i]][perm[i+1]];
    ans = min(ans, sum);
  }while(next_permutation(perm.begin(),perm.end()));
  cout << ans << endl;
}

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

typedef long long ll;
using namespace std;

int n,m;

struct tr{int a,b,c;};

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

	cin >> n >> m;
	
	vector<tr> d;
	int s,t,e;
	while(true){
		cin >> s >> t >> e;
		if(s == 0) break;
		d.push_back({s-1,t-1,e});
	}

	int l; cin >> l;

	for (int i = 0;i < l;i++){
		int b[m];
		for (int j = 0;j < m;j++){
			cin  >> b[j];
		}
		int sum[n];
		memset(sum,0,sizeof(sum));
		for (int j = 0;j < d.size();j++){
			tr tmp = d[j];
			sum[tmp.a] += b[tmp.b]*tmp.c;
		}
		for (int j = 0;j < n;j++){
			cout << sum[j] << (j < n-1 ? " " : "\n");
		}
	}

	return 0;

}



Measured memory_bytes: 3760