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

using namespace std;

const long long MOD = 1000000007;

int H, W;
long long grid[1005][1005];

int main(){
    //freopen("GRID1.INP", "r", stdin);

    cin >> H;
    cin >> W;

    for (int i = 1; i <= H; i++){
        string tmp;
        cin >> tmp;
        tmp = " " + tmp;
        //cout << tmp << "\n";
        for (int j = 1; j <= W; j++){
            grid[i][j] = 0;
            if (tmp[j] == '#'){
                grid[i][j] = -1;
            }
        }
    }

    for (int i = 1; i <= H; i++){
        if (grid[i][1] == 0){
            grid[i][1] = 1LL;
        }
        else {
            break;
        }
    }

    for (int i = 2; i <= W; i++){
        if (grid[1][i] == 0){
            grid[1][i] = 1LL;
        }
        else {
            break;
        }
    }

    for (int i = 2; i <= H; i++){
        for (int j = 2; j <= W; j++){
            if (grid[i][j] == -1){
                continue;
            }
            if (grid[i - 1][j] > 0){
                grid[i][j] = (grid[i][j] + grid[i - 1][j]) % MOD;
            }

            if (grid[i][j - 1] > 0){
                grid[i][j] = (grid[i][j] + grid[i][j - 1]) % MOD;
            }
        }
    }

    cout << grid[H][W];

    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
	int n;
	cin >> n;
	map<string,int> v;
	REP(i, n) {
		string t;
		cin >> t;
		if (v.find(t) == v.end()) {
			v[t] = 1;
		}
		v[t]++;
	}
	int m = 0;
	for (auto itr = v.begin(); itr != v.end();itr++) {
		chmax(m, itr->second);
	}
	for (auto itr = v.begin(); itr != v.end();itr++) {
		if(itr->second==m)
		cout << (itr->first) << endl;
	}

	return 0;
}

Measured memory_bytes: 25216
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, k, ans, fact[MAXN], inv[MAXN];

ll C(ll r, ll n) {
    if (r > n || r < 0) return 0;
    return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

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

    fact[0] = 1;
    for (ll i = 1; i < MAXN; i++) fact[i] = fact[i - 1] * i % MOD;
    for (ll i = 0; i < MAXN; i++) inv[i] = poww(fact[i], MOD - 2, MOD);

    cin >> n >> k;
    k = min(k, n);
    for (ll i = 0; i <= k; i++) {
        ans += C(i, n) * C(n - i - 1, n - 1) % MOD;
    }
    cout << ans % MOD << endl;

    return 0;
}
/*

*/


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

int main()
{   
    int N;
    cin>>N;
    int t[N+1],x[N+1],y[N+1];
    t[0]=0,x[0]=0,y[0]=0;
    for(int i=1;i<=N;i++){
        cin>>t[i]>>x[i]>>y[i];
        int tmp1=t[i]-t[i-1];
        int tmp2=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if(tmp1<tmp2){
            cout<<"No"<<endl;
            return 0;
        }
        else if((tmp1-tmp2)%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
}

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

using namespace std;
typedef long long ll;


int main()
{
    string s1, s2;
    cin >> s1 >> s2;

    int n = s1.size();
    int m = s2.size();

    int dp[n+1][m+1];

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (!i || !j)
                dp[i][j] = 0;
            else if (s1[i-1]==s2[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

    int i = n-1, j = m-1;
    vector<char> v;
    while (v.size()<dp[n][m]) {
        //cout << i << j << ' ' << dp[i][j] << endl;
        if (s1[i]==s2[j]) {
            v.push_back(s1[i]);
            i--;
            j--;
        }
        else if (dp[i+1][j]>dp[i][j+1])
            j--;
        else i--;
        if (i<0||j<0) break;
    }
    reverse(v.begin(),v.end());
    for (int i = 0; i < v.size(); i++)
        cout << v[i];

    return 0;
}


Measured memory_bytes: 35456
#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 ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pi              pair<int,int>
#define vi              vector<int>
#define mi              map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1N
#define loop(i,a,b)     for(int i=a;i<b;i++)

void c_p_c(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin) ;
    // freopen("output.txt","w",stdout) ;
    // #endif
}

int32_t main(){
    c_p_c();
    int a,b,c,d; cin >> a >> b >> c >> d;
    bool flag = true;
    while(flag){
        c -= b;
        if(c<=0){
            cout << "Yes";
            flag = false;
            break;
        }
        else if(c>0){
            a -= d;
        }
        if(a<=0){
            cout << "No";
            flag = false;
            break;

        }
    }



}






























































































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

int main(){
    ll n, d; cin >> n >> d;
    vector<ll> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(sqrt(x[i]*x[i] + y[i]*y[i]) <= d){
            ans++;
        }
    }
    put(ans);
}

Measured memory_bytes: 6380
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int mp[1001][1001];

int main(){
	int W;char c;
	for(int num = 0;cin >> W&&W;num++){
		int v[1001], w[1001], n;
		cin >> n;
		fill((int*)mp, (int*)(mp+n+1), 0);
		for(int i = 0;i < n;i++)cin >> v[i] >> c >> w[i];
		for(int i = 0;i < n;i++){
			
			for(int j = 0;j < W+1;j++){
				if(j < w[i])mp[i+1][j] = mp[i][j];
				else mp[i+1][j] = max(mp[i][j], mp[i][j-w[i]]+v[i]);
			}
		}
		
		int ans = 0;
		for(int i = 1;i < W+1;i++){
			if(mp[n][i] > mp[n][ans])ans = i;
		}
		cout << "Case " << num+1 << ":" << endl;
		cout << mp[n][ans] << endl << ans << endl;
	}
	return 0;
}
/*
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
*/

Measured memory_bytes: 6988
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
  string key[10]={"0",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int n;
  cin>>n;
  for (int nn=0;nn<n;nn++){
    string in;
    vector<int> input;
    string ans;
    cin>>in;
    for (int i=0;i<in.length();i++){
      input.push_back(in[i]-48);
    }
    int count=0;
    int cc=0;
    for (int i=0;i<in.length();i++){
      if (input[i]==0&&i!=0&&count!=0){
	char c=key[input[i-1]][(count-1)%key[input[i-1]].size()];
	ans[cc]=c;
	cc++;
	count=0;
	continue;
      }
      else if (input[i]==0&&i==0)
	continue;
      else if (input[i]==0&&count==0)
	continue;
      else
	count++;
    }
    for (int i=0;i<cc;i++){
      cout<<ans[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1240
n = int(input())
taro = 0
hanako = 0
for i in range(n):
    s = input().split(" ")
    if s[0] > s[1]:
        taro += 3
    elif s[0] < s[1]:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print("{0} {1}".format(taro, hanako))

Measured memory_bytes: 7568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

int main() {
  map<string, int> score;
  int N;
  cin >> N;

  vector<string> A(N);
  REP(i, N) cin >> A[i];

  score["AC"] = 0;
  score["WA"] = 0;
  score["TLE"] = 0;
  score["RE"] = 0;

  REP(i, N) { score[A[i]] += 1; }

  cout << "AC x " << score.at("AC")<<endl;
  cout << "WA x " << score.at("WA")<<endl;
  cout << "TLE x " << score.at("TLE")<<endl;
  cout << "RE x " << score.at("RE")<<endl;
}

Measured memory_bytes: 6360
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var s = ReadString();
            Console.WriteLine(CountOf(s, "WB")+ CountOf(s, "BW"));
        }

        private static int CountOf(string source, string value)
        {
            var index = 0;
            var count = 0;
            while (true)
            {
                index = source.IndexOf(value, index);
                if (index < 0) break;
                count++;
                index += value.Length;
            }
            return count;
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13792
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(0);
    int h, a;
    cin >> h >> a;
    cout << ceil(1.0*h/a) << endl;
}

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

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

int main(){
    int k;
    cin >> k;
    long long ans = 0;
    for(int a = 1; a <= k; a++){
        for(int b = a; b <= k; b++){
            for(int c = b; c <= k; c++){
                if(a == b && a == c) ans += gcd(a,gcd(b,c));
                else if(a != b && b != c && c != a) ans += 6*gcd(a,gcd(b,c));
                else ans += 3*gcd(a,gcd(b,c));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k;
    cin >> k;
    cout << "50\n";
    vector<ll> a(50, k / 50 + 49);
    for (int i = 0; i < 50; i++) {
        if (i >= k % 50) {
            a[i] -= k % 50;
        } else {
            a[i] += 51 - k % 50;
        }
    }
    for (ll i : a) {
        cout << i << " ";
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(n)]
books.sort()

stk = [[0 for _ in range(m + 1)]]
for i in range(n):
    cost = books[i][0]
    effect = books[i][1:]
    for j in range(len(stk)):
        sc = stk[j][0]
        tmp = []
        for k in range(m):
            tmp.append(effect[k] + stk[j][k + 1])
        stk.append([sc + cost] + tmp)

stk.sort()

for s in stk:
    cost = s[0]
    eff = s[1:]
    is_ok = True
    for e in eff:
        if e < x:
            is_ok = False
            break
    if is_ok:
        print(cost)
        exit()
print(-1)

Measured memory_bytes: 11312
#include<map>
#include<set>
#include<queue>
#include<ctime>
#include<cmath>
#include<stack>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define MAXN (10+10000)
#define INF 2147483647
#define LL long long

using namespace std;
int n,a[MAXN],b[MAXN];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)scanf("%d",&b[i]);
    LL t1=0,t2=0;
    for(int i=1;i<=n;i++){
        if(b[i]>=a[i])t1+=(b[i]-a[i])/2;
        else t2+=a[i]-b[i];
    }
    if(t1>=t2)printf("Yes");
    else printf("No");
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int ans=A[0];
  for(int i=1;i<N;i++){
   ans=__gcd(A[i],ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int D;

int main() {
	cin >> D;
	cout << "Christmas";
	while (D != 25) {
		cout << sp << "Eve";
		++D;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
ld dp[305][305][305];
int main(){
	fastio;
	cin>>n;
	int in[3]={0};
	forn(i,n) cin>>x,in[x-1]++;
	ld p=(1/(ld)n);
	ld r=n;
	forn(i,305){
		forn(j,305){
			forn(k,305){
				if(i==0 && j==0 && k==0) continue;
				dp[i][j][k]++;
				if(i>0) dp[i][j][k]+=p*i*dp[i-1][j+1][k];
				if(j>0) dp[i][j][k]+=p*j*dp[i][j-1][k+1];
				if(k>0) dp[i][j][k]+=p*k*dp[i][j][k-1];
				dp[i][j][k]*=1/(p*(i+j+k));
			}
		}
	}
	cout<<setprecision(12)<<fixed;
	cout<<dp[in[2]][in[1]][in[0]]<<ln;
	return 0;
}

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

using namespace std;

#define int long long

signed main()
{
   	cout.tie(0), cin.tie(0), ios::sync_with_stdio(0);

	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];

	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += max(0ll, a[i] - b[i]);
	cout << ans << endl;

	return 0;
}


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

const int MAXN = 100005;

int a[MAXN], b[MAXN], c[MAXN], f[MAXN][3];

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

    for (int i = 1; i <= n; i++) {
        f[i][0] = a[i] + std::max(f[i - 1][1], f[i - 1][2]);
        f[i][1] = b[i] + std::max(f[i - 1][2], f[i - 1][0]);
        f[i][2] = c[i] + std::max(f[i - 1][0], f[i - 1][1]);
    }

    printf("%d\n", std::max({f[n][0], f[n][1], f[n][2]}));
    
    return 0;
}

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

using int64 = long long;
using uint64 = unsigned long long;

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

    int N, A, B;
    std::cin >> N >> A >> B;

    int64 ans = 0;

    std::vector<int64> X(N);
    for (int i = 0; i < N; i++) {
        std::cin >> X[i];

        if (i > 0) {
            ans += std::min(A * (X[i] - X[i - 1]), (int64)B);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<map>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const double PI=acos(-1.0);

int main()
{
    string x;
    cin>>x;
    if(x[2]==x[3]&&x[4]==x[5])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();

        if (N == 1) {
            WriteLine(1);
            return;
        }

        var prime = GeneratePrime(N);
        var n = new List<int>();
        for (int i = 1; i <= N; i++) {
            n.Add(i);
        }

        var cnt = new int[prime.Count];
        for (int i = 0; i < prime.Count; i++) {
            cnt[i] = 1;
        }
        for (int i = 0; i < prime.Count; i++) {
            for (int j = 0; j < n.Count; j++) {
                var hoge = n[j];
                while (hoge % prime[i] == 0) {
                    cnt[i]++;
                    hoge /= prime[i];
                }
            }
        }

        long ans = 1;
        for (int i = 0; i < cnt.Length; i++) {
            ans = ans * cnt[i] % 1000000007;
        }

        WriteLine(ans);
    }

    public static List<int> GeneratePrime(int max) {
        int prime;
        double sqrtMax = Math.Sqrt(max);
        var primeList = new List<int>();

        var searchList = Enumerable.Range(2, max - 1).ToList();

        do {
            prime = searchList.First();
            primeList.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        } while (prime < sqrtMax);

        primeList.AddRange(searchList);
        return primeList;
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {


        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

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

int main(){
  int N;
  int a[1100];
  cin >> N;
  for(int i = 0; i < N;i++){
    cin >> a[i];
  }
  
  sort(a,a+N);
  int ans = a[N-1]-a[0];
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <unordered_set>
using namespace std;

// void removeCharsFromString( string &str, char charsToRemove ) 
// {
  
    

//     // Next, call std::set_intersection to collect the common elements into 
//     // the unordered_set
//     std::unordered_set<int> common;
//     std::set_intersection(arr.begin(), arr.end(), arr1.begin(), arr1.end(), 
//                           std::inserter(common, common.begin()));

//     // Now erase the items in each vector that matches the items in the set
//     arr.erase(std::remove_if(arr.begin(), arr.end(), 
//                              [&](int n) { return common.count(n); }), arr.end());
//     arr1.erase(std::remove_if(arr1.begin(), arr1.end(), 
//                              [&](int n) { return common.count(n); }), arr1.end());

//     // Output results
//     for (auto i : arr)
//       std::cout << i << " ";
//     std::cout << "\n";
//     for (auto i : arr1)
//       std::cout << i << " ";
   
// }

int main() {
 string str;
 cin>>str;
 int count=0;
 int len=str.length();
 int i;
 
 for(i=0;i<len;i++)
 {
    
     if(str[i]=='R')
     {
         count++;
         if(str[i]==str[i+1])
         {
             count++;
            i++;
         }
         else
         break;
     }
 }
    cout<<count<<endl;
    
    
    
    
    
   
      
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>w(n);
	REP(i, n) {
		cin >> w[i];
	}
	int m = 1000000;
	REP(i, n-1) {
		int count = 0;
		int count1 = 0;
		REP(j, n) {
			if (j <= i) {
				count += w[j];
			}
			else {
				count1 += w[j];
			}
		}
		int ans = abs(count - count1);
		if (ans < m) {
			m = ans;
		}
	}
	cout << m << endl;
	return 0;
}

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

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

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

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

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

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

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


int main(void){
    ld t, x;
    cin >> t >> x;

    cout << fixed << setprecision(10) << t / x << endl;

    
}



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

// 插入此處

int h[100005];
vector<int> edges[100005];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &h[i]);
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int ok = true;
        for (auto e: edges[i]) {
            if (h[e] >= h[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        }
    }
    printf("%d\n", ans);
}


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

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		X += D % a == 0 ? D / a : D / a + 1;
	}
	cout << X << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
using namespace std;
int a,b,h;
int main()
{
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 110
signed main()
{
    //ios_base::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll ans=0;
    ans+=(x/500)*1000;

    x%=500;
    ans+=(x/5)*5;
    cout<<ans;
    return 0;
}


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

PS = [[], [], [], []]
S = "RLUD".index

for i in range(N):
    x, y, d = input().split(); x = int(x); y = int(y)
    PS[S(d)].append((x, y))

T = [0]
INF = 10**9

dymin = INF; dymax = -INF
P = []
for i in [0, 1]:
    xmin = INF; xmax = -INF
    for x, y in PS[i]:
        dymin = min(dymin, y)
        dymax = max(dymax, y)
        xmin = min(xmin, x)
        xmax = max(xmax, x)
    P.append((xmin, xmax))
for x0 in P[0]:
    for x1 in P[1]:
        T.append(max(x1 - x0, 0) / 2.)

dxmin = INF; dxmax = -INF
Q = []
for i in [2, 3]:
    ymin = INF; ymax = -INF
    for x, y in PS[i]:
        dxmin = min(dxmin, x)
        dxmax = max(dxmax, x)
        ymin = min(ymin, y)
        ymax = max(ymax, y)
    Q.append((ymin, ymax))
for y0 in Q[0]:
    for y1 in Q[1]:
        T.append(max(y1 - y0, 0) / 2.)

for x0 in [dxmin, dxmax]:
    for x in P[0]:
        T.append(max(x0 - x, 0))
    for x in P[1]:
        T.append(max(x - x0, 0))
for y0 in [dymin, dymax]:
    for y in Q[0]:
        T.append(max(y0 - y, 0))
    for y in Q[1]:
        T.append(max(y - y0, 0))

ans = 10**30
for t in T:
    xmin = dxmin; xmax = dxmax
    ymin = dymin; ymax = dymax

    xi, xa = P[0]
    if xi != INF:
        xmin = min(xmin, xi+t)
        xmax = max(xmax, xa+t)
    xi, xa = P[1]
    if xi != INF:
        xmin = min(xmin, xi-t)
        xmax = max(xmax, xa-t)
    yi, ya = Q[0]
    if yi != INF:
        ymin = min(ymin, yi+t)
        ymax = max(ymax, ya+t)
    yi, ya = Q[1]
    if yi != INF:
        ymin = min(ymin, yi-t)
        ymax = max(ymax, ya-t)
    ans = min(ans, (xmax - xmin) * (ymax - ymin))
print("%.10f" % ans)

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

int main(void){
  int n,m; cin >> n >> m;
  int h[n],a[m],b[m];
  rep(i,n) cin >> h[i];
  rep(i,m) cin >> a[i] >> b[i];
  int good[n]; //いい展望台の数
  rep(i,n) good[i] = 1;
  rep(i,m){
    if(h[a[i]-1] > h[b[i]-1]){
      good[b[i]-1] = 0;
    }
    else if(h[a[i]-1] < h[b[i]-1]){
      good[a[i]-1] = 0;
    }
    else{
      good[a[i]-1] = 0;
      good[b[i]-1] = 0;
    }
  }
  int ans = 0;
  rep(i,n){
    if(good[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5156
#include<iostream>
#include<bitset>
#include<string>
using namespace std;
bool iseven(int x){ return x % 2 == 0; }
bool isodd(int x){ return !iseven(x); }

int dist(int x, int y) { return abs(x - y); }
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int dist_ac = dist(a, c);
    int dist_ab = dist(a, b);
    int dist_bc = dist(b, c);
    //cout << dist_ac << " " << dist_ab << " " << dist_bc << " ";
    if(dist_ac <= d){ cout << "Yes"; }
    else if((dist_ab <= d) && (dist_bc <= d)){ cout << "Yes"; }
    else { cout << "No"; }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  int cnt = 0;
  bool ans = false;
  rep(i, n) {
    int d1, d2;
    cin >> d1 >> d2;
    if(d1 == d2) {
      cnt++;
    } else {
      cnt = 0;
    }
    if(cnt >= 3) ans = true;
  }
  cout << (ans ? "Yes" : "No") << endk;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    stack<long long int>st;
    string s;
    long long int a,b;
    while(cin>>s)
    {
        if(s=="+")
        {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a+b);
        }
        else if(s=="-")
        {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(b-a);
        }
        else if(s=="*")
        {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a*b);
        }
        else st.push(stoi(s));
    }
    cout<<st.top()<<endl;
    return 0;
}



Measured memory_bytes: 3196
import sys
from itertools import accumulate
import bisect
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
Bsum=[0]*(N+1)
for i in range(N):
  Bsum[i+1] = N-bisect.bisect_right(C,B[i])
Bsum=list(accumulate(Bsum))
ans = 0
for i in range(N):
  a = bisect.bisect_right(B,A[i])
  ans += Bsum[-1]-Bsum[a]
print(ans)

Measured memory_bytes: 24192
n = int(input())
data = [int(_) for _ in input().split(" ")]

for i in range(len(data),0,-1):
    count = n//i
    total = 0
    for k in range(count,1,-1):
        total += data[i*k-1]
    if data[i-1]%2 == 0 and total%2 == 0:
        data[i-1] = 0
    elif data[i-1]%2 == 1 and total%2 == 1:
        data[i-1] = 0
    else:
        data[i-1] = 1

m = 0
for ele in data:
    if ele != 0:
        m += 1

print(m)
if m != 0:
    ans = []
    for i in range(len(data)):
        if data[i] != 0:
            ans.append(i+1)
    print(" ".join(map(str,ans)))



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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int c[500],s[500],f[500],ret[500];

int main(){
  int n;
  cin>>n;
  REP(i,n-1){
    cin>>c[i]>>s[i]>>f[i];
  }

  ret[n-1]=0;

  REP(i,n-1){
    int su=0;
    REP(j,n-1-i){
      if(s[i+j]>=su)
	su=s[i+j]+c[i+j];
      else{
	if((su-s[i+j])%f[i+j]==0)
	  su=su+c[i+j];
	else
	  su=f[i+j]*((su-s[i+j]+f[i+j])/f[i+j])+s[i+j]+c[i+j];
      }
    }
    ret[i]=su;
  }

  REP(i,n){
    cout<<ret[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "stdio.h"
#include "limits.h"
#include "iostream"
#include "algorithm"
using namespace std;

long long int tura[111111];
long long int zikan[111111];

int main()
{
  long long int n,l;
  scanf("%lld %lld",&n,&l);
  for(int i = 1; i <= n; i++)
    {
      scanf("%lld",&(tura[i]));
      zikan[i] = 0;
    }
  tura[0] = -1;
  zikan[0] = -1;
  zikan[1] = -1;
  tura[n + 1] = -1;
  zikan[n] = -1;
  zikan[n + 1] = -1;
  for(int i = 1; i <= n; i++)
    {
      if(tura[i] < tura[i - 1] && tura[i] < tura[i + 1])
	{
	  zikan[i] = -1;
	}
    }
  for(int i = 1; i <= n; i++)
    {
      if(tura[i] > tura[i - 1] && tura[i] > tura[i + 1])
	{
	  zikan[i] = l - tura[i];
	  for(int ii = 1; ; ii++)
	    {
	      if(zikan[i - ii] != 0)
		{
		  if(zikan[i - ii] < zikan[i - ii + 1] + (l - tura[i - ii]))
		    {
		      zikan[i - ii] = zikan[i - ii + 1] + (l - tura[i - ii]);
		    }
		  break;
		}
	      else
		{
		  zikan[i - ii] = zikan[i - ii + 1] + (l - tura[i - ii]);
		}
	    }
	  for(int ii = 1; ; ii++)
	    {
	      if(zikan[i + ii] != 0)
		{
		  if(zikan[i + ii] < zikan[i + ii - 1] + (l - tura[i + ii]))
		    {
		      zikan[i + ii] = zikan[i + ii - 1] + (l - tura[i + ii]);
		    }
		  break;
		}
	      else
		{
		  zikan[i + ii] = zikan[i + ii - 1] + (l - tura[i + ii]);
		}
	    }
	}
    }
  sort(zikan + 1,zikan + n + 1);
  printf("%lld\n",zikan[n]);
  return 0;
}

Measured memory_bytes: 2768
src = input()
values = src.split(' ')
n = int(values[0])
a = int(values[1])
b = int(values[2])

result = 0

for x in range(1, n + 1):
    value = str(x)
    sum = 0
    for c in value:
        sum += int(c)

    if a <= sum and sum <= b:
        result += x

print(result)


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

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

  int sum = 0; // 合計点を表す変数
  int x;       // 入力を受け取る変数
  int i = 0;   // カウンタ変数

  while (i < M) {
    cin >> x;
    sum += x;
    i++;
  }

 if(N-sum>=0){
   cout<<N-sum<<endl;
 }
  else{
    cout<<-1<<endl;
  }
  
}



Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC165B
    {
        const bool TESTING = false;
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
            if (TESTING)
            {
                Console.SetIn(new StreamReader(FILE));
            }
            var line = Console.ReadLine();
            long x = long.Parse(line);

            long amount = 100;
            int year = 1;
            while(true)
            {
                amount += (amount / 100);
                if (amount >= x)
                {
                    Console.WriteLine(year);
                    return;
                }

                year += 1;
            }

#if DEBUG
            Console.WriteLine();
#endif
        }
    }
}


Measured memory_bytes: 27472
A,B = map(int, input().split())

h = 100
w = 100
ans = [["#"]*w for _ in range(h)]
for i in range(h):
    for j in range(w//2):
        ans[i][j] = "."
    
L = [0, 0]
for i in range(B-1):
    r = L[0]
    c = L[1]
    ans[r][c] = "#"
    L[1] += 2
    if L[1] >= 50:
        L[0] += 2
        L[1] = 0
    
L = [0, 99]
for i in range(A-1):
    r = L[0]
    c = L[1]
    ans[r][c] = "."
    L[1] -= 2
    if L[1] <= 50:
        L[0] += 2
        L[1] = 99
    
print(h, w)
for i in range(h):
    print("".join(ans[i]))

Measured memory_bytes: 3188
N, M = map(int, input().split())
ks=[]
for _ in range(M):
    ks.append(list(map(int, input().split())))
p=list(map(int, input().split()))

#print(N, M, ks, p)

pos=[None]*N
pattern=0

def check(pos):
    #print(pos)
    count=0
    for i in range(M):
        temp=0
        for j in range(1, len(ks[i])):
            temp+=pos[ks[i][j]-1]
        if temp%2==p[i]:
            #print('OK')
            count+=1
    #print(count)
    if count==M:
        #print(pos)
        return 1
    else:
        return 0

def set(n):
    global pattern
    if n==N-1:
        for i in range(2):
            pos[n]=i
            pattern+=check(pos)
    else:
        for i in range(2):
            pos[n]=i
            set(n+1)
set(0)

print(pattern)

Measured memory_bytes: 3064
import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = []
    B = []
    for _ in range(N):
        a, b = map(int, readline().split())
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    if N%2==1:
        l = A[N//2]
        r = B[N//2]
        print(r-l+1)
    else:
        l1 = A[N//2-1]
        r1 = B[N//2-1]
        l2 = A[N//2]
        r2 = B[N//2]
        ans = (r2+r1) - (l2+l1) + 1
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25452
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    if(a == 0){
        cout << 0 << endl;
        return 0;
    }
    
    ll c = a + b;

    ll tmp = n / c;
    ll rest = n % c;

    if(rest >= a){
        cout << tmp * a + a << endl;
    } else {
        cout << tmp * a + rest << endl;
    }
}   

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

using namespace std;

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

    int n;cin>>n;
    if(n==0) cout<<1<<endl;
    else if(n==1) cout<<2<<endl;
    else if(n==2) cout<<1<<endl;
    else cout<<0<<endl;
}

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

using namespace std;

const int N = 100010;

int n, h[N], f[N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", h + i);
  }
  f[n - 1] = abs(h[n] - h[n - 1]);
  for (int i = n - 2; i > 0; --i) {
    f[i] = min(abs(h[i + 1] - h[i]) + f[i + 1], abs(h[i + 2] - h[i]) + f[i + 2]);
  }
  cout << f[1] << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

int a[1<<18];
pair<Pi,Pi> d[1<<18];
pair<Pi,Pi> res(pair<Pi,Pi> ori,pair<Pi,Pi> ne)
{
	pair<Pi,Pi> p=ori;
	if(p.X.X<ne.X.X)
	{
		p.Y=p.X;
		p.X=ne.X;
	}
	else if(p.Y.X<ne.X.X)
	{
		if(p.X.Y!=ne.X.Y)
			p.Y=ne.X;
	}
	if(p.Y.X<ne.Y.X)
	{
		if(p.X.Y!=ne.Y.Y)
			p.Y=ne.Y;
	}
	return p;
}
int main() {
	fill(d,d+(1<<18),mp(mp(-1,-1),mp(-1,-1)));
	int n;
	scanf("%d",&n);
	fup(i,0,(1<<n)-1,1)scanf("%d",a+i);
	fup(i,1,(1<<n)-1,1)
	{
		auto t=mp(mp(a[0],0),mp(a[i],i));
		if(t.X<t.Y)swap(t.X,t.Y);
		d[i]=res(d[i],t);
		fup(j,0,n-1,1)
		{
			if(!(i&(1<<j)))d[i+(1<<j)]=res(d[i+(1<<j)],d[i]);
		}
	}
	int ans=0;
	fup(i,1,(1<<n)-1,1)
	{
		pair<Pi,Pi> p=d[i];
		ans=max(ans,p.X.X+p.Y.X);
		printf("%d\n",ans);
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


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

    ll C[10][10] = {0};
    repr(i,1,N+1) {
        int b = i % 10;
        int t = i;
        while (t >= 10) t /= 10;
        C[t][b]++;
    }

    ll res = 0;
    rep(i,10) rep(j,10) res += C[i][j]*C[j][i];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 998244353

ll power(ll a, ll n,ll m) 
{ 
    if (n == 0) 
        return 1; 
    ll p = power(a, n / 2,m) % m; 
    p = (p * p) % m; 
    if (n & 1) 
        p = (p * a) % m; 
    return p; 
} 


int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif  
 
    ll t;
    t=1;
    // cin>>t;
    while(t--){
      ll n;
      cin>>n;
      if(n==1)cout<<0;
      else{
        ll ans1 = power(10,n,mod);
        ll ans2 = power(8,n,mod);
        ll ans3 = power(9,n,mod);

       
        ans1 = (ans1-ans3+mod)%mod;
        ans1 = (ans1-ans3+mod)%mod;
         ans1 = (ans1+ans2+mod)%mod;
        
        cout<<ans1;
      }





    }
     
      

      

    

    
return 0;
}     



Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

vector<ll> ans;

int main() {
	while (1) {
		ll n, r, p, c, card[51] = {};
		cin >> n >> r;
		if (n == 0 && r == 0)break;
		for (int i = 1; i <= n; i++)card[i] = n - i + 1;
		for (int i = 1; i <= r; i++) {
			cin >> p >> c;
			ll box[51] = {};
			for (int j = 1; j < p; j++)box[j] = card[j];
			for (int j = 1; j <= c; j++)card[j] = card[j + p - 1];
			for (int j = 1; j < p; j++)card[c + j] = box[j];
		}
		ans.push_back(card[1]);
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}


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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}


int main() {
   ll i,j,k;
    ll n,num=0;
    vector<ll> a;
    cin >>n ;
    for(i=0; i<n; i++)
    {
      ll in;
      num+=1;
      cin >>in;
      a.push_back(in);
    }

    sort(a.begin(),a.end());

    for(i=1; i<num; i++)
    {
      if(a[i]==a[i-1])
      {
        cout << "NO" << endl;
        return 0;
      }
    }
    cout << "YES" << endl;
  
}


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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c;
    cin>>a>>b>>c;
    cout << min(b/a, c) << "\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

re = 0
count = 0
for i in range(N):
	if(B[i] <= A[i]):
		count += B[i]
	else:
		count += A[i]
		if((B[i]-A[i]) < A[i+1]):
			count += B[i]-A[i]
			A[i+1] -= B[i]-A[i]
		else:
			count += A[i+1]
			A[i+1]=0

print(count)

Measured memory_bytes: 18624