akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//
//-----class-----//
class UnionFind{
    public:
        vector<ll> par; //parents
        vector<ll> siz; // sizes of set
        vector<ll> rank; // rank of each element 
    UnionFind(ll n): par(n), siz(n, 1LL), rank(n){
        LREP(i, 0, n) par[i] = i;
    }
    //initialization
    /*
    void init(ll n){
        par.assign(n);
        siz.assign(n, 1LL);
        rank.assign(n);
        LREP(i, 0, n) par[i] = i;
    }
    */

    // find the root of x
    ll find(ll x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    //Unite two set including x or y
    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //Do x and y belong to the same set?
    bool issame(ll x, ll y){
        return find(x) == find(y);
    }

};

int N;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    int B[N-1];
    REP(i, 0, N - 1) cin >> B[i];

    int ans = 0;
    ans += B[0] + B[N-2];
    
    REP(i, 1, N - 1){
        ans += min(B[i - 1], B[i]);
    }
    cout << ans << '\n';

}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

ans = 0
for i in A:
	ans += 1/i
print(1/ans)


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

int main(){
	while(1){
		int n, p=1000, ans=0, i=0;
		int m[6]={500, 100, 50, 10, 5, 1};
		
		scanf(" %d", &n);
		if(n==0) break;
	
		p-=n;
		for(int i=0; i<6; ++i){
			if(p>=m[i]){
				int t=p/m[i];
				ans+=t;
				p-=m[i]*t;
			}			
		}
	
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

#define pb 					push_back

template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}

template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";

	return os;
}

int main() {
    //ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
  int n;
  cin >> n;
  cout << n*n;



	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    int i;
    char s[6];
    
    for(i = 0;i < 6;i++){
        scanf("%c",&s[i]);
    }
    if(s[2] == s[3] && s[4] == s[5]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
V = list(map(int,input().split()))
Vi = V[::-1]
t = min(n,k)
ans = 0
for i in range(1,t+1):#選ぶ個数
    for a in range(0,i+1):
        b = i-a
        houseki = V[0:a] + Vi[0:b]
        houseki.sort()
        tmp=sum(houseki)
        for idx,val in enumerate(houseki):
            if idx==k-i:break
            if val<0:tmp-=val
        ans = max(ans,tmp)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ST (n+1)
#define ED (n+2)
#define MINNODE 1
#define MAXNODE n+2
#define INF LONG_MAX
using namespace std;
int n,E=1;
long long l[200001],dis[200001];
long long to[200001],nex[200001],wei[200001],fir[200001];
void addedge(int x,int y,long long z)
{
	++E;
	to[E]=y;nex[E]=fir[x];fir[x]=E;wei[E]=z;
	++E;
	to[E]=x;nex[E]=fir[y];fir[y]=E;wei[E]=0;
}
bool bfs()
{
	l[1]=ST;
	for(int i=MINNODE;i<=MAXNODE;i++)
		dis[i]=0;
	dis[ST]=1;
	for(int h=1,t=1;h<=t;h++)
	{
		for(int i=fir[l[h]];i;i=nex[i])
		if(wei[i]>0 && !dis[to[i]])
		{
			dis[to[i]]=dis[l[h]]+1;
			l[++t]=to[i];
		}
	}
	return dis[ED]>0;
}
long long dfs(int now,long long flow)
{
	if(flow<=0) return 0;
	if(now==ED) return flow;
	long long all=0;
	for(int i=fir[now];i && flow;i=nex[i])
	if(wei[i]>0 && dis[to[i]]==dis[now]+1)
	{
		int tem=dfs(to[i],min(flow,wei[i]));
		wei[i]-=tem;wei[i^1]+=tem;
		all+=tem;flow-=tem;
	}
	if(flow)
		dis[now]=0;
	return all;
}
int main()
{
	scanf("%d",&n);
	long long bestans=0;
	for(int i=1;i<=n;i++)
	{
		int tem;
		scanf("%d",&tem);
		if(tem>0)
		{
			bestans+=tem;
			addedge(i,ED,tem);
		}
		else
			addedge(ST,i,-tem);
		for(int j=2;j<=n/i;j++)
			addedge(i,i*j,INF);
	}
	while(bfs())
		bestans-=dfs(ST,INF);
	printf("%lld\n",bestans);
	return 0;
}

Measured memory_bytes: 6400
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
//#include <intrin.h>
#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
using namespace::std;

void solve(){
	int N;
	int A,B;
	cin >> N >> A;
	N %= 500;
	cout << (A>=N?"Yes":"No") << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 892
import sys
input = sys.stdin.readline

N,M,Q=map(int,input().split())
E=[list(map(int,input().split())) for i in range(Q)]

# UnionFind

Group=[i for i in range(N)]# グループ分け.Group[i]=jのときiとjは同じグループ

def find(x):# find(a)=find(b)のとき同じグループ
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):  # xとyが同じグループになるよう更新
    if find(x) != find(y):
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))

E1=[]
for a,b,x in E:
    if x==0:
        Union(a,b)
    else:
        E1.append((a,b))

Group=[find(i) for i in range(N)]

for a,b in E1:
    if Group[a]==Group[b]:
        print("No")
        sys.exit()

C=len(set(Group))

if len(E1)==0:
    if N-1<=M<=(N-C)+C*(C-1)//2:
        print("Yes")
    else:
        print("No")

else:
    if N<=M<=(N-C)+C*(C-1)//2:
        print("Yes")
    else:
        print("No")
    


Measured memory_bytes: 45316
import sys
_=input()
A=[int(i) for i in input().split()]
B=[]
for a in A:
  if a % 2 == 0:
    B.append(a)
for b in B:
  if b%3 !=0 and b%5 !=0:
    print("DENIED")
    sys.exit()
else:
  print("APPROVED")

Measured memory_bytes: 38384
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define p_b push_back
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

const int N = 1010;
int n, m;
vector<int> e[N], id[N], _e[N], _id[N];
int p[2][N]; bool w[N];
bool ans[200010];

void dfs(int u, int id, int o) {
	p[o][u] = id;
	for(int i = 0; i < e[u].size(); ++i)
		if(!p[o][e[u][i]]) dfs(e[u][i], id, o);
}

void dfs2(int u) {
	w[u] = 1;
	for(int i = 0; i < e[u].size(); ++i)
		if(!w[e[u][i]]) dfs2(e[u][i]);
}

int main() {
	int i, j, x, y;
	scanf("%d%d", &n, &m);
	rep(i, 1, m) {
		scanf("%d%d", &x, &y);
		e[x].p_b(y); id[x].p_b(i);
		_e[y].p_b(x); _id[y].p_b(i);
	}
	rep(i, 1, n) {
		memset(p, 0, sizeof p);
		p[0][i] = p[1][i] = n+1;
		for(j = 0; j < e[i].size(); ++j)
			if(!p[0][e[i][j]]) dfs(e[i][j], id[i][j], 0);
		for(j = e[i].size()-1u; ~j; --j)
			if(!p[1][e[i][j]]) dfs(e[i][j], id[i][j], 1);
//		rep(j, 1, n) printf("%d ", p[0][j]); puts("");
//		rep(j, 1, n) printf("%d ", p[1][j]); puts("");
		
		for(j = 0; j < e[i].size(); ++j)
		if(p[0][e[i][j]] != id[i][j] || p[1][e[i][j]] != id[i][j]) ans[id[i][j]] ^= 1;
	}
	rep(i, 1, n) {
		memset(w, 0, sizeof w);
		dfs2(i);
		
		for(j = 0; j < _e[i].size(); ++j)
		if(w[_e[i][j]]) ans[_id[i][j]] ^= 1;
	}
	rep(i, 1, m)
	if(ans[i]) puts("diff"); else puts("same");
	return 0;
}

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

using namespace std;

typedef long long ll;

inline ll read(){
	char ch=getchar();ll x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int p[1010011];

int cnt=0; 

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

int a[2020202];

int main(){
	int n=read();
	for(int i=2;i<=100;i++){
		if(prime(i)==1){
			cnt++;
			p[cnt]=i;
		}
	}
	for(int i=1;i<=n;i++){
		int x=i;
		for(int j=1;j<=cnt;j++){
			while(x%p[j]==0 && x>=p[j]){
				a[j]++;
				x/=p[j];
			}
			if(x<p[j]) break;
		}
	}
	int ans=0;
	int b=0,c=0,d=0,e=0;
	for(int i=1;i<=cnt;i++){
		if(a[i]>=74) ans++;
	}
	for(int i=1;i<=cnt;i++){
		for(int j=i+1;j<=cnt;j++){
			if(a[i]>=2 && a[j]>=24) ans++;
			if(a[i]>=24 && a[j]>=2) ans++;
			if(a[i]>=4 && a[j]>=14) ans++;
			if(a[i]>=14 && a[j]>=4) ans++;
		}
	}
	for(int i=1;i<=cnt;i++){
		for(int j=i+1;j<=cnt;j++){
			for(int k=j+1;k<=cnt;k++){
				if(a[i]>=2 && a[j]>=4 && a[k]>=4) ans++;
				 if(a[i]>=4 && a[j]>=4 && a[k]>=2) ans++;
				 if(a[i]>=4 && a[j]>=2 && a[k]>=4) ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}





Measured memory_bytes: 2304
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll cnt = 0;
    rep(i, S.size() - 2)
    {
        cnt +=
            (S[i + 0] == 'A') &&
            (S[i + 1] == 'B') &&
            (S[i + 2] == 'C');
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3136
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll pow (ll x, ll n){
    ll ans = 1;
    while(n>0){
        if(n & 1 == 1){
            ans *= x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}


int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans ;
    ans = a*x + b*y;
    for(int i=0; i<=max(x,y); i++){
        if(i<min(x,y)){
            ll m = a*(x-i) + b*(y-i) + c*i*2;
            ans = min(ans, m);
        }else if(x<y){
            ll m = b*(y-i) + c*i*2;
            ans = min(ans, m);            
        }else{
            ll m = a*(x-i) + c*i*2;
            ans = min(ans, m);
        }
    }

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


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

int main(void){
    int a,b;
    cin >> a >>b;
    if(a>=10 || b>=10){
        cout << -1 <<endl;
    }
    else{
        int ans =a*b;
        cout << ans <<endl;
    }
    
    
    return 0;
    
}
















































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

int main() {
  
  string s;
  cin >> s;
  
  int counta = 0,countz = 0;
  
  for ( int i = 0; i < s.size(); i++){
    if ( s[i] != 'A' ){
      counta++;
    }else{
      break;
    }
  }
  
  for ( int i = s.size() - 1; i >= 0; i--){
    if ( s[i] != 'Z' ){
      countz++;
    }else{
      break;
    }
  }
  
  cout << s.size() - counta - countz << endl;  
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<P>ab(N);
    vector<P>cd(N);
    for(int i = 0; i < N; i++) {
        int a,b;
        cin >> a >> b;
        ab[i].first = a;
        ab[i].second = b;
    }
    for(int i = 0; i < N; i++) {
        int c,d;
        cin >> c >> d;
        cd[i].first = c;
        cd[i].second = d;
    }
    vector<bool>ok(N,false);
    sort(ab.begin(),ab.end());
    reverse(ab.begin(),ab.end());
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int X = INF;
        int Y = INF;
        for(int j = 0; j < N; j++) {
            if(ab[i].first < cd[j].first && ab[i].second < cd[j].second) {
                if((!ok[j]) && X > cd[j].second) {
                    X = cd[j].second;
                    Y = j;
                }
                
            }
        }
        if(Y != INF) {
            ok[Y] = true;
        }
    }
    for(int i = 0; i < N; i++) {
        if(ok[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

class tree{
public:
    void putparent(int n);
    void putleft(int n);
    void putright(int n);
    int getparent();
    string gettype();
    int getleft();
    int getright();
    int getdegree();
    tree();
private:
    int parent;
    int left;
    int right;
};

typedef struct tree Tree;

tree::tree()
{
    parent = -1;
    left = -1;
    right = -1;
}

void tree::putparent(int n)
{
    parent = n;
    return;
}

void tree::putleft(int n)
{
    left = n;
    return;
}

void tree::putright(int n)
{
    right = n;
    return;
}

int tree::getparent()
{
    return parent;
}

string tree::gettype()
{
    if(getparent() == -1) return "root";
    else if(getleft() == -1 && getright() == -1) return "leaf";
    else return "internal node";
}

int tree::getleft()
{
    return left;
}

int tree::getright()
{
    return right;
}

int tree::getdegree()
{
    int cnt = 0;
    if(getleft() != -1) cnt++;
    if(getright() != -1) cnt++;
    return cnt;
}

int getdepth(Tree a[], int n)
{
    int ans = 0;
    if(a[n].getparent() != -1) return getdepth(a, a[n].getparent()) + 1;
    else return 0;
}

int getsibling(Tree a[], int n)
{
    int p = a[n].getparent();
    if(p == -1) return -1;
    int ans = a[p].getleft() + a[p].getright() - n;
    return ans;
}

int getheight(Tree a[], int n)
{
    if(a[n].getleft() == -1 && a[n].getright() == -1) return 0;
    else if(a[n].getleft() == -1) return getheight(a, a[n].getright()) + 1;
    else if(a[n].getright() == -1) return getheight(a, a[n].getleft()) + 1;
    else return max(getheight(a, a[n].getleft()), getheight(a, a[n].getright())) + 1;
}

int main()
{
    int n;
    cin >> n;
    Tree t[25];
    int id, l, r;
    for(int i = 0; i < n; i++){
        cin >> id >> l >> r;
        t[id].putleft(l);
        t[id].putright(r);
        if(l != -1) t[l].putparent(id);
        if(r != -1) t[r].putparent(id);
    }
    for(int i = 0; i < n; i++){
        cout << "node " << i << ": ";
        cout << "parent = " << t[i].getparent() << ", ";
        cout << "sibling = " << getsibling(t, i) << ", ";
        cout << "degree = " << t[i].getdegree() << ", ";
        cout << "depth = " << getdepth(t, i) << ", ";
        cout << "height = " << getheight(t, i) << ", ";
        cout << t[i].gettype() << endl;
    }
}

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

/// @brief Returns the index of sub in s, or -1 if not exist.
int find(const string& s, const string& sub) {
  for (int i = s.size() - sub.size(); i >= 0; --i) {
    bool found = true;
    for (int j = 0; j < sub.size(); ++j)
      if (s[i + j] != '?' && s[i + j] != sub[j]) found = false;
    if (found) return i;
  }
  return -1;
}

int main() {
  string S_prime, T;
  cin >> S_prime >> T;
  int index = find(S_prime, T);
  if (index == -1) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  S_prime.replace(index, T.size(), T);
  replace(S_prime.begin(), S_prime.end(), '?', 'a');
  cout << S_prime << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str;
    int ans = 10000;
    cin >> str;
    for(int i=0;i<str.size()-2;i++){
        int cost=((str[i]-'0')*100+(str[i+1]-'0')*10+(str[i+2]-'0'));
        ans = min(abs(cost-753),ans);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b){
    return a * b / my_gcd(a, b);    
}

vector<int> check;

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    llong ans = 0;
    int right = 0;
    llong sum = 0, tmp = 0;
    rep(left, n) {
    	while (right < n && (sum + A[right]) == (tmp ^ A[right])) {
    		tmp ^= A[right];
    		sum += A[right];
    		++right;
    	}
    	ans += right - left;

    	if (left == right) ++right;
    	else {
    		sum -= A[left];
    		tmp ^= A[left];

    	}
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    string a,b;
    lli l;
    cin>>l;
    string s,t;
    cin>>s>>t;

    lli si=0,i,id;
    if(s+t<t+s)
    {
        rep(i,0,1+l)
        {
            if(i%s.sz()==0 and (l-i)%t.sz()==0)
            {
                id=i;
            }
        }

        string ans="";
        while(ans.sz()<id)
        {
            ans+=s;
        }
        while(ans.sz()<l)
        {
            ans+=t;
        }
        cout<<ans;
    }
    else
    {
        rep(i,0,1+l)
        {
            if(i%t.sz()==0 and (l-i)%s.sz()==0)
            {
                id=i;
            }
        }
        string ans="";
        while(ans.sz()<id)
        {
            ans+=t;
        }
        while(ans.sz()<l)
        {
            ans+=s;
        }
        cout<<ans;
    }
}



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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);

    vector<ll> a(N);
    Rep(i,N) Scll(a[i]);

    bool over  = true;


    ll cnt = 0;
    ll ig[213] = {};
    ll ans = 0;
    while( over ){
        cnt = 0;
        over = false;

        Rep(i,N){
            cnt += a[i]/N;
            ig[i] = a[i]/N;
            a[i] = a[i]%N;
        }
        // printf ("!%llu ", cnt );
        Rep(i,N){
            // printf ("%llu:%llu ", a[i], ig[i] );
            a[i] += cnt - ig[i];
            if( a[i] >= N ) over = true;
        }

        // printf ("\n");


        ans += cnt;

    }

    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = n;
	rep(i, n - 1) {
		if (s[i] == s[i + 1])
			ans--;
	}
	cout << ans << endl;
}







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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


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

    if (k == 1) {
        cout << 0 << endl;
        ret();
    }
    if (n == k) {
        cout << 0 << endl;
        ret();
    }

    if (n < k) {
        cout << min(n, k - n) << endl;
        ret();
    }

    ll n2 = n % k;

    cout << min(n2, k - n2) << endl;


}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int N = array[0];
            int L = array[1];

            int S = 0;
            for (int i = 1; i <= N; i++) {
                S += L + i - 1;
            }

            if (L <= 0 && 0 <= L + N - 1) {
                System.out.println(S);
            } else if (Math.abs(L) <= Math.abs(L + N - 1)) {
                System.out.println(S - L);
            } else {
                System.out.println(S - L - N + 1);
            }
        }
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

}


Measured memory_bytes: 23124
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
MOD = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
d = defaultdict(int)
for a in A:
    d[a] += 1
ans = 0
for i in range(1,2001):
    c = 0
    for j in range(0,i):
        c += d[j]
    ans += c*d[i]*((K-1)*K)//2
    ans %= MOD
for i in range(len(A)):
    a = A[i]
    for j in range(i+1,len(A)):
        if a > A[j]:
            ans += K
ans %= MOD
print(ans)


Measured memory_bytes: 10800
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=2e5+5;
int a[maxn];
long long num[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        num[a[i]]++;
    }
    long long tot=0;
    for(int i=1;i<=n;i++)
        tot+=num[i]*(num[i]-1)/2;
    for(int i=1;i<=n;i++)
    {
        long long cur=num[a[i]];
        long long ans=tot-cur*(cur-1)/2+(cur-1)*(cur-2)/2;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3968
// 2_abc129_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n){
        cin >> w[i];
    }
    vector<int> s(n);
    s[0] = w[0];
    for(int i = 1; i < n; i++){
        s[i] = s[i - 1] + w[i];
    }
    int ans = abs(s[0] - (s[n - 1] - s[0]));
    for(int i = 1; i < n - 1; i++){
        ans = min(ans, abs(s[i] - (s[n - 1] - s[i])));
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,X,Y; cin >> N >> X >> Y;
  int count[2900];
  for(int i=1; i<=N-1; i++){
    for(int j=i+1; j<=N; j++){
      count[min(j-i,abs(X-i)+1+abs(Y-j))]++;
    }
  }
  
  for(int k=1; k<=N-1; k++) cout << count[k] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
double N;

int main(){
	cin>>N;
	cout<<2*N*3.1415926535<<endl;
	return 0;
}

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

#define ll long long
#define pb push_back
#define ull unsigned long long
#define MAX 1000000
int  ar[MAX];

int main()
{
    ll n,k;
    cin>>n>>k;
    if(n>=10)
        cout<<k<<endl;
    else
        cout<<(100*(10-n))+k<<endl;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
d = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                d +=1
print(d)

Measured memory_bytes: 67420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 22100
#include <iostream>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#define llint long long
#define mod 998244353
#define eps 1e-8

using namespace std;

struct BIT{
	int size;
	vector<int> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	int query(int i){
		int ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, int x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};

llint n, k;
llint p[100005];
BIT bit(100005);

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> p[i];
	
	if(n == k){
		for(int i = 0; i < n; i++) p[i] = p[i+1]-1;
		int x;
		for(int i = 0; i < n; i++){
			if(p[i] == 0){
				x = i;
				break;
			}
		}
		for(int i = 0; i < n; i++){
			if(p[(x+i)%n] != i){
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
	
	int inv = 0;
	for(int i = 1; i <= n; i++){
		inv += (i-1) - bit.query(p[i]);
		bit.add(p[i], 1);
	}
	///cout << inv << endl;
	
	if(k % 2 == 0) cout << "Yes" << endl;
	else{
		if(inv % 2 == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,n;cin>>k>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  int max=0;
  for(int i=1;i<n;i++)
    if(v[i]-v[i-1]>max)
      max=v[i]-v[i-1];
  if(max<k-v[n-1]+v[0])
  	max=k-v[n-1]+v[0];
  cout<<k-max<<endl;
  return 0;
}

Measured memory_bytes: 1024
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


// -----------------------------------------------------------------------




// -----------------------------------------------------------------------

int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}

// -----------------------------------------------------------------------



void solve(){
	
	string s;
  cin>>s;
  s[3]='8';
  cout<<s;
	
		
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
tmp = 10**9
for i in range(N):
    if abs(A - T + H[i] * 0.006) < tmp:
        tmp = abs(A - T + H[i] * 0.006)
        ans = i + 1
print(ans)

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

ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int main() {
  ll a,b;
  cin >> a >> b;
  
  ll amari = gcd(a,b);
  
  cout << (a * b / amari) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  string s, t;
  cin >> s >> t;
  ll ans = 0;
  REP(i, 3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

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

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}

int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    cin >> t;
    map<string, int> m;
    while (t--) {
        string temp;
        cin >> temp;
        m[temp]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define allr(v) (v).rbegin(),(v).rend()
#define vrsort(v) sort(allr(v))
#define endl "\n"

int main(){
  ll i,j,N,ans,x,y,d;
  cin>>N;
  vector<tdata> v(N);
  rep(i,N){
    cin>>v[i].second.first>>v[i].second
.second>>v[i].first;
  }
  vrsort(v);
  rep(x,101){
    rep(y,101){
      ans=v[0].first+labs(x-v[0].second.first)+labs(y-v[0].second.second);
      j=1;
      rep1(i,N){
        d=labs(x-v[i].second.first)+labs(y-v[i].second.second);
        if(max(ans-d,(ll)0)!=v[i].first){
          j=0;
          break;
        }
      }
      if(j){
        cout<<x<<" "<<y<<" "<<ans<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int h,w;
  cin>>h>>w;
  rep(i,w+2) cout<<"#";
  cout<<endl;
  rep(i,h){
  string s;
    cin>>s;
  cout<<"#"+s+"#"<<endl;
  }
  rep(i,w+2) cout<<"#";
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n,x;
  cin >> n >> x;
  int mae = 0;
  cin >> mae;
  ll res = 0;
  for(int i = 0;i < n - 1;i++){
    int now = 0;
    cin >> now;
    int sa = 0;
    if(now + mae >= x){
      if(now >= now + mae - x){
        sa = now + mae - x;
      }
      else{
        sa = now;
      }
      res += now + mae - x;
      now -= sa;
      //cout << i << " " << res << endl;
    }
    mae = now;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
*G=gets
~/^1$/&&(puts :First;exit)
$<.map{|l|x=l.split.map &:to_i;x.map{|a|G[a]||=[];G[a].push *x}}
d,*v=->i{a=[[i,0]]
(i,l=a.pop
v[i]=l
G[i].map{|j|v[j]||a<<[j,l+1]})while a[0]},0
d[1]
a=v.index v.max
*v=0
d[a]
puts v.max%3==1?:Second: :First

Measured memory_bytes: 98940
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

ll calccost(ll dp[],ll n,ll h[],ll k)
{
    if(dp[n]!=-1) return dp[n];
    else
    {
        ll min=1e9;
        ll i,temp;
        for(i=1;i<=k&&i<n;++i)
        {
            if(dp[n-i]==-1) dp[n-i]=calccost(dp,n-i,h,k);
            temp=abs(h[n]-h[n-i])+dp[n-i];
            min=std::min(min,temp);
        }
        return min ;
    }
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,f,t,k;
    cin >> n >> k;
    ll h[n+1],dp[n+1];
    repp(i,1,n+1) cin >> h[i] ;
    if(n-1<=k) cout << h[n]-h[1];
    else
    {
        memset(dp,-1,sizeof(dp));
        dp[1]=0;
        cout << calccost(dp,n,h,k);
    }
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define ll long long


using namespace std;

const int MAXN = (int) 2e5;
const int LOG = (int) 18;

string str;

int nxt[MAXN + 1][26];
int first[26];
int last[26];

inline bool check(int len, int n) {
    int p = 0, i, j;
    for(i = 0; i < 26; i++)
        p = max(p, first[i]);
    for(i = 2; i <= len && p <= n; i++) {
        int mx = 0;
        for(j = 0; j < 26; j++)
            mx = max(mx, nxt[p][j]);
        p = mx;
    }
    return p <= n;
}

int dp[MAXN + 1][LOG + 1];


int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, j;
    ios::sync_with_stdio(false);
    cin >> str;
    n = str.size();
    str = " " + str;
    for(i = 1; i <= n; i++) {
        str[i] -= 'a';
        if(first[str[i]] == 0)
           first[str[i]] = i;
        last[str[i]] = i;
    }
    for(i = 0; i < 26; i++)
        if(first[i] == 0)
           first[i] = n + 1;
    for(i = n; i >= 1; i--) {
        for(j = 0; j < 26; j++) {
            if(i == n)
                nxt[i][j] = n + 1;
            else if(str[i + 1] == j)
                nxt[i][j] = i + 1;
            else
                nxt[i][j] = nxt[i + 1][j];
        }
    }
    int rez = 0;
    for(int pas = 1 << 18; pas; pas >>= 1)
        if(rez + pas <= n && check(rez + pas, n) == 1)
            rez += pas;
    rez++;
    for(i = 1; i <= n; i++)
        for(j = 0; j < 26; j++)
            dp[i][0] = max(dp[i][0], nxt[i][j]);
    for(int p2 = 1; (1 << p2) <= n; p2++)
        for(i = 1; i <= n; i++) {
            if(dp[i][p2 - 1] == n + 1)
                dp[i][p2] = n + 1;
            else
                dp[i][p2] = dp[dp[i][p2 - 1]][p2 - 1];
        }

    int p = 0;
    for(i = 1; i <= rez; i++) {
        if(p == n + 1)
           cout << "a";
        else {
            for(j = 0; j < 26; j++) {
                int aux;
                if(i == 1)
                    aux = first[j];
                else
                    aux = nxt[p][j];
                int x = rez - i;
                for(int p2 = LOG; p2 >= 0 && aux <= n; p2--)
                    if((1 << p2) <= x) {
                         aux = dp[aux][p2];
                         x -= (1 << p2);
                    }
                if(aux == n + 1) {
                    cout << (char) (j + 'a');
                    if(i == 1)
                        p = first[j];
                    else
                        p = nxt[p][j];
                    break;
                }
            }
        }
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 35792
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define double long double
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 1000000007;
int n, mx;
map<string, int> mp;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin>>n;
    for(int i=1; i<=n; i++){
    	string s;
    	cin>>s;
    	mp[s]++;
    	mx=max(mx, mp[s]);
    }
    vector<string> ans;
    for(auto it : mp){
    	if(it.y==mx) ans.pb(it.x);
    }
    sort(ans.begin(), ans.end());
    for(string s : ans) cout<<s<<"\n";
}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
  std::cin >> x>>y;
  std::vector<int> v(x);
  rep(i,x){
    std::cin >>v[i];
  }
  rep(i,x){
    if(i==0)z+=y;
    else{
      if(v[i-1]+y>v[i])z+=y+(v[i]-(v[i-1]+y));
      else z+=y;
    }
  }
  std::cout << z << '\n';
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
t = [[i+1] for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    t[A-1].append(B)
    t[B-1].append(A)
from collections import deque
d = deque()
ans = [-1]*(N)
d.append(t[0])
while len(d) > 0:
    z = d.popleft()
    x = z[0]
    for i in range(1,len(z)):
        if ans[z[i]-1] == -1:
            ans[z[i]-1] = x
            d.append(t[z[i]-1])
print("Yes")
for i in range(1,len(ans)):
    print(ans[i])

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

int main() {
  int h,w;
  cin>>h>>w;
  string s[2005];
  for (int i=0; i<h; i++) {
    cin>>s[i];
  }
  pair<int,int> cnt[2005][2005];
  for (int i=0; i<h; i++) {
    int c=0;
    for (int j=0; j<w; j++) {
      if (s[i][j]=='.') {
	c++;
      }
      if (s[i][j]=='#') {
	for (int k=0; k<c; k++) {
	  cnt[i][j-k-1].first=c;
	}
	c=0;
      }
    }
    for (int k=0; k<c; k++) {
      cnt[i][w-k-1].first=c;
    }
  }
  for (int j=0; j<w; j++) {
    int c=0;
    for (int i=0; i<h; i++) {
      if (s[i][j]=='.') {
	c++;
      }
      if (s[i][j]=='#') {
	for (int k=0; k<c; k++) {
	  cnt[i-k-1][j].second=c;
	}
	c=0;
      }
    }
    for (int k=0; k<c; k++) {
      cnt[h-k-1][j].second=c;
    }
  }
  int ans=1;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s[i][j]=='.')
	ans=max(ans,cnt[i][j].first+cnt[i][j].second-1);
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 35712