akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s, ss = "keyence", sf;
	cin >> s;
	int n = s.length(), i, j, k, x;
	bool found = false;
	for (i = 0; i < 7; i++) {
		sf = s.substr(0, i) + s.substr(n - 7 + i);
		if (sf == ss) found = true;
	}

	if (found) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}



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

using namespace std;

int a[100005];
bool vis[100005];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	long long res = 0;
	
	vis[0] = 1;
	vis[n - 1] = 1;
	
	for (int i = 1; i <= n - 1; i++) {
		long long sum = 0;
		int idx = 0;
		
		vector <int> tmp;
		
		while (true) {
			idx++;
			int l = i * idx;
			int r = n - 1 - i * idx;
			
			if (l > n - 1 || r < 0) break;
			if (r <= i) break;
			
			if (l == r) break;
			if (vis[l]) break;
			if (vis[r]) break;
			vis[l] = 1;
			sum += a[l];
			vis[r] = 1;
			sum += a[r];
			
			res = max(res, sum);
			tmp.push_back(l);
			tmp.push_back(r);
		}
		
		for (int j = 0; j < tmp.size(); j++) vis[tmp[j]] = 0;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 1652
#include<iostream>
using namespace std;
int main()
{
    char a1;
    cin>>a1;
    if((a1>=65)&&(a1<=90))
    {
        cout<<'A'<<endl;
    }
    else if((a1>=97)&&(a1<=122))
    {
        cout<<'a'<<endl;
    }

}

Measured memory_bytes: 3056
#include<stdio.h>

int main(){
    int A[4];
    char S[4];
    int i, j, k;
    int ans;

    scanf("%s", &S);
    for(i=0; i<4; i++){
        A[i] = (int)S[i]-'0';
    }

    for(i=0; i<2; i++){
        for(j=0; j<2; j++){
            for(k=0; k<2; k++){
                ans=0;
                ans+=A[0];
                if(i==0){
                    ans+=A[1];
                }else{
                    ans-=A[1];
                }
                if(j==0){
                    ans+=A[2];
                }else{
                    ans-=A[2];
                }
                if(k==0){
                    ans+=A[3];
                }else{
                    ans-=A[3];
                }
                if(ans==7){
                    break;
                }
            }
            if(ans==7){
                break;
            }
        }
        if(ans==7){
            break;
        }
    }

    printf("%d",A[0]);
    if(i==0){
        printf("+");
    }else{
        printf("-");
    }
    printf("%d",A[1]);
    if(j==0){
        printf("+");
    }else{
        printf("-");
    }
    printf("%d",A[2]);
    if(k==0){
        printf("+");
    }else{
        printf("-");
    }
    printf("%d=7",A[3]);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>

using namespace std;

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int l_ab = max(X, Y) * 2;
    int lowest_price = 100000000000;
    int n[3];
    for (int i = 0; i <= l_ab; ++i)
    {
        int l_a = max(X - i / 2, 0);
        int l_b = max(Y - i / 2, 0);
        auto price = l_a * A + l_b * B + i * C;
        if (price < lowest_price)
        {
            lowest_price = price;
            n[0] = l_a;
            n[1] = l_b;
            n[2] = l_ab;
        }
    }

    cout << lowest_price << endl;
}

Measured memory_bytes: 256
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))


N, K = [int(x) for x in input().split()]
D = [x for x in input().split()]

while True:
    isOK = True
    for n in list(str(N)):
        if n in D:
            isOK = False
            break
    if isOK:
        print(N)
        sys.exit()
    N += 1

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

int main(){

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

    int n, a[51];
    long long sum = 0;
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j) sum += (a[i] * a[j]);
    }
    cout << sum << '\n';
    return 0;
}


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

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;

bool operator < (const P& a, const P& b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    P p[4];
    for (int i=0; i<4; i++) {
      double x,y;
      cin >> x >> y;
      p[i] = P(x,y);
    }
    if (abs(cross(p[1]-p[0], p[3]-p[2])) < EPS)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1)a +=13;
  if(b == 1)b += 13;
  string ans = "Draw";
  if(a > b)ans = "Alice";
  else if(a < b)ans = "Bob";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
#include <queue>
#include <utility>

using namespace std;

int main()
{
    int item_total, knapsack_capacity;
    cin >> item_total >> knapsack_capacity;

    vector<int> values(item_total);
    vector<int> weights(item_total);
    map<double, int> vtow_ratio;

    double value_total = 0;

    for (int i = 0; i < item_total; i++)
    {
        cin >> values[i] >> weights[i];
        vtow_ratio[double(values[i])/weights[i]] = i;
    }

    map<double, int>::reverse_iterator it = vtow_ratio.rbegin();
    while (it != vtow_ratio.rend())
    {
        value_total += values[it->second];
        knapsack_capacity -= weights[it->second];
        if (knapsack_capacity < 0)
        {
            value_total += it->first * knapsack_capacity;
            break;
        }
        it++;
    }

    cout << fixed << value_total << endl;



}


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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll N; cin >> N;

    ll cnt = 0;

    for (int i = 1; i <= N; ++i) {
        string s;
        s = to_string(i);

        if (s.length() % 2 == 1) {
            ++cnt;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int K, S; cin >> K >> S;
    int ans = 0;
    for (int x = 0; x <= K; x++)
    {
        for (int y = 0; y <= K; y++)
        {
            int z = S - x - y;
            if(z >= 0 && z <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//Volume1-0149
import java.util.Scanner;

class Main {

	public static void main(String[] arg){

		int     rl  = 0;
		int[][] eye = new int[2][4];
		double	n;

		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			n = sc.nextDouble();
			if(n >= 1.1){
				eye[rl][0]++;
			} else if(n >=0.6){
				eye[rl][1]++;
			} else if(n >=0.2){
				eye[rl][2]++;
			} else {
				eye[rl][3]++;
			}
			rl = 1 - rl;
		}

		for(int i=0;i<4;i++){
			System.out.println(eye[0][i] + " " + eye[1][i]);
		}
	}
}

Measured memory_bytes: 20676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> a(N);
    REP(i,N)a[i] = in();
    int count = 0;
    int before = 0;
    REP(i,N){
        if(before == a[i]){
            count++;
            before = 0;
        }else{
            before = a[i];
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
typedef long long intl;

//k番目の締め切りに間に合う == k番目までの仕事にかかる合計時間以下
int n;
vector<pair<int, int>> tasks;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        tasks.emplace_back(b,a); //emplace_back() 末尾要素追加
        //firstがB(〆切)，secondがA(所要時間)
        //pairは型名は<>で，要素は()で囲む
    }
    //〆切が早い順に並べ替え
    //〆切B_i <= 経過時間sum + 所要時間A_i
    sort(tasks.begin(), tasks.end()); //tasks.firstについて昇順ソート
    int sum = 0;
    bool isYes = true;
    for (auto v : tasks) //範囲for文 全要素にたいして処理を行うとき便利
    {
        sum += v.second; //その仕事自身の所要時間を足したときに，
        if (sum > v.first) //〆切を超過してしまったらNo
        {
            isYes = false;
            break;
        }
    }
    cout << (isYes ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
    fastio;
   	int n;
   	cin>>n;
   vector<int> v(n);
   for(int i=0;i<n;i++)cin>>v[i];
   	vector<int> P = v;
   for(int i=0;i<n;i++)cin>>v[i];
   	vector<int> Q = v;
   int a=0,b=0;
   for(int i=0;i<n;i++)v[i] = i+1;
   int cnt=0;
   	do{
   		if(P==v)a=cnt;
   		if(Q==v)b=cnt;
   		cnt++;
   	}while(next_permutation(all(v)));

   	cout<< abs(a-b)<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, m, n) for(int i = m; i >= n; i--)

int st[200][200];
bool l[200][200];
bool r[200][200];

int main(){
	int n;
	while(cin >> n && n){
		int res = 0;
		memset(l, false, sizeof(l));
		memset(r, false, sizeof(r));
		rep(i,n)rep(j, n) cin >> st[i][j];
		rep(i, n){
			int c = INF;
			rep(j, n){
				c = min(c, st[i][j]);
			}
			rep(j, n){
				if(c == st[i][j]) l[i][j] = true;
			}
		}
		rep(i, n){
			int c = 0;
			rep(j, n){
				c = max(c, st[j][i]);
			}
			rep(j, n){
				if(c == st[j][i] && l[j][i]) res = st[j][i];
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

n, q = [ int(v) for v in input().split() ]
value_list = [ 0 for i in range(n) ]
connect_list = [ [] for i in range(n) ]
for i in range(n-1):
    a, b = [ int(v)-1 for v in input().split() ]
    connect_list[a].append(b)
    connect_list[b].append(a)
for i in range(q):
    c, p = [ int(v)-1 for v in input().split() ]
    value_list[c] += p + 1


serached_list = [ 0 for i in range(n) ]

search_list= connect_list[0]
serached_list[0] = 1
for i in connect_list[0]:
    value_list[i] += value_list[0] 


while search_list != []:
    new_search_list = []
    for i in search_list:
        serached_list[i] = 1
        for j in connect_list[i]:
            if serached_list[j] == 0:
                value_list[j] += value_list[i] 
                new_search_list.append(j)
    search_list = new_search_list
print(*value_list)


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

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

  ll n,m,s; cin>>n>>m>>s;
  struct Train {
    ll s, c, d;
    Train(ll s,ll c,ll d):s(s),c(c),d(d){}
    bool operator>(const Train& x) const {return d>x.d;}
  };
  vector<Train> graph[n];
  for (int i = 0; i < m; i++) {
    ll u,v,a,b; cin>>u>>v>>a>>b; u--; v--;
    graph[u].emplace_back(v,a,b);
    graph[v].emplace_back(u,a,b);
  }
  for (int i = 0; i < n; i++) {
    int c,d; cin>>c>>d;
    graph[i].emplace_back(i,-c,d);
  }
  constexpr ll MAX = 200;
  constexpr ll INF = 1e18;
  vector<array<ll, MAX+1>> dp(n);
  for (auto& arr:dp) arr.fill(INF);
  dp[0][min(s,MAX)] = 0;
  priority_queue<Train, vector<Train>, greater<>> qs;
  qs.emplace(0,s,0);
  while (not qs.empty()) {
    auto [s,c,d] = qs.top(); qs.pop();
    if (d > dp[s][min(c,MAX)]) continue;
    for (auto t:graph[s]) {
      if (c-t.c<0) continue;
      if (d+t.d >= dp[t.s][min(c-t.c,MAX)]) continue;
      dp[t.s][min(c-t.c,MAX)] = d+t.d;
      qs.emplace(t.s, c-t.c, d+t.d);
    }
  }
  for (int i = 1; i < n; i++) {
    cout << *min_element(dp[i].begin(), dp[i].end()) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  double ans=0.0;
  int n,k; cin >> n >> k;

  for(int i=1;i<=n;i++){
    int bin =1;
    while(true){
      if(i*bin>=k) break;
      bin*=2;
    }
    ans += 1.0/bin;
  }

  printf("%.13f",ans/n);

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int a[] = new int[n]; //配列の宣言
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			for(int i = 1; i < n; i++) {
				System.out.print(a[n - i] + " ");
			}
			System.out.print(a[0] + "\n");
		}
	}
}



Measured memory_bytes: 26264
<?php
$arr = explode(' ', trim(fgets(STDIN)));

// Aを考える
$n = $arr[0];
$m = $arr[1];
$q = $arr[2];

for ($i=0; $i < $q; $i++) { 
    # code...
    $qs[] = explode(' ', trim(fgets(STDIN)));
}

// for ($i=1; $i <= $m; $i++) { 
//     # code...
//     $source[] = $i;
// }
// $as = getCPattern($source, $n); 

for ($i=1; $i <= $m; $i++) { 
    # code...
    $as[] = array($i);
}
for ($i=0; $i < $n; $i++) { 
    $as = getArr($as, $m);
}

$s = 0;
// echo '$ct = ' .count($as) . PHP_EOL;
for ($i=0; $i < count($as); $i++) { 
    // echo '$a = ' . implode(',',$as[$i]) . PHP_EOL;
    // $a = sort($as[$i]);
    $a = $as[$i];
    sort($a);
    // echo '$i1 = ' . $i . PHP_EOL;
    // echo '$a = ' . implode(',',$a) . PHP_EOL;
    
    $tmp_s = 0;
    for ($j=0; $j < $q; $j++) { 
        $arr = $qs[$j];
        // echo '$j = ' . $j . PHP_EOL;
        // echo $arr[0] . PHP_EOL;
        // echo $arr[1] . PHP_EOL;
        // echo $arr[2] . PHP_EOL;
        // echo implode(',',$a) . PHP_EOL;

        if(($a[$arr[1] - 1] - $a[$arr[0] - 1]) == $arr[2]){
            $tmp_s = $tmp_s + $arr[3];
        }
    }

    if($tmp_s > $s){
        $s = $tmp_s;
    }
}

echo $s;

return;

function getArr($as, $max) {
    for ($i=0; $i < count($as); $i++) { 
        $a = $as[$i][count($as[$i]) - 1];
        while (true) {
            if ($a > $max) {
                break;
            }
            $tmpArr = $as[$i];
            $tmpArr[] = $a;
            $retArr[] = $tmpArr;
            $a = $a +1;
        }
    }

    return $retArr;
}


?>


Measured memory_bytes: 213344
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;
const int mod = (int) 1e9 + 7;

int n;
int c[MAXN];
map<int, long long> mp;
long long dp[MAXN];

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }

  for (int i = 0; i < n; i++) {
    if (i > 0 && c[i - 1] == c[i]) {
      dp[i] = dp[i - 1];
    } else {
      if (i == 0) {
        dp[i] = 1;
      } else {
        dp[i] = dp[i - 1];
      }
      long long add = dp[i];
      dp[i] = (dp[i] + mp[c[i]]) % mod;
      mp[c[i]] = (mp[c[i]] + add) % mod;
    }
    // cerr << dp[i] << " ";
  }
  // cerr << endl;

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

  return 0;
}


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

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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define mod1 998244353
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef priority_queue <ll> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
    int t;
t=1;
//cin>>t;
while(t--){
	int n,k;
	cin>>n>>k;
	int a[n],dp[n];
	fo(i,n)cin>>a[i],dp[i]=10e8;
	dp[0]=0;
	fo(i,n){
		fo1(j,k){
			if(i-j>=0)dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
		}
	}
	cout<<dp[n-1];

}
    return 0;
}

Measured memory_bytes: 4428
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 2010 * 3;

ll n;
string Sa, Sb;
ll A[maxn], B[maxn];
ll lt[maxn], rt[maxn];
vpii edit;

ll calc(string &Sa, string &Sb) {
    ll sa = 0, sb = 0;
    fori (i, n) {
        A[i] = Sa[i] == '1';
        B[i] = B[i + n] = B[i + n * 2] = Sb[i] == '1';
        sa += A[i], sb += B[i];
    }
    if (sa > 0 && sb == 0) {
        cout << "-1\n";
        exit(0);
    }
    fori (i, n * 3 - 1) lt[i + 1] = B[i + 1] ? 0 : lt[i] + 1;
    forir (i, n * 3 - 1) rt[i] = B[i] ? 0 : rt[i + 1] + 1;
    ll ans = INF;
    fori (sh, n) {
        edit.clear();
        fori (i, n) {
            if (A[i] != B[i + sh]) {
                edit.eb(lt[i + n], rt[i + n]);
            }
        }
        sort(all(edit), greater<pii>());
        ll go = sh;
        ll en = edit.size();
        for (auto x : edit) {
            smin(ans, en + x.F * 2 + sh + (go - sh) * 2);
            smax(go, x.S);
        }
        smin(ans, en + sh + (go - sh) * 2);
    }
    return ans;
}

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

    cin >> Sa >> Sb;
    n = Sa.size();
    ll ans = calc(Sa, Sb);
    reverse(all(Sa)), reverse(all(Sb));
    smin(ans, calc(Sa, Sb));
    cout << ans << '\n';

}


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

using namespace std;

#define Q int t, q; scanf("%d", &t); for(q=1; q<=t; q++)
typedef long long int lli;
#define pi pair<int, int>

char givcar(char a)
{
    if(a == 'r')
        return 'p';

    else if(a == 'p')
        return 's';

    else
        return 'r';
}

char rivcar(char a, char b)
{
    if((a=='r' && b=='s') || (a=='s' && b=='r'))
        return 'p';
    else if((a=='r' && b=='p') || (a=='p' && b=='r'))
        return 's';
    else
        return 'r';
}

int main()
{
    int n, k, r, s, p, i;
    string ss, play;
    cin >> n >> k >> r >> s >> p >> ss;

    lli ans = 0;

    for(i=0; i<n; i++){
        char c;
        c = givcar(ss[i]);

        if((i-k)>=0 && play[i-k] == c){
            if(i+k < n){
                if(givcar(ss[i+k]) == ss[i]){
                    play.push_back(rivcar(givcar(ss[i+k]), c));
                }
                else{
                    play.push_back(ss[i]);
                }
            }
        }
        else{
            play.push_back(c);
            if(c == 'r')
                ans += r;
            else if(c == 'p')
                ans += p;
            else
                ans += s;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 512
n,s=map(int,input().split())
t=list(map(int,input().split()))
ans=t[0]
t_sum=t[0]
for i in range(1,n):
    if t[i-1]+s<t[i]:
        ans +=s
    else:
        ans +=t[i]-t[i-1]
ans +=s
print(ans)

Measured memory_bytes: 25200
import math
a,b,x=map(int,input().split())


def f(a,b,deg):
  theta=math.radians(deg)
  if b*math.tan(math.pi/2-theta)<=a:
    return b*b*math.tan(math.pi/2-theta)*a/2
  else:
    return a*a*b-a*a*math.tan(theta)*a/2


l=0
r=90
while r-l>=10**-6:
  mid=(l+r)/2
  #print(mid,f(a,b,mid))
  if x-10**-6<=f(a,b,mid)<=x+10**-6:
    print(mid)
    exit(0)
  if f(a,b,mid)>x:
    l=mid
  else:
    r=mid
print(l)


Measured memory_bytes: 9528
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N,ans=0;
    string S;
    cin >> N >> S;

    for (int i = 1; i < N; i++) {
        int count = 0;
        string X=S.substr(0,i), Y=S.substr(i);

        for (char j = 'a'; j <='z'; j++) {
            if ((find(X.begin(), X.end(), j) != X.end())&& (find(Y.begin(), Y.end(), j) != Y.end())) {
                count++;
            }
        }
        ans = max(ans, count);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    int r = 1;
    for (int i = 2; i <= n; i++) {
      int current = 0;
      if (i % 2 == 1) {
        continue;
      }
      int j = i;
      while (true) {
        j = j / 2;
        ++current;
        if (j == 0 || j % 2 == 1) {
          break;
        }
      }
      if (current > count) {
        count = current;
        r = i;
      }
    }
    System.out.println(r);
    sc.close();
  }
}


Measured memory_bytes: 35832
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;
import std.numeric;

void main() {
  int N, M;
  readlnTo(N, M);

  long ans = 1;
  for (long i = 1; i * i <= M; i++) {
    if (M % i != 0)
      continue;

    if (M >= i * N)
      ans = max(ans, i);

    if (M >= (M / i) * N)
      ans = max(ans, M / i);
  }

  ans.writeln;
}

// helpers
void readlnTo(T...)(ref T t) {
  auto s = readln.split;
  assert(s.length == t.length);
  foreach(ref ti; t) {
    ti = s[0].to!(typeof(ti));
    s = s[1..$];
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  S[1] = 148 - S[1];
  std::cout << S << std::endl;
  return 0;
}

Measured memory_bytes: 3604
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto qhsd = RDR.ARR;
	auto N = RD * 4;

	long[] cp = [qhsd[0]*8, qhsd[1]*4, qhsd[2]*2, qhsd[3]];

	long ans;
	foreach_reverse (i; 0..4)
	{
		auto pos = MIN_POS(cp[0..i+1]);
		auto q   = N / (2^^i);
		ans     += q * ((2^^i) / (2^^pos)) * qhsd[pos];
		N        = N % (2^^i);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int i=0;
        while(true) {
            int num = scanner.nextInt();
            if (num == 0) {
                break;
            }
            System.out.printf("Case %d: %d\n", ++i, num);
        }
    }
}


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

typedef long long ll;

using namespace std;

#define MAX_N 205
int N;
int n[MAX_N];
int d[MAX_N];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int x[MAX_N],y[MAX_N];
int xmin,xmax;
int ymin,ymax;

int main(){
    while(1){
        scanf("%d",&N);
        if(N == 0)break;
        for(int i = 0;i < N-1;i++){
            scanf("%d %d",&n[i],&d[i]);
        }
        xmin=xmax=ymin=ymax=0;
        x[0]=y[0]=0;
        for(int i = 0;i < N-1;i++){
            x[i+1] = x[n[i]]+dx[d[i]];
            y[i+1] = y[n[i]]+dy[d[i]];
            if(x[i+1] < xmin)xmin=x[i+1];
            if(x[i+1] > xmax)xmax=x[i+1];
            if(y[i+1] < ymin)ymin=y[i+1];
            if(y[i+1] > ymax)ymax=y[i+1];
        }

        printf("%d %d\n",xmax-xmin+1,ymax-ymin+1);

    }
}


Measured memory_bytes: 3192
def f(x):
    if x%10 == 0: return x
    return x + 10 - (x%10)

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

res = f(a) + f(b) + f(c) + f(d) + f(e)

l = [a, b, c, d, e]
l = list(map(lambda x: (x-1)%10, l))
res -= (10-(min(l)+1))
print(res)


Measured memory_bytes: 3064
import sys
import  math
import bisect
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
aaa = na()
bbb = na()
ccc = na()
aaa.sort()
ccc.sort()
l = 0
r = 0
ct = 0
ct = 0
for i in range(n):
    l = bisect.bisect_left(aaa, bbb[i])
    r = bisect.bisect_right(ccc, bbb[i])
    ct += l * (n - r)

print(ct)

Measured memory_bytes: 24684
#include <bits/stdc++.h>
#define ll unsigned long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define vll vector<ll> 
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;
using namespace std;

int main() {
    IOS;
    ll a;
    double d; cin >> a >> d;
    ll b = round(d * 100);
    ll ans = a * b;
    ans /= 100;
    cout << ans;
}

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


int main(){

string s;
cin >> s;
int n = s.size();

int i = 0;
int j = 0;
int a_address, z_address;

for (int i = 0; i < n; i++)
{
    if (s.at(i) == 'A')
    {
        a_address = i;
        break;
    }
    
}

for (int i = n - 1; i > 0; i--)
{
    if (s.at(i) == 'Z')
    {
        z_address = i;
        break;
    }
    
}




cout << z_address - a_address + 1 << endl;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
class Main {
static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    public static void main(String[] args) {
        FastReader sc =new FastReader(); 
        int n = sc.nextInt();
        int m = 0;
        int l=0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n / i; j++) {
                m = n - (j * i);
                if (m != 0) {
                    l++;
                }
            }
        }
        System.out.println(l);
    }
}


Measured memory_bytes: 32764
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    vector<int> v(n);
    f(n)cin>>v[i];
    sort(v.begin(),v.end());
    int answer=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int sum=v[i]+v[j];
            //cout<<sum<<endl;
            auto it=lower_bound(v.begin(),v.end(),sum);

            int index=it-v.begin();
            //cout<<index<<endl;


                int p=index-j-1;

               //cout<<p<<endl;
                answer+=p;





        }



    }
    cout<<answer<<endl;







}

Measured memory_bytes: 3592
s = input()

mod = 10**9 + 7
l = len(s)
dp = [[0] * 13 for _ in range(l+1)]
dp[0][0] = 1
for i in range(1, l+1):
    if s[i-1] == '?':
        for j in range(10):
            for k in range(13): 
                dp[i][(k * 10 + j) % 13] = (dp[i][(k * 10 + j) % 13] + dp[i-1][k]) % mod
    else:
        for k in range(13):
            dp[i][(k * 10 + int(s[i-1])) % 13] = (dp[i][(k * 10 + int(s[i-1])) % 13] + dp[i-1][k]) % mod
print(dp[l][5])

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

const int IINF = 2002002002;
const ll LINF = 9009009009009009009LL;

//===


ll N;


ll dfs(ll k)
{
	if (k > N) {
		return 0;
	}

	ll res = 0;
	bool ok3 = false, ok5 = false, ok7 = false;
	ll k_copy = k;
	while (k_copy) {
		int tmp = k_copy % 10;
		if (tmp == 3) ok3 = true;
		else if (tmp == 5) ok5 = true;
		else if (tmp == 7) ok7 = true;
		k_copy /= 10;
	}
	if (ok3 && ok5 && ok7) res += 1;
	
	res += dfs(k * 10 + 3);
	res += dfs(k * 10 + 5);
	res += dfs(k * 10 + 7);

	return res;
}




int main()
{
	cin >> N;
	cout << dfs(0) << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<char> s(n);
    rep(i,n)  cin >> s.at(i);
    if(n%2 == 1){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i < n/2; ++i){
        if(s.at(i) != s.at(n/2+i)){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] member = new int[n];
		for(int i = 1 ; i <= q ; i++) {
			int index = sc.nextInt();
			member[index - 1]++;
		}
		int border = k - q;
		for(int i = 0 ; i < n ; i++) {
			if(border + member[i] > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 54292
#include<stdio.h>
#include<stdbool.h>

int main()
{
   int x,z,c=0;
   scanf("%d",&x);
   for(int i=0;i<3;i++){
    z = x%10;
    if(z == 1){
        c++;
    }
    x/=10;
}
printf("%d",c);
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> n >> s;
    a = 0, b = 0;
    for(auto& x : s){
        if(x == 'I')
            ++a;
        else
            --a;
        b = max(a, b);
    }
    cout << b << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;


long long int N,W,dp[200][20000]={},v[105],w[105];
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>W;
    for(long long int i = 1; i <= N; i++){
        cin>>v[i]>>w[i];
    }
    for(long long int i = 1; i <= N; i++){
        for(long long int j = 0; j <= W; j++){
            if(j>=w[i]){dp[i][j-w[i]] = max(dp[i][j-w[i]],dp[i-1][j]+v[i]);}
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
        }
    }
    
    cout<<dp[N][0]<<endl;
}




Measured memory_bytes: 11284
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var (
		sum   float64
		limit = n
	)
	if n > k {
		limit = k
		sum += float64(n - k)
	}
	for i := 1; i <= limit; i++ {
		sum += math.Pow(0.5, math.Ceil(math.Log2(float64(k)/float64(i))))
	}
	fmt.Println((1 / float64(n)) * sum)
}


Measured memory_bytes: 512
N,Y = gets.split.map(&:to_i)

puts catch {|tag|
  0.step(N) do |i|
    0.step(N) do |j|
      k = N - i - j
      break if k < 0
      n = i * 10000 + j * 5000 + k * 1000
      throw tag, [i, j, k].join(" ") if i+j+k == N && n == Y
    end
  end
  "-1 -1 -1"
}

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define F first
#define S second

using namespace std;
int main()
{
	int n, w;
	cin >> n >> w;
	vector<int> wt(n), vl(n);
	unordered_map<int, int> M;
	for (int i = 0; i < n; i++) {
		cin >> wt[i] >> vl[i];
	}
	M[0] = 0;
	for (int i = 0; i < n; i++) {
		unordered_map<int, int> T = M;
		for (auto it : M) {
			
			if (it.second + wt[i] > w) continue;
			
			int val = it.first + vl[i];
			if (T.find(val) == T.end() ) {
				T[val] = it.second + wt[i];
			}
			else {
				T[val] = min(T[val], it.second + wt[i]);
			}
		}
		M = T;
	}
	int maxi = 0;
	for (auto it : M) {
		maxi = max(maxi, it.first);
	}
	cout << maxi;
	return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)

int main()
{
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    char out[N*2];
    REP(i, N) {
        out[i * 2] = S[i];
        out[i * 2 + 1] = T[i];
    }
    string _out(out, N * 2);
    cout << _out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int D;
int c[26];
int S[365][26];
int t[365];
set<int>id[26];
main()
{
	cin>>D;
	for(int i=0;i<26;i++)
	{
		cin>>c[i];
		id[i].insert(-1);
	}
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>S[i][j];
	int ans=0;
	for(int i=0;i<D;i++)
	{
		cin>>t[i];
		t[i]--;
		ans+=S[i][t[i]];
		id[t[i]].insert(i);
		for(int j=0;j<26;j++)ans-=c[j]*(i-*id[j].rbegin());
	}
	for(int i=0;i<26;i++)id[i].insert(D);
	int M;cin>>M;
	for(;M--;)
	{
		int d,q;cin>>d>>q;d--,q--;
		ans-=S[d][t[d]];
		ans+=S[d][q];
		set<int>::iterator it=id[t[d]].lower_bound(d);
		it=id[t[d]].erase(it);
		{
			int r=*it;
			int l=*--it;
			ans-=c[t[d]]*(r-d)*(d-l);
		}
		it=id[q].lower_bound(d);
		{
			int r=*it;
			int l=*--it;
			ans+=c[q]*(r-d)*(d-l);
		}
		it++;
		id[q].insert(it,d);
		t[d]=q;
		cout<<ans<<endl;
	}
}

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

int main(){
    string s;
    cin>>s;
    char l=s.back();
    cout<<(
        (l=='3')?"bon"
        :(l=='0'||l=='1'||l=='6'||l=='8')?"pon"
        :"hon"
    )<<endl;
}


Measured memory_bytes: 3620
// this is the fourth test submission for debugging a helper tool
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)

#define MAXN 100000
int main() {
  int n;
  int a[MAXN];
  int h[MAXN];
  cin >> n;
  forr(i,0,n-1)
    cin >> h[i];
  a[0] = 0;
  a[1] = abs(h[1] - h[0]);
  forr(i,2,n-1) {
    a[i] =
     min(a[i-1] + abs(h[i] - h[i-1]), a[i-2] + abs(h[i] - h[i-2]));
  }
  cout << a[n-1] << endl;

}


Measured memory_bytes: 1024