akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

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

  ll n, k;
  cin >> n >> k;

  vll minus, plus, zero;
  rep(i, n) {
    ll tmp;
    cin >> tmp;
    if (tmp > 0) {
      plus.emplace_back(tmp);
    } else if (tmp == 0) {
      zero.emplace_back(tmp);
    } else {
      minus.emplace_back(tmp);
    }
  }

  sort(all(plus));
  sort(all(minus));

  ll ptn_minus = minus.size() * plus.size();
  ll ptn_plus = minus.size() * (minus.size() - 1) / 2 + plus.size() * (plus.size() - 1) / 2;
  ll ptn_zero = n * (n - 1) / 2 - ptn_minus - ptn_plus;

  if (ptn_minus < k && k <= ptn_minus + ptn_zero) {
    cout << 0 << endl;
    return 0;
  }

  ll l, r;

  if (k <= ptn_minus) {
    l = -1e18 - 10;
    r = -1;

    while (l < r) {
      ll c = (l + r) / 2;

      ll cand = 0;
      // k番目はマイナスになる
      rep(i, minus.size()) {
        ll t = c / minus[i] + 1;
        cand += plus.size() - distance(plus.begin(), lower_bound(all(plus), t));
      }
      if (cand >= k) {
        r = c - 1;
      } else {
        l = c;
      }
    }

  } else {
    l = 1;
    r = 1e18 + 10;

    while (l < r) {
      ll c = (l + r) / 2;

      ll cand = 0;

      rep(i, minus.size()) {
        ll t = c / minus[i];
        ll d = distance(minus.begin(), lower_bound(all(minus), t));
        chmax(d, i + 1);
        cand += minus.size() - d;
      }

      rep(i, plus.size()) {
        ll t = c / plus[i];
        ll d = distance(plus.begin(), upper_bound(all(plus), t));
        if (d - i - 1 > 0) {
          cand += d - i - 1;
        }
      }

      cand += ptn_minus + ptn_zero;

      if (cand >= k) {
        r = c;
      } else {
        l = c + 1;
      }
    }
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 10007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

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

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/
int cost[100100];
int n;
struct edge{
    int to;
    int cost;
};
vector<edge> es[100100];
bool used[100100]={};
void dfs(int s){
    used[s]=true;
    for(int i=0;i<es[s].size();i++){
        if(used[es[s][i].to]==false){
            cost[es[s][i].to]=cost[s]+es[s][i].cost;
            dfs(es[s][i].to);
        }
    }
}
signed main(){
    int n;
    cin>>n;
    int a[214514];
    for(int i=0;i<n;i++)cin>>a[i];
    int l[210000],r[210000];
    l[0]=a[0];
    for(int i=1;i<n;i++){
        l[i]=l[i-1]+a[i];
    }
    r[n-1]=a[n-1];
    for(int i=n-1;i>=0;i--){
        r[i]=r[i+1]+a[i];
    }
    int ans=INF;
    for(int i=0;i<n-1;i++){
        ans=min(ans,abs(l[i]-r[i+1]));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    int n;
    string winner = "second";
    cin >> n;
    

    for(int i=0; i<n; i++) {
        int a;
        cin >> a;
        if ( a % 2 != 0 ) {
            winner = "first";
        }
    }
    cout << winner << endl;
} 


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

int main()
{
  int i;
  cin >> i;
  
  if(i=i%1000){
    i=i%1000;
  	i=1000-i;
}
  else{
    i=i%1000;
    i=0;
}
  
  cout << i;

  

return 0;
}


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

int main()
{
	int n,x,i;
	cin >> n;
	i = 1;
	x = 1000 * 1 - n;

	while (x < 0) {
		i++;
		x = 1000 * i - n;
	}
	cout << x << endl;
}


Measured memory_bytes: 3632
# include<stdio.h>
int main (void)
{
	int a,b,c,d,e,t;
	scanf("%d%d",&a,&b);
	c=a+b;
	d=a-b;
	e=a*b;
	if(c>=d) t=c;
	else t=d;
	if(e>t) t=e;
	printf("%d",t);
	return 0;
 } 

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}
uint32_t matrix[1000][1000];

int main() {
  uint64_t H, W, A, B;
  cin >> H >> W >> A >> B;
  for (uint32_t h = 0; h < H; ++h) {
    for (uint32_t w = 0; w < W; ++w) {
      matrix[h][w] = 0;
    }
  }
  if (A != 0 && B != 0) {
    for (uint32_t h = 0; h < B; ++h) {
      for (uint32_t w = 0; w < A; ++w) {
        matrix[h][w] = 1;
      }
    }
    for (uint32_t h = B; h < H; ++h) {
      for (uint32_t w = A; w < W; ++w) {
        matrix[h][w] = 1;
      }
    }
  } else {
    if (A == 0) {
      for (uint32_t w = 0; w < W; ++w) {
        for (uint32_t h = 0; h < B; ++h) {
          matrix[h][w] = 1;
        }
      }
    } else {
      for (uint32_t h = 0; h < H; ++h) {
        for (uint32_t w = 0; w < A; ++w) {
          matrix[h][w] = 1;
        }
      }
    }
  }
  for (uint32_t h = 0; h < H; ++h) {
    for (uint32_t w = 0; w < W; ++w) {
      cout << matrix[h][w];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 5120
def evenOdd(a,b):
    return True if a*b%2==1 or(a%2==0 and b%2==0) else False

x = list(map(int, input().split()))
x = sorted(x)
if evenOdd(x[0],x[1]) and evenOdd(x[1],x[2]) and evenOdd(x[2],x[0]):
    print(int((2*x[2]-x[0]-x[1])/2))
elif evenOdd(x[0],x[1]) and not(evenOdd(x[1],x[2]) and not evenOdd(x[2],x[0])) :
    print(int((x[2]-x[0]-1)/2+(x[2]-x[1]-1)/2 +1))
else:
    print(int((x[2]-x[0])/2)+int((x[2]-x[1])/2)+2)

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

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

#include <string>
#include <vector>
#include <algorithm>
int main(){
    int n,a; cin >> n;
    vector<int> Jun(n+1);
    for(int i=1; i<=n ;i++){
        cin >> a;
        Jun[a] = i;
    }
    for(int i=1; i<=n; i++) printf("%d ",Jun[i]);
    printf("\n");
}

Measured memory_bytes: 3744
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "x " << x;

int main()
{
    char ch;
    cin >> ch;
    cout << (char) (ch + 1) << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

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

  vi h(n);
  rep(i, n){
    cin >> h[i];
  }

  int ans = 0, cnt = 0;;
  rep(i, n){
    if(cnt < h[i]){
      ans += h[i] - cnt;
    }
    cnt = h[i];
  }

  cout << ans << endl;

  return 0;
}


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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans;
  if(x>y) ans=min(a*x+b*y,min(2*c*y+(x-y)*a,2*max(x,y)*c));
  else ans=min(a*x+b*y,min(2*c*x+(y-x)*b,2*max(x,y)*c));
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
    int K;
    int X;
    int num;
    int i;
    
    scanf( "%d", &K );
    scanf( "%d", &X );
    
    for(i=1; i<K; i++ )
    {
        num = X - (K - i);
        printf( "%d", num );
        printf( " " );
    }
    for(i=0; i<K; i++ )
    {
        num = X + i;
        printf( "%d", num );
        printf( " " );
    }
}


Measured memory_bytes: 128
/* Author: Akkapaka Saikiran (@saikidon911) */
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using vi = vector<int>; using vll = vector<long long>; 
using vvi = vector<vector<int> >; using vb = vector<bool>;
#define pb push_back
#define all(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
//////////////////////////////////////////
#define test(t) int t; cin>>t; while(t--)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
////////////////////////////////////////////
#define tki take_input 
#define tkii take_input<int>
template <typename T> void take_input(vector<T> &a,int sz){
	T t;rep(i,sz){cin>>t;a.pb(t);}}
#define prv print_vector
#define prvi print_vector<int> 
template <typename T> void print_vector(vector<T> v){
	rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;}
/////////////////////////////////////////

int main(){
	fastio;

	int n,k; cin>>n>>k;
	vi a; tkii(a,n);

	for(int i = k; i < n; i++){
		if(a[i] > a[i-k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}	
}	

Measured memory_bytes: 4276
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  int[] x=int_arr();
	        		  int n=x[0],k=x[1];
	        		  long[][] prefix=new long[n+1][k+1];
	        		  long mod=(long)1e9+7;
	        		  int[] a=int_arr();
	        		  Arrays.fill(prefix[0],1);
	        		  for(int i=1;i<=n;i++){prefix[i][0]=1;}
	        		  for(int i=1;i<=n;i++){
	        		  	  for(int j=1;j<=k;j++){
	        		  	  	long r=(j-a[i-1]-1>=0)?prefix[i-1][j-a[i-1]-1]:0;
	        		  	  	long l=prefix[i-1][j]; 
	        		  	  	prefix[i][j]=(prefix[i][j-1]+(l-r+mod)%mod)%mod;
	        		  	  }
	        		  }
	        		  long r=(k-a[n-1]-1>=0)?prefix[n-1][k-a[n-1]-1]:0;
	        		  long l=prefix[n-1][k]; 
	        		  out.write((l-r+mod)%mod+"");
                      out.flush();
	        		 
	}
}
	       
	          



	
  





Measured memory_bytes: 125908
#include<bits/stdc++.h>
using namespace std;
#define in cin>>
#define out cout<<
#define change endl

int main(void)
{
   int n;cin>>n;
vector<char> v;
    map<char,int> m;
for(int i=0;i<n;i++)
{ 
string s;cin>>s;v.push_back(s[0]);
}
for(int i=0;i<n;i++)
{
m[v[i]]++;
}
    cout<<"AC x "<<m['A']<<endl;
    cout<<"WA x "<<m['W']<<endl;
    cout<<"TLE x "<<m['T']<<endl;
    cout<<"RE x "<<m['R']<<endl;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll N;
vector<ll> A;
ll fact [200001];
const ll MOD = 1e9 + 7;

ll mod_pow(ll x,ll y = MOD - 2)
{
	ll res = 1;
	while(y){
		if(y & 1) (res *= x) %= MOD;
		(x *= x) %= MOD;
		y >>= 1;
	}
	return res;
}

ll C(ll n,ll r)
{
	if(r < 0 || r > n) return 0ll;
	return fact [n] * mod_pow(fact [r]) % MOD * mod_pow(fact [n - r]) % MOD;
}

int main()
{
	scanf("%lld",&N);
	A.assign(N + 1,0);
	map<ll,ll> mp;
	ll twice = 0;
	FOR(i,0,N + 1){
		scanf("%lld",&A [i]);
		if(++mp [A [i]] == 2){
			twice = A [i];
		}
	}

	fact [0] = 1;
	for(ll i = 1;i <= 200000;i++){
		fact [i] = fact [i - 1] * i % MOD;
	}

	ll x = 0,y = 0,z = 0;
	ll cnt = 0;
	FOR(i,0,N + 1){
		if(A [i] == twice){
			cnt++;
		}
		else if(cnt == 0){
			x++;
		}
		else if(cnt == 1){
			y++;
		}
		else{
			z++;
		}
	}

	for(ll i = 1;i <= N + 1;i++){
		ll ans = C(x + y + z,i - 2);
		(ans += C(x + y + z,i - 1) * 2) %= MOD;
		(ans += C(x + y + z,i)) %= MOD;
		(ans -= C(x + z,i - 1)) %= MOD;
		(ans += MOD) %= MOD;
		printf("%lld\n",ans);
	}

	return 0;
}


Measured memory_bytes: 9856
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

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

const INF = math.MaxInt64

func main() {
	sc.Split(bufio.ScanWords)
	n, k := readInt(), readInt()

	h := make([]int64, n)
	for i := 0; i < n; i++ {
		h[i] = readInt64()
	}

	dp := make([]int64, n)
	for i := 0; i < n; i++ {
		dp[i] = INF
	}
	dp[0] = 0
	dp[1] = abs(int64(h[0] - h[1]))

	for i := 0; i < n; i++ {
		for j := 1; j <= k; j++ {
			if i-j < 0 {
				continue
			}
			dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
		}
	}
	fmt.Println(dp[n-1])
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>

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

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

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

	ll ans = 0;
	ll i = 1;
	while (true)
	{
		ans += i;
		if (ans >= x) {
			break;
		}
		i++;
	}

	cout << i << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	char N[2];
	int i, sum = 0;
	for (i = 0; i < 2; i++) {
		cin >> N[i];
		if (N[i] == '9') {
			sum += 1;
		}
	}
	
	if (sum != 0) {
		cout << "Yes";
	}
	else { cout << "No"; }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

/*
	N = 5*(N - 1)
	1 = 0
	2 = 5
	v = 9.8t
	y = 4.9t^2
	y = 4.9(v/9.8)^2 = 4.9 * (v^2 / (9.8)^2 )
*/
int main(){
	double v;
	while(~scanf("%lf",&v)){
		printf("%d\n",(int)(ceil((4.9*v*v/9.8/9.8)/5.0)+EPS)+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
  int h, w, t, t3, min, minh, minw, i, j;
  int a[150][150];
  while (1) {
    scanf("%d%d", &h, &w);
    if (h == 0 && w == 0) return 0;
    for (i = 0; i < 150; i++)
      for (j = 0; j < 150; j++)
	a[i][j] = 0;
    
    t = h * h + w * w;
    for (i = 1; (i - 1) * (i - 1) <= t; i++) {
      for (j = i + 1; (j - 1) * (j - 1) <= t; j++) {
	t3 = i * i + j * j;
	if (t3 >= t && i != h || j != w) a[i - 1][j - 1] = t3;
      }
    }

    min = 22500;
    minh = 1;
    minw = 1;
    for (i = 0; i < 150; i++) {
      for (j = 0; j < 150; j++) {
	if (t < a[i][j] && a[i][j] < min) {
	  min = a[i][j];
	  minh = i + 1;
	  minw = j + 1;
	} else if (t == a[i][j] && h < i + 1 && a[i][j] < min) {
	  min = a[i][j];
	  minh = i + 1;
	  minw = j + 1;
	}
      }
    }
    printf("%d %d\n", minh, minw);
  }
}

Measured memory_bytes: 688
using System;
class Program
{
	static void Main(string[] args)
	{
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        
        int count = 0;
        Boolean flag = true;
        while(flag){
            for(int i = 0;i < n;i++){
                int tmp = int.Parse(input[i]);
                if(tmp % 2 != 0){
                    flag = false;
                    break;
                }
                input[i] = (tmp/2).ToString();
            }
            if(flag) count++;
        }
        Console.WriteLine(count);
	}
}

Measured memory_bytes: 11092
k, n = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a.append(a[i] + k)

ans = float("inf")
for i in range(n):
    dist = a[i + n - 1] - a[i]
    ans = min(ans, dist)

print(ans)


Measured memory_bytes: 26420
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  ll X;
  while (cin >> N >> X) {
    vector<ll> x(N);
    for (int i = 0; i < N; i++) cin >> x[i];
    auto f = [&](int K) {
      vector<ll> coef(N);
      for (int i = 0; i < K; i++) coef[i] = 5;
      for (int i = K; i < N; i++) coef[i] = 2 * ((i - K) / K + 2) + 1;
      ll cost = (N + K) * X;
      for (int i = 0; i < N; i++) cost += coef[N - i - 1] * x[i];
      return cost;
    };
    int l = 1, r = N;
    while (r - l > 10) {
      int s = (r - l) / 3;
      int a = l + s;
      int b = r - s;
      if (f(a) > f(b)) {
        l = a;
      } else {
        r = b;
      }
    }
    ll res = 1ll << 60;
    for (int k = max(1, r - 10); k <= min(N, r + 10); k++) {
      res = min(res, f(k));
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int N,W;
  cin >> N >> W;
  long long we[N],val[N];
  long long dp[N+2][W+10];
  rep(i,N){
    cin >> we[i] >> val[i];
  }
  rep(i,W+1){
    dp[0][i] = 0;
  }
  for(int i = 0; N > i; i++){
    for(int j = 0; W >= j; j++){
      //cout << i << " " << j << endl;
      if(j >= we[i]){
        dp[i+1][j] = max(dp[i][j-we[i]]+val[i],dp[i][j]);
      }
      else dp[i+1][j] = dp[i][j];
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 79104
#include <iostream>
#include <queue>

int main(void) {
    int N, M;
    std::priority_queue<int> A;

    std::cin >> N >> M;

    for (int i = 0; i < N; i++) {
        int tmp;
        std::cin >> tmp;
        A.push(tmp);
    }

    for (int i = 0; i < M; i++) {
        A.push(A.top() / 2);
        A.pop();
    }

    long long ans = 0;

    while (!A.empty()) {
        ans += A.top();
        A.pop();
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 892
def DFS(N,X):
    if N==0:return 1
    elif X==1:return 0
    elif 1<X<=1+B[N-1]:return DFS(N-1,X-1)
    elif X==2+B[N-1]:return P[N-1]+1
    elif 2+B[N-1]<X<=2+2*B[N-1]:return P[N-1]+1+DFS(N-1,X-2-B[N-1])
    elif X==2*B[N-1]+3:return 2*P[N-1]+1


n,x=map(int,input().split())

P,B=[1],[1]
for i in range(n):
    P.append(P[i]*2+1)
    B.append(B[i]*2+3)

print(DFS(n,x))

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

namespace abc140_b
{
    static class Program
    {
        static void Main(string[] args)
        {
            // 料理の数
            var n = Console.ReadLine().ToInteger();
            // 食べたものの料理番号
            var a = Console.ReadLine().ToIntArray();
            // 料理番号と満足度
            var b = Console.ReadLine().ToIntArray();
            // ボーナスの満足度を得られる料理
            var c = Console.ReadLine().ToIntArray();

            var ans = 0L;
            var prev = -1;
            for (int i = 0; i < a.Length; i++)
            {
                var index = a[i] - 1;
                ans += b[index];
                if (index > 0 && prev >= 0 && prev == index - 1)
                {
                    ans += c[prev];
                }
                prev = index;
            }

            Console.WriteLine($"{ans}");
        }

        static int ToInteger(this string s)
        {
            return int.Parse(s);
        }

        static int[] ToIntArray(this string s, char separator = ' ')
        {
            return s.Split(separator).Select(m => m.ToInteger()).ToArray();
        }
    }
}


Measured memory_bytes: 13396
def d_sum_of_large_numbers(MOD=10**9 + 7):
    N, K = [int(i) for i in input().split()]

    ans = 0
    for k in range(K, N + 2):
        tmp = 1 - k * (k - 1)
        ans += k * N + tmp
        ans %= MOD
    return ans

print(d_sum_of_large_numbers())

Measured memory_bytes: 9184
S=input()
kisu=["R","U","D"]
gusu=["L","U","D"]


for i in range(len(S)):
	if (i+1)%2==0 and S[i] in gusu:
		continue
	elif (i+1)%2!=0 and S[i] in kisu:
		continue
	else:
		print("No")
		exit()

print("Yes")

Measured memory_bytes: 9092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  vector<int> data(5);
  for(int i = 0; i < 5; i++) cin >> data[i];
  int ans = INT_MAX;
  do {
    int time = 0;
    for(int i = 0; i < 5; i++){
      time += data[i];
      if(i != 4) while(time % 10) time++;
    }
    ans = min(ans,time);
  }while(next_permutation(all(data)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
  char s[100000]={0};
  scanf("%s",s);
  int i=0, k=0;
  while(s[i]){
    if(i%2 == 0){
      if(s[i] == '0'){
	k++;
      }
    }else{
      if(s[i] == '1'){
	k++;
      }
    }
    i++;
  }
  printf("%d\n",k<i-k?k:i-k);
  return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str =sc.next();
		Set<String> set = new HashSet<>();

		for(int i=0;i<3;i++) {
			set.add(str.substring(i,i+1));
		}
		System.out.println(set.size()==3?"Yes":"No");

	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n % 2 == 0)cout << n << endl;
	else cout << n * 2 << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

D, T, S = In.ints()

if D/S <= T:
    Out.str("Yes")
else:
    Out.str("No")

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

const int N = 100010;
vi adj[N];
int dist[N];
int c = 0;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n, m;
	cin >> n >> m;
	M00(i, n) dist[i] = -1;
	M00(i, m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	queue<pi> Q;

	Q.push(mp(0, -1));
	while(!Q.empty()) {
		pi state = Q.front();
		Q.pop();
		int v = state.f, d = state.s;
		if(dist[v] != -1) continue;
		dist[v] = d+1;
		c++;
		for(auto u : adj[v]) {
			Q.push(mp(u, d+1));
		}
	}
	if(c == n) {
		cout << "Yes" << endl;
		for(int i = 1; i < n; i++) {
			for(auto u : adj[i]) {
				if(dist[u] + 1 == dist[i]) {
					cout << u + 1 << endl;
					break;
				}
			}
		}
	} else {
		finish("No");
	}
}


Measured memory_bytes: 12344
import java.util.Scanner;

public class Main {

    private Scanner in = new Scanner(System.in);

    void solve() {
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
        if(a + b < c) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
    public static void main(String[] args) {
        new Main().solve();
    }
}


Measured memory_bytes: 21332
n = int(input())
a = list(map(str, input().split()))
b = a.copy()

flag = 1

for _ in range(n-1):
    while flag:
        flag = 0
        for i in range(n-1, 0, -1):
            if a[i][1] < a[i-1][1]:
                a[i], a[i-1] = a[i-1], a[i]
                flag = 1
print(" ".join(map(str, a)))
print("Stable")

for i in range(n):
    minj = i
    for j in range(i, n):
        if b[j][1] < b[minj][1]:
            minj = j
    b[i], b[minj] = b[minj], b[i]
print(" ".join(map(str, b)))
print("Stable" if a == b else "Not stable")


Measured memory_bytes: 5608
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n;
	int a[105000];
	scanf("%d",&n);
	int max=0;
	bool t=false;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>max){
			max=a[i];
		}else{
			if(a[i]+1<max){
				t=true;
			}
		}
	}
	if(t){
		printf("No");
	}
	else{
		printf("Yes");
	}
	return 0;
} 

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

MOD = 10 ** 9 + 7
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
s = sum([math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) for i in range(n) for j in range(n)])

ans = s / n

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    char s[3003],t[3003];
    cin>>s;
    cin>>t;
    int lens=strlen(s);
    int lent = strlen(t);
    int dp[lens+3][lent+3];
    char charDp[lens+3][lent+3];
    int i,j;
    for(i=0;i<=lens;i++){
        for(j=0;j<=lent;j++){
            dp[i][j]=0;
        }
    }
    for(i=1;i<=lens;i++){
        for(j=1;j<=lent;j++){
            if(s[i-1] == t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
                charDp[i][j]='d';
            }
            else{
                if(dp[i-1][j] > dp[i][j-1]){
                    dp[i][j]=dp[i-1][j];
                    charDp[i][j] = 'u';

                }
                else{
                    dp[i][j]=dp[i][j-1];
                    charDp[i][j]='l';
                }
            }
        }
    }
    // for(i=1;i<=lens;i++){
    //     for(j=1;j<=lent;j++){
    //         cout<<charDp[i][j];
    //     }
    //     cout<<endl;
    // }
    vector<char> ans;
    i = lens;
    j = lent;
    while(i>0&&j>0){
        if(charDp[i][j]=='d'){
            //cout<<"F";
            ans.push_back(s[i-1]);
            i--;
            j--;
            continue;
        }
        if(charDp[i][j]=='l'){
            j--;
            continue;
        }
        else
        {
            //cout<<"F";
            i--;
        }
    }
    
    reverse(ans.begin(),ans.end());
    for(i = 0;i<ans.size();i++)
        cout<<ans[i];
    return 0;
}

Measured memory_bytes: 44288
import math

Q_MAX = 2 << 15


def primes(n):
    p = [True] * (n + 1)
    p[0] = p[1] = False
    for i in range(2, int(math.sqrt(n + 1))):
        if p[i]:
            for j in range(i * 2, n + 1, i):
                p[j] = False
    return p


P = [i for i, x in enumerate(primes(Q_MAX)) if x]

while True:
    q = int(input())
    if q == 0: break
    count = 0
    for p in P:
        if p > q / 2:
            break
        if q - p in P:
            count += 1
    print(count)



Measured memory_bytes: 6312
import numpy as np

n = int(input())
ac = []
for i in range(n):
    i = list(map(int,input().split()))
    ac.append(i)
dp = [[0,0,0] for _ in range(n)]
a,b,c = 0,1,2
dp[0] = ac[0][:]

for j in range(1,n):
    dp[j][a] = max(dp[j-1][b],dp[j-1][c]) + ac[j][a]
    dp[j][b] = max(dp[j-1][a],dp[j-1][c]) + ac[j][b]
    dp[j][c] = max(dp[j-1][a],dp[j-1][b]) + ac[j][c]

print(max(dp[n-1]))

Measured memory_bytes: 56476
use std::i64;
use std::cmp;

// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main(){
    input! {
        N: usize,
        h: [i64; N],
    }

    let mut dp = vec![0; N];
    dp[0] = 0;
    dp[1] = (h[0]-h[1]).abs();
    for i in 2 .. N {
        dp[i] = cmp::min(dp[i-1]+(h[i]-h[i-1]).abs(), dp[i-2]+(h[i]-h[i-2]).abs());
    }

    println!("{}", dp[N-1]);
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int N;  cin>>N;
  vector<ll> v(N);
  rep(i,0,N) cin>>v[i];
  ll now = 0;
  ll ans=0;
  rep(i,0,N){
    if(now < v[i]){
      now = v[i];
    }else{
      ans += now - v[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(System.getProperty("line.separator"));
        int n = sc.nextInt();
        String data = sc.next();

        //String???Int????????????
        String[] datas = data.split(" ");
        int[] A = new int[n];
        for (int i = 0; i < A.length; i++) {
			A[i] = Integer.parseInt(datas[i]);
		}

        //disp
    	disp(A);

        for (int i = 1; i < n; i++) {
        	//ex. 5,3 = 3
        	int v = A[i];
        	//ex. 5,3 = 5
        	int j = i -1;

        	//              5  > 3
        	while(j>=0 && A[j] > v){
        		A[j+1] = A[j];
        		j--;
        	}
        	A[j+1] = v;

        	//disp
        	disp(A);


		}
	}

	private static void disp(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if(i!=a.length-1)System.out.print(" ");
		}
		System.out.println();
	}

}

Measured memory_bytes: 33376
#ifdef __cplusplus
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#endif

#define rep(l, end) for(ll l = 0; l < (end); ++l)
#define rep4(l, start, end, step) for (ll l = (start); l < (end); l += (step))
 
#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF_SHORT (1 << 30)
#define INF_SHORT_NEG (INF * -1)
#define INF (1LL << 62)
#define INF_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
ll StrLen(char *s) { for(ll ptr = 0;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, ll n) { ll l = StrLen(s); s[l - n + 1] = '\0'; return l - n; }

ll NumDigits(ll l){ char s[32]; return sprintf(s, "%lld", l); }

ll is1stAns = 1;
#ifdef __cplusplus
template <class T> 
void print(T t) { if (is1stAns) cout << t, is1stAns = 0; else cout << " " << t; }
#else
void printI(int    i) { if (is1stAns) printf(  "%d", i), is1stAns = 0; else printf(  " %d", i); }
void printL(ll     l) { if (is1stAns) printf("%lld", l), is1stAns = 0; else printf(" %lld", l); }
void print (ll     l) { if (is1stAns) printf("%lld", l), is1stAns = 0; else printf(" %lld", l); }
void printD(double d) { if (is1stAns) printf("%.9f", d), is1stAns = 0; else printf(" %.9f", d); }
void printC(char   c) { if (is1stAns) printf(  "%c", c), is1stAns = 0; else printf(  " %c", c); }
void printS(char  *s) { if (is1stAns) printf(  "%s", s), is1stAns = 0; else printf(  " %s", s); }
#endif

signed main()
{
#ifdef __cplusplus
    cout << fixed << setprecision(9);
#endif

    ll N; cin >> N;
    ll *h = new ll[N + 9]; rep(i, N) cin >> h[i];
    ll *dp = new ll[N + 9]; rep(i, N + 9) dp[i] = INF;
    
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    rep4(i, 2, N, 1){
        ll next1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        ll next2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(next1, next2);
    }

    cout << dp[N - 1] << endl;

    delete[] dp;
    delete[] h;

    return 0;
}


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

import sys

p = 0
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for line in sys.stdin:
    flag = False
    tmp = 0
    for i in range(len(line)-1):
        if not flag:
            if line[i] in num:
                flag = True
                tmp += int(line[i])
        else:
            if line[i] in num:
                tmp = tmp*10 + int(line[i])
            else:
                flag = False
                p += tmp
                tmp = 0
    if flag:
        p += tmp
        tmp = 0
print p

Measured memory_bytes: 6448
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,k,c,i,j;
  string s;
  cin>>n>>k>>c>>s;
  vector<int> l(k),r(k);
  j=0;
  for (i=0;i<n;i++){
    if (s.at(i)=='o') {
      l.at(j)=i+1;
      j++;
      i+=c;
    }
    if (j==k) break;
  }
  j=k-1;
  for (i=n-1;i>=0;i--){
    if (s.at(i)=='o') {
      r.at(j)=i+1;
      j--;
      i-=c;
    }
    if (j==-1) break;
  }
  for(i=0;i<k;i++) if (l.at(i)==r.at(i)) cout<<l.at(i)<<endl;
}

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

int main() {
  string n;
  cin>>n;
  if(n[0]==n[1] && n[1]==n[2]) cout<<"Yes"<<endl;
  else if(n[1]==n[2] && n[2]==n[3]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#include <list>
#include <iterator>
#include <sstream>

using namespace std;


class Puzzle
{
public:


	void input()
	{

	}


	void play()
	{
		string str_in;
		stringstream ss;

		vector<string> v_in;
		string buf_in;

		while(getline(cin,str_in)){
			ss << str_in;
			while (ss >> buf_in) {
				v_in.push_back(buf_in);
			}

			/*
			for (auto s : v_in) {
				printf("%s ", s.c_str());
			}
			printf("\n");
			*/

			double ans = calc(v_in);
			printf("%f\n", ans);

			ss.str("");
			ss.clear();
			v_in.clear();
		}

	}

	double calc(vector<string> s_calc) {
		vector<double> st_num;
		vector<string> st_buf;
		double a, b;

		for (int ci = 0; ci < s_calc.size(); ci++) {
			if (s_calc[ci] == "*" || s_calc[ci] == "/" || s_calc[ci] == "+" || s_calc[ci] == "-") {
				b = st_num.back();
				st_num.pop_back();
				a = st_num.back();
				st_num.pop_back();
				if (s_calc[ci] == "*") st_num.push_back(a * b);
				if (s_calc[ci] == "/") st_num.push_back(a / b);
				if (s_calc[ci] == "+") st_num.push_back(a + b);
				if (s_calc[ci] == "-") st_num.push_back(a - b);
			}
			else {
				st_num.push_back(atof(s_calc[ci].c_str()));
			}
		}

		return st_num[0];
	}


};


int main()
{
	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}




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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define pause system("pause")
#define PI acos(-1.0)


signed main() {
	double A, B, H, M;
	double cm,radA,radB,rad,ten;
	double l2, l60, l12;
	l12 = 12.000000000000000;
	l60 = 60.000000000000000;
	l2 = 2.000000000000000;

	cin >> A >> B >> H >> M;
	radA = l2 * PI*(H+M/l60) / l12;
	radB = l2 * PI*M / l60;
	rad = abs(radA - radB);
	if (rad >= PI) {
		rad = abs(l2* PI - rad);
	}
	ten = l2*A*B*cos(rad);
	cm = sqrt(A*A + B*B - ten);
	cout << fixed << setprecision(20) << cm << endl;
	pause;
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll long long
#define vi vector <int >
#define vii vectir < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second

bool mark[100020];
int arr[100020];

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

	memset(mark, 0, sizeof mark);
	memset(arr, 0, sizeof arr);
	int n, m, k;
	cin >> n >> m;
	string s;
	int ans = 0, ans1 = 0;
	forn(i, m){
		cin >> k >> s;
		if(mark[k]) continue;
		if(s == "WA"){
			arr[k]++;
		}else{
			ans++;
			mark[k] = true;
			ans1 += arr[k];
		}
	}

	cout << ans << " " << ans1 << endl;
	

	return 0;
}

Measured memory_bytes: 768
n = int(input())
box = list(map(int,input().split()))

ball = [False for _ in range(n)]

ans = []
for i, a in enumerate(reversed(box)):
    #print("{} {}".format(i,a))
    idx = n - 1 - i
    count_right = 0
    p = 2
    j = (idx + 1) * p
    #print("{}: {} <= {}".format(idx, j,n))
    while j <= n:
        #print("w {} {}".format(idx,n))
        if ball[j-1]:
            count_right += 1
        p+=1
        j = (idx + 1)  * p
    if a != 0:
        if (count_right % 2) != 0:
            ball[idx] = False
        else:
            ball[idx] = True
            ans.append(idx+1)
    else:
        if (count_right % 2) != 0:
            ball[idx] = True
            ans.append(idx+1)
        else:
            ball[idx] = False

ans_len = len(ans)
print(ans_len)
if (int(ans_len) == 0):
    pass #print('exit')
else:
    ans_s = ""
    for i, b in enumerate(ball):
        if b:
            if ans_s == "":
                ans_s = str(i+1)
            else:
                ans_s += " "
                ans_s += str(i+1)
    print(ans_s)
    #    if a != 0:
    #        ball[idx] = True


Measured memory_bytes: 14132
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
using std::swap;
vector <int> P;

int main() {
	int n;
	int t = 0;
	cin >> n;
	P.resize(n);
	for (int i = 0; i < n; ++i)cin >> P[i];
	for (int i = 0; i < n - 2; ++i) {
		if ((P[i] > P[i + 1] && P[i + 2] < P[i + 1]) || (P[i] < P[i + 1] && P[i + 2] > P[i + 1]))++t;
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<char> A(3);
    for(int i=0 ;i<3; i++){
        cin >> A.at(i);
    }
    int ans = 0;
    for (int i=0; i<3; i++){
        if(A.at(i)=='1'){
            ans++;
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256