akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[60][60][5100];
//dp[i][j][k]
//i:どこまで見たか
//j:いくつ持ってるか
//k:現時点での剰余分

ll N, K;
int main() {
    cin >> N >> K;
    if(K % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    K /= 2;
    dp[0][0][K] = 1;
    for(ll index = 1; index <= N; index++) {
        for(ll beforej = 0; beforej < index; beforej++) {
            for(ll beforek = 0; beforek <= 5000; beforek++) {
                //cerr << index - 1 << " " << beforej << " "<< beforek << " " << dp[index-1][beforej][beforek] << endl;
                dp[index][beforej][beforek] += dp[index-1][beforej][beforek];
                //indexをindexにしまう
                dp[index][beforej][beforek] %= mod;
                if(beforej >= 1) {
                    dp[index][beforej][beforek] += dp[index-1][beforej][beforek] * beforej;
                    //indexはindexより前にしまう now[index]はとりあえず空
                    dp[index][beforej][beforek] %= mod;
                    if(beforej >= 1 && beforek >= index) {
                        dp[index][beforej-1][beforek-index] += dp[index-1][beforej][beforek] * beforej * beforej;
                        //indexはindexより前にしまう now[index]には前のものをしまう
                        dp[index][beforej-1][beforek-index] %= mod;
                    }
                }
                if(beforej >= 1) dp[index][beforej][beforek] += dp[index-1][beforej][beforek] * beforej;
                //indexは持つ now[index]に前のものをしまう
                dp[index][beforej][beforek] %= mod;
                dp[index][beforej+1][beforek+index] += dp[index-1][beforej][beforek];
                //indexは持つ now[index]は空
                dp[index][beforej+1][beforek+index] %= mod;
            }
        }
    }
    cout << dp[N][0][0] << endl;
    return 0;
}


Measured memory_bytes: 119168
#include <stdio.h>

int main() {
    int i, n, last = 0, len = 0, res = 0, tmp;
    scanf("%d", &n);
    for (i=0;i<n;i++) {
        scanf("%d", &tmp);
        if (tmp == last) {
            len++;
        } else {
            res += len / 2;
            last = tmp;
            len = 1;
        }
    }
    res += len / 2;
    printf("%d", res);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int N, U, V; 
vector<int> E[100010]; 
int dU[100010], dV[100010];  
int main(){
	cin >> N >> U >> V; 
	U--; V--; 
	for(int i = 0; i < N-1; i++){
		int a, b; cin >> a >> b; 
		a--; b--; 
		E[a].push_back(b); 
		E[b].push_back(a); 
	}
	fill(dU, dU + N, -1); 
	fill(dV, dV + N, -1); 
	dU[U] = 0; dV[V] = 0; 
	queue<int> que; 
	que.push(U); 
	while(que.size()){
		int p = que.front(); que.pop(); 
		for(int i = 0; i < E[p].size(); i++){
			if(dU[E[p].at(i)] == -1){
				dU[E[p].at(i)] = dU[p] + 1; 
				que.push(E[p].at(i)); 
			}
		}
	}
	que.push(V); 
	while(que.size()){
		int p = que.front(); que.pop(); 
		for(int i = 0; i < E[p].size(); i++){
			if(dV[E[p].at(i)] == -1){
				dV[E[p].at(i)] = dV[p] + 1; 
				que.push(E[p].at(i)); 
			}
		}
	}
	int ans = 0; 
	for(int i = 0; i < N; i++){
		if(dU[i] < dV[i]) ans = max(ans, dV[i]); 
	}
	cout << ans - 1 << endl; 
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N;
const LL B1 = 1007;
const LL M1 = 1000000007;
vector<LL> pow1;
void init(){
  pow1.assign(N+1,1);

  for(int i=0;i<N;++i){
	pow1[i+1] = pow1[i] * B1 % M1;
  }
}

struct RollingHash{
  vector<LL> hash1;
  RollingHash(const string& str){
	int N = str.size();
	hash1.assign(N+1,0);

	for(int i=0;i<N;++i){
	  hash1[i+1] = (hash1[i] * B1 + str[i]) % M1;
	}
  }

  // [l,r), 0 <= l < r <= n
  LL hash(int l, int r){
	LL res = 0;
	res = ((hash1[r] - hash1[l] * pow1[r-l]) % M1 + M1) % M1;
	return res;
  }
};


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

  cin >> N;
  init();
  VS vs(N);
  cin >> vs;

  vector<RollingHash> vc, vr;
  REP(x,N){
	string tmp(2*N, 'a');
	REP(y,N*2){
	  tmp[y] = vs[y%N][x];
	}
	vc.emplace_back(tmp);
  }
  REP(y,N){
	string tmp = vs[y] + vs[y];
	vr.emplace_back(tmp);
  }

  int ans = 0;
  REP(yy,N){
	for(int rx=0;rx<N;++rx){
	  bool ok = true;
	  for(int y=0;y<N;++y){
		if(vr[(yy+y)%N].hash(0,N) != vc[(yy+y+N-rx)%N].hash(rx,rx+N)){
		  ok = false;
		  break;
		}
	  }

	  if(ok) ++ans;
	}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3200
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

X = INT()

cnt500 = X // 500 * 1000
cnt5 = (X % 500) // 5 * 5
ans = cnt500 + cnt5
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
#include<set>
#include<deque>
#include<queue>
#include<math.h>
#include<chrono>
#include<list>
#include<random>
#include<bitset>
#include<assert.h>
#include<ctime>
#include<cstdio>
#include <unordered_map>

using namespace std;

#define fast_input() {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
//#define ll long long
using ll = long long;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
MIKUNO - 15/02/1999
*/

template <class T, class Op>
class SegmentTree {
private:
    const Op op;
    const T ID;
    std::vector<T> vec;
    size_t sz;

public:
    SegmentTree(size_t _n, Op _op, T _identity) noexcept
        : op(_op), ID(_identity) {
        sz = 1;
        while (sz < _n) sz <<= 1;
        vec.resize(sz * 2, ID);
    }
    SegmentTree(const std::vector<T>& _vec, Op _op, T _identity) noexcept
        : op(_op), ID(_identity) {
        size_t n = _vec.size();
        sz = 1;
        while (sz < n) sz <<= 1;
        vec.resize(sz * 2, ID);
        set_array(_vec);
    }
    void set_value(size_t _idx, T _val) noexcept {
        vec[_idx + sz] = _val;
    }
    template <class RandomIt>
    void set_array(RandomIt _begin, RandomIt _end) noexcept {
        std::copy(_begin, _end, vec.begin() + sz);
    }
    void set_array(const std::vector<T>& _newvec) noexcept {
        set_array(_newvec.begin(), _newvec.end());
    }
    void build() noexcept {
        for (size_t i = sz - 1; i > 0; i--) {
            vec[i] = op(vec[i * 2], vec[i * 2 + 1]);
        }
    }
    void update(size_t _idx, T _val) noexcept {
        _idx += sz;
        vec[_idx] = _val;
        for (_idx >>= 1; _idx > 0; _idx >>= 1) {
            vec[_idx] = op(vec[_idx * 2], vec[_idx * 2 + 1]);
        }
    }
    // 区間[_i, _r)に対するクエリを実行する
    T query(size_t _l, size_t _r) const noexcept {
        T l_val = ID, r_val = ID;
        _l += sz, _r += sz - 1;
        for (; _l <= _r; _l >>= 1, _r >>= 1) {
            if (_l & 1) l_val = op(l_val, vec[_l++]);
            if (!(_r & 1)) r_val = op(r_val, vec[_r--]);
        }
        return op(l_val, r_val);
    }
    const T& operator[](size_t _idx) const noexcept {
        return vec[_idx + sz];
    }
};

using Bs = bitset<26>;

const int N = 1e5 + 5;
//	priority_queue <ll, vector<ll>, greater<ll> > q;
int n, m, k, cnt, rs, q;
string s;

int main()
{
	fast_input();
    int N;
    cin >> N;
    string S;
    cin >> S;
    auto op = [](const Bs& a, const Bs& b) {
        return a | b;
    };
    SegmentTree<Bs, decltype(op)> seg(N, op, Bs());
    for (int i = 0; i < N; i++) {
        seg.set_value(i, Bs().set(S[i] - 'a'));
    }
    seg.build();
    int Q;
    cin >> Q;
    while (Q--) {
        int query;
        cin >> query;
        if (query == 1) {
            int idx;
            char c;
            cin >> idx >> c;
            seg.update(idx - 1, Bs().set(c - 'a'));
        }
        else {
            int l, r;
            cin >> l >> r;
            --l, --r;
            cout << seg.query(l, r + 1).count() << '\n';
        }
    }

}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int main(){
    ll n,m;
    cin >> n >> m;
    ll s1,s2,s3,ans=INT_MAX;
    lrep(i,1,n-1){
        ll N=n;
        s1=i*m;
        N -= i;

        s2=(N/2)*m;
        s3=(N-N/2)*m;
        ans = min(ans,max({s1,s2,s3})-min({s1,s2,s3}));

        s2=(m/2)*N;
        s3=(m-m/2)*N;
        ans = min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
    }
    lrep(i,1,m-1){
        ll M=m;
        s1=i*n;
        M -= i;
        
        s2=(M/2)*n;
        s3=(M-M/2)*n;
        ans = min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
        
        s2=(n/2)*M;
        s3=(n-n/2)*M;
        ans = min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
 
int main(){
int a=read(),b=read();
puts(a<=8&&b<=8?"Yay!":":(");
}

Measured memory_bytes: 256
N=gets.to_i
A=gets.split.map(&:to_i)

x = 0
(1..N).each do |n|
  if n%2 == 0
    x -= A[n-1]
  else
    x += A[n-1]
  end
end
x /= 2

ans = Array.new(N)
ans[0] = x
(N-1).times do |i|
  ans[i+1] = A[i] - ans[i]
end
ans.map!{|a|a*2}
puts ans.join(" ")

Measured memory_bytes: 14084
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

H,W = imn()

s = [input() for _ in range(H)]
d = [[INF for _ in range(W)] for _ in range(H)]
d[0][0] = 0
if s[0][0] == '#': d[0][0] = 1

xd = [1, 0]
yd = [0, 1]
que = deque([(0, 0)])
cnt = 0
while len(que) > 0:
    cnt += 1
    point = que.popleft()
    x = point[0]
    y = point[1]
    if x == W-1 and y == H-1: continue
    for i in range(2):
        nx = x + xd[i]
        ny = y + yd[i]
        if nx >= W or ny >= H: continue
        if s[ny][nx] == '#' and s[y][x] == '.': 
            if d[ny][nx] > d[y][x]+1:
                d[ny][nx] = d[y][x]+1
                que.append((nx,ny))
        else:
            if d[ny][nx] > d[y][x]:
                d[ny][nx] = d[y][x]
                que.append((nx,ny))
print(d[H-1][W-1])






Measured memory_bytes: 5288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main(){
    int r,g,b,n; cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            if(n - (i*r+j*g) >= 0 && (n - (i*r+j*g)) % b == 0){
                ans++;
            }
        }
    }
    cout << ans;
}



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

using namespace std;

int main() {
    string s;

    cin >> s;

    bool isN = false, isW = false, isS = false, isE = false;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'N') {
            isN = true;
        }

        if (s[i] == 'W') {
            isW = true;
        }

        if (s[i] == 'S') {
            isS = true;
        }

        if (s[i] == 'E') {
            isE = true;
        }
    }

    if (isN == isS && isW == isE) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>

int main()
{
  std::string input = "";
  unsigned long long inputNum = 0;
  unsigned long long result = 0;
  std::cin >> input;
  std::istringstream(input) >> inputNum;
  result = static_cast<unsigned long long>((inputNum - 1) * inputNum) / 2;
  std::cout << result << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
	#include<stdlib.h>
 
	int n,bp,tp,r,t[100],i,c;
	int cmp(const void *a,const void *b)
	{
	return *(int*)b-*(int*)a;
	}

	int main()
	{
	scanf("%d%d%d%d",&n,&bp,&tp,&c);
	for(i=0;i<n;i++)
		scanf("%d",&t[i]);
	qsort(t,n,4,cmp);
	for(i=0,r=c/bp,bp+=tp;i<n;i++,bp+=tp)
		c+=t[i],r=r<c/bp?c/bp:r;
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxM = 3e5+7;
const int maxV = 90010;
 
const int MOD = 1e9+7;
 
int T;
const int maxN = 1e5+8;
const ll INF = 1000000000000000010LL;
const int K = 15;
ll a[maxN];
ll b[maxN];
int n;



int main() {
	int n;
	scanf("%d",&n);
	int m = n;
	int cnt = 0;
	a[0] = 1;
	for(int i=1;i<=n;i++)
	{
		a[i] = a[i-1]*10;
	}
	while(n)
	{
		cnt++;
		n/=10;
	}
	int ans = 0;
	if(cnt%2 == 1)
	{
		ans += m-a[cnt-1]+1;
	}
	for(int i=1;i<cnt;i+=2)
		ans += a[i]-a[i-1];
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ctime>
#define ll long long int
#define MOD 1000000007
using namespace std;
#define pb push_back
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define rev(i, n, x) for (ll i = n; i > x; i--)
clock_t start;

void FAST(int argc)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    start = clock();
    if (argc == 2)
        freopen("std.in", "r", stdin);
}
/*vector<ll> v;
void seive()
{
    v.pb(2);
    for (int i = 3; i < 100000; i += 2)
    {
        for (int j = 0; j < v.size(); j++)
        {
            if (i % v[j] == 0)
                break;
            if (v[j] * v[j] > i)
            {
                v.pb(i);
                break;
            }
        }
    }
}
/*
void prime_factor(ll x, vector<ll> &r)
{
    ll sqrt_x = sqrt(x);

    for (ll i : v)
    {
        if (i > sqrt_x)
            break;

        if (x % i == 0)
            r.pb(i);

        while (x % i == 0)
        {
            x /= i;
        }
    }

    if (x >= 2)
        r.pb(x);
}
*/
/*
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return res;
}
*/
/*
inline void dfs(long long int curr, long long int prev)
{

    for (long long int i : a[curr])
        if (i != prev)
            dfs(i, curr);
}
*/
/*
ll multi(ll a, ll b)
{
    return ((a * b) % MOD);
}
*/
//---------------------CODE STARTS HERE---------------------

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

    ll testcase = 1;
    //cin >> testcase;

    while (testcase--)
    {
        int n;
        cin>>n;
        int h[n];
        rep(i, 0, n)
                cin >>
            h[i];
        int ans[n] = {0};
        ans[0] = 0;
        if(n>1)
            ans[1] = abs(h[1] - h[0]);
        rep(i, 2, n)
        {
            ans[i] = min(abs(h[i] - h[i-1]) + ans[i-1],abs( h[i] - h[i-2]) + ans[i-2]);
        }
        //rep(i,0,n)
        cout << ans[n-1] << endl;
        //--------??--------CLEAR VECTORS--------??--------
    }

    //v.clear();
    //cout << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n';
    return 0;
}
//vector <pair <int,int> > vect;

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return (x * 1ll * y) % MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    t=1;
    while(t--)
    {
        lld n,m;
        cin>>n>>m;
        lld ar[n+1];
        for(i=1;i<=n;i++)
            cin>>ar[i];
        vector<lld>v[n+1];
        for(i=0;i<m;i++)
        {
            lld a,b;
            cin>>a>>b;
            v[a].push_back(b);
            v[b].push_back(a);
        }
        lld ans=0;
        for(i=1;i<=n;i++)
        {
            lld ctr=1;
            for( lld x:v[i])
            {
                if(ar[x]>=ar[i])
                    ctr=0;
            }
            if(ctr==1)
               ans++;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 10248
# _*_ coding:utf-8 _*_
#  CADDi2018 for Beginners B AtCoderAlloy
#  https://atcoder.jp/contests/caddi2018b/tasks/caddi2018b_b

def checkGetArroy(getArroyHeight,getArroyWidth,nowArroyHeight,nowArroyWidth):
	if(getArroyHeight <= nowArroyHeight) and (getArroyWidth <= nowArroyWidth):
		return True
	else:
		return False


def countGetArroy(allArroyNumber,arroyHeight,arroyWidth,eachArroyHeightList,eachArroyWidthList):

	counter = 0
	patternRange = range(0,allArroyNumber,1)
	for i in patternRange:
		checkResult = checkGetArroy(arroyHeight,arroyWidth,eachArroyHeightList[i],eachArroyWidthList[i])
		if (checkResult==True):
			counter = counter + 1

	return counter


if __name__ == '__main__':
	n , h , w = map(int,input().strip().split(' '))
	alloyRange = range(0,n,1)
	heightList = []
	widthList = []
	for i in alloyRange:
		tmpHeight,tmpWidth = map(int,input().strip().split(' '))
		heightList.append(tmpHeight)
		widthList.append(tmpWidth)
	solution=countGetArroy(n,h,w,heightList,widthList)
	print(solution)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  ll N, W;
  cin >> N >> W;

  vector<ll> values(N);
  vector<ll> weights(N);

  for (ll i = 0; i < N; i++) {
    cin >> weights[i] >> values[i];
  }

  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));

  for (ll i = 0; i < N; i++) {
    for (ll w = 0; w < W + 1; w++) {
      if (w + weights[i] <= W) {
        dp[i + 1][w + weights[i]] =
            max(dp[i][w] + values[i], dp[i][w + weights[i]]);
      }

      dp[i + 1][w] = max(dp[i][w], dp[i + 1][w]);
    }
  }

  // for (ll i = 0; i < N + 1; i++) {
  //   for (ll w = 0; w < W + 1; w++) {
  //     cout << dp[i][w] << " ";
  //   }
  //   cout << endl;
  // }

  ll ans = 0;
  for (auto d : dp[N]) {
    ans = max(ans, d);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {

	int n, m;
	cin >> n;
	vector <string> red(n);
	rep(i, n) cin >> red.at(i);
	cin >> m;
	vector <string> blue(m);
	rep(i, m) cin >> blue.at(i);
	vector <int> score(n);
	rep(i, n) {
		int cnt = 0;
		rep(j, n) {
			if (red.at(i) == red.at(j)) cnt++;
		}
		rep(k, m) {
			if (red.at(i) == blue.at(k)) cnt--;
		}
		score.push_back(cnt);
	}
	sort(score.begin(), score.end());
	reverse(score.begin(), score.end());

	cout << max(0, score.at(0)) << endl;

	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // Input
            int N = Integer.parseInt(sc.next());
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = Integer.parseInt(sc.next());
            }

            // Calc
            int cnt = 0;
            for (int i = 0; i < N; i += 2) {
                if (a[i] % 2 != 0) cnt++;
            }
            System.out.println(cnt);
        }
    }
}


Measured memory_bytes: 35852
#include<stdio.h>

int main(){
	int a,b,c;
	int i;
	int ct=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0) ct++;
	}
	printf("%d\n",ct);

	return 0;
}

Measured memory_bytes: 596
N = int(input())
#S = str(input())
#L, R, d = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  if i % 2 == 0:
    if A[i] % 2 == 1:
      ans += 1
      
print(ans)




Measured memory_bytes: 9160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0063
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int cnt = 0;
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) break;
                if (line == string.Join("",line.Reverse())) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }

}



Measured memory_bytes: 18204
def is_palindrome(s):
    is_palindrome = True
    for i in range(len(s) // 2):
        if s[i] != s[len(s) - 1 - i]:
            is_palindrome = False
            break
    
    return is_palindrome

S = input()
n = len(S)
is_strong = True
if not is_palindrome(S):
    is_strong = False
if not is_palindrome(S[:(n - 1) // 2]):
    is_strong = False
if not is_palindrome(S[( n + 3) // 2 - 1:]):
    is_strong = False

if is_strong:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

k, s = map(int, input().split())

ans = 0

for i in range(k+1):
    for j in range(k+1):
        k2 = s - j - i

        if k2 > k or k2 < 0:
            continue

        if s == i + j + k2:
            ans += 1

print(ans)


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

int main(){
  string s;
  cin >> s;
  
  if(count(&s[0],&s[2]+1,'A')==0 || count(&s[0],&s[2]+1,'B')==0)cout << "No";
  else cout << "Yes";

  return 0;
}

Measured memory_bytes: 256
n = (int)(input())
a = list(map(int, input().split(" ")))
temp = [0 for i in range(n + 1)]
aaa = sorted(a)
count = 0
for i in range(n - 1):
  if aaa[i] == aaa[i + 1]:
    count+= 1
  else:
    temp[aaa[i]] = count + 1
    count = 0
else:
  if len(a) == 1:
    temp[aaa[0]] = 1
  else:
    temp[aaa[-1]] = count + 1
ans = 0

#---ここまで231ms

#print(temp)#各数字の出現回数
for i in range(n + 1):
  if temp[i] >= 2:
    ans += temp[i] * (temp[i] - 1) / 2
    
#---ここまでで1553ms

#print(ans)#ansは全体の組み合わせの合計。割れない

for i in range(n):
  kotae = ans
  if temp[a[i]] >= 3:
    #print(ans, comb(temp[a[i]], 2), comb(temp[a[i]] - 1, 2))
    #print(temp[a[i]], i)
    kotae = ans - (temp[a[i]] * (temp[a[i]] - 1) / 2) + ((temp[a[i]] - 1) * (temp[a[i]] - 2) / 2)
  elif temp[a[i]] == 2:
    kotae = ans -1
  print((int)(kotae))

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    string s;
    cin >> s;
    s.push_back('S');
    int count=0;
    int cs=0,ct=0;
    int t=0,l=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='S'){
            if(t==-1){
                l=min(cs,ct);
                count+=l;
                cs-=l;
                ct=0;
            }
            cs++;
            t=1;
        }
        if(s[i]=='T'){
            ct++;
            t=-1;
        }
    }
    cout << s.length()-count*2-1 << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

ll mod_num = 1000000000 + 7;

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i) {
        sum *= i;
        sum %= mod_num;
    }
    return sum;
}

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    ll x, y; cin >> x >> y;
    if((x+y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll use_x_2 = 0;
    rep(i, (x+y)/3) {
        if((use_x_2*2)+((x+y)/3-i) == x) {
            break;
        } else {
            use_x_2++;
        }
    }
    ll use_y_2=0;
    rep(i, (x+y)/3) {
        if((use_y_2*2)+((x+y)/3-i) == y) {
            break;
        } else {
            use_y_2++;
        }
    }
    if(use_x_2+use_y_2 != (x+y)/3) {
        cout << 0 << endl;
        return 0;
    }

    ll div_num = modinv(facctorialMethod(use_x_2)%mod_num * facctorialMethod(use_y_2)%mod_num, mod_num);

    ll tmp = facctorialMethod((x+y)/3) % mod_num;
    ll ans = (tmp * div_num) % mod_num;

    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 256
from functools import reduce


def lcm(a, b):
    ab = a * b
    while b != 0:
        a, b = b, a % b
    return ab // a


def solve(string):
    n, m, *a = map(int, string.split())
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (2 * m + 2 if _a % c or not _a // c % 2 else _a for _a in a))
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 15612
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N;
        static int[] a;
       

        public static void Input()
        {
            var cin = new Scanner();
            N = int.Parse(Console.ReadLine());
            a = cin.SplitReader();
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            Sort(a);
            long ans = 0;
            
            int cnt = 0;
            for (var i = 0; i < N; i++)
            {
                cnt++;
                if (i == N - 1)
                {
                    if (cnt < a[i]) { ans += cnt; }
                    if (cnt > a[i]) { ans += cnt - a[i]; }
                    
                }
                else if (a[i] != a[i + 1])
                {
                    if (cnt < a[i]) { ans += cnt; }
                    if (cnt > a[i]) { ans += cnt - a[i]; }
                    cnt = 0;
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();

        }

       
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 32348
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int Bitroop(int n, int m, vector<int> k, vector<int> p, vector<vector<int>> S)
{
	int ans = 0;
	rep(s, 1 << n) //1をn桁だけ左シフト -> O(2^n)
	{
		//int cost= 0;
		vector<int> d(m,0);
		rep(i, n) //あるパターンにおいて、n個の要素について調べる
		{
			if (s >> i & 1) //1：使う，0：使わない
			{
				//cost += price[i];
				rep(j, m)
					rep(num, k[j])
					if (S[j][num] == i + 1)
						++d[j];
			}
		}
		bool ok = true;
		rep(j, m)
			if (d[j] % 2 != p[j])
				ok = false;
		if (ok)
			++ans;
	}
	return ans;
}

int main()
{
	int N,M;
	cin >> N >> M;
	vector<int> k(M),p(M);
	vector<vector<int>> s(M);
	reps(i, 0, M)
	{
		cin >> k[i];
		reps(j, 0, k[i])
		{
			int x;
			cin >> x;
			s[i].emplace_back(x);
		}
	}
	rep(i, M)
		cin >> p[i];

	cout << Bitroop(N,M,k,p,s) << endl;

	return 0;
}

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

typedef long long ll;
#define endl "\n"

const int M = (int) 1e9+7;
int n,k;
ll ans=1;
vector<ll> pos, neg;
int pcnt=0, ncnt=0;

ll solve(){
    cin>>n>>k;
    for (int i=0; i<n; ++i){
        ll foo; cin>>foo;
        if (foo>0) pos.push_back(foo);
        else neg.push_back(abs(foo));
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    int P=pos.size(), N=neg.size();
    if (k==n ? N%2==0 : P || k%2==0){
        reverse(pos.begin(), pos.end());
        reverse(neg.begin(), neg.end());
        for ( ; k; --k){
            if (pcnt<P && (ncnt>=N || pos[pcnt]>neg[ncnt])){
                ans=ans*pos[pcnt]%M; ++pcnt;
            }
            else{
                ans=ans*neg[ncnt]%M; ++ncnt;
            }
        }
        if (ncnt&1){
            ans=1;
            if (pcnt<P && ncnt>=1 && (ncnt>=N || !pcnt || pos[pcnt]*pos[pcnt-1]>neg[ncnt]*neg[ncnt-1])){
                for (int tt=0; tt<pcnt+1; ++tt)
                    ans=ans*pos[tt]%M;
                for (int tt=0; tt<ncnt-1; ++tt)
                    ans=ans*neg[tt]%M;
            }
            else{
                for (int tt=0; tt<pcnt-1; ++tt)
                    ans=ans*pos[tt]%M;
                for (int tt=0; tt<ncnt+1; ++tt)
                    ans=ans*neg[tt]%M;
            }
        }
        return ans;
    }
    for(; k; --k) {
        if(pcnt<P &&(ncnt>=N || pos[pcnt]<neg[ncnt])) {
            ans=ans*pos[pcnt]%M; ++pcnt;
        }
        else {
            ans=ans*neg[ncnt]%M; ++ncnt;
        }
    }
    return (M-ans)%M;
}

int main(){
    // INT VS LL
    // freopen("input.txt", "r", stdin);
    //    INT VS LL
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<solve();
    return 0;
}


Measured memory_bytes: 5632
H, W = [int(x) for x in input().split()]
ret = 10 ** 9 + 7

def f(a, b, c):
  s = [a[0] * a[1], b[0] * b[1], c[0] * c[1]]
  return max(s) - min(s)

a, b, c = [H // 3] * 3
if H % 3 > 0:
  a += 1
if H % 3 == 2:
  b += 1

ret = min(ret, f([a, W],[b, W],[c, W]))

a, b, c = [W // 3] * 3
if W % 3 > 0:
  a += 1
if W % 3 == 2:
  b += 1

ret = min(ret, f([a, H],[b, H],[c, H]))

a, b = [W // 2] * 2
if W % 2 == 1:
  a += 1
for i in range(1, H):
  t = f([a, H - i],[b, H - i],[i, W])
  ret = min(ret, t)
  
a, b = [H // 2] * 2
if H % 2 == 1:
  a += 1
for i in range(1, W):
  t = f([a, W - i],[b, W - i],[i, H])
  ret = min(ret, t)

print(ret)

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

const int N = 2*1e5+10;

int sz[N];

int main() {
    int n,a;
    cin>>n;
    for(int i=1;i<n;i++) {
        cin>>a;
        sz[a-1]++;
    }
    for(int i=0;i<n;i++) {
        printf("%d\n",sz[i]);
    }
    return 0;
}

Measured memory_bytes: 4476
def main():
    n, m = map(int, input().split())
    p = 2**n
    dp = [10**7]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([2**(int(i)-1) for i in input().split()])
        for s in range(p):
                t = s|c
                if dp[t] > dp[s] + a:
                    dp[t] = dp[s] + a
    ans = dp[-1]
    if ans == 10**7:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 46168
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    int min(int a, int b) {
        if (a >= b) {
            return b;
        }
        return a;
    }

    char s[];
    int n;

    public void solve() throws IOException {
        s = nextToken().toCharArray();
        n = s.length;

        long d[] = new long[26];
        for (int i = 0; i < n; i++) {
            d[s[i] - 'a']++;
        }
        long res = 0;
        for (int i = 0; i < 26; i++) {
            for (int j = i + 1; j < 26; j++) {
                res += d[i]*d[j];
            }
        }
        out.print(res + 1);
    }


    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("sum2.in"));
//            out = new PrintWriter(new File("sum2.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

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

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

Measured memory_bytes: 25704
#include <iostream>

using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  int change_cnt = 0;
  for(int i = 0; i < n; i++) {
    int minj = i;
    for(int j = i; j < n; j++) {
      if(a[j] < a[minj]) {
        minj = j;
      }
    }
    if(minj != i) {
      int tmp = a[i];
      a[i] = a[minj];
      a[minj] = tmp;
      change_cnt++;
    }
  }

  for(int i = 0; i < n; i++) {
    cout << a[i];
    if(i != n-1) cout << " ";
    else cout << endl;
  }
  cout << change_cnt << endl;
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#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 ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    int N;cin>>N;
    int count = 0;
    bool flag = false;
    REP(i,N){
        int d,e;cin>>d>>e;
        if(d == e){
            count++;
            if(count == 3){
                flag = true;
                //break;
            }
        }
        else{
            count = 0;
        }
    }
    cout << (flag ? "Yes" : "No")<<endl;
}



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

int main(){
    ll a, b, n; cin >> a >> b >> n;
    ll res = 0;
    
    if(n<b){
        ll x1 = (a*n/b); 
        ll x2 = n/b; x2 *= a;
        res = x1-x2;
        cout << res << endl;
    }
    else{
        n = b-1;
        ll x1 = (a*n/b); 
        ll x2 = n/b; x2 *= a;
        res = x1-x2;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        String[][] input = new String[N][2];
        for (int i = 0; i < N; i++) {
            String str = sc.nextLine();
            input[i][0] = str.split(" ")[0];
            input[i][1] = str.split(" ")[1];
        }
        double ans = 0.0;
        for (int i = 0; i < input.length; i++) {
            double price = Double.parseDouble(input[i][0]);
            double samePrice = input[i][1].equals("JPY") ? price : price * 380000;
            ans += samePrice;
        }
        System.out.println(ans);
    }
}


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


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


int main(){
	ll A,B,C;
	cin>>A>>B>>C;
	ll count=0;
	
	REP(i,10000){
		if(A%2==1||B%2==1||C%2==1) break;
		
		ll a,b,c;
		a=(B+C)/2;
		b=(C+A)/2;
		c=(A+B)/2;
		
		A=a;
		B=b;
		C=c;
		count++;
	}
	
	if(count==10000) cout<<-1<<endl;
	else cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	cin >> N;
	vector<ll>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];

	ll ans = A[0]-1;
	ll cur = 2;
	for (int i = 1; i < N; i++) {
		if (cur > A[i])continue;
		else if (cur == A[i])cur++;
		else ans += (A[i] - 1) / cur;
	}
	puts(ans);
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
#define MAX 2000000000
using ll = long long;
using Graph = vector<vector<int>>;
//二項係数を求める。

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

Measured memory_bytes: 256
from collections import deque

s = deque(list(input()))
q = int(input())
head = 0

for i in range(q):
    L = list(input().split())
    if L[0] == '1' :
        head = (head + 1)%2
    if L[0] == '2' :
        if head == 0:
            if L[1] == '1' :
                s.appendleft(L[2])
            if L[1] == '2' :
                s.append(L[2])
        if head == 1:
            if L[1] == '1' :
                s.append(L[2])
            if L[1] == '2' :
                s.appendleft(L[2])
if head == 0:
    print(''.join(s))
else: 
    print(''.join(reversed(s)))


Measured memory_bytes: 8420
#define Link "https://arc074.contest.atcoder.jp/tasks/arc074_d?fbclid=IwAR1u2WnBRSm0lLs0cqi_vsg5Ne3D8MWtHeTec3YuJGfEQHdq9CtY2QFdpYQ"

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

#define TASK "atcoder_arc074F"

using namespace std;

const int maxn = 2e2 + 10;
int h,w,S,T,cnt,_u[maxn*maxn],_v[maxn*maxn],cf[maxn*maxn*2],d[maxn*2];
vector <int> e[maxn*2];
vector <int> :: iterator key[maxn*2];
queue <int> qu;

void Connect(int u, int v, int d)
{
    ++cnt;
    _u[cnt] = u;
    _v[cnt] = v;
    cf[cnt*2] = d;
    cf[cnt*2+1] = d;
    e[u].push_back(cnt*2);
    e[v].push_back(cnt*2+1);
}

void Enter()
{
    cin >> h >> w;
    for (int i=1;i<=h;++i)
        for (int j=1;j<=w;++j) {
            char a;
            cin >> a;
            if (a == 'S') {
                Connect(0,i,1e9);
                Connect(i,j+h,1e9);
            }
            if (a == 'T') {
                Connect(w+h+1,i,1e9);
                Connect(j+h,w+h+1,1e9);
            }
            if (a != '.')
                Connect(i,j+h,1);
        }
}

void Init()
{

}

bool BFS()
{
    fill(d,d+h+w+10+1,-1);
    d[S] = 0;
    qu.push(S);
    while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        key[u] = e[u].begin();
        for (int i : e[u]) {
            int v = _u[i/2] + _v[i/2] - u;
            if (d[v] == -1 && cf[i] != 0) {
                d[v] = d[u] + 1;
                qu.push(v);
            }
        }
    }
    return d[T] != -1;
}

int DFS(int u, int val)
{
    if (u == T || val == 0)
        return val;
    int X = 0;
    for (;key[u]!=e[u].end();++key[u]) {
        int i = *key[u];
        int v = _u[i/2]  + _v[i/2] - u;
        if (d[v] == d[u] + 1) {
            int k = DFS(v,min(val,cf[i]));
            X += k;
            cf[i] -= k;
            cf[i^1] += k;
            val -= k;
        }
        if (val == 0)
            break;
    }
    return X;
}

void Solve()
{
    S = 0;
    T = h + w + 1;
    int res = 0;
    while (BFS())
        res += DFS(S,1e9);
    if (res == 1e9)
        cout << -1;
    else
        cout << res;
}

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

#ifdef LHL
    freopen(".INP","r",stdin);
    freopen(".OUT","w",stdout);
#else
//    freopen(TASK".INP","r",stdin);
//    freopen(TASK".OUT","w",stdout);
#endif // LHL

    Enter();
    Init();
    Solve();
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>

using namespace std;

int main(void){
  int a,b,c,d;
  
  cin>>a>>b>>c>>d;
  
  if(abs(a-c)<=d)
    cout<<"Yes"<<endl;
  else if(abs(a-b)<=d&&abs(c-b)<=d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;

}

Measured memory_bytes: 256