akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


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

  std::vector<string>v = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  if (s == "SUN") {
    cout << "7" << endl;
    return 0;
  }
  for(int i=1; i<7; i++) {
    if (v[i] == s) {
      cout << 7 - i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		int n=s.nextInt();
		int k=s.nextInt();
		int[]a=new int[n+1];
		for(int i=0;i<n;++i)
			a[i+1]=gInt();
		Arrays.parallelPrefix(a,Integer::sum);
//		System.err.println(Arrays.toString(a));

		System.out.println(IntStream.range(k,n+1)
				.mapToDouble(i->(a[i]-a[i-k]+k)*0.5)
				.max().getAsDouble());
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}

Measured memory_bytes: 60056
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    //変数：パーティに参加している友人の数「 N 」とケーキを持ってきた友人の数「 C 」と全ケーキの個数「 maxCake」置く
    int N, C;
    int maxCake = 0;
    
    //入力：パーティに参加している友人の数「 N 」とケーキを持ってきた友人の数「 C 」を入力
    cin >> N >> C;
    
    //変数：友人が持ってきたケーキの数「 P[配列] 」と置く
    vector<int>P(N);
    
    
    
    //入力：友人が持ってきたケーキの数「 P[配列] 」を入力
   for(int i = 0; i < N; i++){
       cin >> P[i];
       maxCake += P[i];
   }
    
    
    //出力：私がもらえるケーキの数を出力
    cout << (maxCake % (N + 1) == 0 ? (maxCake / (N + 1)) : (maxCake / (N + 1) + 1)) << endl;
    
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int n;
double x,ans;
const double z=380000.000000;
int main()
{
	scanf("%d",&n);
	string s;
	for(register int i=1;i<=n;++i)
	{
		cin>>x>>s;
		if(s=="JPY") ans+=x;
		if(s=="BTC") ans+=x*z;
	}
	printf("%.5lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
int main()
{
	int ans = 1e9 +100 ;
	string s ; 
	cin >> s ; 
	s = '+' + s ; 
	for(int i=1 ; i<s.size() ; i++)
	{
		if(s[i] != s[i+1])
			ans = min(ans , max(i , (int)s.size()-i-1)) ; 
	}
	cout << ans ; 
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,m,ans=0;
  cin >> n >> m;
  ll s[20][20];
  vector<ll> k(m),p(m);
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]) cin >> s[i][j];
  }
  rep(i,m) cin >> p[i];

  for(ll i=0;i<(1<<n);i++){
    ll tapu = 0;
    vector<ll> on(n,0);
    rep(j,n){
      if(i & (1<<j)) on[j] = 1;
    }
    rep(a,m){
      ll cnt = 0;
      rep(b,k[a]){
        if(on[s[a][b]-1]==1) cnt++;
      }
      if(cnt%2==p[a]) tapu++;
    }
    if(tapu==m) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

dp = []
for i in range(N):
    dp.append(0)


def mincos(dp, a, i):
    if i == 0:
        return 0
    elif i == 1:
        return abs(a[0] - a[1])
    else:
        return min(dp[i-1]+abs(a[i] - a[i - 1]), dp[i-2]+abs(a[i] - a[i - 2]))


for i in range(N):
    dp[i] = mincos(dp, a, i)

print(dp[N-1])


Measured memory_bytes: 13980
class Point(object):
    __slots__ = ["x", "y"]

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __iter__(self):
        yield self.x
        yield self.y

    def __add__(self, other: "Point") -> "Point":
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other: "Point") -> "Point":
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, s: int):
        return Point(self.x * s, self.y * s)

    def project(self, vector: "Vector") -> "Point":
        return (vector * (Vector(vector.p1, self).dot(vector) / vector.norm)).p2

    def reflect(self, vector: "Vector") -> "Point":
        return self + (self.project(vector) - self) * 2


class Vector(object):
    __slots__ = ["p1", "p2", "x", "y", "norm", "abs"]

    def __init__(self, p1: Point, p2: Point):
        self.p1 = p1
        self.p2 = p2
        self.x = p2.x - p1.x
        self.y = p2.y - p1.y
        self.norm = self.x ** 2 + self.y ** 2
        self.abs = abs(self.x + self.y)

    def __mul__(self, s):
        return Vector(self.p1, Point(self.p1.x + self.x * s, self.p1.y + self.y * s))

    def __lt__(self, other: "Vector"):
        return other.abs > self.abs

    def __gt__(self, other: "Vector"):
        return other.abs < self.abs

    def dot(self, other: "Vector"):
        return self.x * other.x + self.y * other.y

    def cross(self, other: "Vector"):
        return self.x * other.y - self.y * other.x


if __name__ == "__main__":
    import sys
    for x1, y1, x2, y2, xq, yq in (map(float, l.split(",")) for l in sys.stdin):
        vector = Vector(Point(x1, y1), Point(x2, y2))
        print(*Point(xq, yq).reflect(vector))


Measured memory_bytes: 5644
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> t(n), v(n + 1);
  for(int i = 0; i < n; i++) cin >> t[i];
  for(int i = 0; i < n; i++) cin >> v[i];
  v[n] = 0;
  double ans = 0, spd = 0;
  for(int i = n - 1; i >= 0; i--) {
    if(v[i] > spd + t[i]) v[i] = spd + t[i];
    spd = v[i];
  }
  spd = 0;
  for(int i = 0; i < n; i++) {
    if(v[i] - spd + max(v[i] - v[i + 1], 0.0) < t[i]) {
      ans += (t[i] - v[i] + spd - max(v[i] - v[i + 1], 0.0)) * v[i];
      ans += (v[i] - spd) * (spd + v[i]) / 2;
      ans += max(v[i] - v[i + 1], 0.0) * (v[i] + min(v[i], v[i + 1])) / 2;
      spd = min(v[i + 1], v[i]);
    } else {
      if(spd + t[i] < v[i + 1]) {
        ans += t[i] * t[i] / 2;
        ans += t[i] * spd;
        spd += t[i];
      } else {
        double x = (t[i] + v[i + 1] - spd) / 2, y = spd + x;
        ans += x * (spd + y) / 2;
        ans += (t[i] - x) * (y + v[i + 1]) / 2;
        spd = v[i + 1];
      }
    }
  }
  printf("%.9lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int main() {
    int N; cin >> N;
    vector<int> L(N); rep(i, N) cin >> L[i];

    int t = 0;
    rep(i, N) t ^= L[i];

    rep(i, N) L[i] = t ^ L[i];

    cout << L << endl;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

const ll mod = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll ret = 1;
    while (n>0) {
        if (n&1) ret = (ret * x) % mod;
        n >>= 1;
        x = (x * x) % mod;
    }
    return ret % mod;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    ll zero = 0;
    map<pair<ll, ll>, ll> cnt;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;

        if (A == 0 and B == 0) {
            zero++;
        }
        else {
            ll g = __gcd(A, B);
            A /= g;
            B /= g;

            if (A < 0) {
                A *= -1;
                B *= -1;
            }

            pair<ll, ll> tmp = {A, B};
            cnt[tmp]++;
        }
    }

    ll ans = 1;
    for (auto c : cnt) {
        if (c.second < 0) continue;
        cnt[c.first] = -1;
        ll a = c.first.first, b = c.first.second;

        ll g1 = c.second, g2;

        if (b < 0) {
            g2 = cnt[{-b, a}];
            cnt[{-b, a}] = -1;
        }
        else {
            g2 = cnt[{b, -a}];
            cnt[{b, -a}] = -1;
        }

        ll tmp = (mod_pow(2, g1, mod) - 1 + mod) % mod;
        tmp = (tmp + mod_pow(2, g2, mod) - 1 + mod) % mod;
        tmp = (tmp + 1) % mod;
        ans = (ans * tmp) % mod;
    }
    cout << (ans + zero - 1 + mod) % mod << endl;
}


Measured memory_bytes: 31280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string s;
  vector<char> ans;
  cin >> s;
  for(auto &it:s){
    if(it == 'B'&&ans.size()!=0)ans.pop_back();
    if(it != 'B')ans.push_back(it);
  }
  for(auto &it:ans){
    cout << it;
  }
  cout <<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input());
v = input().split(" ");
for i in range(n) :
	v[i] = int(v[i]);

v.sort(reverse=True);

ans = 0;
for i in range(n-1) :
	ans += v[i] / (2**(i+1));

ans += v[n-1] / (2**(n-1));
print(ans);

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

int main()
{
    int n;
    cin >> n;
    map<string, int> a;
    rep(i,n) {
        string s;
        cin >> s;
        a[s]++;
    }
    cout << "AC x " << a["AC"] << endl;
    cout << "WA x " << a["WA"] << endl;
    cout << "TLE x " << a["TLE"] << endl;
    cout << "RE x " << a["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3628
/*
 * Author       : YangDavid
 * Created Time : 2020年01月13日 星期一 20时00分57秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

/*
   Let A_i = 1 + x_1 + x_2 + ... + x_i
   Find the sum of max(N-[x_2,x_3,...,x_n] \cdot [1,2,...,3,2], 0)
     for all nonnegative x_i.
 */
const int maxn = 5555;
int n, MOD;
int add(int x, int y) { return x+y>=MOD ? x+y-MOD : x+y; }
int sub(int x, int y) { return x-y<0 ? x-y+MOD : x-y; }
int mul(int x, int y) { return 1LL*x*y%MOD; }

int dp[maxn];
int main() {
	scanf("%d%d", &n, &MOD);
	dp[0] = 1;
	for(int i = 1; i < n; ++i) {
		int j = i/2 + 1;
		for(int c = 0; c <= n-j; ++c) {
			dp[c + j] = add(dp[c + j], dp[c]);
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; ++i)
		ans = add(ans, mul(dp[i], n - i));
	printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 384
import sys
n = int(input())
if n == 0:
    print(0)
    sys.exit()
ans = []
while n != 0:
    if n < 0:
        r = n % -2
        n = -(-n//-2)
        if r < 0:
            r *= -1
    else:
        r = n%2
        n = n//2
        n *= -1 
    ans.append(str(r))
ans = ans[::-1]
print(''.join(ans))

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;

string to_upper(string str) {
    int diff = 'a' - 'A';
    for (int i = 0; i < str.size(); i++) {
        char c = str[i];
        if ('A' <= c && c <= 'Z') {
            c += diff;
            str[i] = c;
        }
    }
    return str;
}

int main() {

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double w = x1 - x2;
    double h = y1 - y2;

    double ww = w * w;
    double hh = h * h;

    double ans = sqrt(ww + hh);
    printf("%.20f\n", ans);

}



Measured memory_bytes: 3288
from collections import deque

n=int(input())
d=deque(list(input()))
#print(d)
r=0
while n>1:
  #print(d)
  tempr=False
  n-=1
  if d.pop()=="W":
    pass
  else:
    while n>0:
      n-=1
      if d.popleft()=="R":
        pass
      else:
        r+=1
        break
  #print(d,r)
print(r)

Measured memory_bytes: 12220
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long long gcd(long long n, long long m)
{
  if (n%m == 0)
  {
    return m;
  }
  else
  {
    return gcd(m, n%m);
  }
}

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

  long long temp;
  for (int i = 0; i < N; ++i)
  {
    long long A;
    cin >> A;

    if (i == 0) temp = A;
    else temp = gcd(temp, A);
  }
  cout << temp << endl;
}

Measured memory_bytes: 256
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            pw.println((n + 1) / 2 / (n + 0.0));
        }
    }

    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("input"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("output"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}


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

#define ROT(a,b,c,d) tmp = o[(a)]; o[(a)]=o[(b)]; o[(b)]=o[(c)]; o[(c)]=o[(d)]; o[(d)]=tmp 


class Dice
{
public:
	int label[7];
	int orientation[7];

	Dice() { }
	Dice(int l[6]) : orientation{0,1,2,3,4,5,6}
	{
		for(int i=1; i<7; ++i) label[i] = l[i-1];
	}

	Dice &rotate(int face) {
		auto &o = orientation;
		int tmp;

		switch(face) {
		case 1: ROT(2,3,5,4); break;
		case 2: ROT(1,4,6,3); break;
		case 3: ROT(1,2,6,5); break;
		case 4: ROT(1,5,6,2); break;
		case 5: ROT(1,3,6,4); break;
		case 6: ROT(2,4,5,3); break;
		}

		return *this;
	}

	int getIndex(int l) const {
		int i=0;
		while(++i<7) if(l == label[i]) break;
		return i;
	}

	friend bool operator==(const Dice &a, const Dice &b) {
		bool equal = true;
		for(int i=1; i<7; ++i) equal &= a.label[a.orientation[i]] == b.label[b.orientation[i]];
		return equal;
	}

};


int main()
{
	int label1[6], label2[6];
	for(auto &l : label1) cin >> l;
	for(auto &l : label2) cin >> l;

	Dice dice1(label1), dice2(label2);
	for(int i=1; i<7; ++i) dice2.orientation[i] = dice1.getIndex(dice2.label[i]);
	for(int i=1; i<7; ++i) dice2.label[i] = dice1.label[i];

	for(int a=0; a<6; ++a) {
		for(int i=0; i<4; ++i) {
			dice1.rotate(1);
			if(dice1 == dice2) {
				cout << "Yes" << '\n';
				return 0;
			}
		}
		if(a<4) dice1.rotate(4);

		if(a==3) dice1.rotate(2);
		else if(a==4) dice1.rotate(2).rotate(2);
	}

	cout << "No" << '\n';

	return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j;

string N;
ll K;
ll dp1[100][4];
ll dp0[100][4];

ll k0(ll x,ll y){
   if(y==-1)return 0;
   if(dp0[x][y]>=0)return dp0[x][y];
   if(x==0){
      if(y==1)return dp0[x][y]=1;
      else return dp0[x][y]=0;
   }
   else{
      int c=N[x]-'0';
      if(c==0)return dp0[x][y]=k0(x-1,y);
      else return dp0[x][y]=k0(x-1,y-1);
   }
}

ll k1(ll x,ll y){
   if(y==-1)return 0;
   if(dp1[x][y]>=0)return dp1[x][y];
   int c=N[x]-'0';
   if(x==0){
      if(y==1)return c-1;
      else if(y==0)return 1;
      return 0;
   }
   else{
      if(c==0)return dp1[x][y]=k1(x-1,y)+k1(x-1,y-1)*9;
      return dp1[x][y]=k1(x-1,y)+k1(x-1,y-1)*9+k0(x-1,y)+k0(x-1,y-1)*(c-1);
   }
}
int main(){
   cin>>N;
   cin>>K;
   ll keta=N.length();


   rep(i,keta){
      rep(j,K+1){
         dp1[i][j]=-1;
         dp0[i][j]=-1;
      }
   }

   
   ll ans=k0(keta-1,K)+k1(keta-1,K);
   cout<<ans<<endl;
   
   
   

}


Measured memory_bytes: 256
N,M=map(int,input().split())
s=[]
c=[]
for _ in range(M):
    S,C=map(int,input().split())
    s.append(S)
    c.append(C)

num=[10]*N

for i in range(M):
    if N>1 and s[i]==1 and c[i]==0:
        num="-1"
        break
    elif num[s[i]-1]==10:
        num[s[i]-1]=c[i]
    elif num[s[i]-1]!=10 and num[s[i]-1]!=c[i]:
        num="-1"
        break
if num=="-1":
    print(num)
else:
    for l in range(N):
        if num[l]==10:
            num[l]=0
    if num[0]==0 and N>1:
        num[0]=1
    for j in range(N):
        print(num[j],end="")

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ans = new int[HW[0], HW[1]];
            int curH = 0, curW = 0;
            var directR = true;

            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < a[i]; j++)
                {
                    if (directR)
                    {
                        if (curW == HW[1])
                        {
                            curW--;
                            curH++;
                            ans[curH, curW] = i + 1;
                            curW--;
                            directR = !directR;
                        }
                        else
                        {
                            ans[curH, curW] = i + 1;
                            curW++;
                        }
                    }
                    else
                    {
                        if (curW == -1)
                        {
                            curW++;
                            curH++;
                            ans[curH, curW] = i + 1;
                            curW++;
                            directR = !directR;
                        }
                        else
                        {
                            ans[curH, curW] = i + 1;
                            curW--;
                        }
                    }
                }
            }

            for (var i = 0; i < HW[0]; i++)
            {
                for (var j = 0; j < HW[1]; j++)
                {
                    Console.Write(ans[i, j]);
                    if (j != HW[1] - 1) Console.Write(" ");
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 13536
#!/usr/bin/env python3
import sys
from math import sqrt

def solve(N: int, D: int, X: "List[List[int]]"):
    
    ans = 0
    for i in range(N-1):
        l = [.0]*N
        for j in range(i+1,N):
            t = sum([(X[j][k]-X[i][k]) ** 2 for k in range(D)])
            l[j] = sqrt(t)

        for j in range(1,N):
            if(l[j] != 0 and l[j].is_integer()):
                ans += 1

    print(ans) 
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [ [ int(next(tokens)) for _ in range(D) ] for _ in range(N) ]  # type: "List[List[int]]"
    solve(N, D, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
int a,b,c;
int main() {
	scanf("%d %d %d",&a,&b,&c);
	bool t=false;
	for (int k=0;k<b;k++)
		if ((a*k)%b==c) {
			t=true;
			break;
		}
	if (t)
		printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;


int main(int argc, char *argv[])
{
	//init
	int n, k;
	cin >> n >> k;

	vector<int> p;
	for(int i = 0; i < n; i++){
		int pi;
		cin >> pi;

		p.push_back(pi);
	}


	//calc
	int k_begin = 0;
	int k_end = k - 1;
	int current_sum_k = 0;
	for (int i = k_begin; i <= k_end; i++){
		current_sum_k += p[i];
	}

	int max_k_index = k_begin;
	int max_sum_k = current_sum_k;
	while (k_end + 1 <= n - 1){
		k_begin++;
		k_end++;

		int next_sum_k = current_sum_k;
		next_sum_k -= p[k_begin - 1];
		next_sum_k += p[k_end];
		
		if (max_sum_k < next_sum_k){
			max_k_index = k_begin;
			max_sum_k = next_sum_k;
		}

		current_sum_k = next_sum_k;
	}


	//ans
	k_begin = max_k_index;
	k_end = k_begin + k - 1;
	double ans = 0;
	for (int i = k_begin; i <= k_end; i++){
		int pi = p[i];

		ans += (double)(pi + 1);
	}
	ans /= 2.0;

	cout << setprecision(10) << ans << endl;


	return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    ++mp[s];
  }

  int mx = 0;
  for (auto p : mp) {
    mx = max(mx, p.second);
  }

  vector<string> ans;
  for (auto p : mp) {
    if (p.second == mx) {
      ans.push_back(p.first);
    }
  }

  sort(ans.begin(), ans.end());
  for (auto s : ans) {
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 26868
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse = True)
    return divisors

import heapq
#from collections import deque
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
#mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, K = LI()
A = LI()
cou = int(0)
sumA = sum(A)
anscandi = make_divisors(sumA)
#print(anscandi)

for i in anscandi:
    Smod = int(0)
    que = []
    for j in range(N):
        que.append((A[j] % i) *(-1))
        Smod += A[j] % i
    need = Smod//i
    heapq.heapify(que)
    for _ in range(need):
        heapq.heappop(que) * (-1)
    if K>=(sum(que)*(-1)):
        ans = i
        break


print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;

//i*2^X>=K
//2^X>=
int main() {
	vector<int>Prk(181),dp(1000001,mod), dpi(1000001, mod);
	for (size_t i = 1; i <= 180; i++)
	{
		Prk.at(i) = i * (i + 1) * (i + 2) / 6;
	}
	dp.at(0) = 0;
	dpi.at(0) = 0;
	for (size_t i = 1; i <= 180; i++)
	{
		for (size_t j = Prk.at(i); j <= 1000000; j++)
		{
			dp.at(j) = min(dp.at(j - Prk.at(i)) + 1, dp.at(j));
			if (Prk.at(i) % 2)dpi.at(j) = min(dpi.at(j - Prk.at(i))+1, dpi.at(j));
		}
	}
	int task;
	while (true)
	{
		cin >> task;
		if (task == 0)return 0;
		cout << dp.at(task) << " " << dpi.at(task) << endl;
	}
}


Measured memory_bytes: 10580
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

    for(ll i = 1;i <= 3500;i++){
        for(ll j = 1;j <= 3500;j++){
            if((4*i*j - n*(i+j)) != 0){
                if((n * i * j)%(4*i*j - n * (i+j)) == 0){
                    if((n * i * j)/(4*i*j - n * (i+j)) > 0){
                        cout << i << " " << j << " " << (n * i * j)/(4*i*j - n * (i+j)) << endl;
                        return 0;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[100100];

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inverse(ll x) {
    return mod_pow(x, mod-2);
}

const int max_n = 100100;
ll fact[max_n];
ll fact_inv[max_n];
void calc_fact() {
    fact[0] = 1;
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
    fact_inv[max_n-1] = mod_inverse(fact[max_n-1]);
    for (ll i = max_n-2; i >= 0; i--)
        fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod;
}
ll mod_comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return (fact[n] * fact_inv[k] % mod) * fact_inv[n-k] % mod;
}

void solve() {
    calc_fact();
    int num[n+1];
    memset(num, 0, sizeof(num));
    int z = 0;
    int b, c;
    for (int i = 0; i <= n; i++) {
        num[a[i]]++;
        if (num[a[i]] > 1) {
            z = a[i];
            c = n - i;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] == z) {
            b = i;
            break;
        }
    }
    for (int k = 1; k <= n+1; k++) {
        cout << ((mod_comb(n-1, k) + mod_comb(n-1, k-2) + 2*mod_comb(n-1, k-1) - mod_comb(b+c, k-1)) % mod + mod) % mod<< endl;
    }
}

void input() {
    cin >> n;
    for (int i = 0; i <= n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 3584
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)
  .map(e => (e === 1 ? 14 : e))

const res = _ => {
  if (a === b) return 'Draw'
  if (a > b) return 'Alice'
  return 'Bob'
}

console.log(res())


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h, w; cin >> h >> w;
  vector<string> m(h); cin >> m;
  vector<ll> X, Y;
  rep(y, h) rep(x, w) {
    if (m[y][x] == '#') {
      X.pb(x);
      Y.pb(y);
    }
  }
  sort(all(X));
  sort(all(Y));
  X.erase(unique(all(X)), X.end());
  Y.erase(unique(all(Y)), Y.end());
  const ll nh = Y.size(), nw = X.size();
  vector<string> nm(nh);
  rep(y, nh) rep(x, nw) {
    nm[y] += m[Y[y]][X[x]];
  }
  each(line, nm) {
    cout << line << endl;
  }
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>

int GCD(long long n1, long long n2);

int main()
{
    long long a, b;
    long long num;
    scanf("%lld %lld", &a, &b);
    num = GCD(a, b);
    printf("%lld", a / num * b);
    return 0;
}

int GCD(long long n1,long long n2)
{
    return n1 % n2 ? GCD(n2, n1 % n2) : n2;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int K;
  cin >> K;
  string S;
  cin >> S;

  if(S.size()<=K){
    cout << S << endl;
  }else{
    S=S.substr(0,K);
    cout << S + "..." << endl;
  }
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i=0;i<26;i++) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(D);
    //ここで日程を決定する==========
    //for (int i=0;i<D;i++){
    //    t[i] = i%26 + 1;
    //}
    //=============================
    for (int i=0;i<D;i++) cin >> t[i],t[i]--;

    int M;
    cin >> M;
    vector<int> d(M), q(M);
    for (int i=0;i<M;i++){
        cin >> d[i] >> q[i];
        d[i]--;q[i]--;
    }
    
    
    for (int m=0;m<M;m++){
        t[d[m]] = q[m];
        ll sum = 0;
        vector<int> last(26);
        for (ll i=0;i<D;i++){
            sum += s[i][t[i]];
            last[t[i]] = i+1;
            for (int j=0;j<26;j++){
                sum -= c[j]*(i+1-last[j]);
            }
        }
        cout << sum << "\n";
    }
}

Measured memory_bytes: 3816
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l =[0]*n
for j in range(n):
  a = s.count(s[j])
  b = t.count(s[j])
  l[j] = a-b
print(max(max(l),0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

void func(vector<int> X){
  int n = X.size();
  REP(i, n){
    cout << X[i];
    if(i == n-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> A(N, 0);
  REP(i, N){
    cin >> A[i];
  }
  func(A);
  for(int i = 1; i < N; i++){
    int v = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    func(A);
  }
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   cout << (n+1)/2 << '\n';
   return 0;
} 


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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= n; --i)
#define debug(x) cout << #x <<" = "<< x << endl

char s[10];

int main () {
	scanf ("%s", s);
	bool f = 0;
	rep(i, 0, 2) if (s[i] == s[i + 1]) f = 1;

	if (f) puts("Bad");
	else puts("Good");
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define MaxN 1000010
//#define MOD 998244353
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define endl '\n'
#define LL long long
#define PII pair<int,int>
#define rint register int 
#define ULL unsigned long long
const int MOD=1e9+7;
//int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
template<class T> inline void read(T& x){
    x=0;int f=0;char ch=getchar();
    while( !isdigit(ch) ) f|=( ch == '-' ) , ch=getchar();
    while( isdigit(ch) )  x = ( x<<1 ) + ( x<<3 ) + ( ch^48 ) , ch=getchar();
    x = f ? -x : x;
}
template<class T> inline void print(T x){
	if ( x < 0 ) { putchar('-'); x = -x; }
	if ( x >= 10 ) print( x / 10 );
	putchar(x % 10 + '0');
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int n; cin>>n;
    string str; cin>>str;
    int ans=0,left=0,right=str.length()-1;
    while( left <= right ){
        while( str[left] !='W' && left < n ) left++;
        while( str[right] !='R' && right >= 0 ) right--;
        if( left > right ) break;
        if( str[left] =='W' && str[right]=='R' ){
            ans++;
            swap(str[left],str[right]);
        //    cout<<str<<endl;
            left++,right--;
        }
        if( left > right ) break;
    //    cout<<str<<endl;
    }
    cout<<ans;
	return 0; 
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
// << left shift *2 and >>right shift /2
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;cin>>n;long long int a[n];for(auto &x:a)cin>>x;
    long long int dp[n];dp[0]=0,dp[1]=abs(a[1]-a[0]);
    for(long long int i=2;i<n;i++)
    {
        long long int op1=abs(a[i]-a[i-2])+dp[i-2];
        long long int op2=abs(a[i]-a[i-1])+dp[i-1];
        dp[i]=min(op1,op2);
    }
    cout<<dp[n-1]<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;
    //cin>>t;long long int temp=t;
    while(t--)
    {
        //cout<<"Case "<<temp-t<<": ";
        solve();
    }
}


Measured memory_bytes: 5220
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <time.h>
#include <stdlib.h>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define LL_INF 1e18

#define nmax 200010

#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007
#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

typedef long long int ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

ll h;

ll my_pow(ll x, ll p)
{
    ll sol = 1;

    while (p > 0) {

        if (p % 2 == 1) sol = sol * x;

        p /= 2;
        x = x * x;
    }

    return sol;
}

int main()
{
    scanf("%lld", &h);

    int l = 0;

    while (h > 0) {

        l++;
        h /= 2;
    }

    printf("%lld", my_pow(2LL, l) - 1);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;


signed main()
{
    int x;
    for(int i = 1; cin >> x , x; i++){
        printf("Case %d: %d\n", i, x);
    }

    return 0;
}

/*



*/



Measured memory_bytes: 3124
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


typedef long long ll;

using namespace std;

#define PI 3.1415 
  
double circumference(double r) 
{ 
    double cir = 2*PI*r; 
    return cir; 
} 

int main() 
{ 

	double r;
	cin >> r;

	cout << circumference(r);

	return 0; 
} 


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

char get_te(char& c) {
  if (c == 'r') return 'p';
  else if (c == 's') return 'r';
  else if (c == 'p') return 's';
  return 'x';
}

int score(char& c, int& r, int& s, int& p) {
  if (c == 'r') return r;
  else if (c == 's') return s;
  else if (c == 'p') return p;
  return 0;
}

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

  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  vector<char> te(n);
  ll ans = 0;
  rep(i, n) {
    char b = get_te(t[i]);   // 出したい手
    if (i < k) {
      te[i] = b;
      ans += score(b, r, s, p);
    } else {
      if (te[i-k] == b) {   // 諦める
        te[i] = '*';
      } else {
        te[i] = b;
        ans += score(b, r, s, p);
      }
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define all(x) (x).begin(), (x).end()

int n, m, q;
int a[500000];
vector<int> line;
int pos[500000];
int cnt[500000];

signed main()
{
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) cin >> a[i];
    fill(pos, pos + m + 1, -1);
    for (int i = q - 1; i >= 0; i--)
    {
        int x = a[i];
        if (pos[x] == -1)
        {
            pos[x] = line.size();
            cnt[x]++;
            line.push_back(x);
        }
        else
        {
            if (pos[x] == 0)
            {
                cnt[x]++;
                continue;
            }
            else
            {
                if (cnt[line[pos[x] - 1]] > cnt[x])
                {
                    cnt[x]++;
                }
            }
        }
    }
    int t = 1;
    for (int i = 0; i < line.size(); i++)
    {
        if (cnt[line[i]] < n)
        {
            t = 0;
        }
    }
    if (t) cout << "Yes";
    else
    {
        vector<int> g, f;
        for (int i = 0; i < line.size(); i++)
        {
            g.push_back(line[i]);
            if (cnt[line[i]] >= n) f.push_back(line[i]);
        }
        for (int i = 1; i <= m; i++)
        {
            if (cnt[i] == 0) g.push_back(i);
            if (cnt[i] < n) f.push_back(i);
        }
        //for (auto e : g) cout << e << " "; cout << endl;
        //for (auto e : f) cout << e << " "; cout << endl;
        if (g == f)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
}


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

using namespace std;

int n, m;
string s, t;

int main() {
    cin >> n >> m;
    cin >> s >> t;

    if (s[0] != t[0]) {
        cout << -1 << '\n';
        return 0;
    }
    long long L = 1LL * n * m / __gcd(n, m);
    int j = 1;
    int X = L / n, Y = L / m;

    for (int i = 1; i < n; i++) {
        while (1LL * j * Y < 1LL * i * X) {
            j++;
        }
        if (1LL * j * Y == 1LL * i * X && s[i] != t[j]) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << L << '\n';
    return 0;
}


Measured memory_bytes: 512
#include <iostream> 
#include <unordered_set> 
#include <unordered_map>
#include <algorithm>
#include <string>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	long long X,count=0,val=100;
	
	cin >>X;
	while (val < X)
	{
		val += val / 100;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3648