akhauriyash/Code-Regression huggingface dataset:
def main():
    n, t = map(int, input().split())
    t_list = list(map(int, input().split()))
    ans = 0

    for i in range(n - 1):
        if t_list[i] + t < t_list[i + 1]:
            ans += t
        else:
            ans += t_list[i + 1] - t_list[i]

    print(ans + t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 103840
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 998244353

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << (a+b)*c/2 << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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 = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1) << endl;
}

Measured memory_bytes: 3560
import heapq


class Reverse:
    def __init__(self, val):
        self.val = val

    def __lt__(self, other):
        return self.val > other.val

    def __repr__(self):
        return repr(self.val)


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        if len(self.hq) == 0:
            return None
        if self.desc:
            return heapq.heappop(self.hq).val
        else:
            return heapq.heappop(self.hq)

    def push(self, a):
        if self.desc:
            heapq.heappush(self.hq, Reverse(a))
        else:
            heapq.heappush(self.hq, a)

    def top(self):
        if self.desc:
            return self.hq[0].val
        else:
            return self.hq[0]

    def __len__(self):
        return len(self.hq)


n, m = map(int, input().split(' '))
ab = []
for _ in range(n):
    a, b = map(int, input().split(' '))
    if a > m:
        continue
    ab.append((a, b))
ab.sort(reverse=True)

ans = 0
h = Heapq([], desc=True)
for i in range(1, m+1):
    while ab and ab[-1][0] <= i:
        a, b = ab.pop()
        h.push(b)
    if h:
        ans += h.pop()
print(ans)


Measured memory_bytes: 26740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c,d,s;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	s=max(a*c,b*d);
	s=max(s,a*d);
	s=max(s,b*c);
	cout<<s;
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main (int argc, char **argv) {
  double r;;
  cin >> r;

  double area = M_PI * r * r;
  double len = 2 * M_PI * r;
  
  cout << fixed << setprecision(8) << area << " " << len << endl;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 2 * N;

LL a;

int main()
{
	cin >> a;
	cout << (a - 1) * a / 2 << endl;
    return 0;
}

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  string s,t;
  cin >> s >> t;
  ll mc = 0;
  REP(i,s.length()-t.length()+1){
    ll tmp = 0;
    REP(j,t.length()){
      if(s[i+j]==t[j]) tmp++;
    }
    mc = max(mc,tmp);
  }
  cout << t.length() - mc << endl;
  return 0;
}


Measured memory_bytes: 3616
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

a, b = map(int,input().split())
a_set = set()
for num, _ in factorization(a):
    a_set.add(num)
b_set = set()
for num, _ in factorization(b):
    b_set.add(num)
ans = a_set & b_set
if 1 not in ans:
    ans.add(1)
print(len(ans))


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}


ll A, B, N;

ll f(ll x) {
  return floor(A * x / B) - A * floor(x / B);
}




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

    cin >> A >> B >> N;

    ll ans = 0;
    if (A == B) {
      ans = f(0);
    } else {
      if (N >= B - 1) {
        ans = f(B - 1);
      } else {
        ans = f(N);
      }
    }

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



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

int main() {
    set< char > st;
    int k;
    cin >> k;
    while (k--) {
        char c; cin >> c;
        st.emplace(c);
    }
    if(st.size() == 3) puts("Three");
    else puts("Four");
}

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

bool is_pal(string s) {
    string t;
    t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

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

    string s;
    cin >> s;
    cout << (is_pal(s) && is_pal(s.substr(0, s.size() / 2)) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int get_parent(int i, int *parent) {
  while (i != parent[i]) i = parent[i];
  return i;
}

void Union(int i, int j, int *parent, int *rank) {
  i = get_parent(i, parent);
  j = get_parent(j, parent);
  if (i == j) return;
  if (rank[i] < rank[j]) swap(i, j);
  parent[j] = i;
  rank[i] = max(rank[i], rank[j] + 1);
  return;
}


int main(void) {

  int n, m, parent[100100], Rank[100100];
  cin >> n >> m;

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  
  rep(i, n) parent[i] = i;

  rep(i, m) {
    int x, y;
    cin >> x >> y;
    Union(x, y, parent, Rank);
  }

  
  int cnt = 0, p;
  vector<int> num(n, -1);
  vector< vector<ll> > v(n);
  rep(i, n) {
    p = get_parent(i, parent);
    if (num[p] == -1) {
      num[p] = cnt++;
    }
    v[num[p]].push_back(a[i]);
  }
  rep(i, cnt) sort(v[i].begin(), v[i].end());
  
  if (cnt == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  ll ans = 0;
  vector<ll> r;
  rep(i, cnt) {
    ans += v[i][0];
    for (int j = 1; j < v[i].size(); j++) r.push_back(v[i][j]);
  }
  if (r.size() < cnt - 2) {
    cout << "Impossible\n";
    return 0;
  }
  sort(r.begin(), r.end());
  rep(i, cnt - 2) ans += r[i];

  cout << ans << endl;

  return 0;

}
  
    

  

  
  


Measured memory_bytes: 7680
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: h,n
      integer(16),allocatable :: a(:)
      
      read*,h,n
      allocate(a(n))
      read*,a(:)
      
      if( sum(a)>=h )then
        print*,'Yes'
      else
        print*,'No'
      end if
      
      
      
      
      
      END PROGRAM

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

const string YES = "Yes";
const string NO = "No";
int main(){
  string N; cin >> N;
  bool ans = false;
  rep(i, 3) if (N[i] == '7') ans = true;
  if (ans) cout << YES << endl;
  else cout << NO << endl;
}


Measured memory_bytes: 3628
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int s[500][27];
int c[27];
int cal(int x) {
	return (x - 1) * x / 2;
}
int n;
int l[27];
int val(vi t) {
	int ans = 0;
	memset(l, -1, sizeof(l));
	for (int i = 0; i < n; i++)
		ans += s[i][t[i]], 
		ans -= c[t[i]] * cal(i - l[t[i]]), 
		l[t[i]] = i;
	for (int i = 0; i < 27; i++)
		ans -= cal(n - l[i]) * c[i];
	return ans;
}
vi upd(vi s) {
	int nans = val(s);
	while (1.0 * clock() / CLOCKS_PER_SEC < 1.5) {
		int fl = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 26; j++) {
				vi e = s;
				e[i] = j;
				int na = val(e);
				if (chkmax(nans, na)) 
					s = e, fl = 0;
			}
		if (fl) {
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					if (s[i] == s[j]) continue;
					vi e = s;
					swap(e[i], e[j]);
					int na = val(e);
					if (chkmax(nans, na))
						s = e, fl = 0; 
				}
			}
		}
		if (fl) break;
	}
	return s;
}
std::mt19937 rd;
const int mxs = 1e9;
int main() {
//	freopen("sample2.in", "r", stdin);
	cin >> n;
	for (int i = 0; i < 26; i++)
		cin >> c[i];
	vi cur(n);
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];
			if (s[i][j] > s[i][cur[i]])
				cur[i] = j;
		}
	vector<vi> tot;
	cur = upd(cur);
	vi mx = cur;
	for (auto v : mx) 
		cout << v + 1 << endl;
	cout << endl;
//	cout << val(mx) << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int N;
int main()
{
    cin >> N;
    int C[N-1], S[N-1], F[N-1];
    for (int i = 0; i < N-1; ++i) cin >> C[i] >> S[i] >> F[i];
    for (int i = 0; i < N-1; ++i) {
        int s;
        s = 0;
        for (int j = i; j < N-1; ++j) s = (s<S[j]?S[j]:s%F[j]!=0?s = s+F[j]-s%F[j]:s) + C[j];
        cout << s << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    string s;

    cin >> s;

    bool f = true;

    for(int i = 0; i < s.size(); i += 2) {
        if(s[i] == 'h' and s[i+1] == 'i');
        else f = false;
    }

    cout << ((f and s.size()%2==0)?"Yes\n":"No\n");
  
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<algorithm>
#include<vector>
using namespace std;
const int M=1e5+1;

int main(){
    int n;
    cin >> n;
    int v[n];
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    vector<pair<int,int>> even(M),odd(M);
    for(int i=0;i<M;i++){
        even[i].first=0;
        odd[i].first=0;
        even[i].second=i;
        odd[i].second=i;
    }
    for(int i=0;i<n;i++){
        if(i%2==0){
            even[v[i]].first++;
        }else{
            odd[v[i]].first++;
        }
    }
    sort(even.begin(),even.end());
    reverse(even.begin(),even.end());
    sort(odd.begin(),odd.end());
    reverse(odd.begin(),odd.end());
    
    if(even[0].second!=odd[0].second){
        cout << n-even[0].first-odd[0].first << endl;
    }else{
        cout << n-max(even[0].first+odd[1].first,even[1].first+odd[0].first) << endl;
    }



}

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

using lint = long long int;
using pll = std::pair<lint, lint>;
using node = std::pair<pll, int>;

using std::vector;
using std::stack;

vector<node> ve[4], vec;
bool check[100100];
stack<int> st;

int main(void) {
	lint R, C, N;
	scanf("%lld %lld %lld", &R, &C, &N);

	for(int i = 1; i <= N; i++){
		lint x1, y1, x2, y2;
		scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
		if ((x1 == 0 || x1 == R || y1 == 0 || y1 == C) && (x2 == 0 || x2 == R || y2 == 0 || y2 == C)) {
			if (x1 == 0) {
				ve[0].push_back(node(pll(x1, y1), i));
			}
			else if (x1 == R) {
				ve[2].push_back(node(pll(x1, y1), i));
			}
			else if (y1 == 0) {
				ve[3].push_back(node(pll(x1, y1), i));
			}
			else if (y1 == C) {
				ve[1].push_back(node(pll(x1, y1), i));
			}

			if (x2 == 0) {
				ve[0].push_back(node(pll(x2, y2), i));
			}
			else if (x2 == R) {
				ve[2].push_back(node(pll(x2, y2), i));
			}
			else if (y2 == 0) {
				ve[3].push_back(node(pll(x2, y2), i));
			}
			else if (y2 == C) {
				ve[1].push_back(node(pll(x2, y2), i));
			}
		}
	}

	sort(ve[0].begin(), ve[0].end());
	sort(ve[1].begin(), ve[1].end());
	sort(ve[2].begin(), ve[2].end(), std::greater<node>());
	sort(ve[3].begin(), ve[3].end(), std::greater<node>());

	for (int i = 0; i <= 3; i++) {
		for (int j = 0; j < ve[i].size(); j++) {
			vec.push_back(ve[i][j]);
		}
	}

	for (int i = 0; i < vec.size(); i++) {
		int cur = vec[i].second;
		if (check[cur]) {
			if (st.top() == cur) {
				st.pop();
				check[cur] = false;
			}
			else {
				printf("NO");
				return 0;
			}
		}
		else {
			check[cur] = true;
			st.push(cur);
		}
	}

	printf("YES");

	return 0;
}

Measured memory_bytes: 15644
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
  string input(s);

  vector<char> v;
  for(char c: s){
    if(c != 'B') v.push_back(c);
    else if(!v.empty()) v.pop_back();
  }

  for(char c: v) cout << c;
  cout << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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



signed main(){
	
	ll a,b,cnt = 1,ans = 0;
	cin >> a >> b;
	while(cnt < b){
		cnt += a-1;
		ans++;
	}
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const long double PI = acos(-1.0);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
signed main() {
	my_io();
	int h1, w1, h2, w2;
	cin >> h1 >> w1 >> h2 >> w2;
	cout << h1 * w1 - h2 * w1-(h1-h2)*w2 << endl;
	return 0;

}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
VO=[]
VE=[]
for i in range(n):
  if i%2==1:
    VO.append(V[i])
  else:
    VE.append(V[i])
vo=Counter(VO).most_common(2)
ve=Counter(VE).most_common(2)
if ve[0][0]!=vo[0][0]:
  ans=n-ve[0][1]-vo[0][1]
else:
  if len(ve)==1 and len(vo)==1:
    ans=n//2
  elif len(ve)==1:
    ans=n-ve[0][1]-vo[1][1]
  elif len(vo)==1:
    ans=n-vo[0][1]-ve[1][1]
  else:
    ans=min((n-ve[0][1]-vo[1][1]),(n-vo[0][1]-ve[1][1]))    
print(ans)

Measured memory_bytes: 16100
#include <iostream>

using namespace std;

int par[100010];
int N,M;
int X,Y,Z;
int r[100010]={};
int res=0;
void init(){
  for(int i=0;i<N;i++) par[i]=i;
}

int root(int x){
  //根を返す．経路圧縮対応
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

bool same(int x,int y){
  return root(x)==root(y);
}

void unite(int x,int y){
  //結合(ランク無し)
  x=root(x);
  y=root(y);
  if(x==y)return;
  par[x]=y;
}
//AtCoder UnionFindを参照
int main(){
  cin >> N >> M;
  init();
  for(int i=0;i<M;i++){
    cin >> X >> Y >> Z;
    unite(X,Y);
  }
  for(int i=0;i<N;i++) r[root(i)]=1;
  for(int i=0;i<N;i++) res+=r[i];
  cout << res << endl;
  return 0;
}


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

int N, M, Q;
vector<int> a, b, c, d;
vector<int> A;

int dfs(int n)
{
    int res = 0;
    if (n == N) {
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                res += d[i];            
            }
        }
        return res;
    }
    for (int v = (n == 0 ? 1 : A[n-1]); v <= M; v++) {
        A[n] = v;
        res = max(res, dfs(n+1));
    }
    return res;
}

int main()
{
    cin >> N >> M >> Q;
    a = b = c = d = vector<int>(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    A.resize(N);
    cout << dfs(0) << endl;
}


Measured memory_bytes: 3628
def abc122b_atcoder():
    s = input()
    cnt = 0
    max_val = 0
    for c in s:
        if c in ['A', 'C', 'G', 'T']:
            cnt +=1
        else:
            max_val = max(max_val, cnt)
            cnt = 0
    max_val = max(max_val, cnt)
    print(max_val)
abc122b_atcoder()

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

//#pragma GCC optimize("ffast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

using namespace std;

/** Interface */

inline int readChar();
template <class T = int> inline T readInt();
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x );
inline void writeWord( const char *s );

/** Read */

static const int buf_size = 4096;

inline int getChar() {
    static char buf[buf_size];
    static int len = 0, pos = 0;
    if (pos == len)
        pos = 0, len = fread(buf, 1, buf_size, stdin);
    if (pos == len)
        return -1;
    return buf[pos++];
}

inline int readChar() {
    int c = getChar();
    while (c <= 32)
        c = getChar();
    return c;
}

template <class T>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
    if (write_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
    write_buf[write_pos++] = x;
}

template <class T>
inline void writeInt( T x, char end ) {
    if (x < 0)
        writeChar('-'), x = -x;

    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}

inline void writeWord( const char *s ) {
    while (*s)
        writeChar(*s++);
}

struct Flusher {
    ~Flusher() {
        if (write_pos)
            fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
    }
} flusher;

typedef long long ll;
typedef long double ld;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i <= m; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i * n + (m - i * 2) * j == k) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint N;
  bool check=true;
  cin >> N;
  lint A[N];
  //う　し　た　ぷ　に　き　あ　く　ん　笑
  rep(i,N) cin >> A[i];
  lint rem=((1+N)*N)/2;
  lint sum=accumulate(A,A+N,0LL);
  if(sum%rem!=0) check=false;
  lint ret=sum/rem;
  lint remmax[N]={};
  rep(i,N){
    remmax[i]=(ret-(A[(i+1)%N]-A[i]))/N;
    if((ret-(A[(i+1)%N]-A[i]))%N!=0) check=false;
    if(remmax[i]<0) check=false;
  }
  if(accumulate(remmax,remmax+N,0LL)!=ret) check=false;
  lint stone=0;
  rep(i,N) stone+=(N-i)*remmax[i];
  if(stone!=A[0]) check=false;
  for(int i=1;i<N;i++){
    stone+=ret-remmax[i-1]*N;
    if(stone!=A[i]) check=false;
  }
  if(check) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int N;
    cin >> N;
    vector<int>A(1+N);
    vector<int>B(1+N);
    for(int i = 0; i <= N; i++) {
        cin >> A[i];
    }
    B[N] = 0;
    for(int i = N; i > 0; i--) {
        B[i-1] = B[i]+A[i];
    }
    int ans = 0;
    int cnt = 1;
    for(int i = 0; i <= N; i++) {
        ans+=cnt;
        cnt-=A[i];
        if(cnt < 0) {
            ans = -1;
            break;
        }
        cnt*=2;
        cnt = min(cnt,B[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
import java.util.*;

/**
 * Created by mizuk on 2017/07/26.
 */
public class Main {
    private static int N;
    private static int M;
    private static ArrayList<Integer> a = new ArrayList<Integer>();
    private static ArrayList<Integer> b = new ArrayList<Integer>();
    private static boolean from[];
    private static boolean to[];

    public static void input(){
        Scanner scan = new Scanner(System.in);
        N = scan.nextInt();
        M = scan.nextInt();

        from = new boolean[N];
        to = new boolean[N];

        for(int i=0;i<M;i++) {
            a.add(scan.nextInt());
            b.add(scan.nextInt());
            if(a.get(i) == 1){
                from[b.get(i)] = true;
            }
            if(b.get(i) == N){
                to[a.get(i)] = true;
            }
        }
    }

    public static void main(String args[]){
        //入力
        input();

        for (int i=0;i<N;i++){
            if(from[i] && to[i]){
                System.out.println("POSSIBLE");
                return;
            }
        }

        System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 114752
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;
 
int main(){
    ll n;
    cin >> n;
 
    int mi = 1e9;
    for(ll i=1; i*i<=n;i++){
        if(n%i!=0)continue;
        int A=i,B=n/i;
 
        int cntA=0, cntB=0;
        while(A!=0) {
            A/=10;
            cntA++;
        }
        while(B!=0) {
            B/=10;
            cntB++;
        }
        mi = max(cntA, cntB);
    }
    cout << mi << endl;
    return 0;
}

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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    ll n;
    cin >> n;
    vector<ll> h(n),a(n);
    for(int i=0;i<n;i++)
    {
        cin >> h[i];
    }
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    vector<ll> v;
	map<ll,ll> m;
    m[0]=0;
    for(int i=0;i<n;i++)
    {
        ll x=h[i];
        auto itr=m.upper_bound(x);
        if(itr==m.end())
        {
            ll val=(a[i]+(*(--itr)).second);
            //cout << "val:"<<val << endl;
            m[x]=val;
        }
        else{
            auto itr3=itr;
            --itr3;
            ll val2=(*itr3).second+a[i];
            //cout << "val2 :" << val2 << endl; 
            auto itr4=itr;
            int test=0;
            for(itr4=itr;itr4!=m.end();itr4++)
            {
                if((*itr4).second>=val2)
                {
                    m.erase(itr,itr4);
                    test=1;
                    break;
                }
            }
            if(test==0)
            {
                m.erase(itr,itr4);
            }
            m[x]=val2;
        }
    }
    ll ans=0;
    for(auto itr=m.begin();itr!=m.end();itr++)
    {
        //cout << (*itr).first <<" : " << (*itr).second << endl;
        if(ans<(*itr).second)
        {
            ans=(*itr).second;
        }
    }
    cout <<ans << endl;

}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 15872
S = input()
a, b = int(S[:2]), int(S[2:])
if a == 0:
  if b == 0:
    print('NA')
  elif b <= 12:
    print('YYMM')
  else:
    print('NA')
elif a <= 12:
  if b == 0:
    print('MMYY')
  elif b <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if b == 0:
    print('NA')
  elif b <= 12:
    print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui N{}; std::cin >> N;

  vector<vector<ull>> dp(N, vector<ull>(3));
  rep(0, N)
  {
    vector<ui> ABC(3);
    rep_uj(0, ABC.size()) cin >> ABC[j];
    if(!i)
    {
      rep_uj(0, ABC.size()) dp[i][j] = ABC[j];
      continue;
    }

    dp[i][0] = std::max(ABC[0] + dp[i - 1][1], ABC[0] + dp[i - 1][2]);
    dp[i][1] = std::max(ABC[1] + dp[i - 1][0], ABC[1] + dp[i - 1][2]);
    dp[i][2] = std::max(ABC[2] + dp[i - 1][0], ABC[2] + dp[i - 1][1]);
  }

  auto ans = *boost::max_element(dp[dp.size() - 1]);
  cout << ans << '\n';
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main() {

    int L, R;
    cin >> L >> R;
    vector<int> numbers(2020);
    // int initial_number = L % 2019;
    for(int i=0;i<=min(2019, R-L);i++){
        numbers.at((L+i)%2019) = 1;
    }
    int min_number = 2020;
    for(int i=0;i<2020;i++){
        for(int j=i+1;j<2020;j++){
            if(numbers.at(i)==1&&numbers.at(j)==1){
                min_number = min(min_number, (i*j)%2019);
                // cout << i << ", " << j << endl;
            }
        }
    }
    cout << min_number << endl;
    return 0;

}

Measured memory_bytes: 256
import java.io.*;
    
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
    
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++) if((i&(1<<0))!=0&&(i&pic[0])!=0) dp[0][i]=1;
for(int i=1;i<n;i++)
for(int j=1;j<(1<<3);j++)
for(int k=1;k<(1<<3);k++)
if((k&pic[i])!=0){
if((j&pic[i])!=0) dp[i][k]+=dp[i-1][j];
else if((j&k)!=0) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
int ans=0;
for(int i=1;i<1<<3;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
  
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
}

Measured memory_bytes: 18596
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
	int dp[33]={0};
	
	dp[0]=1;
	for(int i=0;i<33;i++){
		if(i-1>=0)dp[i]+=dp[i-1];
		if(i-2>=0)dp[i]+=dp[i-2];
		if(i-3>=0)dp[i]+=dp[i-3];
	}
	
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		printf("%d\n",(dp[n]+3649)/3650);
	}
}

Measured memory_bytes: 1144
import itertools as it
# -*- coding: utf-8 -*-
# 個数の入力
N = int(input())
# 改行区切りの名前の入力
S = []
for i in range(N):
    S.append(input())
# データの加工
for i in range(N):
	S[i] = S[i][0]

# 文字列カウント
count = [S.count('M'), S.count('A'), S.count('R'), S.count('C'), S.count('H')]

# 数え上げ
answer = count[0]*count[1]*count[2]
answer = count[0]*count[1]*count[3] + answer
answer = count[0]*count[1]*count[4] + answer
answer = count[0]*count[2]*count[3] + answer
answer = count[0]*count[2]*count[4] + answer
answer = count[0]*count[3]*count[4] + answer
answer = count[1]*count[2]*count[3] + answer
answer = count[1]*count[2]*count[4] + answer
answer = count[1]*count[3]*count[4] + answer
answer = count[2]*count[3]*count[4] + answer

# 出力
print(answer)

Measured memory_bytes: 9784
C = [0] * 6
for _ in [0] * int(raw_input()):
  a, b = map(int, raw_input().split('.'))
  if a<165: C[0]+=1
  else: C[(a-160)/5] += 1
for i in range(6):
  print '%d:%s' %(i+1, '*'*C[i])

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

void solve(){
    long long int n,w;
    cin>>n>>w;
    long long int wt[n],val[n];
    for(long long int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }    
    // for(long long int i=0;i<n;i++) 
    long long int dp[n+1][w+1];
    for(long long int i=0;i<=n;i++){
        for(long long int j=0;j<=w;j++){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }
            else{
                if(wt[i-1] <= j){
                    dp[i][j] = max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
                }
                else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    cout<<dp[n][w];
}


int main(){
  solve();
}

Measured memory_bytes: 82288
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  unordered_map<ll, ll> mp;
  ll sum = 0;
  int n, q;
  cin >> n;
  REP(i, n) {
    int x;
    cin >> x;
    mp[x] += 1;
    sum += x;
  }
  vector<ll> ans;
  cin >> q;
  REP(i, q) {
    int x, y;
    cin >> x >> y;
    if (mp[x] == 0) {
      ans.push_back(sum);
    } else {
      sum += (y - x) * mp[x];
      mp[y] += mp[x];
      mp[x] = 0;
      ans.push_back(sum);
    }
  }
  REP(i, q) { cout << ans[i] << endl; }
}

Measured memory_bytes: 7852
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<utility>
#include<queue>
#define fi first
#define se second
#define MK(a,b) make_pair((a),(b))
using namespace std;
typedef long long ll;
const int N=100005;
const ll mod=1e9+7;
typedef pair<ll,int> pii;
inline void MOD(int &x) {if (x>=mod) x-=mod;}


int n,m;
int hd[N],pr[N*4],to[N*4],len[N*4],tot;
void addedge(int u,int v,int d) {to[++tot]=v;pr[tot]=hd[u];len[tot]=d;hd[u]=tot;}



ll ds[N],dt[N];
int S,T,fs[N],ft[N],q[N],hh,tt;
bool b[N];

void work(int S,ll *dis,int *f)
{
	for (int i=1;i<=n;i++) dis[i]=1e15,b[i]=false;
	dis[S]=0;
	priority_queue< pii ,vector< pii >,greater< pii > > heap;
	heap.push(MK(dis[S],S));
	hh=1,tt=0;
	while (!heap.empty()) 
	{
		pii t=heap.top();heap.pop();
		int u=t.se;
		if (b[u]) continue;b[u]=true;
		q[++tt]=u;
		for (int i=hd[u];i;i=pr[i]) if (dis[to[i]]>dis[u]+len[i]) 
		{
			dis[to[i]]=dis[u]+len[i];
			heap.push(MK(dis[to[i]],to[i]));
		}
	}

	f[S]=1;
	for (int u,k=1;k<=n;k++) 
	{
		u=q[k];
		for (int i=hd[u];i;i=pr[i]) if (dis[to[i]]==dis[u]+len[i]) MOD(f[to[i]]+=f[u]);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d%d",&S,&T);
	for (int u,v,d,i=1;i<=m;i++) 
	{
		scanf("%d%d%d",&u,&v,&d);
		addedge(u,v,d);
		addedge(v,u,d);
	}

	work(S,ds,fs);
	work(T,dt,ft);
	
	//for (int i=1;i<=n;i++) printf("fs=%d ds=%lld ft=%d dt=%lld\n",fs[i],ds[i],ft[i],dt[i]);
	
	
	int ans=(ll)fs[T]*fs[T]%mod;ll tm=ds[T]>>1;;
	//printf("%d\n",ans);
	if (tm+tm==ds[T]) 
	{
		for (int i=1;i<=n;i++) 
		if (ds[i]==tm&&dt[i]==tm) ans=((ll)ans-(ll)fs[i]*fs[i]%mod*ft[i]%mod*ft[i]%mod+mod)%mod;
	}

	for (int u,v,i=1;i<=m*2;i+=2) 
	{
		u=to[i],v=to[i+1];
		if (ds[u]>ds[v]) swap(u,v);
		if (ds[u]+dt[v]+len[i]!=ds[T]) continue;
		if (ds[u]<tm&&ds[v]>tm) 
		ans=((ll)ans-(ll)fs[u]*fs[u]%mod*ft[v]%mod*ft[v]%mod+mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11732
using System;
using System.Collections;
using System.Linq;

public class Test
{
	public static void Main( )
	{

		int[] nums = Console.ReadLine().Split( ' ' ).Select( a => int.Parse( a ) ).ToArray();
		int x = Math.Max( nums[0], nums[1] );
		int y = Math.Min( nums[0], nums[1] );
		while( 0 != y ) {
			int t = y;
			y = x%y;
			x = t;
		}
		
		Console.WriteLine( x );
	}
}

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

int main(){
	int sum[4];
	int num;
	char type[2];
	
	for(int i = 0; i < 4; i++) sum[i] = 0;
	
	while((scanf("%d,%s", &num, type)) != EOF){
		if(type[0] == 'A' && type[1] == 'B') sum[2]++;
		else if(type[0] == 'A') sum[0]++;
		else if(type[0] == 'B') sum[1]++;
		else if(type[0] == 'O') sum[3]++;
	}
	
	for(int i = 0; i < 4; i++){
		printf("%d\n", sum[i]);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define xxx         exit(0);
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x)/log(base));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll i,l,j,k,x1,y1,n,ans,x,y,q;
    	cin>>n;
    	ll h[n],dp[n]; l=0;
    	rep(i,0,n) cin>>h[i];
    	dp[0]=0;
    	dp[1]=abs(h[0]-h[1]);
    	rep(i,2,n) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		cout<<dp[n-1];
	}
	return 0;
}

Measured memory_bytes: 5180
import java.io.IOException;
import java.util.NoSuchElementException;

 
public class Main{
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a<b&&b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}









class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}





Measured memory_bytes: 24164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll y;cin>>y;cout<<y*y<<endl;
  //caricurate
  //output
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		ArrayList<String> list = new ArrayList<>();
		sc.nextLine();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextLine());
		}
		Collections.sort(list, Comparator.naturalOrder());
		StringBuilder sb = new StringBuilder();
		for(String str: list) {
			sb.append(str);
		}
		System.out.println(sb.toString());
		
	}
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

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

	vector<int> p(n);
	rep(i, n)cin>>p[i];
	SORT(p);
	ll ans = 0;
	rep(i,k){
			ans += p[i];
		}
		cout << ans << endl;
}


Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<int>();
            if (9 < A || 9 < B)
                WriteLine(-1);
            else
                WriteLine(A * B);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27584