akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

//Dividing Snacks
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), INF = 1<<29;
		int[] a = new int[n+2];
		for(int i=1;i<n;i++)a[i]=sc.nextInt();
		int[][][] dp = new int[2][2][n/2+1];
		for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int k=0;k<=n/2;k++)dp[i][j][k]=INF;
		dp[0][0][0] = 0;
		int x = 1;
		for(int i=1;i<=n;i++,x=1-x)for(int j=0;j<2;j++){
			int t = Math.min(i, n>>1);
			for(int k=0;k<=t;k++){
				dp[x][0][k] = Math.min(dp[1-x][0][k], dp[1-x][1][k]);
				if(0<k)dp[x][1][k] = Math.min(dp[1-x][0][k-1]+a[i-1]+a[i], dp[1-x][1][k-1]-a[i-1]+a[i]);
			}
		}
		System.out.println(Math.min(dp[1-x][0][n/2], dp[1-x][1][n/2]));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  int l = 0, r = 1e9 + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    int count = 0;
    for (int i = 0; i < n; i++) count += a.at(i) / mid - (a.at(i) % mid == 0);
    if (count <= k) r = mid;
    else l = mid;
  }
  
  cout << r << '\n';
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = -n;
    rep(i, n) {
        ans += a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int p, q, r;
  cin >> p >> q >> r;

  cout << min({p+r, p+q, q+r}) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  set<ll> st;
  vector<ll> A(n);
  rep(i, n) {
    cin >> A[i];
    st.insert(A[i]);
  }
  cout << (st.size() == n ? "YES" : "NO") << "\n";
  return 0;
}


Measured memory_bytes: 14176
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {
	static int INF = 2 << 27;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n+1; i++) {
			G.add(new ArrayList<Edge>());
		}
		used = new boolean[n+1];
		int[] c = new int[n];
		for(int i = 1; i < n; i++) {
			c[i] = sc.nextInt();
			if(c[i] != 0) {
				add_edge(i,n,INF);
			}
		}
		for(int i = 0; i < n-1; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int p = sc.nextInt();
			add_edge(u,v,p);
		}
		int ans = max_flow(0,n);
		System.out.println(ans);
		
	}
	static class Edge {
		int to;
		int cap;
		int rev;
		Edge(int a, int b, int c) {
			to = a;
			cap = b;
			rev = c;
		}
	}
	static ArrayList<ArrayList<Edge>> G = new ArrayList<ArrayList<Edge>>();
	static boolean[] used;
	
	static void add_edge(int from, int to, int cap) {
		G.get(from).add(new Edge(to,cap,G.get(to).size()));
		G.get(to).add(new Edge(from,0,G.get(from).size()-1));
	}
	
	static int dfs(int v, int t, int f) {
		if(v == t) return f;
		used[v] = true;
		for(int i = 0; i < G.get(v).size(); i++) {
			Edge e = G.get(v).get(i);
			if(!used[e.to] && e.cap > 0) {
				int d = dfs(e.to,t,Math.min(f,e.cap));
				if(d > 0) {
					e.cap -= d;
					G.get(e.to).get(e.rev).cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	static int max_flow(int s, int t) {
		int flow = 0;
		for(;;) {
			Arrays.fill(used, false);
			int f = dfs(s,t,INF);
			if(f == 0) return flow;
			flow += f;
		}
	}
	
	
	
}

Measured memory_bytes: 34940
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Aug  2 21:14:47 JST 2020
 **/

signed main() {
    Int n, D;
    std::cin >> n >> D;
    Int ans = 0;
    REP(i, n) {
        Int x, y;
        std::cin >> x >> y;
        ans += x * x + y * y <= D * D;
    }
    std::cout << ans << std::endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  rep(i,n) p[i]++;
  int mx = 0;
  int s = 0;
  queue<int> q;
  rep(i,n) {
    s += p[i];
    q.push(p[i]);
    if (q.size() > k) {
      s -= q.front(); q.pop();
    }
    if (q.size() == k) {
      mx = max(mx, s);
    }
  }
  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1792
while True:
    cnt = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    cnt += 1
    print(cnt)


Measured memory_bytes: 5592
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc =new Scanner(System.in);
        int a=sc.nextInt(), b = sc.nextInt(), c =sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
        long ans = x*a + y*b;
        
        ans = Math.min(ans ,Math.max(x,y)*2*c);
        
        if(y-x>=1)
        ans = Math.min(ans, x*2*c + (y - x)*b);
        if(x-y >=1)
        ans = Math.min(ans, y*2*c + (x - y)*a);
            
        System.out.println(ans);
    }
}


Measured memory_bytes: 20820
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

s = input()

g_count, p_count = 0, 0
ans = 0
for si in s:
    if si == "g":
        if p_count < g_count:
            p_count += 1
            ans += 1
        else:
            g_count += 1
    elif si == "p":
        if p_count < g_count:
            p_count += 1
        else:
            g_count += 1
            ans -= 1
print(ans)
        

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

int main() {
    long long N, K;
    cin >> N >> K;
    if (K >= N) {
        cout << 0;
        return 0;
    }
    vector<long long> H(N);
    for (int i = 0; i < N; i++)cin >> H[i];

    sort(H.begin(), H.end());

    long long ans = (long long)accumulate(H.begin(), H.end() - K, 0LL);

    cout << ans;

}

Measured memory_bytes: 1792
H,W = map(int,input().split())
s = [input() for _ in range(H)]

def check(i,j):
    if s[i][j] == '.':
        return True
    if i != 0 and s[i-1][j] == '#':
        return True
    if j != 0 and s[i][j-1] == '#':
        return True
    if i != H-1 and s[i+1][j] == '#':
        return True
    if j != W-1 and s[i][j+1] == '#':
        return True
    return False

for i in range(H):
    for j in range(W):
        if not check(i,j):
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
  // 入力
  int N;
  cin >> N;

  vector<double> a(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  double sum = 0; // 要素の合計値
  double ave = 0; // 要素の平均値
  double absmin = 101; // 平均値との差を比較するための変数
  int ans = 0;

  for (int i = 0; i < N; i++) {
    sum += a[i];
  }

  ave = sum / N;

  for (int j = 0; j < N; j++) {
    if (abs(a[j] - ave) < absmin) {
      absmin = abs(a[j] - ave);
      ans = j;
    }
  }
  // 出力
  cout << ans << endl;
}

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

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

  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> A(N + 1);

  for(int i = 1; i < N; i++){
    if(S[i - 1] == 'A' && S[i] == 'C'){
      A.at(i + 1) = A.at(i) + 1;
    } else{
      A.at(i + 1) = A.at(i);
    }
  }

  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
      cout << A.at(r) - A.at(l) <<endl;
  }
}

Measured memory_bytes: 1488
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <memory.h>

using namespace std;

typedef long long ll;

const ll MININF = -1e15;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  ll a[3*N+1];
  for(int i=1;i<=3*N;i++) cin >> a[i];
  priority_queue<ll, vector<ll>, greater<ll> > prePQ;
  priority_queue<ll> sufPQ;
  ll preSum[N+1], sufSum[N+1];
  preSum[0] = 0, sufSum[N] = 0;
  for(int i=1;i<=N;i++){
    prePQ.push(a[i]);
    preSum[0] += a[i];
  }
  for(int i=2*N+1;i<=3*N;i++){
    sufPQ.push(a[i]);
    sufSum[N] += a[i];
  }
  for(int i=N+1;i<=2*N;i++){
    prePQ.push(a[i]);
    ll tmp = prePQ.top(); prePQ.pop();
    preSum[i-N] = preSum[i-N-1] + (a[i] - tmp);
  }
  for(int i=2*N;i>=N+1;i--){
    sufPQ.push(a[i]);
    ll tmp = sufPQ.top(); sufPQ.pop();
    sufSum[i-N-1] = sufSum[i-N] + (a[i] - tmp);
  }
  /*
  for(int i=0;i<=N;i++){
    cout << preSum[i] << " " << sufSum[i] << endl;
  }
  */
  ll maxVal = MININF;
  for(int i=0;i<=N;i++){
    maxVal = max(maxVal, preSum[i] - sufSum[i]);
  }
  cout << maxVal << endl;
}

Measured memory_bytes: 5876
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  string s;
  cin >> s;
  if (s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N;
  //cin >> N;
  string s;
  cin >>s;
  N=s.length();
 

  //累積和で解く。
  vector<int> r(N+1,0);//r[0]=0;
   vector<int> b(N+1,0);//b[0]=0;
  //0の数を数えて累積和としてAC[]に保存
  for(int i=0;i<N;i++){
      if(s[i]=='0'){
          r[i+1]=r[i]+1;
          b[i+1]=b[i];
      }
      else//ACの数に変化なし
      {
          b[i+1]=b[i]+1;
          r[i+1]=r[i];
      }
      
  }
  if(r[N]>b[N]){
      cout << 2*b[N]<<endl;
  }
  else
  {
    cout << 2*r[N]<<endl;
  }
  
 
  

return 0;
}

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

const int A = 1000005;

int gcd(int a, int b) {
    int x = max(a,b);
    int y = min(a,b);
    int r = x % y;

    while(r!=0){
        x = y;
        y = r;
        r = x % y;
    }

    return y;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);

  rep(i,n){
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for(int i = 2; i < A; i++){
    int cnt = 0;
    for(int j = i; j < A; j += i){
      cnt += c[j];
    }
    if(cnt > 1) pairwise = false;
  }
  if(pairwise){
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = a[0];
  rep(i,n){
    g = gcd(g,a[i]);
    if(g==1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "not coprime" << endl;

  return 0;
}


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

using namespace std;
using LL = long long;
const LL LINF = 1e18;
const LL MOD = 1e9+7;


int main(){
    int n;cin >> n;
    int n100 = n /100;
    int n10 = n%100/10;
    int n1 = n%10;
    if(n100 == 9){
        n100 = 1;
    }else if(n100 == 1){
        n100 = 9;
    }
    if(n10 == 9){
        n10 = 1;
    }else if(n10 == 1){
        n10 = 9;
    }
    if(n1 == 9){
        n1 = 1;
    }else if(n1 == 1){
        n1 = 9;
    }
    cout<<n100<<n10<<n1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int grid[14][14] = { 0 };

void small(int x, int y){
	grid[x][y]++;
	grid[x - 1][y]++;
	grid[x + 1][y]++;
	grid[x][y - 1]++;
	grid[x][y + 1]++;
}

void medium(int x, int y){
	small(x, y);
	grid[x - 1][y - 1]++;
	grid[x + 1][y - 1]++;
	grid[x - 1][y + 1]++;
	grid[x + 1][y + 1]++;
}

void large(int x, int y){
	medium(x, y);
	grid[x - 2][y]++;
	grid[x + 2][y]++;
	grid[x][y - 2]++;
	grid[x][y + 2]++;
}

int main(){
	int x, y, size;
	
	while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
		if (size == 1) small(x + 2, y + 2);
		else if (size == 2) medium(x + 2, y + 2);
		else if (size == 3) large(x + 2, y + 2);
	}

	int ans1 = 0;
	int ans2 = 0;

	for (int i = 2; i < 12; i++){
		for (int j = 2; j < 12; j++){
			if (grid[i][j] == 0)
				ans1++;
			else
				ans2 = max(ans2, grid[i][j]);
		}
	}

	printf("%d\n%d\n", ans1, ans2);

	return 0;
}

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

const int maxn = 1e5 + 5;

int main() {

    int N, K;
    scanf("%d%d", &N, &K);

    vector<int> a(N), dp(K+1);

    for (int &x: a) {
        scanf("%d", &x);
        dp[x] = 1;
    }

    for (int k = 1; k <= K; ++k) {
        for (int x: a) {
            if (k - x >= 0 and !dp[k-x]) {
                dp[k] = 1;
            }
        }
    }

    if (dp[K] == 1) printf("First\n");
    else printf("Second\n");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()

int main(){
	int n;
	cin>>n;
	int a[n];
	in(a,n);
	int b[n+1],c[n+1];
	rep(i,n){
		b[i]=a[i]+i+1;
		c[i]=i+1-a[i];
	}
	b[n]=2000000000;
	c[n]=2000000000;
	sort(b,b+n);
	sort(c,c+n);
	int bp=0,cp=0;
	ll sum=0,bcount,ccount;
	while(bp<n&&cp<n){
		if(b[bp]>c[cp])cp++;
		else if(b[bp]<c[cp])bp++;
		else{
			bcount=0;
			for(int start=b[bp];b[bp]==start;bp++)bcount++;
			ccount=0;
			for(int start=c[cp];c[cp]==start;cp++)ccount++;
			sum+=bcount*ccount;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 5928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

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

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

int main(){
  
  int K;
  cin >> K;
  int A;
  int B;
  cin >> A >> B;

  for(int i = A;i <= B;i++){
    if(i%K == 0){
      cout << "OK";
        return 0;
    }
  }
  
  cout << "NG";
}
  

Measured memory_bytes: 3632
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>
#include <random>
#include <cmath>
#include <climits>
constexpr int limit = 3000;
template<typename T>
bool valid_index(const std::vector<T> &vec, const int index) {
	return 0 <= index && index < vec.size();
}
std::vector<std::vector<double>> estimated(const int s, const int g, const std::vector<int> &dice, const std::vector<int> &direction) {
	std::vector<std::vector<double>> result(direction.size(), std::vector<double>(limit + 1, 0));
	result[g][0] = 0;
	for (auto i = 1; i < result.size(); ++i) {
		result[(i + g) % result.size()][0] = limit;
	}
	for (auto i = 1; i <= limit; ++i) {
		for (auto pos = 0; pos < result.size(); ++pos) {
			double min = 0;
			for (const auto d : dice) {
				double temp = result[pos][i - 1] + 1;
				if (valid_index(direction, pos + d) && valid_index(result, pos + d + direction[pos + d])) {
					if (temp > result[pos + d + direction[pos + d]][i - 1]) {
						temp = result[pos + d + direction[pos + d]][i - 1];
					}
				}
				if (valid_index(direction, pos - d) && valid_index(result, pos - d + direction[pos - d])) {
					if (temp > result[pos - d + direction[pos - d]][i - 1]) {
						temp = result[pos - d + direction[pos - d]][i - 1];
					}
				}
				min += temp / dice.size();
			}
			result[pos][i] = min + 1;
		}
		result[g][i] = 0;
	}
	return result;
}
int main() {
	int m; std::cin >> m;
	std::vector<int> dice(6);
	for (auto &d : dice) std::cin >> d;
	int s, g; std::cin >> s >> g; --s; --g;
	std::vector<int> direction(m);
	for (auto &d : direction) std::cin >> d;
	auto est = estimated(s, g, dice, direction);
	auto current = s;
	int di;
	for (auto count = limit; count > 0; --count) {
		std::cin >> di;
		auto d = dice[di - 1];
		double temp = est[current][count];
		int next = current;
		int out = 0;
		if (valid_index(direction, current + d) && valid_index(est, current + d + direction[current + d])) {
			if (temp > est[current + d + direction[current + d]][count]) {
				temp = est[current + d + direction[current + d]][count];
				out = 1;
				next = current + d + direction[current + d];
			}
		}
		if (valid_index(direction, current - d) && valid_index(est, current - d + direction[current - d])) {
			if (temp > est[current - d + direction[current - d]][count]) {
				out = -1;
				next = current - d + direction[current - d];
			}
		}
		//std::cout << "from " << current << ", to " << next << ", dice " << d << ", direction " << direction[current + out * d] << std::endl;
		current = next;
		std::cout << out << std::endl;
		if (current == g) return 0;
	}
}


Measured memory_bytes: 10016
import sys
input = sys.stdin.readline
import numpy as np
INF=10**9+1
def main():
    n, W = map(int, input().split())
    dp = np.full(n*1000+1,INF,dtype=int)
    dp[0]=0
    for i in range(1,n+1):
        w,v=map(int,input().split())
        dp[v:]=np.minimum(dp[v:],dp[:-v]+w)
    for i in range(len(dp)-1, -1, -1):
        if dp[i] <= W:
            print(i)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 14912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,A,B; cin >> N >> A>>B;
    cout << min(B,N*A) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long A, long long B) {
  cout << A * B << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


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

void solve()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int,input().split()))
B = (10**5+1)*[0]
ans = 0

for a in A:
  if a<=10**5:
    B[a]+=1
  else:
    ans+=1

for n in range(10**5):
  if B[n]<n:
    ans+=B[n]
  elif n<B[n]:
    ans+=B[n]-n

print(ans)

Measured memory_bytes: 20600
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const double pi=acos(-1);

int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double ans=0;
  ans+=pow(x1-x2,2)+pow(y1-y2,2);
  ans=sqrt(ans);
  cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long double x;
	long double c;
	cin >> x >> c;
	x *= c;
	ll d = x;
	cout << d;
    return 0;
}


Measured memory_bytes: 3744
s = gets.strip.split("")

c = s.size / 2
count = 0
if s.size.even?
   for x in (0..c)
      unless s[x] == s[s.size - x - 1]
         s[s.size - x - 1] = s[x]
         count += 1
      end
   end
else
   for x in (0..c)
      unless s[x] == s[s.size - x - 1]
         s[s.size - x - 1] = s[x]
         count += 1
      end
   end
end

puts count


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int max1 = 0, max2 = 0;
    rep(i, n) {
        if (a[i] >= max1) {
            max2 = max1;
            max1 = a[i];
        } else if (a[i] > max2) {
            max2 = a[i];
        }
    }

    rep(i, n) {
        if (a[i] == max1) {
            cout << max2 << endl;
        } else {
            cout << max1 << endl;
        }
    }

    return 0;
}

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

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

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

    for (int i = 1; i <= N; i++) {
        dp[i] = dp[i-1] + 1;  // 1を使った場合

        int digit = 6;
        while (true) {
            int now = i - digit;
            if (now >= 0) dp[i] = min(dp[i], dp[now] + 1);
            else break;

            digit *= 6;
        }

        digit = 9;
        while (true) {
            int now = i - digit;
            if (now >= 0) dp[i] = min(dp[i], dp[now] + 1);
            else break;

            digit *= 9;
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	s := make([]string, n)
	result := map[string]int{"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

	for i:=0; i<len(s); i++{
		fmt.Scan(&s[i])
		switch s[i] {
		case "AC" :
			result["AC"]++
		case "WA":
			result["WA"]++
		case "TLE":
			result["TLE"]++
		case "RE":
			result["RE"]++
		}
	}

	fmt.Printf("AC x %d\n", result["AC"])
	fmt.Printf("WA x %d\n", result["WA"])
	fmt.Printf("TLE x %d\n", result["TLE"])
	fmt.Printf("RE x %d\n", result["RE"])

}

Measured memory_bytes: 6860
#include<cstdio>
#include<set>
using namespace std;
int n,a;
set <int> s;
int main()
{
	s.clear();
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(*s.find(a)!=a) s.insert(a);
		else s.erase(a);
	}
	printf("%d",s.size());
	return 0;
}

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

const int N = 2e5 + 5;

int A[N] , n;

int main(void) {
	scanf("%d" , &n);
	for(int i = 1;i <= n;++ i) {
		scanf("%d" , &A[i]);
		if(A[i] > A[i - 1] + 1) 
		return 0 * puts("-1");
	}
	if(A[1]) return 0 * puts("-1");
	long long ans = 0;
	int now = n - A[n]; ans += A[n];
	for(int i = n - 1;i >= 1;-- i) {
		int it = i - A[i];
		if(it == now) continue;
		else {
			now = it;
			ans += A[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define NUM 2001

int main(){
	int s;
	scanf("%d", &s);
	long long dp[NUM];
	long long mod = 1000000007;
	dp[0] = 1;
	dp[1] = 0;
	dp[2] = 0;
	for(int i=3; i<=s; i++) {
		dp[i] = dp[i-1] + dp[i-3];
		dp[i] %= mod;
	}
	printf("%lld", dp[s]);
	return 0;
}


Measured memory_bytes: 1720
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    cnt = 0
    n = f()[0]
    for i in range(1,n+1):
        cnt_divisor = 0
        if i%2 == 0:
            continue
        for j in range(1, i+1):
            if i%j == 0:
                cnt_divisor += 1
        
        if cnt_divisor == 8:
            cnt += 1
    
    print(cnt)

solve()


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

using namespace std;

const int N = 1e5 + 10;

long long n, a[ N ], b[ N ];

int main() {
  cin >> n;
  for ( int i = 1 ; i <= n ; ++i )
    cin >> a[ i ];

  long long sm = 0, tar = n * ( n + 1 ) / 2;
  for ( int i = 1 ; i <= n ; ++i )
    sm += a[ i ];
  if ( sm % tar != 0 ) {
    cout << "NO" << endl;
    return 0;
  }
  
  long long times = sm / tar;

  for ( int i = 1 ; i < n ; ++i )
    b[ i ] = a[ i + 1 ] - a[ i ];
  b[ n ] = a[ 1 ] - a[ n ];

  for ( int i = 1 ; i <= n ; ++i ) {
    b[ i ] -= times;
    b[ i ] = -b[ i ];
    if ( b[ i ] < 0 ) {
      cout << "NO" << endl;
      return 0;
    }
  }

  for ( int i = 1 ; i <= n ; ++i ) {
    if ( b[ i ] % n != 0 ) {
      cout << "NO" << endl;
      return 0;
    }
    times -= b[ i ] / n;
  }

  if ( times != 0 )
    cout << "NO" << endl;
  else 
    cout << "YES" << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

bool solve() {
    int N;
    scanf("%d", &N);
    if(N == 0) return false;
    vector<int> bless(1000, 0);
    vector<bool> present(1000, false);
    int prev_time = 0;
    int prev_date = 0;
    TIMES(_, N) {
        int month, day, h, m, id;
        char event;
        scanf("%d/%d %d:%d %c %d", &month, &day, &h, &m, &event, &id);
        const int date = month * 100 + day;
        const int t = h*60 + m;
        if(date != prev_date) {
            if(present[0]) {
                const int rem = 24*60 - prev_time;
                TIMES(i, 1000) {
                    if(present[i]) bless[i] += rem;
                }
            }
            fill(present.begin(), present.end(), false);
            prev_time = 0;
        }
        if(present[0]) {
            TIMES(i, 1000) {
                if(present[i]) bless[i] += t - prev_time;
            }
        }
        present[id] = (event == 'I');
        prev_time = t;
        prev_date = date;
    }
    bless[0] = 0;
    printf("%d\n", *max_element(bless.begin(), bless.end()));
    return true;
}

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

Measured memory_bytes: 1176
s = int(input())
ans = set([])

ans.add(s)
j = 1
while 1:
        if j  > 1000000:
                break
        if s % 2 == 0:
                s = s // 2
        else:
                s = 3 * s + 1
        j += 1
        for i in ans:
                if s == i:
                        print(j)
                        exit()
        ans.add(s)


Measured memory_bytes: 38512
n=list(input())

n==n.reverse()

if (n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9"):
    print("hon")
elif (n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8"):
    print("pon")
elif (n[0]=="3"):
    print("bon")


Measured memory_bytes: 9076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

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


void solve(){
    int a, b;
    cin >> a >> b;
    double ans_a = a/0.08;
    int ans = ans_a;
    if(ans != ans_a)
        ans++;
    int tax = ans * 0.1;
    while(tax != b){
        ans++;
        tax = ans * 0.1;
        int tax_a = ans * 0.08;
        if(tax_a != a){
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PIなどの定義を使用するのに必要
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>

using namespace std;

int main()
{
  int R;

  cin >> R;

  cout << fixed << setprecision(8) << 2 * M_PI * R << endl;

  return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MAX = 101010;

int main() {
  int q; cin >> q;
  vll l(q), r(q);
  rep(i, q) cin >> l[i] >> r[i];

  vll is_prime(MAX, 1); //エラトステネスのふるい
  is_prime[0] = 0, is_prime[1] = 0;
  for (int i = 2; i < MAX; i++) {
    if (is_prime[i])
      for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
  }
  vll a(MAX, 0), s(MAX+1, 0);
  for (int i = 0; i < MAX; i++)
    if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
  for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];

  rep(i, q) cout << s[r[i]+1] - s[l[i]] << endl;
  return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

void solve() {
	const string yes = "Yes", no = "No";
	string a, b;
	cin >> a >> b;
	int n = a.size();
	map<char, char> a_map, b_map;
	for (int i = 0; i < n; i++) {
		char ac = a[i], bc = b[i];
		if (a_map.count(ac)) {
			if (a_map[ac] != b[i]) {
				cout << no;
				return;
			}
		} else if (b_map.count(bc)) {
			if (b_map[bc] != a[i]) {
				cout << no;
				return;
			}
		}
		a_map[a[i]] = b[i];
		b_map[b[i]] = a[i];
	}
	cout << yes;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
	solve();
}

Measured memory_bytes: 916
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll a[200105];
ll sum=0;
int d[200105][35],n;
 
void init()
{
    int i,j;
    for(i=0;i<n;i++)
        d[i][0]=i;
    for(j=1;(1<<j)<=n;j++)
    for(i=0;i+(1<<j)-1<n;i++)
        d[i][j]=a[d[i][j-1]] < a[d[i+(1<<(j-1))][j-1]]? d[i][j-1]:d[i+(1<<(j-1))][j-1];
}
int RMQ_indx_min(int s,int v)
{
    int k=(int)(log((v-s+1)*1.0)/log(2.0));
    return a[d[s][k]]<a[d[v-(1<<k)+1][k]]? d[s][k]:d[v-(1<<k)+1][k];
}
 
 
void dfs(int l,int r)
{
    if(l==r){
        sum+=(ll)a[l];
        return ;
    }
    int minn=RMQ_indx_min(l,r);
    sum=sum+(ll)(minn-l+1)*(r-minn+1)*a[minn];
    if(l<=minn-1)
        dfs(l,minn-1);
    if(r>=minn+1)
        dfs(minn+1,r);
}
int main (){
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    init();
    dfs(0,n-1);
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 38528
import java.util.*;

public class Main {
	 
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		while(true) {
			String str=cin.nextLine();
			
			int sum=0;
			
			for(int i=0;i<str.length();i++) {
				char c=str.charAt(i);
				if(i==0 && c=='0')return;
				sum+=(int)(c-48);
			}
			
			System.out.println(sum);
		}
	}
	
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll h[100005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n;

    ll m = 0;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        std::cin >> h[i];

        if (m > h[i]) {
            ok = false;
            break;
        }

        m = std::max(m, h[i] - 1);
    }

    if (ok)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}


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

int main() {
int a;
cin >> a;
int min = 999999999,max = 0;
int b[a];
for (int i=0; i < a; i++){
    cin >> b[i];
    if(min > b[i]){min = b[i];}
    if(max < b[i]){max = b[i];}
}
cout << max - min << "\n";
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 For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	int n;
	cin >> n;
	int res = 0;
	FOR(i, 1, n+1) {
		int k = i;
		int cnt = 0;
		while (k > 0) {
			k /= 10;
			cnt++;
		}
		if (cnt % 2 == 1) {
			res++;
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
meiro = [list(input()) for i in range(H)]
right = [[0 for _ in range(W)] for _ in range(H)]
left= [[0 for _ in range(W)] for _ in range(H)]
up = [[0 for _ in range(W)] for _ in range(H)]
down = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    cur=0
    for j in range(W):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        left[i][j]=cur
for i in range(H):
    cur=0
    for j in range(W-1,-1,-1):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        right[i][j]=cur
for i in range(W):
    cur=0
    for j in range(H):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        up[j][i]=cur
for i in range(W):
    cur=0
    for j in range(H-1,-1,-1):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        down[j][i]=cur
res = 0
for i in range(H):
    for j in range(W):
        res = max(res,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(res)

Measured memory_bytes: 314120
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(void){
    // Here your code !
    while(true){
    int a,b,c;
    string op ;
    cin>>a>>op>>b;
    if(op=="?") {
       break;
    }
    if(op=="+"){
        c=a+b;
    }
    else if(op=="-"){
        c=a-b;
    }
    else if(op=="*"){
        c=a*b;
    }
    else if(op=="/"){
        c=a/b;
    }
    
    cout<<c<<endl;
    
   
}
 return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <cmath>
#include <vector>
 
using namespace std;
 
int main()
{
  int n; cin >> n;
  vector<int> h;
  
  for (int i = 0; i < n; ++i) {
    int v; cin >> v;
    h.push_back(v);
  }
  
  int dp[n];
  for (int i=0; i < n; ++i){
  	 if (i==0) dp[0] = 0;
     else if (i==1) dp[1] = abs(h[0] - h[1]);
     else {
       dp[i] = min(abs(h[i-1]-h[i])+dp[i-1],
                   abs(h[i-2]-h[i])+dp[i-2]);
     }
  }
  cout << dp[n-1];
  return 0;
}

Measured memory_bytes: 1144
n = int(input())
h = list(map(int,input().split()))
max_move = 0
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
        if count > max_move:
            max_move = count
    else:
        if count > max_move:
            max_move = count
        count = 0
print(max_move)


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

int main() {
	int dataset[10000];
	int input;
	int count = 0;

	while(cin >> input) {
		if(input == 0) {
			break;
		} else {
			dataset[count] = input;
			count++;
		}
	}

	for(int i=0; i<count; i++) {
		cout << "Case " << i+1 << ": " << dataset[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
 
int main() {
int n,m;
cin >> n >> m;
vector<vector<ll>> a(n,vector<ll>(2));
vector<vector<ll>> b(m,vector<ll>(2));
rep(i,n) cin >> a.at(i).at(0) >> a.at(i).at(1);
rep(i,m) cin >> b.at(i).at(0) >> b.at(i).at(1);

rep(i,n){
  ll md = pow(10,18);
  int num;
  rep(j,m){
  ll d = abs(a.at(i).at(0)-b.at(j).at(0))+ abs(a.at(i).at(1)-b.at(j).at(1));
  if(md > d){
    md = d;
    num = j+1;
  }
}
cout << num << endl;
}

}

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

int main() {
	int N;
  	cin >> N;
  	int N2 = N;
  	int total = 0;
  	for(int i = 0; i < 9; i++){
    	total += N % 10;
      	N = N / 10;
    }
  	if(N2 % total == 0){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}


Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))
one = max(a)
if one%2 == 0:
    test = one//2
else:
    test = one//2+1
x = float("inf")
diff = float("inf")
for i in a:
    if i < one:
        if abs(test-i) < diff:
            x = i
            diff = abs(test-i)
print(one,x)

Measured memory_bytes: 20052
#include<iostream>
#include<vector>
#include<string>
#include<tuple>
#include<algorithm>

using namespace std;

int main(){
    int a,b;

    cin >> a >> b;

    if(a<=5)
    {
        cout << "0";
    }else if(a>5 && a<=12){
        cout << b/2;
    }else{
        cout << b;
    }


}

Measured memory_bytes: 256
while True:
    n, x = list(map(int,input().split()))
    if (n, x) == (0, 0):
        break
    else:
        ans = 0
        for i in range(1,n-1):
            for j in range(i+1,n):
                if j < x - i - j <= n:
                    ans += 1
        print(ans)


Measured memory_bytes: 5596
x=int(input())
def cal(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
num=cal(x)
numset=sorted(list(set(num)))
cnt=[0]*len(numset)
now=0
for i in range(len(num)):
    if numset[now]==num[i]:
        cnt[now]+=1
    else:
        now+=1
        cnt[now]+=1
ans=0
for j in range(len(cnt)):
    s=1
    plu=2
    c=0
    flag=0
    while flag!=1:
        if s<=cnt[j]:
            c+=1
            s+=plu
            plu+=1
        else:
            ans+=c
            flag=1
print(ans)


Measured memory_bytes: 9256
package main

import (
	"fmt"
)

func main() {
	var (
		n,a,b int
		sum = 0
	)
	fmt.Scan(&n,&a,&b)
	for i := 0; i < n+1; i++ {
		if check(i) >= a && check (i) <=  b {
			sum += i
		}
	}
	fmt.Println(sum)
}

func check(i int) int {
	var wa = 0
	for flag := true; flag; {
		wa += i % 10
		i /= 10
		if i == 0 {
			flag = false
		}
	}
	return wa
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> V(N);
  rep(i,N) cin>>V[i];
  sort(all(V));
  double ans=V[0];
  rep(i,N-1) ans=(ans+V[i+1])/2;
  cout<<ans<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int Mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
    int n,mn=INT_MAX,s1,s2;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; i++)
    {
        s1=0,s2=0;
        for(int j=0; j<i; j++)
            s1+=a[j];
        for(int j=i; j<n; j++)
            s2+=a[j];
        mn=min(mn,abs(s1-s2));
    }
    cout<<mn<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <sstream>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        print_to(os, ", ", "\n", __VA_ARGS__);            \
        std::cerr << os.str();                            \
    } while (0)
#define dump_(a)                                          \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #a << " = [";          \
        print_to_(os, ", ", "]\n", all(a));               \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#define dump_(...)
#endif

template <typename T>
void print_to(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) {
    os << fst << del;
    print_to(os, del, tail, rst...);
}
template <typename Iter>
void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) {
    for (Iter it = bgn; it != end;) {
        os << *it;
        if (++it != end) {
            os << del;
        } else {
            os << tail;
        }
    }
}
template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, " ", "\n", fst, rst...);
}
template <typename Iter>
void println_(Iter bgn, Iter end) {
    print_to_(std::cout, "\n", "\n", bgn, end);
}
template <typename Iter>
void print_(Iter bgn, Iter end) {
    print_to_(std::cout, " ", "\n", bgn, end);
}

// const int MOD = 1000000007;
namespace trush {
    int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
             std::ios::sync_with_stdio(0), 0);
}

int R, G;

signed main()
{
    cin >> R >> G;

    cout << G + (G - R) << endl;
}


Measured memory_bytes: 256