akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(d,t,s);
    yn(t*s>=d);
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <unordered_map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<string> S(N);
  unordered_map<string,ll> mp;
  REP(i,N){
    cin>>S[i];
    sort(ALL(S[i]));
    mp[S[i]]++;
  }

  ll ans=0ll;
  for(auto e:mp){
    ans+=(e.second*(e.second-1))/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 16164
#include<bits/stdc++.h>
#define db double
#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define fir first
#define sec second
#define pb push_back
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pii pair<int,int>
#define sc(x) scanf("%d",&(x))
#define sz(x) (int)(x).size()
#define ms(x) memset((x),0,sizeof(x));
#define all(x) (x).begin(), (x).end()
#define er(x) cerr<<(x)<<" ";
#define err(x) cerr<<#x<<": "<<(x)<<" ";
#define errn cerr<<endl;
using namespace std;
#define mod 1000000007
const db pi=acos(-1.0);
template <class T> void R(T &x) { cin>>x; }
void R(int &x) { scanf("%d",&x); }
void R(ll &x) { scanf("%lld",&x); }
void R(double &x) { scanf("%lf",&x); }
void R(char &x) { scanf(" %c",&x); }
void R(char *x) { scanf("%s",x); }
ll _pow(ll a,ll b) { ll res=1ll; while(b){ if(b&1)
res=res*a%mod; a=a*a%mod; b>>=1; } return res; }
///_____________________________________________

#define mxn 100005

int main()
{
    int a,b;
    R(a),R(b);
    puts(a*b%2?"Yes":"No");
    
    return 0;
}



Measured memory_bytes: 256
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 15:32:16
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

set<ll> divisors;
ll n;
ll ans;

void solve(ll divi)
{
	ll tri = n;
	if(divi == 1)
		return;
	while(tri % divi == 0)
		tri/=divi;
	if(tri % divi == 1)
		++ans;	
}

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

	cin >> n;
	for(ll i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
   			solve(i);
   			divisors.insert(i);
   			if(i * i != n)
   			{
   				solve(n / i);
   				divisors.insert(n/i);
   			}
		}
	}
	--n;
	for(ll i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			if(divisors.find(i) == divisors.end())
				++ans;
			if(i * i != n)
			{
				if(divisors.find(n/i) == divisors.end())
					++ans;
			}
		}
	}
	cout << ans << endl;

	return 0;
}             


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

using namespace std;

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

  string hoge = "";
  for(int i = 0 ; i < (int)s.length() ;){
    char c = s[i];
    hoge += s[i];
    while(c == s[i]) i++;
  }
  if(hoge.length() == 0) cout << 0 << endl;
  else cout << hoge.length()-1 << endl;
}


Measured memory_bytes: 640
N = int(input())
Q = [list(map(int, input().split())) for i in range(N)]

# 全体の偶奇が一致しているか
tmp = set()
for X, Y in Q:
    tmp.add((X + Y) % 2)
if len(tmp) != 1:
    print(-1)
    exit()

# 2べきの腕を用意
D = [2 ** i for i in range(30, -1, -1)]

# 偶数なら長さ1の腕を一本追加しておく
if 0 in tmp:
    D.append(1)

# 答えを作る
print(len(D))
print(" ".join(map(str, D)))

move = [(1, 0, "R"), (-1, 0, "L"), (0, 1, "U"), (0, -1, "D")]
for X, Y in Q:
    nx, ny = 0, 0
    ans = ""
    for d in D:
        tmp_move_ans = ""
        tmp_move = None
        min_move_cost = float('inf')
        for mx, my, s in move:
            cost = abs(nx + mx * d - X) + abs(ny + my * d - Y)
            if cost < min_move_cost:
                tmp_move_ans = s
                min_move_cost = cost
                tmp_move_x = mx
                tmp_move_y = my

        ans += tmp_move_ans
        nx, ny = nx + tmp_move_x * d, ny + tmp_move_y * d
    print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

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

    int k = s.size();
    int count = 0;

    REP(i, k){
        if(s[i] == 'o') count++;
    }

if(count  >= k-7 ){
  cout << "YES" << endl;
}else{
    cout << "NO" << endl;
}
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x=int(input())
    year=0
    yen=100
    while True:
        year+=1
        yen=yen*1.01//1
        if yen>=x:
            print(year)
            break

if __name__=='__main__':
    main()

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
int count(int X){
  int a=2;
  int b=1;
  int con=0;
  while(X>=b){
    b=a+b;
    a=a+1;
    con++;    
  }
  return con;
    

}

int main() {

  long N;
  int aaa;
  cin >> N;
  int i=2;
  int ans=0;
  while(i<2000000 && N!=1){
    aaa=0;
   while(N%i==0){
     N=N/i;
     aaa=aaa+1;     
   }
    ans=ans+count(aaa);
    i++;
  }
  
  if(i==2000000){
    ans=ans+1;
  }
  cout << ans<< endl;
 return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long ll;
const ll LLINF=1ll<<60;
const int mx=1e6+7;
// int n;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
// vector<int> adj[mx];
//vector<int> ans;
//---dfs--
//bool visited[mx];
//vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		string s,t;
		cin>>s>>t;
		int ans=(int)s.size()+1;
		for(int i=0;i<=(int)s.size()-(int)t.size();i++){
			string temp;
			for(int j=i;j<i+(int)t.size();j++) temp+=s[j];
			int cnt=0;
			for(int j=0;j<(int)t.size();j++){
				if(temp[j]!=t[j]) cnt++;
			}
			ans=min(ans,cnt);
		}
		cout<<ans<<"\n";
 	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n, ans, p, q;
    cin >> n;
    p = n/15;
    q = n%15;
    vector<long long> quo = {0,1,3,3,7,7,7,14,22,22,22,33,33,46,60};
    vector<long long> que = {0,1,2,2,3,3,3,4,5,5,5,6,6,7,8};
    ans = quo.at(q);
    ans += 60*p*p+15*p*que.at(q);
    printf("%lld\n",ans);
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    int n;cin >> n;
    vector<ll>a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    ll sum = 0;
    for(int i = 0;i<n-1;i++){
        if(a[i]>a[i+1]) {
            sum += (a[i]-a[i+1]);
            a[i+1] = a[i];
        }
    }
    cout << sum;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[110000];

LL solve(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	a=0;
	for(i=0;i<=n;i++){
		cin>>t[i];
		a+=t[i];
	}
	b=1;
	LL s=0;
	for(i=0;i<=n;i++){
		if(b<=0)return -1;
		s+=b;
		b-=t[i],a-=t[i];
		if(b<0)return -1;
		b*=2;
		b=min(b,a);
	}
	return s;
}

int main(){
	cout<<solve()<<endl;
}

Measured memory_bytes: 3988
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1000000000100000000;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
   int a, b, h; cin >> a >> b >> h;
   int res = (a+b)*h/2;
   cout << res << ln;
}

Measured memory_bytes: 3492
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

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

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func PrimeFactorsMap(n int) map[int]int {
	pfs := map[int]int{}
	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2]++
		} else {
			pfs[2] = 1
		}
		//pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i]++
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		if _, ok := pfs[n]; ok {
			pfs[n]++
		} else {
			pfs[n] = 1
		}
	}

	return pfs
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	f := make([]int, N+1)
	for i := range f {
		f[i] = 1
	}
	ans := 0
	for k := 2; k <= N; k++ {
		for j := 1; k*j <= N; j++ {
			f[k*j]++
		}
	}

	for i := 1; i <= N; i++ {
		ans += i * f[i]
	}
	fmt.Println(ans)
}


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

#define int long long
#define vec vector
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sq(x) (x)*(x)
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

using namespace std;
typedef pair<long long, long long> PII;
typedef long double ld;
vec < int > pr, sz;
int fin(int v){
    if(pr[v] == v) return v;
    return pr[v] = fin(pr[v]);
}
void un(int a, int b){
    a = fin(a);
    b = fin(b);
    if(a == b) return;
    if(sz[a] < sz[b]) swap(a, b);
    pr[b] = a;
    sz[a] += sz[b];
    sz[b] = sz[a];
    return;
}
void build(int n){
    pr.resize(n);
    sz.resize(n, 1);
    for(int i = 0; i < n; ++i) pr[i] = i;
}
signed main()
{
    int n, m, k;
    cin >> n >> m >> k;
    build(n);
    vec < PII > fr(m);
    vec < PII > dis(k);
    for(auto &i: fr) cin >> i.fi >> i.se, i.fi--, i.se--,
                    un(i.fi, i.se);
    for(auto &i: dis) cin >> i.fi >> i.se, i.fi--, i.se--;
    vec < int > ans(n);
    for(int i = 0; i < n; ++i)
        ans[i] = sz[fin(i)]-1;
//    for(auto &i: ans) cout << i << " ";
//    cout << "\n";
    for(auto &i: fr)
        ans[i.fi]--, ans[i.se]--;
//    for(auto &i: ans) cout << i << " ";
//    cout << "\n";
    for(auto &i: dis){
        if(fin(i.fi) == fin(i.se))
            ans[i.fi]--, ans[i.se]--;
    }
    for(auto &i: ans) cout << i << " ";
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
int N, arr[1001];
bool flag;
int main()
{
    cin>>N;
    for(int i = 0; i<N; ++i)
        cin>>arr[i];
    flag = true;
    for(int i = 0; i<N; ++i)
    {
        if(arr[i]%2==0)
        {
            if(arr[i]%3 && arr[i]%5)
            {
                flag = false;
                break;
            }  
        }
    }
    if(flag) cout<<"APPROVED\n";
    else cout<<"DENIED\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n;
    cin >> n;
    int a[n + 1];
    rep(i, 0, n) cin >> a[i];
    a[n] = 0;

    int cnt = 1;
    int ans = 0;
    rep(i, 0, n) {
        if (a[i] == a[i + 1]) {
            cnt ++;
        } else {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(N+1)]
 
for a in A:
  B[a] += 1
nums = [b for b in B if b > 0]
nums.sort()
n = len(nums)
if n <= K:
  print(0)
else:
  print(sum(nums[:n-K]))

Measured memory_bytes: 32204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string a,b;
    int cnt=0;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3924
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
vec a;

int dp[10101];

signed main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int tmp;
    cin >> tmp;
    a.pb(tmp);
  }

  for (int i = 0; i < 10000; i++) dp[i] = -INF;
  dp[0] = 0;

  for (int i = 1; i <= N; i++) {
    for (auto x : a) {
      if (num[x] <= i) dp[i] = max(dp[i], dp[i - num[x]] + 1);
    }
  }

  map<int, int> mp;
  for (int i = 1; i < 10; i++) mp[i] = num[i];

  sort(ALL(a), greater<int>());

  int now = N;
  while (now > 0) {
    for (auto x : a) {
      if (now - mp[x] >= 0 && dp[now - mp[x]] == dp[now] - 1) {
        cout << x;
        now -= mp[x];
        break;
      }
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xmod int(1e9+7)
#define hmod 1223334444555553LL
using namespace std;

int n,a[2000005],ct,ans;
int main(){
	scanf("%d",&n);ct=1;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (a[i] == ct)
		ct++;
		else
		ans++;
	}
	if (ct == 1)
	printf("-1\n");
	else
	printf("%d\n",ans);
    return 0;
}	

Measured memory_bytes: 1024
#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;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }


struct unionfind {
    vector<int> par;
    vector<int> sizes;

    unionfind(int n) : par(n),sizes(n,1){
        rep(i,0,n) par[i] = i;
    }

    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x,int y){
        x = root(x);
        y = root(y);

        if(x == y) return;

        if(sizes[x] < sizes[y] ) swap(x,y);

        par[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;

        return;
    }

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

    int size(int x){
        return sizes[root(x)];
    }
};


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

    unionfind uf(n);
    ll a[m],b[m];
    vector<ll> ans;

    rep(i,0,m){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }

    ll temp = n*(n-1)/2;
    ans.push_back(temp);

    rep(i,0,m){
        if(!uf.same(a[m-i-1],b[m-i-1])){
            temp -= uf.size(a[m-i-1])*uf.size(b[m-i-1]);     
        }
        ans.push_back(temp);
        uf.unite(a[m-i-1],b[m-i-1]);
    }


    
    rep(i,1,sz(ans)){
        cout << ans[sz(ans)-1-i] << endl;
    }
    

    return 0;
}


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

namespace ConsoleApp14
{
    class Class17
    {
        static void Main()
        {
            var HN = Console.ReadLine().Split();
            int H = int.Parse(HN[0]);
            int N = int.Parse(HN[1]);
            int[] DP = new int[H + 1];

            DP[0] = 0;
            for (int i = 1; i <= H; i++) DP[i] = int.MaxValue;

            for(int i = 0; i < N; i++)
            {
                var read = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int A = read[0];int B = read[1];

                for(int j = 0; j < H; j++)
                {
                    if (DP[j] != int.MaxValue)
                    {
                        int k = Math.Min(H, j + A);
                        DP[k] = Math.Min(DP[k], DP[j] + B);
                    }
                }
            }
            Console.WriteLine(DP[H]);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cstring>
using namespace std;
char map[110][110];
int visited[110][110];
int num=0;
int a,b;
void dfs(int i,int j){
	if(visited[i][j]!=0)return;
	visited[i][j]=num;
	char ch=map[i][j];
	if(i+1<=a&&map[i+1][j]==ch)dfs(i+1,j);
	if(j+1<=b&&map[i][j+1]==ch)dfs(i,j+1);
	if(i-1>=1&&map[i-1][j]==ch)dfs(i-1,j);
	if(j-1>=1&&map[i][j-1]==ch)dfs(i,j-1);
}
int main(){
	cin>>a>>b; 
	while(a!=0&&b!=0){
		num=0;
		memset(visited,0,sizeof(visited));
		for(int i=1;i<=a;i++){
			for(int j=1;j<=b;j++){
				cin>>map[i][j];
			}
		}
		for(int i=1;i<=a;i++)
		for(int j=1;j<=b;j++){
			if(visited[i][j]==0){
				num++;dfs(i,j);
			}
		}
		cout<<num<<endl;
		cin>>a>>b;
	}
	return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cntr = 0, cntw=0;
  int ans = 0;
  rep(i,n){
    if (s[i] == 'W') cntw++;
    else cntr++;
  }
  rep(i,cntr){
    if (s[i] == 'W') ans++;
  }
  cout << min({cntw,cntr,ans}) << endl;

  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <string>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

int main(){
    int n;
    cin >> n;
    if(400<=n and n <= 599){
        p(8);
    } else if (600<=n and n <= 799){
        p(7);
    } else if (800<=n and n <= 999){
        p(6);
    } else if (1000<=n and n <= 1199){
        p(5);
    } else if (1200<=n and n <= 1399){
        p(4);
    } else if (1400<=n and n <= 1599){
        p(3);
    } else if (1600<=n and n <= 1799){
        p(2);
    } else {
        p(1);
    }
}

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

string solve() {
    char A;
    cin >> A;
    int n = (int)(A - 'a');
    if ( n >= 0 && n < 26 ) return "a";
    else return "A";
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    string s; 
    int a,b,c;
    cin >> s;
    if(s == "SUN"){
        cout << 7 << endl;
    }else if(s == "MON"){
        cout << 6 << endl;
    }else if(s == "TUE"){
        cout << 5 << endl;
    }else if(s == "WED"){
        cout << 4 << endl;
    }else if(s == "THU"){
        cout << 3 << endl;
    }else if(s == "FRI"){
        cout << 2 << endl;
    }else if(s == "SAT"){
        cout << 1 << endl;
    }
}


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

int main(){
  int n,m,i,j,ans=0;
  cin >> n;
  vector<string> s(n);
  for(i=0; i<n; i++){
    cin >> s[i];
  }
  cin >> m;
  vector<string> t(m);
  for(i=0; i<m; i++){
    cin >> t[i];
  }
  int cur1;
  string cur;
  for(i=0; i<n; i++){
    cur=s[i];
    cur1=0;
    for(j=0; j<n; j++){
      if(cur==s[j]) cur1++;
    }
    for(j=0; j<m; j++){
      if(cur==t[j]) cur1--;
    }
    ans=max(ans,cur1);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)

using namespace std;

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

    string s;
    ll r = 0, W = 0;

    cin >> s;

    ford(i, sz(s))
    {
        W += (s[i] == 'W');

        if(s[i] == 'B')
            r += W;
    }

    cout << r << "\n";

    return 0;
}


Measured memory_bytes: 720
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N-2):
  if A[i+1]!=max(A[i],A[i+1],A[i+2]) and A[i+1]!=min(A[i],A[i+1],A[i+2]):
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
using System;
using System.Linq;

class main{
  public static void Main(string[] args){
    int cnt = int.Parse(Console.ReadLine());
    var num = Console.ReadLine().Split(" ").Select(s => int.Parse(s)).OrderByDescending(p => p).ToArray();
    int a = 0;
    int b = 0;
    
    for(int i = 0; i < cnt; i++){
      if(i%2 == 0) a += num[i];
      else if(i%2 != 0) b += num[i];
    }
    Console.WriteLine(a - b);
  }
}

Measured memory_bytes: 28364
#include <stdio.h>
 
int int_sort( const void *a, const void *b ){
    return *(int *)b - *(int *)a;
}
 
int main(void){
    // 変数
    int result = 0;
    int subtract = 0;
    int max = 0, max_index = 0;
    int k, n;
    int i;
    int a[210000];
    int total[210000];
 
    // 入力
    scanf( "%d %d", &k, &n );
    for( i = 0; i < n ; i++ ){
        scanf( "%d", &a[ i ] );
    }
 
    // 演算
    qsort( (void * )a, n, sizeof( a[0] ), int_sort );
 
    // 区間毎の距離格納、最大値の要素番号を格納
    for( i = 0 ; i < (n-1) ; i++ ){
        total[ i ] = a[ i ] - a[ i + 1 ];
        if( max < a[ i ] - a[ i + 1 ] ){
            max = a[ i ] - a[ i + 1 ];
            max_index = i;
        }
    }
 
    // 座標０をまたいだ計算
    subtract = ( k - a[0] ) + a[ n - 1 ];
 
    // 距離の総和
    for( i = 0; i < ( n - 1 ); i++ ){
        result += total[ i ];
    }
 
    // 区間毎の最大値と、座標０をまたいだ距離を比較し、どちらが大きいか比較
    if( subtract < max ){
        // 区間毎の方が大きい場合
        result += subtract;
        result -= total[ max_index ];
    }
 
    printf( "%d\n", result );
 
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;


int main() {
    int N;
    cin>>N;
    vector<double> A(N);
    rep(i,N)cin>>A.at(i);
    vector<double> B(N);
    double ans=0;
    rep(i,N){B.at(i)=1/A.at(i);ans+=B.at(i);}
    cout<<fixed<<setprecision(10);
    cout<<1/ans<<endl;
}


Measured memory_bytes: 256
s = input()

while(1):
    if len(s) == 0:
        print('YES')
        break
    if s.endswith('dreamer') :
        s = s[:-7]
    elif s.endswith('eraser'):
        s = s[:-6]
    elif s.endswith('dream') or s.endswith('erase'):
        s = s[:-5]
    else:
        print('NO')
        break

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

void main_()
{
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;

    vector<ll> hand2score = { P, R, S };

    vector<vector<int>> Tss(K);
    {
        // 入力TをK個のサブ問題に分割
        string T;
        cin >> T;

        array<char, 256> c2i;
        c2i['r'] = 0;
        c2i['s'] = 1;
        c2i['p'] = 2;

        int i = 0;
        for (auto ch : T) {
            Tss[i++].push_back(c2i[ch]);
            i %= K;
        }
    }

    ll ans = 0;
    for (auto&& Ts : Tss) {
        vector<ll> dp(3);
        for (size_t i = 0; i < Ts.size(); ++i) {
            vector<ll> dp_n(3);
            for (int j = 0; j < 3; ++j) { // 今回出す手
                // 前回のgcpそれぞれの手を出した中で最大スコアを得る
                for (int k = 0; k < 3; ++k) {
                    if (j != k) {
                        // K回前と違う手しか出せない
                        dp_n[j] = max(dp_n[j], dp[k]);
                    }
                }

                if (j == Ts[i]) {
                    // 勝てる手を出す場合、スコアを獲得
                    dp_n[j] += hand2score[j];
                }
            }
            dp = move(dp_n);
        }
        ans += max({ dp[0], dp[1], dp[2] });
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	if (s == "RRR")
		cout << 3 << endl;
	else if (s == "RRS" || s == "SRR")
		cout << 2 << endl;
	else if (s == "SSS")
		cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

signed main(){
	string s, t; cin >> s >> t;
	vector<vector<lint> > data(26);
	vector<lint> cs(26, 0), ct(26, 0);
	lint N = s.size(), M = t.size();
	for(lint i = 0; i < N; i++) data[s[i] - 'a'].push_back(i + 1), cs[s[i] - 'a']++;
	for(lint i = 0; i < M; i++) ct[t[i] - 'a']++;
	for(lint i = 0; i < 26; i++){
		if(cs[i] == 0 && ct[i] != 0){
			cout << -1 << endl;
			return 0;
		}
	}
	lint ans = 0, index = 0;
	for(lint i = 0; i < M; i++){
		lint x = t[i] - 'a';
		lint next = upper_bound(data[x].begin(), data[x].end(), index) - data[x].begin();
		if(next == data[x].size()) ans += (N - index + data[x][0]), index = data[x][0];
		else ans += data[x][next] - index, index = data[x][next];
	}
  cout << ans << endl;
}

Measured memory_bytes: 1724
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define two(i) (1<<(i-1))
using namespace std;
const int maxn=15+10,inf=1000000000;
int f[(1<<16)+10][maxn],p[(1<<16)+10],id[(1<<16)+10];
int dis[maxn][maxn];
int i,j,k,l,r,s,t,n,m,now,all,ans,sum;
int lowbit(int x){
	return x&-x;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n) id[two(i)]=i;
	all=(1<<n)-1;
	fo(i,1,m){
		scanf("%d%d%d",&j,&k,&t);
		sum+=t;
		dis[j][k]=dis[k][j]=t;
	}
	fo(i,1,all){
		now=id[lowbit(i)];
		p[i]=p[i-two(now)];
		fo(j,now+1,n)
			if ((i&two(j))) p[i]+=dis[now][j];
	}
	fo(i,0,n)
		fo(j,0,all)
			f[j][i]=-inf;
	f[two(1)][1]=0;
	ans=-inf;
	fo(s,1,all){
		fo(i,1,n){
			r=s;
			while (r){
				if ((r&two(i))) f[s][i]=max(f[s][i],f[(s-r)|two(i)][i]+p[r]);
				r=(r-1)&s;
			}
			fo(j,1,n)
				if (!(s&two(j))&&dis[i][j]) f[s|two(j)][j]=max(f[s|two(j)][j],f[s][i]+dis[i][j]);
		}
		if ((s&two(n))) ans=max(ans,f[s][n]);
	}
	printf("%d\n",sum-ans);
}

Measured memory_bytes: 3840
#include<stdio.h>
int main(void){
  int n;
  int p[50];
  scanf("%d",&n);
  int i;
  int w=0;
  for(i=1;i<=n;++i){
    scanf("%d",&p[i]);
  }
  for(i=1;i<=n;++i){
    if(p[i]!=i){
      ++w;
    }
  }
  if(w<3){
    puts("YES");
  }
  else{
    puts("NO");
  }
  return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	string s;
	cin >> s;
	int n = s.length();

	for (int i = n-2; i > 0; i-=2)
	{
		
		if (s.substr(0, i / 2 )== s.substr(i / 2,i/2)) {
			cout << i << endl;
			return 0;
		}
	}


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int n,k,x,y; cin >> n >> k >> x >> y;
	if (n >= k)
		cout << k*x + ((n-k)*y) << endl;
	else 
		cout << n*x << endl;
	return (0);
}


Measured memory_bytes: 256
#include <stdio.h>

int     main(void)
{
    int a;
    int b;
    int c;
    
    scanf("%d %d %d", &a, &b, &c);
    if (a < b && b < c)
        printf ("Yes\n");
    else
        printf("No\n");
    return (0);
}


Measured memory_bytes: 2004
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin>>n;

    vector<int> h(n+1);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }

    vector<int> c(n+1);
    c[1]=0;
    c[2]=abs(h[1]-h[2]);

    for(int i=3;i<=n;i++){
        c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]));
    }

    cout<<c[n]<<"\n";
    return 0;
}

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

long double expect(long double a) {
  return (a+1) * 0.5;
}
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int n,k;
  cin >> n >> k;
  vector<long double> p(n);
  rep(i, n) {
    long double tmp;
    cin >> tmp;
    p[i] = expect(tmp);
  }

  long double ans = 0;
  long double total = 0;
  rep(i, k-1) {
    total += p[i];
  }

  for(int i = k-1; i < n; i++) {
    total += p[i];
    ans = max(ans, total);
    total -= p[i-k+1];
  }

  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}
#line 2 "main.cpp"
int main(){
	lint a,b,c,d;
	std::cin>>a>>b>>c>>d;
	std::cout<<std::max({a*c,a*d,b*c,b*d})<<std::endl;
	return 0;
}

Measured memory_bytes: 3632
using System;

class B {
    public static void Main() {
        var line = Console.ReadLine().Split();
        var a = long.Parse(line[0]);
        var b = long.Parse(line[1]);
        var x = long.Parse(line[2]);
        Func<long, long> f = c => c < 0 ? 0 : c / x + 1;
        Console.WriteLine(f(b) - f(a - 1));
    }
}


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

const int M = 1e5 + 10;

struct P
{
    int b;
	ll c;
    bool operator < ( const P & rhs ) const
	{
        return c > rhs.c;      
    }
} p[M];

int n,m,i,x,b;

int main ()
{
	cin >> n >> m;
    priority_queue < ll , vector < ll > , greater < ll > > que;
    for ( i = 0 ; i < n ; ++ i )
	{
		cin >> x;
        que.push ( ( ll ) x );
    }    
    for ( i = 0 ; i < m ; ++ i )
	    cin >> p[i].b >> p[i].c;
    sort ( p , p + m );
    for ( i = 0 ; i < m ; ++ i )
	{
        b = p[i].b;
        if ( p[i].c <= que.top () )
		   break;
        while ( b -- )
		{
            if ( que.top () < p[i].c )
			{
                que.pop ();
                que.push ( p[i].c );
            }
			else
			{
                break;
            }
        }
    }
    
    ll sum = 0;
    
    while ( ! que.empty () )
	{
        x = que.top ();
		que.pop ();
        sum += x;
    }
    
    cout << sum << endl;
    
    return 0;
    
}

Measured memory_bytes: 2676
using System;
using System.Collections.Generic;
using System.Linq;

class Solver
{
    void Solve()
    {
        while (true)
        {
            var str = Console.ReadLine();
            if (string.IsNullOrEmpty(str))
                return;
            var input = str.Split(' ');
            var len = int.Parse(input[0]);
            var rArray = new int[input.Length - 1];
            var n = rArray.Length;
            for (int i = 1; i < input.Length; i++)
                rArray[i - 1] = int.Parse(input[i]);
            var dp = new double[12, 1 << n];
            for (int i = 0; i < 12; i++)
                for (int j = 0; j < 1 << n; j++)
                    dp[i, j] = len + 100;
            for (int i = 0; i < n; i++)
                dp[rArray[i], 1 << i] = rArray[i];

            for (int p = 0; p <= 10; p++)
            {
                for (int i = 1; i <= 10; i++)
                    for (int j = 0; j < 1 << n; j++)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            var r = rArray[k];
                            if (dp[i, j] > len)
                                continue;
                            if (((j >> k) & 1) == 1)
                                continue;
                            var dy = (i - r) * (i - r);
                            var d = (i + r) * (i + r);
                            var dx = Math.Sqrt(d - dy);
                            dp[r, j | 1 << k] = Math.Min(dp[r, j | 1 << k], dp[i, j] + dx);
                        }
                    }
            }
            var f = false;
            for (int i = 1; i <= 10; i++)
                if (dp[i, (1 << n) - 1] + i <= len)
                {
                    f = true;
                    break;
                }
            if (f) Console.WriteLine("OK");
            else Console.WriteLine("NA");

        }
    }
    static void Main()
    {
#if DEBUG
        var oStream = new System.IO.FileStream("debug.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);
        var iStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(oStream, System.Text.Encoding.UTF8)));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
        Console.ReadKey(true);
#endif
    }

}

//*/


Measured memory_bytes: 6172
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;

bool is_Prime(int n) {
    //素数判定
    for (int i = 2; i * i < n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return n != 1;
}

vector<int> divisor(int n) {
    //約数の列挙
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (n / i != i)
                res.push_back(n / i);
        }
    }
    return res;
}

map<int, int> prime_factor(int n) {
    //素因数分解
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}


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

    int n;
    cin >> n;
    if (n == 1) {
        cout << 1 << ':' << ' ' << 1 << endl;
        return 0;
    }

    int ans = n;
    cout << n << ':';
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0) {
                n /= i;
                cout << ' ' << i;
            }
        }
    }

    if (n == 1) {
        cout << endl;
    } else {
        cout << ' ' << n << endl;
    }

    return 0;
}


Measured memory_bytes: 3208