akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int h;
  h = n / 3600;
  n -= 3600 * h;
  int m;
  m = n / 60;
  n -= 60 * m;
  int s = n;
  std::cout << h << ":" << m << ":" << s << std::endl;
  return 0;
}

Measured memory_bytes: 3076
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int h,w,ans;
  scanf("%d%d",&h,&w);
  if(h%3==0 || w%3==0){
    printf("0\n");
    return 0;
  }
  ans=min(h,w);
  int Smax=w*(h/3), Smin=w*(h/3);
  Smax=max(Smax,(h-h/3)*(w/2));
  Smax=max(Smax,(h-h/3)*((w+1)/2));                          
  Smin=min(Smin,(h-h/3)*(w/2));
  Smin=min(Smin,(h-h/3)*((w+1)/2));
  ans=min(ans,Smax-Smin);
  
  Smax=w*(h/3+1), Smin=w*(h/3+1);
  Smax=max(Smax,(h-h/3-1)*(w/2));
  Smax=max(Smax,(h-h/3-1)*((w+1)/2));                          
  Smin=min(Smin,(h-h/3-1)*(w/2));
  Smin=min(Smin,(h-h/3-1)*((w+1)/2));
  ans=min(ans,Smax-Smin);
  
  Smax=h*(w/3), Smin=h*(w/3);
  Smax=max(Smax,(w-w/3)*(h/2));
  Smax=max(Smax,(w-w/3)*((h+1)/2));                          
  Smin=min(Smin,(w-w/3)*(h/2));
  Smin=min(Smin,(w-w/3)*((h+1)/2));
  ans=min(ans,Smax-Smin);
  
  Smax=h*(w/3+1), Smin=h*(w/3+1);
  Smax=max(Smax,(w-w/3-1)*(h/2));
  Smax=max(Smax,(w-w/3-1)*((h+1)/2));                          
  Smin=min(Smin,(w-w/3-1)*(h/2));
  Smin=min(Smin,(w-w/3-1)*((h+1)/2));
  ans=min(ans,Smax-Smin);
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import io.StdIn._
 
object Main extends App {
  val n   = readInt()
  val seq = readLine().split(" ").map(_.toInt).toSeq
 
  require(2 <= n && n <= 100)
  require(seq.forall(_ <= 100000))
 
  println(
    seq.zipWithIndex
      .foldLeft(Seq.empty[Int])((s, a) => seq.lift(a._2 - 1).map(b => s.appended(b.min(a._1))).getOrElse(Seq(a._1)))
      .sum + seq.last
  )
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  
    int T=1;
    //cin >> T;
    while(T--){
        ll n,m;
        cin>>n>>m;
        ll a[n];
        ll s=0;
        rep(i,n){
            cin>>a[i];
            s+=a[i];
        }
        sort(a,a+n,greater<>());
        ll z;
        if(s%(4*m)==0) z=s/(4*m);
        else z=s/(4*m)+1;
        int f=1;
        rep(i,m){
            if(a[i]<z) f=0;
        }
        if(f) cout<<"Yes"<<el;
        else cout<<"No"<<el;
    }

    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H, W; cin >> H >> W;
  if (H % 3 == 0 || W % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  auto g = [&](ll a, ll b, ll c) -> ll {
    return max(max(a, b), c) - min(min(a, b), c);
  };
  auto f = [&](ll x, ll y) -> ll {
    ll vmin = LLONG_MAX;
    for (ll p = 0; p <= 1; p++) {
      for (ll q = 0; q <= 1; q++) {
	ll xx = x / 3 + p;
	ll yy = y / 2 + q;
	vmin = min(vmin, g(xx * y, (x - xx) * yy, (x - xx) * (y - yy)));
      }
    }
    vmin = min(vmin, g(x/3 * y, x/3 * y, (x/3 + 1) * y));
    return vmin;
  };
  cout << min(f(H, W), f(W, H)) << endl;

  return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n;
	VVI dp(n*2+1000,VI(3,-INF));
	VVI val(n,VI(3));
	rep(i, n) cin >> val[i][0]>>val[i][1]>>val[i][2];

	//初期条件
	rep(i,n) dp[0][i]=val[0][i];
	rep(i,n-1){
		//次の日
		rep(j,3){
			//今日
			rep(k,3){
			if(j==k) continue;
			//kー＞ｊに移る
			//次の日の幸福度j番目＝今の幸福度k番目＋次にもらえる幸福度j番目
			ll happiness = val[i+1][j];
			dp[i+1][j] = max(dp[i+1][j], dp[i][k]+happiness);
			}
		}
	}
	res=MAX(dp[n-1]);
	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 16768
N = int(input())

mod = 10 ** 9 + 7

def C(n, r, mod):
    num = 1
    den = 1
    for i in range(r):
        num *= n-i
        den *= i+1
    return (num * pow(den, mod-2, mod)) % mod

count = N // 3
ans = 0

while count != 0:
    n = N - count*2-1
    r = count - 1
    ans += C(n, r, mod)
    count -= 1
    
print(ans % mod)

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

  int N ;
  int ans = 0 ;
  cin >> N ;
  vector<string> A(N) ;
  vector<int> B(N) ;
  rep(i,N){
    cin >> A.at(i) >> B.at(i) ;
  }
  string S ;
  cin >> S ;
  rep(i,N){
    if( S == A.at(i) ){
      //cout << i << endl ;
		for(int j = i+1 ; j < N ; j++ ){
          ans += B.at(j) ;
          if(j == N-1){
			cout << ans << endl;
            return 0 ;
          }
        }
    }
  }
  cout << ans << endl;
  return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main() {
  int n,i,j,l;
  double s[10020];
  double a2,m,a;
   
  while(1) {
    m=0;
    a2 = 0;
    scanf("%d" , &n);
    if(n == 0) {
      break;
    }
 
    for(i=0;i<n;i++) {
      scanf("%lf", &s[i]);
    m=m+s[i];
    //printf("m[%d] = %lf\n",i ,m);
    }
    m=m/n;
 
    for(i=0; i<n; i++) {
      a2 =a2+(s[i]-m)*(s[i]-m);
    }
    a2 = a2/n;
 
    printf("%.11lf\n",sqrt(a2));
 
  }
 
  return 0;
 
}


Measured memory_bytes: 2088
// 9/19 リアルタイム参加
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

    int n = S.size();
    if (S[n-1] == 's') {
        cout << S << "es" << endl;
    } else {
        cout << S << "s" << endl;
    }



}

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

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5, mod = 1e9 + 7;

int n;
int siz[N], mul[N], ans[N];
vector<int> g[N];

int pw(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1)
			res = (ll)res * x % mod;
		x = (ll)x * x % mod;
		y >>= 1;
	}
	return res; 
}

void dfs(int u, int fa) {
	siz[u] = 1, mul[u] = 1;
	for (auto v : g[u]) 
		if (v != fa) {
			dfs(v, u);
			siz[u] += siz[v];
			mul[u] = (ll)mul[u] * mul[v] % mod;
		}
	mul[u] = (ll)mul[u] * siz[u] % mod;
}

void dfs2(int u, int fa, int fromFa) {
	if (u != 1)
		ans[u] = (ll)mul[u] * pw(siz[u], mod - 2) % mod * n % mod * fromFa % mod;
	else 
		ans[u] = (ll)mul[u] * fromFa % mod; 
	for (auto v : g[u]) 
		if (v != fa) {
			int tmp = (ll)fromFa * mul[u] % mod * pw(mul[v], mod - 2) % mod * pw(siz[u], mod - 2) % mod * (n - siz[v]) % mod;
			dfs2(v, u, tmp);
		}
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 0);
	dfs2(1, 0, 1);
	int x = 1;
	for (int i = 1; i <= n; i++)
		x = (ll)x * i % mod;
	for (int i = 1; i <= n; i++)
		cout << (ll)x * pw(ans[i], mod - 2) % mod << '\n';
	return 0; 
}

Measured memory_bytes: 16244
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  REP(j,m) cin >> b[j];
  vector<vector<int>> a(n,vector<int>(m));
  int cnt = 0;
  REP(i,n) {
    REP(j,m) {
      cin >> a[i][j];
    }
  }
  REP(i,n) {
    int sum = c;
    REP(j,m) sum += b[j] * a[i][j];
    if(sum > 0) cnt++;
  }
  cout << cnt << endl;
}

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

int main(void){

  int N[30],n;

  for(int i=0 ; i < 30 ; i++){
    N[i]=1;
  }
  
  for(int i=0; i < 28 ; i++){
    cin >> n;
    N[n-1]=0;
  }

  for(int i=0 ; i < 30 ; i++){ 
    if(N[i] == 1){
      cout <<i+1<<endl;
    }
  }
  return 0;
  
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  cout << "ABC" << N << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int num[3];
int main() {
		int a, b, c; cin>>a>>b>>c;
		if(a>b) swap(a,b);
		int cnt = 0;
		for(int i=a;i<=b;i++) {
			if(c%i==0) cnt++; 
		}
		cout<<cnt<<endl;
	
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

class BinomialCoefficient {
int pow(int x, int p) {
    int ans = 1;
    while(p) {
        if(p % 2) ans = ((long long)ans * x) % prime;
        x = ((long long)x * x) % prime;
        p /= 2;
    }
    return ans;
}
public:
    int prime;
    vector <int> f, inv_f;
    BinomialCoefficient(int maxN, int prime = 1e9 + 7) {
        this->prime = prime;
        f.assign(maxN + 1, 1);
        inv_f.assign(maxN + 1, 1);
        inv_f[0] = pow(1, prime - 2);
        for(int i = 1; i <= maxN; i++) {
            f[i] = (long long)f[i - 1] * i % prime;
            inv_f[i] = pow(f[i], prime - 2);
        }
    }
    int choose(int N, int K) {
        return (((long long)f[N] * inv_f[N - K] % prime) * inv_f[K]) % prime;
    }
};

const int MOD = 1e9 + 7;struct ModularInt{int n;ModularInt(int n_=0):n(n_){}};
ModularInt operator-(ModularInt a){return -a.n+MOD*(a.n!=0);}
ModularInt operator+(ModularInt a,ModularInt b){int x=a.n+b.n;return x-(x>=MOD)*MOD;}
ModularInt operator-(ModularInt a,ModularInt b){int x=a.n-b.n;return x+(x<0)*MOD;}
ModularInt operator*(ModularInt a,ModularInt b){return (long long)a.n*b.n%MOD;}
ModularInt &operator+=(ModularInt &a,ModularInt b){return a=a+b;}
ModularInt &operator-=(ModularInt &a,ModularInt b){return a=a-b;}
ModularInt &operator*=(ModularInt &a,ModularInt b){return a=a*b;}
istream &operator>>(istream &i,ModularInt &a){return i>>a.n;}
ostream &operator<<(ostream &o,ModularInt a){return o<<a.n;}
int N, M, K;

BinomialCoefficient binomialCoefficient(200005, MOD);

ModularInt solve(int n, int m, int k) {
    ModularInt bc = binomialCoefficient.choose(n * m - 2, k - 2);
    ModularInt ans = 0;
    for(int d = 1; d < m; d++) {
        ans += (ModularInt)d * n * n * (m - d) * bc;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M >> K;
    cout << solve(N, M, K) + solve(M, N, K) << endl;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val nLine = readLine()!!.toInt()
    val values = arrayOfNulls<Int>(nLine)
    for (i in 0..nLine-1) {
        val value = readLine()!!.toInt()
        values[i] = value
    }

    val maxValues = arrayOfNulls<Int>(nLine-1)
    val minValues = arrayOfNulls<Int>(nLine-1)
    val diffValues = arrayOfNulls<Int>(nLine-1)

    var currentMax = values[nLine-1]!!
    for (i in 0..nLine-2) {
        val startIndex = nLine-1-i
        val currentValue = values[startIndex]!!
        currentMax = Math.max(currentMax, currentValue)
        maxValues[startIndex-1] = currentMax
    }

    var currentMin = values[0]!!
    for (i in 0..nLine-2) {
        val currentValue = values[i]!!
        currentMin = Math.min(currentMin, currentValue)
        minValues[i] = currentMin
    }

    for (i in 0..nLine-2) {
        diffValues[i] = maxValues[i]!! - minValues[i]!!
    }

    var maxDiff = Int.MIN_VALUE
    for (i in 0..nLine-2) {
        maxDiff = Math.max(maxDiff, diffValues[i]!!)
    }

    println(maxDiff)
}


Measured memory_bytes: 60296
n, m = [int(_) for _ in input().split()]
b = [[int(_) for _ in input().split()] for __ in range(m)]
p = [int(_) for _ in input().split()]
ans = 0
for i in range(2**n):
    s = format(i, '0'+str(n)+'b')
    for j in range(m):
        on = 0
        for k in range(b[j][0]):
          on += int(s[b[j][k+1]-1])
        on %= 2
        if p[j] != on:
          break
    else : ans += 1
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n = 5;
        vector<int> v(n);
        rep(i, 0, n) cin >> v[i];

        sort(all(v), [](int a, int b) {
            if (a % 10 == 0) return true;
            if (b % 10 == 0) return false;
            return (a % 10) > (b % 10);
        });

        int ans = 0;
        for (int i = 0; i < n; ++i) {
            if (ans % 10) {
                ans += 10;
                ans -= ans % 10;
            }
            ans += v[i];
        }

        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())


struct UnionFind
{
    vector<int> d;
    UnionFind(int n = 0) : d(n, -1) {}
    int root(int x)
    {
        if (d[x] < 0)return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (-d[x] < -d[y])swap(x, y); //y.size()が小でx.size()が大にしておきたい
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -d[root(x)]; }
};

ll deg_size(int a)
{
    ll ans;
    ans = (ll) (a - 1) * (ll)a / 2;
    return ans;
}

int main()
{
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<int> A(m);
    vector<int> B(m);
    vector<ll> free(m+1);
    free[m] = 0;
    rep(i,m)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        A[i] = a;
        B[i] = b;

    }
    for (int i = m-1; i >=0; i--)
    {
        free[i] = free[i+1];
        ll sub1, sub2;
        sub1 = deg_size(uf.size(A[i]));
        sub2 = deg_size(uf.size(B[i]));
        bool ok = uf.unite(A[i], B[i]);
        if (ok)
        {
            free[i]= free[i] + deg_size(uf.size(A[i])) - sub1 - sub2; 
        }
    }
    ll ans;
    ans = (ll)n*(n-1)/2;
    for (int i = 1; i < m+1; i++)
    {
        cout << ans - free[i] << endl;
    }
    
}

Measured memory_bytes: 3328
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){var e=t.in(),n=t.in(),r=t.in(),i=t.in(),s=e*n-r*n-i*e+r*i;console.log(s)}}]);

Measured memory_bytes: 7500
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
#define SIZE 200005
#define read(a,n) for(i=0;i<n;i++)cin>>a[i];
#define pii pair<int,int>
#define pb push_back
#define forn for(i = 0; i < n; i++)
using namespace std;
typedef	long long ll;
ll n, m, i, j, k, h, t, maxn, ttt, t1, t2, sig = 0;
multiset<ll>st;
ll a[1005], b[1005], c[1005];
bool cmp(ll a, ll b) {
	return a > b;
}
int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x, y, z;
	cin >> x >> y >> z >> t;
	read(a, x);
	read(b, y);
	read(c, z);
	sort(a, a + x, cmp);
	sort(b, b + y, cmp);
	sort(c, c + z, cmp);
	priority_queue<ll, vector<ll>, greater<ll>>q;
	for (i = 0; i < x; i++) {
		for (j = 0; j < y; j++) {
			for (k = 0; k < z; k++) {
				if (q.size() < t) q.push(a[i] + b[j] + c[k]);
				else {
					if (q.top() < a[i] + b[j] + c[k]) {
						q.pop();
						q.push(a[i] + b[j] + c[k]);
					}
					else break;
				}
			}
		}
	}
	vector<ll>s(t + 1);
	j = 0;
	for (i = 0; i < t; i++) {
		s[j++] = q.top();
		q.pop();
	}
	for (i = 0; i < j; i++) {
		cout << s[j - i - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int cnt = 0;
        rep (i, 1, n - 1) {
            rep (j, i + 1, n) {
                int k = x - i - j;
                if (k > n) continue;
                if (k <= j) break;
                // cout << i << j << k << "\n";
                cnt++;
            }
        }
        cout << cnt << "\n";
    }
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
 double dp[301][301][301];
 void ini()
 {
     for(ll i=0;i<301;i++)
     {
         for(ll j=0;j<301;j++)
         {
             for(ll k=0;k<301;k++)
             dp[i][j][k]=-1;
         }
     }
 }
 double f(ll a,ll b,ll c,ll n)
 {   if(a==-1 || b==-1 || c==-1)
     return 0;
     else if(dp[a][b][c]!=-1)
     return dp[a][b][c];
     else
     {
         
             double k1=a+b+c;
             double k=double(n)/k1;
             double a1=double(a)/k1;
             double b1=double(b)/k1;
             double c1=double(c)/k1;
             dp[a][b][c]=k+a1*f(a-1,b,c,n)+b1*f(a+1,b-1,c,n)+c1*f(a,b+1,c-1,n);
             return dp[a][b][c];
        
    }
 }
int main()
{
   ll n;
   cin>>n;
   ini();
   ll cnt1=0;
   ll cnt2=0;
   ll cnt3=0;
   ll d;
   for(ll i=0;i<n;i++)
   {
       cin>>d;
       if(d==1)
       cnt1++;
       else if(d==2)
       cnt2++;
       else 
       cnt3++;
   }
   dp[0][0][0]=0;
  double ans=f(cnt1,cnt2,cnt3,n);
  cout<<setprecision(12);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 213376
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

ll gcd(ll a, ll b){
    if(a%b == 0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}

int main()
{
    int n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll gcdd=a[0];
    for(int i=1;i<n;i++){
        gcdd=gcd(gcdd,a[i]);
    }
    sort(rall(a));
    if(k<=a[0]&&k%gcdd==0){
        cout<<"POSSIBLE"<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, D, X, res; cin >> N >> D >> X;
    res = 0;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        int Ai = A[i];
        res++;
        for (int j = 1; j*Ai+1 <= D; j++)
        {
            res++;
        }
    }

    cout << (res + X) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mem[45][45][45];
int G[45][45];
ll dp(int s, int t, int u){
    if (s == u) return 1;
    else if (s == t || t == u) return 0;
    if (mem[s][t][u] != -1) return mem[s][t][u];
    //printf("%d %d %d\n",s,t,u);
    ll ans = 0;
    for (int p1 = s; p1 < t; p1++){
        for (int p2 = t+1; p2 <= u; p2++){
            //printf("can take %d-%d\n",p1,p2);
            for (int r1 = s; r1 <= p1; r1++){
                for (int r2 = p2; r2 <= u; r2++){
                    if (G[r1][r2] == 0) continue;
                    //printf("+%lld*%lld*%lld\n",dp(s,r1,p1),dp(p1+1,t,p2-1),dp(p2,r2,u));
                    ll num = dp(s,r1,p1)*dp(p1+1,t,p2-1)*dp(p2,r2,u);
                    //printf("if take %d-%d: add %lld\n",r1,r2,num);
                    ans += num;
                }
            }
        }
    }
    //printf("%d %d %d: %lld\n",s,t,u,ans);
    return mem[s][t][u] = ans;
}
int main(){
	int n;
	scanf("%d",&n);
	for (int i = 0; i < 2*n; i++){
        for (int j = 0; j < 2*n; j++){
            char x;
            scanf(" %c",&x);
            G[i][j] = x-'0';
        }
	}
	memset(mem,-1,sizeof(mem));
	ll ans = 0;
	for (int i = 1; i <= 2*n-1; i++){
        if (G[0][i]){
            ans += dp(1,i,2*n-1);
            //printf("if take 0-%d, %lld\n",i,dp(1,i,2*n-1));
        }
	}
	printf("%lld",ans);
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>
int main ( void ) {
    char input;int i,len;
    while(1){
    scanf("%c",&input);
        if(input=='\n') break;
        if(islower(input)){
            input=toupper(input);
        }
        if(input==' '){
            printf(" ");
        }else if(input=='.'){
            printf(".");
        }else printf("%c",input);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  //cout<<S.at(0)<<S.at(1)<<S.at(2)<<endl;
  int N=S.size();//cout<<N<<endl;
  vector<int>a(N+10);
  //for(int i=0;i<N+1;i++){cout<<a.at(i)<<endl;}
   for(int i=0;i<N;i++){
    if(S.at(i)=='<'){a.at(i+1)=a.at(i)+1;}
  } //cout<<S.at(N-1)<<endl;
  //for(int i=0;i<N+1;i++){cout<<a.at(i);}cout<<a.size()<<endl;

  for(int i=N-1;i>=0;i--){
    if(S.at(i)=='>'){a.at(i)=max(a.at(i),a.at(i+1)+1);}
  }
  //for(int i=0;i<N+1;i++){cout<<a.at(i);}cout<<endl;
   //for(int i=0;i<N;i++){cout<<a.at(i)<<" ";}//cout<<endl;//
   
  int64_t sum=0;
  for(int i=0;i<N+1;i++){
    sum+=a.at(i);
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 2820
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int c = 0;
            while (sc.hasNext()) {
                int n = Integer.parseInt(sc.nextLine());
                if (isPrimeNumber(n)) {
                    ++c;
                }
            }
            System.out.println(c);
        } catch (NoSuchElementException | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static boolean isPrimeNumber(int n) {
        int compositeNumber = (int)Math.pow(n, 0.5);
        for (int i = 2; i <= compositeNumber; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    private static class IllegalTestCaseException extends RuntimeException {
        IllegalTestCaseException() {
            super("Illegal condition.");
        }
    }
}



Measured memory_bytes: 66296
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var v = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var c = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (v[i] - c[i] > 0) ans += v[i] - c[i];
        }
        Console.WriteLine(ans);
    }
}

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

int main() {
  int len;
  string s;
  cin >> len;
  cin >> s;
  int occ = 0;
  for (int i = 0; i < len; ++i) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
      ++occ;
  }
  cout << occ;
}

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

void solve(std::string S)
{
    S.replace(0, 4, "2018");
    cout << S << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	int n, q;
	long a[1000], c[1000];

	cin >> n;

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

	cin >> q;

	for (int i = 0; i < q; i++) {
		int b, e;
		cin >> b >> e;

		memset(c, 0, sizeof(c));

		for (int i = 0; i < e - b; i++)
			c[i] = a[b + i];

		for (int i = 0; i < e - b; i++)
			a[b + i] = c[e - b - i - 1];
	}

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

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(),greater<int>())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define VLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define VSTR(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,x,y,z,ans=100000000,ans2=0,cnt=0;
string s,S,t;
bool flag=false;
int main() {
long double x;
ios_base::sync_with_stdio(false);
cin>>S;n=S.size();
for(int i=2;i<n-1;i++){
  if(S[i]=='C'){
    cnt++;
    a=i;
  }
}
if(cnt!=1){
  cout <<"WA"<<endl;
   return 0;
}
REP(i,n){
  if(i!=0&&a!=i){
    if(isupper(S[i])){
    cout <<"WA"<<endl;
    return 0;
  }
 }
}
if(S[0]!='A'){
 cout << "WA";
   return 0;
}
cout <<"AC";
   return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    public class Main {

        public static void main(String[] args) throws IOException {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String l = br.readLine();

            if(l.charAt(2) == l.charAt(3) && l.charAt(4) == l.charAt(5)){
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }

        }
    }
//int lines = Integer.parseInt(br.readLine());
//
//            for(int i = 0; i < lines; i++){
//                String [] info = br.readLine().split(" ");
//                int n = Integer.parseInt(info[0]);
//                int a = Integer.parseInt(info[1]);
//                int b = Integer.parseInt(info[2]);
//                int c = Integer.parseInt(info[3]);
//                int d = Integer.parseInt(info[4]);
//                int maxSum = n*(a+b);
//                int minSum = n*(a-b);
//                int tMin = c-d;
//                int tMax = c+d;
//
//
//                if((minSum >= tMin && minSum <= tMax) || (maxSum >= tMin && maxSum <= tMax)){
//                    System.out.println("Yes");
//                }
//                else{
//                    System.out.println("No");
//                }
//            }


Measured memory_bytes: 22484
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
int d;
int c[30]={};
int s[370][30];
int calc(vector<int>const& t){
  int res=0;
  vector<int> last(26,0);
  rep1(i,d){
    res+=s[i][t[i]];
    last[t[i]]=i;
    int buf=0;
    rep1(j,26){
      buf+=c[j]*(i-last[j]);
    }
    res-=buf;
    cout<<res<<"\n";
  }
  return res;
}
signed main(){
  cin>>d;
  rep1(i,26)cin>>c[i];
  rep1(i,d){
    rep1(j,26)cin>>s[i][j];
  }
  vector<int> t(d+1,0);
  rep1(i,d)cin>>t[i];
  calc(t);
  //cout<<calc(t)<<"\n";
  return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n, l; cin >> n >> l;
  vector<string> vec(n);
  rep(i, n) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  rep(i, n) {
    cout << vec.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

int main(){
	int n, m; scan(n, m);
	printf("%d\n", n*(n-1)/2 + m*(m-1)/2);
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val (x, y) = (sc.nextInt(), sc.nextInt())
    debug(x, y)

    (x + y / 2).toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


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

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

ll n;
ll arr[100001];

ll dp[100001];

ll util(ll i){
	if(i>=n-1) return 0;

	if(dp[i]!=-1) return dp[i];

	ll a=inf, b=inf;

	if(i<n-2) a = abs(arr[i]-arr[i+2]) + util(i+2);
	b = abs(arr[i]-arr[i+1]) + util(i+1);

	return dp[i] = min(a,b);
}

void alpha(){

	cin>>n;
	memset(dp, -1, sizeof(dp));
	
	loop(i,0,n) cin>>arr[i];

	cout<<util(0)<<endl;

	return;

}

int main(){

	ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

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

using namespace std;

int const N = 1234567;

int a[N], b[N];
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	long long have = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] < a[i]) {
			have += a[i] - b[i];
			b[i] = a[i];
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] < b[i]) {
			int can = (b[i] - a[i]) / 2;
			can = (int) min((long long) can, have);
			have -= can;
			a[i] += can * 2;
		}
	}
	if (have > 0) {
		puts("No");
		return 0;
	}
	puts("Yes");
}


Measured memory_bytes: 2304
#include<stdio.h>
int table[100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",table+i);
		int ret=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<a-1;j++){
				if(table[j]>table[j+1]){
					ret++;
					int val=table[j];
					table[j]=table[j+1];
					table[j+1]=val;
				}
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!

h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0
for si in range(2 ** h):
    for sj in range(2 ** w):
        count = 0
        for i in range(h):
            for j in range(w):
                if si>>i & 1:
                    continue
                if sj>>j & 1:
                    continue
                if c[i][j] == "#":
                    count += 1
        if count == k:
            ans += 1
print(ans)            
        

Measured memory_bytes: 9196
#[allow(dead_code)]
fn main() {
    let (n,k) = i::u2();
    let mut ans = 1;
    for _ in 0..n {
        if ans < k {
            ans *= 2;
        } else {
            ans += k;
        }
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn u4() -> (usize, usize, usize, usize) {
        (read(), read(), read(), read())
    }

    pub fn u5() -> (usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read())
    }

    pub fn u6() -> (usize, usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn iv3(n: usize) -> Vec<(i64, i64, i64)> {
        (0..n).map(|_| iv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv4(n: usize) -> Vec<(usize, usize, usize, usize)> {
        (0..n)
            .map(|_| uv(4))
            .map(|a| (a[0], a[1], a[2], a[3]))
            .collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int main()
{
    int n,i;
    char tmp_c[12];
    string tmp;
    map<string,int> mp;
    map<string, int>::iterator itr;
    long res,count;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++)
    {
        scanf("%s",tmp_c);
        sort(tmp_c,tmp_c+10);
        tmp = tmp_c;
        mp[tmp] = mp[tmp] + 1;
    }
    
    res = 0;
    for(itr=mp.begin();itr!=mp.end(); itr++)
    {
        count = itr->second;
        count = count - 1;
        res = res + (((count + 1) * count) / 2);
        
    }
    
    printf("%ld\n",res);
    
    return 0;
}



Measured memory_bytes: 11136
#include <cstdio>
#include <cmath>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, eor, a[100];
const int MOD = 1000000007;
int dp[101][256][101];

LL f(LL x) {
	if(x == 0) { return 1; }
	return (x * f(x - 1)) % MOD;
}

int main() {
	scanf("%d%d", &n, &eor);
	inc(i, n) { scanf("%d", &a[i]); }
	
	dp[0][0][0] = 1;
	inc(i, n) {
		inc(j, 256) {
		inc(k,   n) {
			(dp[i + 1][j][k] += dp[i][j][k]) %= MOD;
			(dp[i + 1][ j ^ a[i] ][k + 1] += dp[i][j][k]) %= MOD;
		}
		}
	}
	
	LL ans = 0;
	inc1(k, n) {
		(ans += f(k) * dp[n][eor][k]) %= MOD;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


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


typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  int n,memo,ans=0,k,M=0,m; cin>>n;
  
  set<int> s;
  set<int> kabu;
  vec v(n);
  rep(i,n){cin>>v[i]; M=max(M,v[i]);}
  sort(v.begin(), v.end());
  for(int i=1;i<n;i++)if(v[i]==v[i-1])kabu.insert(v[i]);
  
  
  rep(i,n)s.insert(v[i]);
  
 /* 
  for(auto x:s){
    if(!kabu.count(x))ans++;
    memo=x;
    k=min(1000009,M)/memo+1;
    for(int i=1;i<=k;i++){s.erase(memo*i);}
  }
  
  */
  
  while(s.size()){
    int x=*begin(s);
    
    if(!kabu.count(x))ans++;
    memo=x;
    k=min(1000009,M)/memo+1;
    for(int i=1;i<=k;i++){s.erase(memo*i);}
    //m=s.size()
    //if(m==0)break;
  }


  cout<<ans<<endl;
}

Measured memory_bytes: 13496
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
	int a,ans = 0;
	cin >> a;
	int n[a];
	for (int i = 0; i < a; ++i)
	{
		cin >> n[i];
	}

	for (int i = 0; i < a-2; ++i)
	{
		if (n[i+1] > n[i] && n[i+1] < n[i+2] || n[i+1] < n[i] && n[i+1] > n[i+2])
		{
			ans++;
		}
	}
	cout << ans;

    return 0;
}

Measured memory_bytes: 256