akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> a(n+1), b(n+1), c(n);
    rep(i, n) cin >> a[i+1];
    rep(i, n) cin >> b[i+1];
    rep(i, n - 1) cin >> c[i+1];

    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += b[a[i]];
        if(i < n){
            if(a[i] + 1 == a[i+1]){
                ans += c[a[i]];
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static long gcd(long a, long b) {
        if (a > b) return gcd(b, a);
        if (a == 0) return b;
        return gcd(b % a, a);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long A = sc.nextLong();
        long B = sc.nextLong();
        long d = gcd(A, B);

        int sol = 1;
        for (long i = 2; i * i <= d; i++) {
            if (d % i == 0) sol++;
            while (d % i == 0) d /= i;
        }

        if (d != 1) sol++;
        System.out.println(sol);
    }
}


Measured memory_bytes: 25172
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using namespace std;
 
int main(int argc, char const* argv[])
{
    int n, m, c, count = 0;
    cin >> n >> m >> c;
    vector<int> b;
    for (int j = 0; j < m; j++) {
        int x;
        cin >> x;
        b.push_back(x);
    }
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            int a;
            cin >> a;
            sum += a * b[j];
        }
        if (sum + c > 0) {
            count++;
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int main()
{
  double l;
  cin >> l;

  cout << pow(l/3,3) << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTakahashisInformation solver = new CTakahashisInformation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTakahashisInformation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = 3;
            int[][] c = new int[n][n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    c[i][j] = in.nextInt();
                }
            }

            int[] a = {c[0][0],
                       c[1][0],
                       c[2][0]};
            int[] b = {0,
                       c[0][1] - c[0][0],
                       c[0][2] - c[0][0]};

            boolean answer = true;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    answer &= c[i][j] == a[i] + b[j];
                }
            }

            out.println(answer ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22356
#include <stdio.h>

int main(void){
  char C[2][3];

  scanf("%s%s",C[0],C[1]);

  if(C[0][0] == C[1][2] && C[0][2] == C[1][0] && C[0][1] == C[1][1]){
    printf("YES\n");
  }else{
    printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 128
N = gets.to_i
V = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0
1.upto(N) do |n|
  (0..N-1).to_a.combination(n) do |c|
    x = 0
    y = 0
    c.each do |i|
      x += V[i]
      y += C[i]
    end

    ans = x - y if x - y > ans
  end
end

puts ans


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int x;
  cin >> x;
  int ans = x / 500 * 1000;
  ans += (x % 500) / 5 * 5;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  int a,b;
  cin >> a >> b;
  cout << max(0,a-2*b) << endl;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int64 sqr(int64 x) {
  return x * x;
}

int main() {
  int64 a, b, c;
  cin >> a >> b >> c;
  if (c > a + b && sqr(c - a - b) > 4 * a * b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
bool isred[100001]={false};
int box[100001];
int main(){
    int n,m;
    //int x,y;
    int old = 1;
    scanf("%d%d",&n,&m);
    isred[1]=true;
    for(int i=1;i<=n;i++){
        box[i]=1;
    }
    for(int i=0;i<m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        if(box[x]>1&&isred[x]){
            isred[y] = true;
        }else if(box[x]==1&&isred[x]){
            isred[x] = false;
            isred[y] = true;
        }
        box[y]+=1;
        box[x]-=1;
    }
    int ans =0;
    for(int i=1;i<=n;i++){
        if(isred[i])
            ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 640
n = int(input())
p = list(map(int, input().split()))
a = 0
for i in range(len(p) - 2):
    if p[i] < p[i + 1] < p[i + 2] or p[i + 2] < p[i + 1] < p[i]:
        a += 1
print(a)

Measured memory_bytes: 9032
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;
long long int num[500001];


int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W;
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> num[i];
	int ret[10000] = {};
	for (int i = 1; i <= N; i++) {
		for (int j = ans; j < ans + num[i]; j++) {
			ret[j] = i;
		}
		ans += num[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j)cout << " ";
			if (i % 2 == 0)cout << ret[i*W + j];
			else cout << ret[i*W + W - 1 - j];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 384
N = input()

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

sum = 0
befcuis = 0
cuis = 0

for x in A:
    sum += B[x-1]
    cuis=x
    if  befcuis == cuis- 1:
        if befcuis -1 >=0:
            sum+=C[befcuis-1]
    
    befcuis = cuis
    
print(sum)

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

int main() {
  vector<vector<int>> c(3, vector<int>(3, 0));
  for (int i=0; i<9; i++) cin >> c.at(i/3).at(i%3);
  if ((c.at(0).at(0)-c.at(1).at(0)==c.at(0).at(1)-c.at(1).at(1) &&
       c.at(0).at(1)-c.at(1).at(1)==c.at(0).at(2)-c.at(1).at(2) &&
       c.at(0).at(2)-c.at(1).at(2)==c.at(0).at(0)-c.at(1).at(0)) &&
      (c.at(1).at(0)-c.at(2).at(0)==c.at(1).at(1)-c.at(2).at(1) &&
       c.at(1).at(1)-c.at(2).at(1)==c.at(1).at(2)-c.at(2).at(2) &&
       c.at(1).at(2)-c.at(2).at(2)==c.at(1).at(0)-c.at(2).at(0)) &&
      (c.at(0).at(0)-c.at(2).at(0)==c.at(0).at(1)-c.at(2).at(1) &&
       c.at(0).at(1)-c.at(2).at(1)==c.at(0).at(2)-c.at(2).at(2) &&
       c.at(0).at(2)-c.at(2).at(2)==c.at(0).at(0)-c.at(2).at(0)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail)
{
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}

int main()
{
  int n;
  cin >> n;
  VEC<int> a(n, 0);
  map<int, int> m;
  REP(i, 0, n)
  {
    cin >> a[i];
    ++m[a[i]];
  }
  sort(ALL(a));
  DUMP(a);
  LL del = 0;
  for (auto p : m)
  {

    if (p.second == 1)
      p.second = 0;
    else if (p.second > 1)
    {
      del += p.second - 1;
    }
  }
  int deleted = ((del + 1) / 2) * 2;
  DUMP(del, deleted);
  cout << n - deleted << endl;

  return 0;
}


Measured memory_bytes: 5376
from collections import defaultdict
from sys import stdin
N = int(stdin.readline().rstrip())
S = (stdin.readline().rstrip())
d = defaultdict(list)
for ind, i in enumerate(S):
    d[i].append(ind+1)
ans = 0

for a in range(10):
    for b in range(10):
        for c in range(10):
            if (a == b == c) and (len(d[str(a)]) < 3):
                continue
            if d[str(a)] and d[str(b)] and d[str(c)]:
                i_a = d[str(a)][0]
                i_b = -1
                i_c = -1
                for j in d[str(b)]:
                    if i_a < j:
                        i_b = j
                        break
                for k in d[str(c)]:
                    if i_b < k:
                        i_c = k
                        break
                if i_a < i_b < i_c:
                    ans += 1
            else:
                continue
print(ans)

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



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

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	int a, b;
	cin >> a >> b;

	if (a == b) {
		cout << "Draw" << endl;

	}
	else if (a == 1)
	{
		cout << "Alice" << endl;
	}
	else if (b == 1)
	{
		cout << "Bob" << endl;
	}
	else {
		if (a > b) {
			cout << "Alice" << endl;

		}
		else {
			cout << "Bob" << endl;

		}
	}




	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,b[105],ans,a[105];
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	b[1]=a[1];
//	cout<<b[1]<<" ";
	ans+=b[1];
	for(int i=2;i<n;i++){
		b[i]=min(a[i],a[i-1]);
		ans+=b[i];
	}
	ans+=a[n-1];
	cout<<ans;
}

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

#define INF 999999

int n;
int d[10][10];
int a, b, c;

signed main()
{
	while (true)
	{
		cin >> n;
		if (n == 0) break;

		rep(i,10) rep(j,10) d[i][j] = INF;

		int machi_kazu = 0;
		rep(i,n)
		{
			cin >> a >> b >> c;
			if (machi_kazu < a) machi_kazu = a;
			if (machi_kazu < b) machi_kazu = b;
			d[a][b] = c;
			d[b][a] = c;
		}

		rep(i,10) d[i][i] = 0;

		rep(k,10) rep(i,10) rep(j,10) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

		/*
		rep(i,10)
		{
			rep(j,10)
			{
				printf("% 3d ", d[i][j]);
			}
			printf("\n");
		}
		*/

		int machi_ans = 0;
		int ans_min_souwa = INF;
		for (int i=0; i<=machi_kazu; i++)
		{
			int souwa = 0;
			for (int j=0; j<=machi_kazu; j++)
			{
				souwa += d[i][j];
			}

			if (souwa < ans_min_souwa)
			{
				machi_ans = i;
				ans_min_souwa = souwa;
			}
		}

		printf("%d %d\n", machi_ans, ans_min_souwa);
	}
}

Measured memory_bytes: 1144
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner input = new Scanner(System.in);
    String s = input.next();
    
    int i=0,j=s.length()-1;
    int g = 0;
    while(i<j)
    {
      if(s.charAt(i)!=s.charAt(j))
        	g++;
      i++;
      j--;
    }
    
    System.out.println(g);
   }
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    string s;
    cin, s;
    reverse(s.begin(), s.end());

    int mod1 = 0;
    REP(i, 0, n) {
        mod1 += (s[i] == '1');
    }

    int mod2 = -1, mod3 = -1;
    if (mod1 > 0) {
        mod2 = mod1 - 1;
    }
    mod3 = mod1 + 1;

    vector<ll> p2(n + 1, 1), p3(n + 1, 1);
    REP(i, 1, n + 1) {
        if (mod2 > 0) {
            p2[i] = (p2[i - 1] * 2) % mod2;
        }
        p3[i] = (p3[i - 1] * 2) % mod3;
    }

    ll a2 = 0, a3 = 0;
    REP(i, 0, n) {
        if (s[i] == '1') {
            if (mod2 > 0) {
                a2 = (a2 + p2[i]) % mod2;
            }
            a3 = (a3 + p3[i]) % mod3;
        }
    }

    auto solve = [](int t) {
        int ans = 1;
        while (t) {
            int bits = 0;
            int tt = t;
            while (tt) {
                bits += (tt % 2);
                tt >>= 1;
            }
            t %= bits;
            ans++;
        }
        return ans;
    };

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '1') {
            if (mod2 == 0) {
                print(0);
            } else {
                ll tmp = (a2 - p2[i] + mod2) % mod2;
                print(solve(tmp));
            }
        } else {
            ll tmp = (a3 + p3[i] + mod3) % mod3;
            print(solve(tmp));
        }
    }

    return 0;
}


Measured memory_bytes: 6728
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created by Arifur on 9/8/2015.
 */
public class Main {
    public static void main(String[] arg) {
        Scanner scanner=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x=scanner.nextInt();
        ArrayList<Integer> list=new ArrayList<Integer>();
        for (int i = 0; i < x; i++) {
            list.add(scanner.nextInt());
        }
        Collections.reverse(list);
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i));
            if(i<x-1){
                System.out.print(" ");
            }
        }
        System.out.println();

    }
}

Measured memory_bytes: 19752
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class Monoid>
struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int size;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid &unity)
      : F(f), UNITY(unity), size(n), dat(2 * n, unity) {}

  // Sets i-th value (0-indexed) to x for initial setup.
  // build() must be called after set() calls.
  void set(int i, const Monoid &x) { dat[size + i] = x; }
  void build() {
    for (int k = size - 1; k > 0; --k) {
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Sets i-th value (0-indexed) to x.
  void update(int i, const Monoid &x) {
    int k = size + i;
    dat[k] = x;
    while (k > 1) {
      k >>= 1;
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Queries by [l,r) range (0-indexed, open interval).
  Monoid fold(int l, int r) {
    l += size;
    r += size;
    Monoid vleft = UNITY, vright = UNITY;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vleft = F(vleft, dat[l++]);
      if (r & 1) vright = F(dat[--r], vright);
    }
    return F(vleft, vright);
  }

  // Queries by a single index (0-indexed).
  Monoid operator[](int i) { return dat[size + i]; }

  /* debug */
  void print() {
    for (int i = 0; i < size; ++i) {
      cout << (*this)[i];
      if (i != size - 1) cout << ",";
    }
    cout << endl;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, i64>> inputs(M);
  REP(i, M) {
    int l, r;
    i64 c;
    cin >> l >> r >> c;
    inputs[i] = {r, l, c};
  }
  sort(inputs.begin(), inputs.end());

  const i64 INF = 1e18;
  SegTree<i64> st(
      N + 10, [](i64 x, i64 y) { return min(x, y); }, INF);
  st.update(1, 0LL);

  for (auto [r, l, c] : inputs) {
    i64 val = st.fold(l, r + 1);
    if (val < INF) {
      i64 y = st[r];
      if (y > val + c) {
        st.update(r, val + c);
      }

      //   REP(x, N + 1) {
      //     i64 y = st[x];
      //     if (y == INF)
      //       cerr << "_ ";
      //     else
      //       cerr << st[x] << ' ';
      //   }
      //   cerr << endl;
    }
  }

  i64 ans = st[N];
  cout << (ans < INF ? ans : -1LL) << endl;
}


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

int main (){
    int N;
    cin>>N;
    vector<int> H(N);
    int Max=0;
    int Walk=0;
    cin>>H.at(0);
    for(int i=1; i<N; i++){
        cin>>H.at(i);
        if(H.at(i-1)>H.at(i)-1){
            Walk ++;
        }
        else{
            Max=max(Max, Walk);
            Walk=0;
        }

    }
    Max=max(Max, Walk);
    cout<<Max<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007

int main(){
  ll q,h,s,d,n;
  cin >> q >>h >> s >>d;
  cin >> n;

  ll res_qh=min(2*q,h);
  ll res=min(2*res_qh,s);
    ll ans=0;
  if(2*res>d){
    ll tmp=n/2;
    ans=d*tmp+res*(n-tmp*2);
  }else{
    ans=res*n;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    char[] kurai = N.toCharArray();
    
    int sum = 0;
    for(int i = 0; i < kurai.length; i++){
      int k = Character.getNumericValue(kurai[i]);
      sum += k;
    }
    
    
    
    if(sum%9 == 0){
      System.out.println("Yes");
      return;
    }else{
      System.out.println("No");
      return;
    }
    
  }
}

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

using namespace std;

int main()
{
    double a, b, ans = 0.0;
    cin >> a;

    while(a--)
    {
        cin >> b;
        ans = ans + (1.0/b);
    }

    ans = 1.0/ans;

    printf("%.13lf\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
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;
  string t;
  cin >> t;

  vector<vector<ll>> s_char_loc(26);
  rep(i, s.size()) {
    char ch = s[i];
    s_char_loc[ch - 'a'].pb(i);
  }


  ll round = 0;
  ll now_ind = -1;
  rep(i, t.size()) {
    char next = t[i];
    vector<ll>& nvec = s_char_loc[next - 'a'];

    if (nvec.size() == 0) {
      cout << -1 << endl;
      return 0;
    }

    auto itr = upper_bound(all(nvec), now_ind);
    if (itr != nvec.end()) {
      now_ind = *itr;
    } else {
      round++;
      now_ind = nvec[0];
    }
  }

  ll ans = round * s.size() + now_ind + 1;
  cout << ans << endl;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<vector<int>> in(N, vector<int>(3, 0));
    for (int i = 0; i < N; ++i) cin >> in[i][0];
    for (int i = 0; i < N; ++i) {
        int input; cin >> input;
        for (int j = 0; j < N; ++j) {
            if (in[j][0] - 1 == i) in[j][1] = input;
        }
    }
    for (int i = 0; i < N - 1; ++i) {
        int input; cin >> input;
        for (int j = 0; j < N; ++j) {
            if (in[j][0] - 1 == i) {
                in[j][2] = input;
                break;
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int now = in[i][0];
        sum += in[i][1];
        if (in[i][2] != 0 && i != N - 1) {
            if (now + 1 == in[i + 1][0]) {
                sum += in[i][2];
            }
        }
    }
    printf("%d\n", sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    int V, E; cin >> V >> E;
    vector<vector<int>> to(V);
    vector<int> Nyuji(V);
    for(int i=0; i<E; i++){
        int s, t; cin >> s >> t;
        to[s].push_back(t);
        Nyuji[t]++;
    }
    
    vector<PII> S;
    for(int i=0; i<V; i++){
        if(Nyuji[i]==0) S.push_back({i, 1});
    }
    
    vector<int> ans;
    int done = 0;
    while(S.size()){
        PII p = S.back();
        done++;
        ans.push_back(p.fs);
        S.pop_back();
        for(int t:to[p.fs]){
            Nyuji[t]--;
            if(Nyuji[t]==0){
                S.push_back({t, p.sc+1});
            }
        }
    }
    
    if(done!=V){
        cout << 1 << endl;
        return 0;
    }
    
//    for(int a:ans) cout <<  << endl;
    cout << 0 << endl;
    
    return 0;
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int x1,y1,x2,y2;
    cin >>x1>>y1>>x2>>y2;
    cout << x2 - (y2-y1) << ' ' << y2 + (x2-x1) << ' ' << x1 - (y2 - y1) << ' ' << y2 + (x2-x1) - (y2 - y1) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ull unsigned long long
using namespace std;

int main() {
  string s;
  cin>>s;
  int ans=0;
  int e=s.size()-1;
  for(int i=0;i<e;i++) {
    if(s.at(i)!=s.at(i+1)) {
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int n;
  cin >> n;
  int dp[n+1];
  dp[0] = dp[1] = 1;
  for(int i = 2;i <= n; i++) {
    dp[i] = dp[i-1] + dp[i-2];
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 3116
using System;

class Program
{
    static void Main()
    {
        while(true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int H = int.Parse(s[0]);
            int W = int.Parse(s[1]);
            if (H == 0 && W == 0)
                break;
            for(int i =0;i<H;i++)
            {
                for(int j =0;j<W;j++)
                {
                        if (j==0||j==W-1)
                            Console.Write("#");
                        else
                        {
                            if(i==0||i==H-1)
                                Console.Write("#");
                            else
                                Console.Write(".");
                        }
                }
                Console.WriteLine("");
            }
            Console.WriteLine("");

        }
    }
}

Measured memory_bytes: 8868
package main

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

func calc(x int) []int {
	for a := -118; a <= 119; a++ {
		for b := -119; b <= 118; b++ {
			if a*a*a*a*a-b*b*b*b*b == x {
				return []int{a, b}
			}
		}
	}
	return []int{}
}

func main() {
	x := readInt()
	ans := calc(x)
	fmt.Printf("%d %d\n", ans[0], ans[1])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

int main() {
  string input;
  cin >> input;
  string target;
  cin >> target;
  input	+= input;
  if (input.find(target) == -1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c[3];
  rep(i,3)cin>>c[i];
  if(c[0]==c[1]&&c[0]==c[2])cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int hi=scan.nextInt();
int wo=scan.nextInt();
int na=scan.nextInt();
  
int nb=na/Math.max(hi, wo);
if(na%Math.max(hi, wo)==0){
    System.out.println(nb);
}else{
    System.out.println(nb+1);
}
  
}
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(){
    unsigned long long int n,k,s=0;
    scanf("%llu",&n);
    k=n;
    while(n!=0){
        s=s+n%10;
        n=n/10;
    }
    if(k%s==0){printf("Yes");}
    else printf("No");
}

Measured memory_bytes: 1696
def longest_common(x, y):
  cost = [0]
  for c in y:
    for i in range(len(cost)-1, -1, -1):
      index = x.find(c, cost[i]) + 1
      if index:
        if i + 1 < len(cost):
          cost[i + 1] = min(cost[i+1], index)
        else:
          cost.append(index)
  return len(cost) -1

n = int(input())
for _ in range(n):
  x = input()
  y = input()
  print(longest_common(x, y))



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

int main(void) {
	int n, d;
	int cnt = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		double dist = 0;
		double x, y;
		cin >> x >> y;
		dist = sqrt(x * x + y * y);
		if (dist <= d)cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner scanner = new Scanner(System.in)) {
      final int start = scanner.nextInt();
      final int end   = scanner.nextInt();
      final int c     = scanner.nextInt();
      int counter = 0;
      for (int i = start; i <= end; i++) {
        if (c % i == 0) {
          counter++;
        }
      }
      System.out.println(counter);
    }
  }
}

Measured memory_bytes: 26212
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int inv[2005],cnt[2005];
int a[2005];
void solve(){  
    int n,k;
    cin>>n>>k;
    rep(i,0,n) cin>>a[i];  
    rep(i,0,n){
        rep(j,0,n){
            if(a[j]<a[i]){
                cnt[i]++;
                if(j>i) inv[i]++;
            }
        }
    }
    int ans=0;
    rep(i,0,n){
        ans+=inv[i]*k;
        ans%=hell;
        ans+=(k*(k-1)/2)%hell*cnt[i]%hell;
        ans%=hell;
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 256
H,W,K = map(int, input().split())
cnt = 0
ans = []
z = 1
for i in range(H):
    f = list(input())
    if f.count("#") == 0: 
        z += 1
    elif f.count("#") == 1:
        cnt += 1
        row = [cnt] * W
        for i in range(z):
            ans.append(row)
        z = 1
    else:
        _c = 0
        cnt += 1
        row = []
        for j,s in enumerate(f):
            if s == "#":
                if _c == 0:
                    _c += 1
                else:
                    _c += 1
                    cnt += 1
            row.append(cnt)
        for i in range(z):
            ans.append(row)
        z = 1

if z > 1:
    for z in range(z-1):
        ans.append(row)
for i in range(H):
    print(*ans[i])

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

using namespace std;

int n;
vector<int> edg[100024];
queue<int> que;
vector<int> bfs(int x){
	que.push(x);
	vector<int> d(n+1,-1);
	d[x]=0;
	while(!que.empty()){
		int y=que.front();
		que.pop();
		for(int i=0;i<edg[y].size();i++){
			int z=edg[y][i];
			if(d[z]==-1){
				d[z]=d[y]+1;
				que.push(z);
			}
		}
	}
	return d;
}
int main()
{
	int u,v;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		scanf("%d%d",&u,&v);
		edg[u].push_back(v);
		edg[v].push_back(u);
	}
	vector<int> a1=bfs(1);
	vector<int> a2=bfs(n);
	int l=0,r=0;
	for(int i=1;i<=n;i++){
		if(a1[i]<=a2[i]){
			l++;
		}else
		r++;
	}
	if(l>r) printf("Fennec\n");
	else printf("Snuke\n");
	return 0;
}

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

using namespace std;

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

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

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

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

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

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

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

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

///////////////////////////////////////////////////////////////////////////


ll vs(ll r,ll b){
    if(r == b)ret r;
    if(r < b)ret b-r;
    ret r-b;
}

ll a[100000005] = {};

int main(){
    ll n;
    cin >> n;
    n = modpow(2,n);

    rep(i,0,n)cin >> a[i];
	ll l = 0;
	
	while(n-l > 1){
        ll r = a[l],b = a[l+1];
        l+=2;
        a[n++] = vs(r,b);
	}
	P(a[n-1]);
	return  0;
}

Measured memory_bytes: 6400
#include <iostream>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, X;
  cin >> K;
  cin >> X;
  
  for(int i = K-1; i > -K; i--){
   	cout << X-i << " ";
  }
  cout << endl;
}

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

const int N = 205;

int n, a[N];

vector<int> ans;

void op (int X) {
	ans.push_back(X);
	for(int i=X;i<n;i++) {
		swap(a[i], a[i-X]);
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++) {
		while(a[n-1] != i) {
			op(1);
		}
		while(i && a[n-2] != i-1) {
			op(n-1);
			op(1);
		}
	}
	printf("%d\n",(int)ans.size());
	for(auto &T : ans) {
		printf("%d\n",T);
	}
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

const int N = 1010;
int dp[N][N] = {0};
string s[N];
const int mod = 1e9 + 7;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        s[i] = " " + s[i];
    }
    dp[1][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if(s[i][j] == '#') continue;
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= mod;
        }
    }
    cout << dp[n][m] << "\n";
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    string sh[n];
    map <string, int> mp;
    int cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> sh[i];
        mp[sh[i]]++;
        if (mp[sh[i]] == 1)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 25480
#include<cstdio>
using namespace std;
bool rev[1010];
int main(){
	int n,m,c,d,ans;
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%d",&c,&d);
		for(int i=c;i<d;i++) rev[i]=true;
	}
	ans=n+1;
	for(int i=1;i<n;i++) if(rev[i]) ans+=2;
	printf("%d\n",ans);
	return 0;
}

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

#define lli long long int
#define pb push_back

lli dp[100001];

main()
{
    lli n,i,a,b;

    cin>>n;
    lli arr[n];

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

    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);

    for(i=2;i<n;i++)
    {
        dp[i] = min(dp[i-2]+abs(arr[i]-arr[i-2]), dp[i-1] + abs(arr[i]-arr[i-1]));
    }

    cout<<dp[n-1];

}


Measured memory_bytes: 1792
N = int(input())
A = []
A.append([int(n) for n in input().split(sep=' ')])
A.append([int(n) for n in input().split(sep=' ')])

Q = [(0, 0, A[0][0])]

anss = []
while len(Q) != 0:
    s = 0
    p = Q.pop()
    if p[0] == 1 and p[1] == N - 1:
        anss.append(p[2])
    if p[0] < 1:
        Q.append((p[0] + 1, p[1], p[2] + A[p[0] + 1][p[1]]))
    if p[1] < N - 1:
        Q.append((p[0], p[1] + 1, p[2] + A[p[0]][p[1] + 1]))

print(max(anss))

Measured memory_bytes: 3064
k = int(input())
ls = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ls[k-1])

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

using namespace std;

int main() {
	long long x;
	cin >> x;

	auto f = [&] (long long a) {
		return a * a * a * a * a;
	};
	
	map<long long, int> mp;

	for(long long i = -1000; i <= 1000; ++i) {
		mp[f(i)] = i;
	}

	for(long long i = 0; i <= 1000; ++i) {
		if(mp.count(f(i) - x)) {
			cout << i << ' ' << mp[f(i) - x] << '\n';
			exit(0);
		}
	}

	return 0;
}

Measured memory_bytes: 3752
def main():
  li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  n = int(input())
  print(li[n-1])

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")
#define int long long
#define y1 hoainambimaysolokill
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,pair<int,int> >
#define PII3 pair<pair<int,int>,int >
const long long inf=1e18+3;
void solve()
{
   string s,t;
   cin>>s>>t;
   cout<<(s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]);
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen("BOXES.inp", "r", stdin);
    //freopen("BOXES.out", "w", stdout);

    //int t;cin>>t;while(t--)

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define ull unsigned long long

using namespace std;

static const ull MOD = 1000000007LL;
// char s[100005];

ll dp[100005][13];

void print_table(int len) {
  for (int i = 0; i <= len; i++) {
    for (int j = 0; j < 13; j++) {
      char s[100];
      sprintf(s, "%03d", dp[i][j]);
      cout << s << " ";
    }
    cout << endl;
  }
  cout << "=======================================" << endl;
}

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

  // string s = "??2??5";
  int n = s.size();

  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int c;
    if (s[i] == '?') {
      c = -1;
    } else {
      c = s[i] - '0';
    }
    for (int j = 0; j < 10; j++) {
      if (c != -1 && c != j) {
        continue;
      }
      for (int ki = 0; ki < 13; ki++) {
        int source_i = i;
        int source_j = ki;
        int target_i = i + 1;
        int target_j = (ki * 10 + j) % 13;
        ll plus = dp[source_i][source_j];
        dp[target_i][target_j] += plus;
      }
    }
    for (int j = 0; j < 13; j++) {
      dp[i + 1][j] %= MOD;
    }

    // print_table(n);
  }

  cout << dp[n][5] << endl;
  return 0;
}


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

const int MAX=100,INF=100000000;
int N;
int S[MAX][MAX],T[MAX][MAX],D[MAX][MAX];

void ford(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            if(S[i][k]==INF) continue;
            for(int j=0;j<N;j++){
                if(S[k][j]==INF) continue;
                S[i][j]=min(S[i][j],S[i][k]+S[k][j]);
            }
        }
    }
    return;
}

void check(){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if(S[i][j]==T[i][k]+S[k][j]){
                    if(k!=i) D[i][k]=1;
                }
                if(S[i][j]==S[i][k]+T[k][j]){
                    if(k!=j) D[k][j]=1;
                }
            }
        }
    }
}


int main(){
    
    int M;cin>>N>>M;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            S[i][j]=INF;
            T[i][j]=INF;
            D[i][j]=0;
        }
    }
    for(int i=0;i<N;i++){
        S[i][i]=0;
        T[i][i]=0;
    }
    for(int i=0;i<M;i++){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        S[a][b]=c;
        S[b][a]=c;
        T[a][b]=c;
        T[b][a]=c;
    }
    ford();
    check();
    int cnt=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(D[i][j]==1) cnt++;
        }
    }
    cout<<M-cnt/2<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

lint search(lint x, vector<vector<lint>>& edge, vector<lint>& res) {
  if(res[x] != -1) return res[x];

  lint tmp = 0;

  REP(y, edge[x].size()) {
    tmp = max(search(edge[x][y], edge, res) + 1, tmp);
  }

  res[x] = tmp;
  return res[x];
}

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

    lint N; cin >> N; lint M; cin >> M;

    vector<vector<lint>> edge(N, vector<lint>());
    vector<lint> res(N, -1);

    REP(_, M) {
      lint x,y; cin >> x; cin >> y;
      edge[x-1].push_back(y-1);
    }

    REP(i, N) {
      search(i, edge, res);
    }

    lint res2 = 0;

    REP(i, N) {
      res2 = max(res2, res[i]);
    }
    PRINT(res2);
    return 0;
}


Measured memory_bytes: 9216