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

using namespace std ;

int main () { 

ios_base::sync_with_stdio(false) ;
cin.tie(0) ; 
cout.tie(0) ; 

long long x ; 
cin >> x ; 
int t = 0 ; 
long long y=  100 ; 
while ( y < x ) {
	//cout << y << endl ;
	t++ ; 
	y = y + ( y*0.01);
}
cout << t << endl ; 

}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

const int mod = 1000000007;
class mint {
  long long x;
public:
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { 
  return mint(-x);
  }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const  mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint& a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res/=a;
  }
  friend ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
  }
};

int main(){
  string l;cin >> l;
  vector<vector<mint>> dp(100005,vector<mint>(2));
  dp[0][0] = mint(1);
  dp[0][1] = mint(0);
  rep(i,l.size()){
    if(l[i] == '1'){
      dp[i+1][0] = dp[i][0]*2;
      dp[i+1][1] = dp[i][0] + dp[i][1]*3;
    }else{
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1]*3;
    }
  }
  cout << (dp[l.size()][0]+dp[l.size()][1]) << endl;

  
  
}

Measured memory_bytes: 8752
#include<stdio.h>
char s[15];
int main(){
	int i,j,x,y;
	scanf("%s",s);
	for(i=0;i<8;i++){
		x=s[0]-'0';
		j=3;
		y=i;
		while(j--){
			if(y%2){
				x-=s[3-j]-'0';
			}else{
				x+=s[3-j]-'0';
			}
			y/=2;
		}
		if(x==7){
			y=i;
			printf("%c",s[0]);
			j=3;
			while(j--){
				if(y%2){
					printf("-%c",s[3-j]);
				}else{
					printf("+%c",s[3-j]);
				}
				y/=2;
			}
			printf("=7\n");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
const int MAXN=200001;
int n,m,k,tot=0,ans=0;
map <int,int> MAP;
struct num
{
	int data,appear;
	num() {data=0;appear=0;}
}NUM[MAXN];
inline bool CMP(const num &a,const num &b)
{
	return a.appear>b.appear;
}
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i)
	{
		k=read();
		if(MAP.count(k)==false) MAP.insert(pair<int,int>(k,1));
		else ++MAP[k];
	}
	for(map<int,int>::iterator it=MAP.begin();it!=MAP.end();++it)
	{
		NUM[++tot].appear=it->second;
		NUM[tot].data=it->first;
	}
	sort(NUM+1,NUM+tot+1,CMP);
	for(int i=1;i<=m;++i)
		ans+=NUM[i].appear;
	printf("%d",n-ans);
	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if(a >= b && a>= c){
        ans = a * 10 + b + c;
    } else if(b >= a && b >= c){
        ans = b * 10 + a + c;
    } else if(c >= a && c >= b){
        ans = c * 10 + a + b;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)){
		if(n==0&&m==0)
		break;
		vector<int> p,sum;
		int ans=0,temp;
		
		p.push_back(0);
		for(int i=1;i<=n;i++){
			scanf("%d",&temp);
			p.push_back(temp);
		}
		sort(p.begin(),p.end());
		for(int i=0;i<=n;i++){
			for(int j=i;j<=n;j++){
				if(p[i]+p[j]<=m)
				sum.push_back(p[i]+p[j]);
			}
		}
		sort(sum.begin(),sum.end());
		int sumx=sum.size()-1;
		for(int i=0;i<=sumx;i++){
			while(sum[i]+sum[sumx]>m)
			sumx--;
			if(ans<sum[i]+sum[sumx])
			ans=sum[i]+sum[sumx];
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 6796
#include <iostream>

using namespace std;

int f(int c)
{
    if (((c/10000)==(c%10))&&((c/1000%10)==((c%100)/10)))
        return 1;
    else return 0;
}
int main()
{
    int a,b,sum=0,cot=0;
    cin>>a>>b;
    int i,j;
    
    for (i=a;i<=b;i++)
        if (f(i))
            sum++;
        cout<<sum<<endl;
    return 0;
}

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

typedef long long int llt;

bool chk(int n,set<int> st)
{
	
	while(n!=0)
	{
		int dig=n%10;
		if(st.find(dig)!=st.end())
		return false;
		n/=10;
	}
	return true;

}

int main()
{
	llt n,k;
	cin>>n>>k;
	set<int> st;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		st.insert(x);
	}
	int res=n;
	for(int i=n;;i++)
	{
		if(chk(i,st))
		{
			res=i;
			break;
		}
	}
	cout<<res<<endl;
	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(b - a == c - b){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 22100
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	while(cin>>str){
		int pos = 0;
		int joi,ioi;
		joi = ioi = 0;
		while( (pos=str.find("JOI",pos)+1) )joi++;
		pos = 0;
		while( (pos=str.find("IOI",pos)+1) )ioi++;
		
		printf("%d\n%d\n",joi,ioi);
	}
	return 0;
}

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

int main() {
	int a[3] = { 1, 0 ,0 }, tmp = 0;
	char x, t, y;
	while (cin >> x) {
		cin >> t >> y;

		tmp = a[x - 'A'];
		a[x - 'A'] = a[y - 'A'];
		a[y - 'A'] = tmp;
	}
	for (int i = 0; i < 3; i++) {
		if (a[i]) {
			cout << (char)(i + 'A') << endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
int n, x,t;
int count;

while(cin>>n>>x>>t)
{
	int time = t;
	if(n<x)
	{
		cout<<t<<endl;
	}
	else
	{
		while(n>x)
		{
			time += t;
			n = n- x;
		}
		cout<<time;
	}
}

	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    int q;
    cin >> q;
    ll cnt = 0;
    for(int i=0; i<q; ++i) {
        int p, n;
        char c;
        cin >> p >> c >> n;
        if(c == '(') {
            cnt -= n;
        } else {
            cnt += n;
        }
        if(cnt == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int N,X,Y;
vector<vector<int>> G;
vector<vector<int>> dist;
vector<int> res;

void bfs(int s) {
    dist[s][s] = 0;
    queue<int> Q;
    Q.push(s);
    while(!Q.empty()) {
        int v = Q.front(); Q.pop();
        for(int to : G[v]) {
            if(dist[s][to] == -1) {
                dist[s][to] = dist[s][v] + 1;
                Q.push(to);
            }
        }
    }

    for(int i=0; i<N; ++i) {
        if(i == s) continue;
        res[dist[s][i]] += 1;
    }
}

int main() {
    cin >> N >> X >> Y;
    G.resize(N);
    dist.resize(N, vector<int>(N, -1));
    res.resize(N, 0);
    for(int i=0; i+1<N; ++i) {
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[X - 1].push_back(Y - 1);
    G[Y - 1].push_back(X - 1);

    for(int i=0; i<N; ++i) bfs(i);

    
    for(int k=1; k<N; ++k) cout << res[k] / 2 << '\n';
}

Measured memory_bytes: 16128
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 2e6+1;
 
typedef long long ll;
typedef long double ld;  
 
void test_case()
{
    ll n,m,i,j;
    string s, t;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    ll ans = 0;
    f(i,0,n)
    {
        if(s[i] != t[i])
            ans++;
    }
    cout << ans << '\n';
 
}
 
int32_t main()
{
    IOS(); 
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3796
// 模範解答 from プログラミングコンテスト攻略のためのアルゴリズムとデータ構造 (マイナビ)

#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000; // 問題の制約を踏まえて順分に小さい初期値
	int minv = R[0];

	for (int i = 1; i < n; i++) { // "i = 0"は初期値として使用したので"i = 1"からスタート
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;
	return 0;
}

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

using namespace std;


int A[100];

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

  int ret=X;
  for(int i=0;i<N;i++)
  {
    ret+=D/A[i]+(D%A[i]?1:0);
  }
  cout<< ret<< endl;
  
  return 0;
}


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

using namespace std;
#define LL long long
#define mod 1000000007

int N,A[333333][66]={},bcnt[66]={};
LL ans=0;

int main() {
	cin>>N;
	for(int i=0;i<N;i++){
		LL a;
		cin>>a;
		for(int j=0;a>0;j++){
			A[i][j]=a%2;
			bcnt[j]+=a%2;
			a>>=1;
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<61;j++){
			if(A[i][j])ans+=(1ll<<j)%mod*(N-i-bcnt[j])%mod;
			else ans+=(1ll<<j)%mod*bcnt[j]%mod;
			ans%=mod;
			bcnt[j]-=A[i][j];
		}
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 78080
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()


int main(){
    int n; cin>>n;
    int l[10]; rep(i,n) cin>>l[i];
    int sum = 0; int M = 0;
    rep(i,n){ sum+=l[i]; M = max(M, l[i]); }
    if (M < sum-M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
  int A, B, C, X;
  int count=0;
  int resA,resB,resC;

  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;

  for (int i = 0; i < A+1; i++)
  {
    resA = X - 500*i;
    if(resA == 0){
      count++;
      continue;
    }
    for (int j = 0; j < B+1; j++)
    {
      resB = resA - 100*j;
      if(resB == 0){
        count++;
        continue;
      }
      for (int k = 0; k < C+1; k++)
      {
        resC = resB - 50*k;
        if(resC == 0){
          count++;
          continue;
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char s[305];
	int i,l,k,u,p,c,cnt;
	scanf("%s",s);
	l=strlen(s);
	for(i=0,k=0,u=0,p=0,c=0;i<l;i++){
		switch(s[i]){
			case 'K':
				k++;
				break;
			case 'U':
				u++;
				break;
			case 'P':
				p++;
				break;
			case 'C':
				c++;
				break;
		}
	}
	cnt=0;
	while(1){
		k--,u--,p--,c--;
		if(k>=0&&u>=0&&p>=0&&c>=0){
			cnt++;
		}else break;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////
int n,m,R;
ll d[205][205] = {};
vector<int> r;

int main(){
    
	cin >> n >> m >> R;
    r.resize(R);
     
    rep(i,0,n+2)rep(j,0,n+2){
        if(i != j)d[i][j] = linf;
    }
    
    rep(i,0,R)cin >> r[i];
    rep(i,0,m){
        ll a,b,c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(k,1,n+1){
        rep(i,1,n+1){
            rep(j,1,n+1){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]); 
            }
        }
    }

/*    rep(i,1,n+1){
        rep(j,1,n+1)cout << d[i][j] << " ";
        cout << endl;
    }*/
   
    
    ll ans = linf;
    vsort(r);
    do{
		ll tmp = 0;
        int num = r[0];
       // cout << r[0] << " " ;
        rep(i,1,R){
         //   cout << r[i] << " " ;
            tmp += d[num][r[i]];
            num = r[i];
        }
      //  cout << tmp << endl;
        ans = min(ans,tmp);
		 	
	}while(next_permutation(r.begin(),r.end()));
	
	P(ans);
	return  0;
}

Measured memory_bytes: 512
#include<cstdio>

int main(void){
    
    int a=0,b=0,c=0,count=0;
    scanf("%d %d %d",&a,&b,&c);
    
    for(int i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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







int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll sz = 0,k = 1;
    while(k <= n){
        k *= 10;
        sz ++;
    }
    ll ans = 0;
    if(sz%2 == 0){
        --sz;
    }else{
        ans += n-k/10 + 1;
        sz -= 2;
    }

    while(sz > 0){
        ll k = 9;
        rep(i,sz-1){
            k *= 10;
        }
        ans += k;

        sz -= 2;
    }

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


Measured memory_bytes: 3644
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,t,y=100000000000,m;
cin>>n;
ll a[n];
for(i=0;i<n;i++)
cin>>a[i];
ll dp[n]={0};
dp[1]=abs(a[1]-a[0]);
for(i=2;i<n;i++)
{
   dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
}
cout<<dp[n-1];
  	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

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

int main(){
    ll n, k;
    cin >> n >> k;
    if(abs(n%k) <= abs(n%k-k)) cout << abs(n%k) << endl;
    else cout << abs(n%k-k) <<endl;

    return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int ss=s.size(),tt=t.size();
    if(ss==tt){
        if(s>t)cout << "GREATER";
        else if(s<t) cout << "LESS";
        else cout << "EQUAL";
    }
    else {
        if(ss>tt)cout << "GREATER";
        else cout << "LESS";
    }
}

Measured memory_bytes: 256
strings = input()
l = len(strings)
even = []
odd = []
i = 0
while i <= l:
  try:
    odd.append(strings[i])
  except:
    pass
  try:
    even.append(strings[i+1])
  except:
    pass
  i += 2

if ("L" in odd) or ("R" in even):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38384
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
 
x.sort(reverse=True)
y.sort()
 
 
flag=0
for i in range(X+1,Y+1):
  if x[0]<i and y[0]>=i:
    flag=1
    break
  
 
  else:
    flag=0
    
if flag==1:
  print('No War')
  
else:
  print('War')

Measured memory_bytes: 9128
package main

import (
	"fmt"
)

func checkSubstr(s string, d []string) bool {
	for i := 0; i < len(d); i++ {
		if len(s) < len(d[i]) {
			continue
		}
		if s[0:len(d[i])] == d[i] {
			if len(s) == len(d[i]) {
				return true
			}
			return checkSubstr(s[len(d[i]):], d)
		}
	}
	return false
}

func reverse(s string) string {
	rs := []rune(s)
	for i,j := 0, len(s)-1; i < j; i,j = i+1,j-1 {
		rs[i],rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main() {
	var s string
	fmt.Scan(&s)
	
	d := []string{"maerd", "remaerd", "esare", "resare"}
	s = reverse(s)
  
	if checkSubstr(s,d) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char s[SIZE];
int dp[1<<26];
void update(int &x,int v){
    if(!x||x>v)x=v;
}
int qq(int x){
    if(!dp[x])return MOD;
    return dp[x]+1;
}
int main(){
    RS(s);
    int now=0;
    dp[0]=1;
    for(int i=0;s[i];i++){
        int c=s[i]-'a';
        now^=1<<c;
        int v=1e9;
        REP(i,26){
            v=min(v,qq(now^(1<<i)));
        }
        v=min(v,qq(now));
        update(dp[now],v);
        if(s[i+1]==0)cout<<v-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 262272
#include <iostream>
#include <stack>
#include <sstream>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  string c;
  stack<int> st;
  while(cin >> c){
    if(c == "+"){
      int i2 = st.top(); st.pop();
      int i1 = st.top(); st.pop();
      st.push(i1+i2);
    }else if(c == "-"){
      int i2 = st.top(); st.pop();
      int i1 = st.top(); st.pop();
      st.push(i1-i2);
    }else if(c == "*"){
      int i2 = st.top(); st.pop();
      int i1 = st.top(); st.pop();
      st.push(i1*i2);
    }else{
      stringstream ss;
      int tmp;
      ss << c;
      ss >> tmp;
      st.push(tmp);
    }
  }
  cout << st.top() << endl;
  st.pop();
  return 0;
}

Measured memory_bytes: 1228
from copy import deepcopy
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

def check(ny, nx, sS):
    if 0<=ny<H and 0<=nx<W:
        if sS[ny][nx]=='.':
            return True
    else:
        return False

def bfs(sy, sx, sS):
    deq = deque()
    deq.append([(sy-1, sx-1)]) # insert indices
    sS[sy-1][sx-1] = '#'
    ddy = [-1, 0, 1, 0]
    ddx = [0, -1, 0, 1]
    step = 0
    while deq[0]:
        #print('deq', deq)
        nqueue = []
        cqueue = deq.popleft()
        for val in cqueue:
            y, x = val
            for dy, dx in zip(ddy, ddx):
                ny, nx = y+dy, x+dx
                if check(ny, nx, sS):
                    sS[ny][nx] = '#'
                    nqueue.append((ny, nx))
        deq.append(nqueue)
        if not(deq[0]):
            break
        step += 1
    return step

res = 0
for i in range(H):
    for j in range(W):
        #print('i, j:', i, j)
        if S[i][j] == '.':
            sS = deepcopy(S)
            val = bfs(i+1, j+1, sS)
            res = max(res, val)

print(res)


Measured memory_bytes: 57052
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){

	int n;
	while(~scanf("%d",&n)){
		int sum=1;
		for(int i=0;i<n;i++){
			sum += i+1;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
# ABC142C - Go to School
def main():
    N, *A = map(int, open(0).read().split())
    ans = [0] * (N + 1)
    for i, j in enumerate(A, 1):
        ans[j] = i
    print(" ".join(map(str, ans[1:])))


if __name__ == "__main__":
    main()

Measured memory_bytes: 18020
#include <stdio.h>

int main(void)
{
	int x, y;
	scanf("%d %d", &x, &y);

	while (x != 0 && y != 0) {
		if (x > y) {
			x = x % y;
		} else {
			y = y % x;
		}
	}
	if (x == 0){
		printf("%d\n", y);
	} else {
		printf("%d\n", x);
	}
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std; 
int main(){
//  freopen("test.in","r",stdin);
//  freopen("test.out","w",stdout);
	int n,o=0;
	cin>>n;
	char slimes[n+1],a[n+1];
	memset(a,0,sizeof(a));
	cin>>slimes;
	for(int i =0;i<n-1;i++){
			if(slimes[i]==a[o]) continue;
			if(slimes[i]==slimes[i+1]){
				a[o]=a[i];
			}
			else o++;
	}
	cout<<o+1;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}


//------------------------main function-------------------------------
void Main(){
    int n, d, ans = 0; cin >> n >> d;
    ans = (n % (( 2 * d ) + 1)  == 0)?( n / ( ( 2 * d ) + 1 ) ) : ( n / ( ( 2 * d ) + 1 ) ) + 1 ;
    cout << ans << endl;
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int Notprime[200005], Prime[200005], tot;
void Euler(int Max) {
  for (RI i = 2; i <= Max; ++i) {
    if (!Notprime[i]) Prime[++tot] = i;
    for (RI j = 1; j <= tot && i * Prime[j] <= Max; ++j) {
      Notprime[i * Prime[j]] = 1;
      if (i % Prime[j] == 0) break;
    }
  }
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  Euler(2e5);
  int n; cin >> n;
  for (RI i = 1; i <= tot; ++i)
    if (Prime[i] >= n) {
      cout << Prime[i] << endl;
      break;
    }

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    bool ok=true;
    if(n%2!=0) ok=false;
    REP(i, 0, n/2){
        if(s[i]!=s[i+n/2]){
            ok=false;
            break;
        }
    }

    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  for (int i=0; i<N; i++){
    string S;
    cin >> S;
    
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (S != "Y"){
      if (i < N-1){
      continue;
      }
      else{
        cout << "Three" << endl;
      }
    }
  }  
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll y1 = x / d;
    ll y2 = y1+1;
    ll ans = 0;
    if(k <= y1) {
        ans = x - k * d;
    } else {
        k -= y1;
        if(k & 1)ans = x - d * y2;
        else ans = x - d * y1;
    }
    cout << abs(ans) << endl;
    return 0;
}


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

int k;
int memo[100005] = {0};
deque<int> dq;

int solve();

int main() {
  cin >> k;
  for(int i = 0; i < k; ++i) memo[i] = 1000000;
  cout << solve() << endl;
  return 0;
}

int solve() {
  memo[1] = 1;
  dq.push_back(1);
  while(dq.size() > 0) {
    int now = dq.front(), nf, nb;
    dq.pop_front();
    nf = now * 10 % k;
    nb = (now + 1) % k;
    if(memo[nf] > memo[now]) {
      memo[nf] = memo[now];
      dq.push_front(nf);
    }
    if(memo[nb] > memo[now] + 1) {
      memo[nb] = memo[now] + 1;
      dq.push_back(nb);
    }
  }
  return memo[0];
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
		using namespace std;
		typedef long long ll;
		#define PI 3.14159265358979
		#define EPS 1e-8
		#define mod  998244353
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define endl "\n"
			 
		const ll INF=1e15;	
		const int N=2e5+50;
		 

		 
		long long binpow(long long a, long long b, long long m) {
			a %= m;
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = res * a % m;
				a = a * a % m;
				b >>= 1;
			}
			return res;
		}
		
		ll modinverse(ll a,ll m)
		{
			return binpow(a,m-2,m);
		}
		
		
		int main()
		{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);cout.tie(0);
			
			ll n;
			cin>>n;
			
			ll arr[305][305];
			
			for(ll i=1;i<=n;i++)
			{
				for(ll j=1;j<=n;j++)
				{
					cin>>arr[i][j];
				}
			}
			
			ll ans=0;
			
			for(ll i=1;i<=n;i++)
			{
				for(ll j=1;j<=n;j++)
				{
					if(i==j)
						continue;
					ll val=INF;
					
					for(ll k=1;k<=n;k++)
					{
						if(k==i || k==j)
							continue;
						val=min(val,arr[i][k]+arr[k][j]);
					}
					if(arr[i][j]>val)
						{
							cout<<-1;
							exit(0);
						}
					else if(arr[i][j]<val)
					{
						ans+=arr[i][j];
					}
				}
			}
			cout<<ans/2;
		}
			
			
		


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

using namespace std;

const int N = 200005;

int n, a[N];

int main() {

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	int maxx1 = 0, pos = 0, maxx2 = 0;
	for (int i = 1; i <= n; i ++) {
		if (a[i] > maxx1) {
			maxx1 = a[i];
			pos = i;
		} 
	}
	for (int i = 1; i <= n; i ++) {
		if (i != pos && a[i] > maxx2) {
			maxx2 = a[i];
		}
	}
	for (int i = 1; i <= n; i ++) {
		cout << ((a[i] != maxx1) ? maxx1 : maxx2) << '\n';
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> h(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }
    ll H = -1, Cx, Cy;
    //h = max(H - |x - Cx| - | y - Cy |, 0)
    // H は h 以上
    // Hは一意に定まる
    bool isOK;
    for(size_t cx=0;cx<=100; cx++)
    {
        for(size_t cy=0;cy<=100; cy++)
        {
            H = -1;
            isOK = true;
            for(size_t i=0;i<N; i++)
            {
                ll _H;
                if(h[i] == 0) continue;
                _H = h[i] + abs(ll(x[i] - cx)) + abs(ll(y[i] - cy));
                if(H==-1) H = max(_H, 0ll);
                else
                {
                    if(H != _H)
                    {
                        isOK = false;
                        break;
                    }
                }
            }
            for(size_t i=0;i<N; i++)
            {
                if(h[i]>0) continue;
                if(h[i] != max(H - abs(ll(x[i] - cx)) - abs(ll(y[i] - cy)), 0ll)) isOK = false;
            }
            if(isOK)
            {
                Cy = cy;
                break;
            }
        }
        if(isOK)
        {
            Cx = cx;
            break;
        }
    }
    cout << Cx << " " << Cy << " " << H << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    temp = C
    A = list(map(int, input().split()))
    for i in range(M):
        temp += A[i]*B[i]
    if temp > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int x[100010];

int main()
{
	int n;
	cin >> n;
	rep(i, n){
		int a, b;
		cin >> a >> b;
		x[a]++; x[b+1]--;
	}
	int cnt = 1, ans = 0;
	rep(i, n+2){
		cnt += x[i];
		if(i <= cnt) ans = max(ans, i-1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1216
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a % b)

N,X = map(int,input().split())
x = sorted([X] + list(map(int,input().split())))

ans = x[1] - x[0]
for i in range(2,N+1):
    ans = gcd(ans,x[i] - x[i-1])

print(ans)


Measured memory_bytes: 14252
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	r := bufio.NewReader(reader)
	a := 0
	n := "0"
	b := 0
	var s string
	for {
		if c, _, err := r.ReadRune(); err != nil {
			if err == io.EOF {
				break
			} else {
				log.Fatal(err)
			}
		} else {
			s = string(c)
			if s != "0" && s != "1" {
				break
			}
		}
		if s == n {
			b++
		} else {
			a++
		}
		if n == "0" {
			n = "1"
		} else {
			n = "0"
		}
	}
	if b < a {
		a = b
	}
	_, _ = fmt.Fprintf(writer, "%d\n", a)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


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

A = sorted([int(x) for x in input().split()])
flag = True
isOk = False
for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            isOk = True
        else:
            isOk = False
            flag = False
            break
    else:
        pass


if isOk or flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var input = Reads();
        var n = input[0];
        var m = input[1];
        var c = input[2];
        var input0 = Reads();
        var b = new long[m];
        for (int i = 0; i < m; i++)
            b[i] = input0[i];
        long count = 0;
       
        for (int j = 0; j < n; j++)
        {
            var input1 = Reads();
            long sum = 0;
            for (int i = 0; i < m; i++)
            {
                sum += input1[i] * b[i];
            }
            if (sum + c > 0)
                count++;
        }
        Console.WriteLine(count);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll ans;
int n;
ll a[110000];

int main(){
  cin>>n;

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

   ll s=0;
  rep(i,n){
    s+=a[i];
    if(a[i]==0){
      ans+=s/2;
      s=0;
    }
  }
  ans+=s/2;

  cout<<ans<<endl;

  return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int n, k; cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = k; i < n; i++){
        if(a[i] > a[i - k]) cout << "Yes\n";
        else cout << "No\n";
    }
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

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

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int H,N;
    cin >> H >> N;
    vector<pair<int,int>> A(N);
    REP(i,N){
        cin >> A[i].first;
        cin >> A[i].second;
    }
    int dp[20000];
    REP(i,20000)dp[i] = 147483646;
    dp[0] = 0;
    REP(i,H){
        REP(l,N)dp[i+A[l].first] = min(dp[i+A[l].first],dp[i]+A[l].second);
    }
    int minimum = INT32_MAX;
    for(int i = H;i < 20000;i++){
        minimum = min(minimum,dp[i]);
    }
    cout <<minimum<< "\n";
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            //String str[] = br.readLine().split(" ");
            long n = Integer.parseInt(br.readLine());
            ArrayList<Long> a = new ArrayList<Long>();
            ArrayList<Long> b = new ArrayList<Long>();
            for (int i = 0; i < n; i++) {
                String tmp[] = br.readLine().split(" ");
                a.add(Long.parseLong(tmp[0]));
                b.add(Long.parseLong(tmp[1]));
            }
            long count = 0;
            for (long i = n; i > 0; i--) {
                Long atmp = a.get((int) (i - 1));
                atmp = atmp + count;
                Long btmp = b.get((int) (i - 1));
                long tmp = (atmp) % btmp;
                if (tmp != 0) {
                    count = count + (btmp - tmp);
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

ll knapSack(ll n,ll v[],ll W,ll w[],ll tot)
{
    ll K[n+5][tot+5];
    for (ll i=0; i<=n; i++)
    {
        for (ll pr=0; pr<=tot; pr++)
        {
            if (i==0 && pr==0)
                K[i][pr]=0;
            else if(i==0)
                K[i][pr]=1e11;
            /*else if(w[i-1]<=wt)
                K[i][wt]=max(v[i-1]+K[i-1][wt-w[i-1]],K[i-1][wt]);*/
            else if(v[i-1]<=pr)
                K[i][pr]=min(w[i-1]+K[i-1][pr-v[i-1]],K[i-1][pr]);
            else
                K[i][pr]=K[i-1][pr];
        }
    }
    ll val=0;
	for(ll pr=0; pr<=tot; pr++)
		if(K[n][pr]<=W)
            val=pr;
	return val;
}

int main()
{
    ll n,W;
    cin>>n>>W;
    ll v[n+5],w[n+5];
    ll tot=0;
    for(int i=0; i<n; i++){
        cin>>w[i]>>v[i];
        tot+=v[i];
    }
    ll ans=knapSack(n,v,W,w,tot);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 82552
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RI(K, S);

  u32 c = 0;
  for (i32 x = 0; x <= K; x++) {
    for (i32 y = 0; y <= K; y++) {
      c += 0 <= S - (x + y) && S - (x + y) <= K;
    }
  }

  PUI(c);
}


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

using namespace std;

const int mod = 1000000007;

constexpr long long power(long long b, long long e){
  long long ret = 1;
  while(e){
    if(e & 1){
      ret *= b;
      ret %= mod;
    }

    b *= b;
    b %= mod;
    e >>= 1;
  }

  return ret;
}

int main(){
  int N;
  cin >> N;
  
  map<pair<long long, long long>, long long> iwashi;
  for(int i = 0; i < N; i++){
    long long A, B;
    cin >> A >> B;
    
    if(A || B){
      long long g = gcd(A, B);
      A /= g;
      B /= g;
    }
    
    if(A < 0 || (A == 0 && B < 0)){
      A = -A;
      B = -B;
    }
    
    ++iwashi[{A, B}];
  }
  
  long long box = 1;
  for(auto[p, c] : iwashi){
    long long A = p.first, B = p.second;
    if(A == 0 && B == 0) continue;
    
    long long t = 0;
    if(B <= 0){
      if(iwashi.count({-B, A})) continue;
    }else{
      if(iwashi.count({B, -A})) t = iwashi[{B, -A}];
    }
    
    box *= (power(2, c) + power(2, t) - 1) % mod;
    box %= mod;
  }
  
  box += iwashi[{0, 0}] - 1;
  
  box %= mod;
  if(box < 0) box += mod;
  
  cout << box << endl;
  
  return 0;
}

Measured memory_bytes: 16024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int fx[]={0,1,0,-1};
int fy[]={-1,0,1,0};
int main()
{
    ll t,i,j,n,m,k,r,r1,ans,ck,cnt=0,sum=0,c=0;
    cin>>n>>m;
    ll a[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++){
            a[i][j]=0;
        }
    }
    cin>>r>>r1;
    for(i=0;i<r;i++)
    {
        for(j=0;j<m;j++){
            a[i][j]=1;
        }
    }
    for(j=0;j<r1;j++)
    {
        for(i=0;i<n;i++){
           a[i][j]=1;
        }
    }for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++){
           if(a[i][j]==0)cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0; i<n; ++i)
cin>>arr[i];
int dp[n];
for(int i=0; i<n; ++i)
dp[i]=1000000000;
dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
for(int i=2; i<n; ++i)
{
for(int j=1; j<=k; ++j)
{
if(i-j>=0)
dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
}
}
cout<<dp[n-1];
}


Measured memory_bytes: 1024