akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 1000005
int N, M;
int A[MXN];

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

    cin>>N;
    M = (1<<N);
    FOR(i,0,M-1)cin>>A[i];
    sort( A, A+M, greater<int>() );

    int now = 0;
    priority_queue< int, vector<int> > pq;
    pq.push( N );

    while( now < M )
    {
        int cnt = 1;
        while( now+1<M && A[now+1]==A[now] )now++,cnt++;

        if( cnt>pq.size() )
        {
            cout<<"No\n";
            return 0;
        }

        vector<int> V;
        FOR(i,1,cnt)
        {
            V.pb( pq.top() );
            pq.pop();
        }
        for(int vi : V)
        {
            FOR(i,0,vi-1)pq.push(i);
        }

        now++;
    }

    cout<<"Yes\n";

    return 0;
}



Measured memory_bytes: 2552
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut dp = vec![0; 100001];
    dp[0] = 1;
    for i in 0..6 {
        for j in 100 + i..100001 {
            dp[j] |= dp[j - 100 - i];
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    r = r * 100 + g * 10 + b;
    if (r % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
count = 0
for i in range(len(S)):
    if S[i] in "abcdefghijklmnopqrstuvwxyz":
        count += 1
if S[0] == "A" and "C" in S[2:-1] and count == len(S)-2:
    print("AC")
else:
    print("WA")

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

using namespace std;

namespace {
    typedef double real;

    int N;
    vector<int> A;
    void input() {
        cin >> N;
        A.clear(); A.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> A[i];
        }
    }

    const int L = int(1e5) * 2 + 5;
    const real INF = 1e9;

    real calc(int a, int b) {
        // ある貨幣を価値aから価値bに変更するときのコスト
        return abs(real(a - b)) / real(a);
    }
    
    void solve() {
        /* dp[i][j] :: i番の貨幣価値をjにして、0 ~ i番までの貨幣体系がbeautifulになるよう調整する最小コスト */
        vector< vector<real> > dp(N, vector<real>(L, INF));
        for (int j = 1; j <= 2 * A[0]; j++) {
            dp[0][j] = calc(A[0], j);
        }
        for (int i = 1; i < N; i++) {
            for (int j = 1; j <= 2 * A[i]; j++) { // コストが1を越えることはないので, もとの価値の高々2倍までみればよい
                int x = j;
                real ncost = calc(A[i], j);
                for (int k = 1; k * k <= x; k++) {
                    if (x % k == 0) {
                        int a = k, b = x / k;
                        dp[i][j] = min(dp[i][j], max(dp[i - 1][a], ncost));
                        dp[i][j] = min(dp[i][j], max(dp[i - 1][b], ncost));
                    }
                }
            }
        }
        real ans = 1.0;
        for (int j = 1; j <= 2 * A[N - 1]; j++) {
            ans = min(ans, dp[N - 1][j]);
        }
        printf("%.12lf\n", ans);
    }
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 33740
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]


lasts = [[-1] * 26 for _ in range(D + 1)]
S = 0
for d in range(D):
    S += s[d][t[d] - 1]

    for i in range(26):
        if i == t[d] - 1:
            lasts[d+1][i] = d
        else:
            lasts[d+1][i] = lasts[d][i]

    for i in range(26):
        S -= c[i] * (d - lasts[d+1][i])

    print(S)


Measured memory_bytes: 69412
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int n = 0;

  cin >> n;

  vector<ll> a(n);

  ll mx = 0, ans = 0;

  for(int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
    ans += mx - a[i];
  }

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 4828
#include <stdio.h>

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	if(n<=1){
		n=0;
	}
	if(m<=1){
		m=0;
	}
	if(n==2){
		n=1;
	}
	if(m==2){
		m=1;
	}
	if(n>2){
		n = 0.5*n*(n-1);
	}
	if(m>2){
		m = 0.5*m*(m-1);
	}
	printf("%d\n", m+n);
	return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const double pi = 3.1415926;
int a[1006]={0};
int main()
{
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            a[i*j]=1;
        }
    }
    int n;
    cin >>n;
    if(a[n])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

int main()
{
    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0)
            return 0;

        vector<string> tile(h);
        for(int i=0; i<h; ++i)
            cin >> tile[i];

        vector<vector<bool> > check(h, vector<bool>(w, false));
        int y = 0;
        int x = 0;
        for(;;){
            char c = tile[y][x];
            if(c == '.'){
                cout << x << ' ' << y << endl;
                break;
            }
            check[y][x] = true;
            if(c == '>')
                ++ x;
            else if(c == '<')
                -- x;
            else if(c == 'v')
                ++ y;
            else
                -- y;
            if(check[y][x]){
                cout << "LOOP" << endl;
                break;
            }
        }
    }
}

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



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

using namespace std;
int n;
int a[2000];
int main(){
  cin >> n;
  double wa;
  REP(i,n){
    int k;
    cin >> k;
    wa += k;
    a[i] = k;
  }
  wa /= (double) n;
  int wa2;
  wa2 = round(wa);
  int ans = 0;
  REP(i,n){
    ans += (wa2-a[i]) *(wa2-a[i]) ;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
input = raw_input

n, m = map(int, input().split(" "))

hs = [None] + map(int, input().split(" "))
#graph = {}
#for i in range(1, n+1):
#    graph[i] = []

outs = [None] + [True] * n

for _ in range(m):
    a, b = map(int, input().split(" "))

    if hs[a] == hs[b]:
        outs[a] = False
        outs[b] = False
    elif hs[a] < hs[b]:
        outs[a] = False
    else:
        outs[b] = False

    #graph[b].append(a)
    #graph[a].append(b)

out = sum(outs[1:])
print(out)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

string s;
int dp[20][1000][2][2];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> s;
  int n = s.size();
  //memset(dp, -1, sizeof(dp));
  memset(dp, 0, sizeof(dp));
  dp[0][0][0][0] = 1;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < 1000; ++j) {
      for(int k = 0; k < 2; ++k) {
	for(int l = 0; l < 2; ++l) {
	  //if(dp[i][j][k][l] == -1) continue;
	  int lim = l ? 9 : s[i]-'0';
	  for(int d = 0; d <= lim; ++d) {
	    int nj = j%100*10+d;
	    int nk = j/10*100+d == 5103;
	    /*
	    if(!k && nk) {
	      //cout<<i<<" "<<j<<" "<<nj<<" "<<j*10+d<<endl;
	      if(dp[i+1][nj][k||nk][l||d<lim] == -1) dp[i+1][nj][k||nk][l||d<lim] = 0;
	      dp[i+1][nj][k||nk][l||d<lim] += dp[i][j][k][l];
	    } else {
	    */
	    //if(dp[i+1][nj][k||nk][l||d<lim] == -1) dp[i+1][nj][k||nk][l||d<lim] = 0;
	      dp[i+1][nj][k||nk][l||d<lim] += dp[i][j][k][l];
	      //}
	  }
	}
      }
    }
  }

  int ans = 0;
  rep(i, 1000) {
    rep(j, 2) {
      if(~dp[n][i][1][j]) ans += dp[n][i][1][j];
    }
    //cout<<dp[n][i][1][0]<<" "<<dp[n][i][1][1]<<endl;
  }
  cout << ans << endl;

  return 0;
}



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

int main(void){
    string s, t;
    cin >> s >> t;
    
    int flag;
    int i, j;
    for(i = s.length() - t.length(); i >= 0; i--){
        flag = true;
        for(j = 0; j < t.length(); j++){
            if(!(s[i + j] == '?' || s[i + j] == t[j])){
                flag = false;
            }
        }
        if(flag == true){
            break;
        }
    }
    
    if(flag == false){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    for(j = 0; j < s.length(); j++){
        if(j >= i && j < i + t.length()){
            cout << t[j - i];
        }else if(s[j] == '?'){
            cout << 'a';
        }else{
            cout << s[j];
        }
    }
    
    cout << endl;
    
    return 0;
}


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

int main(void){
  int i, size, count;
  int *x;

  count = 0;
  size = 10000;
  x = (int *)malloc(sizeof(int)*size);

  for(i=0;i<size;i++){
    x[i] = 0;
  }

  while(1){
    scanf("%d", &x[count]);
    if(x[count] == 0){
      break;
    }
    count++;
  }

  for(i=0;i<count;i++){
    printf("Case %d: %d\n", i+1, x[i]);
  }

  return 0;

}



Measured memory_bytes: 2044
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";

int main() {
	cin >> S;
	if(S[5] == '1' || S[6] > '4') {
		printf("TBD\n");
	} 
	else {
		printf("Heisei\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

using namespace std;

const int INF = 1 << 30;

int N, T[50];
int dp[850][850];

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> T[i];
  }
  fill_n(*dp, 850 * 850, INF);
  dp[0][0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 849; j >= 0; j--) {
      for(int k = 849; k >= 0; k--) {
        dp[j][k] += T[i];
        if(j >= T[i]) dp[j][k] = min(dp[j][k], dp[j - T[i]][k]);
        if(k >= T[i]) dp[j][k] = min(dp[j][k], dp[j][k - T[i]]);
      }
    }
  }

  int ret = INF;
  for(int i = 0; i <= 849; i++) {
    for(int j = 0; j <= 849; j++) {
      ret = min(ret, max({i, j, dp[i][j]}));
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 5916
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    int min_price = 0x3f3f3f3f;
    int min_count = 0;
    int max_profit = 0;
    long long int max_count = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] - min_price > max_profit) {
            max_count = min_count;
            max_profit = v[i] - min_price;
        } else if (v[i] - min_price == max_profit) {
            max_count += min_count;
        }

        if (v[i] < min_price) {
            min_count = 1;
            min_price = v[i];
        } else if (v[i] == min_price) {
            min_count++;
        }
    }
    cout << max_count << endl;
}


Measured memory_bytes: 3784
#include <stdio.h>
    int main(){
    int a,b;
    scanf("%d %d",&a,&b);
     
    if(a==2||b==2) puts("No");  
    else 
    if((a==4||a==6||a==9||a==11)&&(b==4||b==6||b==9||b==11))
    puts("Yes");
    else
    if((a==7||a==5||a==3||a==1||a==8||a==10||a==12)&&(b==7||b==5||b==3||b==1||b==8||b==10||b==12))
    puts("Yes");
    else
      puts("No");
     
    return 0;  
    }

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

int digits (int i){
  int dgt = 0;
  while(i!=0){
    i = i / 10;
    dgt++;
  }
   return dgt;
}
    
int main(){
  int n;
  cin >> n;
  
  int ans = 0;
  for(int i=1; i<=n; i++){
    if (digits(i)%2 == 1) ans++;
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<ctime>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 200005;
int n, m;
long long k, ans;
long long a[MAXN];
long long t[MAXN];
long long b[MAXN];
long long Query(int x)
{
	long long ret = 0;
	while(x)
	{
		ret += b[x];
		x -= (x & -x);
	}
	return ret;
}
void Insert(int x)
{
	while (x <= m+1)
	{
		++b[x];
		x += (x & -x);
	}
}
int main()
{
	scanf("%d%lld", &n, &k);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%lld", &a[i]);
		t[i] = (a[i] += a[i-1] - k);
	}
	sort(t, t + n + 1);
	m = unique(t, t + n + 1) - t + 1;
	for (int i = 0; i <= n; ++i)
	{
		a[i] = lower_bound(t, t + m, a[i]) - t + 1;
		ans += Query(a[i]);
		Insert(a[i]);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

typedef long long ll;
const double EPS = 1e-10;
const double PI  = acos(-1);

void solve(ll n, ll y) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n-i; j++) {
      for (int k = 0; k <= n-i-j; k++) {
	if (i+j+k == n) {
	  ll sum = 10000*i + 5000*j + 1000*k;
	  if (sum == y) {
	    std::cout << i << " " << j << " " << k << std::endl;
	    return;
	  }
	}
      }
    }
  }

  std::cout << "-1 -1 -1" << std::endl;
  return;
}

int main(int argc, char* argv[])
{
  ll n, y;
  std::cin >> n >> y;

  solve(n, y);
  
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,k,x,y; cin >> n >> k >> x >> y;

  int ans = k<n ? x*k:x*n;
  if(k<n) ans += (n-k)*y;

  cout << ans << endl;
    
  return 0;
}


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

using namespace std;

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

	int mode = 0, answer = 1;
	int v; cin >> v;

	for (int i = 1; i < n; ++i){
		int c; cin >> c;

		int nm;

		if (c == v) nm = mode;
		else nm = c > v ? +1 : -1;

		if (mode != nm){
			if (mode == 0) mode = nm;
			else{
				answer++;
				mode = 0;
			}
		}

		v = c;
	}	

	cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c)cout<<"Yes\n";
    else if(a==c&&a!=b)cout<<"Yes\n";
    else if(b==c&&a!=b)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,num=1;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        if(num*2>num+k) num=num+k;
        else num=num*2;

    }
    cout<<num<<endl;
    return 0;
}


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

int main() {

    string S;
    cin >> S;

    int ans = 0;
    int l = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') {
            l++;
            ans = max(ans, l);
        }
        else {
            l = 0;
        }
    }
    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return [set(self.members(r)) for r in self.roots()]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n, m = map(int, input().split())
    P = list(map(lambda x:int(x) - 1, input().split()))
    uf = UnionFind(n)
    for _ in range(m):
        x, y = map(lambda x:int(x) - 1, input().split())
        uf.union(x, y)
    ans = 0
    for i, p in enumerate(P):
        if uf.same(i, p):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20704
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n;
	cin>>n;
	vi a(n);
	for(ll i=0;i<n;++i)
	{
		cin>>a[i];
	}
	vi c(n);
	c[0]=0;
	c[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;++i)
	{
		c[i]=min(c[i-2]+abs(a[i]-a[i-2]),c[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<c[n-1]<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 1792
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = "";
		int x;
		
		for(int i=1; i<=n; i++) {
			x = i;
			if(x%3 == 0) {
				str += " "+i;
				continue;
			}
			if(x%10 == 3) {
				str += " "+i;
				continue;
			}
			x /= 10;
			while(x != 0) {
				if(x%10 == 3) {
					str += " "+i;
					break;
				}
				x /= 10;
			}
		}
		
		System.out.println(str);
	}
}

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

int main(){
    string S;
    cin >> S;
    int A = S.size() - 1;
    int count = 0;

    if(S.size() == 1){
        cout << 0 << endl;
        return 0;
    }    
    for(int i = 0; A >= S.size()/2; i++){
        if(S.at(i) != S.at(A)){
            count++;
        }
        A--;
    }
    
    cout << count << endl;

}

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

int main() {
  string S,T,U; 
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if(S==U) A-=1;
  if(T==U) B-=1;
  cout << A << " " << B << endl;
}

Measured memory_bytes: 3608
function Main(input) {
  var _arr = input[0].split(" "), n = parseInt(_arr[0]), m = parseInt(_arr[1]);
  var x = [], y = [], z = [];
  for (var i=0; i<n; i++) {
    var _arr = input[i+1].split(" ");
    x[i] = parseInt(_arr[0]);
    y[i] = parseInt(_arr[1]);
    z[i] = parseInt(_arr[2]);
  }
  var ans = 0;

  var muls = [1, -1];
  for(var mi=0; mi<2; mi++){
    for(var mj=0; mj<2; mj++){
      for(var mk=0; mk<2; mk++){
        var tmp_arr = [];
        for (var i=0; i<n; i++){
          tmp_arr.push(x[i]*muls[mi] + y[i]*muls[mj] + z[i]*muls[mk]);
        }
        tmp_arr.sort(function (a, b) {
          return a - b;
        });
        var sums = 0;
        for (var i=0; i<m; i++) sums += tmp_arr[n-i-1];
        ans = Math.max(ans, sums);
      }
    }
  }

  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));


Measured memory_bytes: 10652
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

vector<vector<pll>> lines;

vector<ll> dijkstra (int start, int N){
    priority_queue<pll, vector<pll>, greater<pii>> pq;
    vector<ll> dist(N+1, LLONG_MAX);
    vector<ll> route(N+1, LLONG_MAX);
    dist[start] = 0;
    route[start] =0;
    pq.push({dist[start],start});

    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        ll d = p.first;
        int from = p.second;
        if (dist[from]<d) continue;
        for (auto nxt: lines[from]) {
            ll to = nxt.first;
            ll c = nxt.second;
            if (dist[from] + c < dist[to]) {
                dist[to] = dist[from] + c;
                route[to] = from;
                pq.push({dist[to], to});
            }
        }
    }
    return route;
}

int main() {
    // input, ready
    int N,M;
    cin >> N >> M;
    lines.resize(N+1);
    for (int i=0; i<N+1; i++) {
        vector<pll> tmp;
        lines[i] = tmp;
    }
    for (int i=0; i<M; i++) {
        ll A,B;
        cin >> A >> B;
        lines[A].push_back({B,1});
        lines[B].push_back({A,1});
    }

    // resolve
    auto route = dijkstra(1,N);
    // output
    bool yes = true;
    for (int i=2; i<N+1; i++) {
        if(route[i] == LINF) yes=false;
    }
    if (!yes) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        for (int i=2; i<N+1; i++) {
            cout << route[i] << endl;
        }        
    } 

    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    for (int64_t i = 0; i < n; i++) cin >> A[i];

    vector<int64_t> l_gcd(n), r_gcd(n);
    l_gcd[0] = A[0];
    r_gcd[n - 1] = A[n - 1];

    for (int64_t i = 0; i < n - 1; i++)
        l_gcd[i + 1] = __gcd(l_gcd[i], A[i + 1]);
    for (int64_t i = n - 1; i > 0; i--)
        r_gcd[i - 1] = __gcd(r_gcd[i], A[i - 1]);

    int64_t ans = max(l_gcd[n - 2], r_gcd[1]);

    for (int i = 1; i < n - 1; i++)
        ans = max(ans, __gcd(l_gcd[i - 1], r_gcd[i + 1]));

    cout << ans << endl;

}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 N, M;
  cin >> N >> M;
  M *= 2;
  vector< int64 > A(N);
  cin >> A;
  int64 lcm = 1;
  for(int i = 0; i < N; i++) {
    lcm = lcm / __gcd(lcm, A[i]) * A[i];
    if(lcm > M + M) {
      cout << 0 << endl;
      return 0;
    }
  }

  int64 X = lcm / 2;
  for(int i = 0; i < N; i++) {
    int64 Z = 2 * X / A[i];
    if(Z % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << (M + lcm) / (lcm * 2) << endl;
}



Measured memory_bytes: 1024
n, m = map(int, input().split())

ac = [False for _ in range(n)]
wa = [0 for _ in range(n)]

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p - 1] = True
    if s == 'WA' and not ac[p - 1]:
        wa[p - 1] += 1

r1 = sum(ac)
r2 = sum(wa[i] if ac[i] else 0 for i in range(n))

print(r1, r2)



Measured memory_bytes: 85892
#include <stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d%d",&a,&b);
  if(a<10 && b<10){
    c=a*b;
    printf("%d\n",c);
  }
  else{
    printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n;
    cin >> n;
    string s;
    cin >> s;

    int l = 0, r = n - 1;
    int ans = 0;
    while (l < r) {
        while (l < r and s[l] == 'R') l++;
        while (l < r and s[r] == 'W') r--;
        if (l < r) {
            swap(s[l], s[r]);
            l++;
            r--;
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
	string s;
	while(cin >> s){
		for(int i = 0;i < s.size();i++){
			if(s[i] == '@'){
				for(int j = 0;j < s[i+1]-'0';j++)cout << s[i+2];
				i += 2;
			}else cout << s[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)

import operator

N,H,W = map(int,readline().split())
m = map(int,read().split())
RCA = sorted(zip(m,m,m),key=operator.itemgetter(2),reverse=True)

root = list(range(H+W))
size = [0] * (H+W)
no_cycle = [True] * (H+W)

def find_root(x):
    y = root[x]
    if x == y:
        return y
    z = find_root(y)
    root[x] = z
    return z

def merge(x,y):
    x,y = find_root(x),find_root(y)
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    no_cycle[x] = no_cycle[x] and no_cycle[y]

answer = 0
for R,C,A in RCA:
    x,y = R-1,H+C-1
    rx,ry = find_root(x),find_root(y)
    if rx == ry:
        if not no_cycle[rx]:
            continue
        no_cycle[rx] = False
    else:
        if (not no_cycle[rx]) and (not no_cycle[ry]):
            continue
        merge(rx,ry)
    answer += A

print(answer)

Measured memory_bytes: 101608
from math import factorial
def comb(n,r):
    return factorial(n)//(factorial(n-r)*factorial(r))
n,p=map(int,input().split())
A=list(map(int,input().split()))
cnt_odd=0
cnt_even=0
for i in range(n):
    if A[i]%2:
        cnt_odd+=1
    else:
        cnt_even+=1
ans=0
for i in range(p%2,cnt_odd+1,2):
    ans+=2**cnt_even*comb(cnt_odd,i)
print(ans)

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

int main(){
    long long int n,i,c0=0,c1=0,c2=0,c3=0 ;
    string s;
    cin>>n;

    for(i=1;i<=n;i++){
        cin>>s;
        if(s =="AC" || s=="ac"){
            c0=c0+1;
        }
        else if(s=="WA" || s=="wa"){
            c1=c1+1;
        }
        else if(s=="TLE" || s=="tle"){
            c2=c2+1;
        }
        else if(s=="RE" || s=="re"){
            c3=c3+1;
        }
    }

    cout<<"AC x "<<c0<<endl;
    cout<<"WA x "<<c1<<endl;
    cout<<"TLE x "<<c2<<endl;
    cout<<"RE x "<<c3<<endl;



}



Measured memory_bytes: 3628
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int money = 100000;
		int n = sc.nextInt();
		
		for (int i = 0; i < n ; i++)
		{
			money += money * 5 / 100;
			int a;
			if ((a = money % 1000) != 0) money = money - a + 1000; 
		}
		System.out.println(Integer.toString(money));
	}
}

Measured memory_bytes: 11000
def gcd(a,b):
  while b: a,b = b, a%b
  return a

t = int(input())
for _ in range(t):
  a, b, c, d = map(int, input().split())
  if a < b or d < b: print('No')
  elif c >= b: print('Yes')
  else:
    g = gcd(b,d)
    if b-g+a%g > c: print('No')
    else: print('Yes')
      

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

using namespace std;
using ll = long long;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)cin >> a[i] >> b[i];

    ll nax = 0;

    for(int j = 0; j < n; j++) {
        if((a[j] | k) == k)nax += b[j]; 
    }

    for(int i = 0; i < 30; i++) {
        if(((1<<i)&k)==0)continue;
        //i桁目を潰す
        int lim = k;
        lim ^= (1<<i);
        for(int j = 0; j < i; j++)lim |= (1<<j);
        ll sum = 0;
        for(int j = 0; j < n; j++) {
            if((a[j] | lim) == lim)sum += b[j];
        }
        nax = max(nax, sum);
    }
    cout << nax << endl;
}

Measured memory_bytes: 4060
#include<iostream>
using namespace std;
int main()
{
	int d;
	cin>>d;
	if(d==25)
		cout<<"Christmas";
	if(d==24)
		cout<<"Christmas Eve";
	if(d==23)
		cout<<"Christmas Eve Eve";
	if(d==22)
		cout<<"Christmas Eve Eve Eve";
	return 0;
 } 

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


A, B, K = mi()

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        B += A // 2
        A //= 2
    else:
        if B % 2 == 1:
            B -= 1
        A += B // 2
        B //= 2

print(A, B)


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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll a[n];
    ll t = 1e18;
    for(int i=0;i<n;i++){
        cin>>a[i];
        t=min(a[i],t);
    }
    for(int i=0;i<n;i++){
        if(a[i]==t){
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n;
  cin >> n;
  
  if (n % 2 == 1)
    cout << 0 << endl;
  else {
    n /= 2;
    long count = 0;
    
    while (n >= 5) {
      n /= 5;
      count += n;
    }
    
    cout << count << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    double x;
    cin >> x;
    cout << fixed << setprecision(8) << 2.0 * acos(-1) * x << endl;
}


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

int main(){
    string S; cin >> S;
    int ans=0;
    for (int i=0; i<S.size()/2; i++){
        if(S[i]!=S[S.size()-(1+i)]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>

using namespace std;
typedef long long ll;

int main(){
    set<ll> s;
    ll N, temp;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> temp;
        if(s.find(temp)==s.end())
        {
            s.insert(temp);
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
import queue
k=int(input())
q=queue.Queue()
for i in range(1,10):
    q.put(i)
lunlun=list(range(1,10))
cnt=9

while cnt<=k:
    v=q.get()
    last=v%10
    if last!=0:
        new=v*10+last-1
        q.put(new)
        lunlun.append(new)
        cnt+=1
    new=v*10+last
    q.put(new)
    lunlun.append(new)
    cnt+=1
    if last!=9:
        new=v*10+last+1
        q.put(new)
        lunlun.append(new)
        cnt+=1
print(lunlun[k-1])

Measured memory_bytes: 14052
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

// N の約数列挙. O(sqrt(N))
VI all_factors(ll N) {
	VI res;
	for(ll d=1; d*d<=N; d++) {
		if(N%d==0) {
			res.PB(d);
			if(N/d!=d) res.PB(N/d);
		}
	}
	sort(ALL(res));
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N>>M) {
		VI ds = all_factors(M);
		ll ans = 0;
		REPR(i, ds.size()) {
			if(N<=M/ds[i]) {
				ans = ds[i];
				break;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using static System.Console;
namespace a754
{
    class a754
    {
        static void Main(string[] args)
        {
            string x = ReadLine();
            int op = 999;
            for (int p=0; p <= x.Length - 3; p++)
            {
                int y = Math.Abs(int.Parse(x.Substring(p, 3)) - 753);
                op = (op > y) ? y : op;
            }            
             WriteLine(op);
        }
    }
}

Measured memory_bytes: 11092
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto s = readln.strip;
	auto k = readln.strip.to!int;
	
	auto delta = k - 1;
	
	foreach( letter; s.getLetterList )
	{
		string[] subs;
		
		for( ptrdiff_t index = 0; index < s.length; index++ )
		{
			index = s.indexOf( letter, index );
			if( index < 0 ) break;
			
			for( auto length = 1; index + length <= s.length && length <= k; length++ )
			{
				subs ~= s[ index .. index + length ];
			}
		}
		
		auto hoge = sort( subs ).uniq;
		if( delta < hoge.count )
		{
			writefln( hoge.array[ delta ] );
			break;
		}
		
		delta -= hoge.count;
		hoge = hoge.init;
	}
}



auto getLetterList( string s )
{
	dchar[] results;
	
	foreach( c; s )
	{
		results ~= c;
	}
	
	return sort( results ).uniq;
}


Measured memory_bytes: 2684
#include<stdio.h>
 
void right_triangle(int x, int y, int z);
 
int main(void)
{
    int n;
    scanf("%d", &n);
    int i = 0;
    int x, y, z;
    while (i < n) {
        scanf("%d %d %d", &x, &y, &z);
        right_triangle(x, y, z);
        i++;
    }
    return 0;
}
 
void right_triangle(int x, int y, int z)
{
    int i = x * x;
    int j = y * y;
    int k = z * z;
    if (i == j + k || j == k + i || k == i + j) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}

Measured memory_bytes: 1008
#include <iostream>

using namespace std;

int main() {
    int n,m;
    cin>>n>>m;
    if(n>m){
        for(int i=0;i<n;i++){
            char c='0'+m;
            cout<<c;
        }
    }else{
        for(int i=0;i<m;i++){
            char c='0'+n;
            cout<<c;
        }
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

int main(void) {
  int n, t, a, h, r;
  double m, j;
  scanf("%d%d%d", &n, &t, &a);
  scanf("%d", &h);
  m = fabs((double)t - (double)h * 0.006 - a);
  r = 1;
  for(int i = 0; i < n - 1; i++) {
    scanf("%d", &h);
    j = fabs((double)t - (double)h * 0.006 - a);
    if(m > j) m = j, r = i + 2;
  }
  printf("%d\n",  r);
  return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
k = int(input())
if(a >= b):
    if(a >= c):
        for i in range(k):
            a = a*2
    else :
        for i in range(k):
            c = c*2
else :
    if(b >= c):
        for i in range(k):
            b = b*2
    else:
        for i in range(k):
            c = c*2
print(a+b+c)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll A,B,md;
ll nums[200009];

ll f(ll x,ll y,ll idx){
    x+=nums[idx];
    y-=nums[idx];
    return abs(x-y);
}

void calc(vector<pair<ll,ll>> &X){
    A=nums[0],B=0,md=0;
    rep1(i,N-1){
        B+=nums[i];
        while(abs(A-B)>f(A,B,md+1)){
            md++,A+=nums[md],B-=nums[md];
        }
        X[i].first=min(A,B);
        X[i].second=max(A,B);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>nums[i];
    
    vector<pair<ll,ll>> L(N),R(N);
    calc(L);
    reverse(nums,nums+N);
    calc(R);
    reverse(all(R));
    
    ll mn=LLINF;
    rep1(i,N-3){
        ll d=max(L[i].second,R[i+1].second)-min(L[i].first,R[i+1].first);
        if(mn>d) mn=d;
    }
    cout1(mn)
}

Measured memory_bytes: 8064