akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }

template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulmod(ll a,ll b,ll mod) 
{ ll res=0; a=a%mod; 
    while(b>0)
    { if(b%2==1) res=(res+a)%mod; 
      a=(a*2)%mod; b/=2; }
    return res % mod; } 

ll mulpow(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 

ll modInverse(ll n, ll p) 
{ return mulpow(n, p-2, p); } 

ll log(ll n, ll b)
{ ll c=0;
	while(n>(b-1))
	{ c++; n/=b; } return c; }

ll fib(ll n) 
{ double phi=(1+sqrt(5))/2; 
  return round(pow(phi,n)/sqrt(5)); } 

vector<bool> prime;
void sieve(int n)
{ prime.resize(n,true);
	for(int p=2;p*p<=n;p++)
		if(prime[p])
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false; }

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vvl vector<vl>
#define vs vector<string>
#define vvs vector<vs>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define vpl vector<pl>
#define vpd vector<pd>
#define vvpl vector<vpl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);


void solve()
{
	ll i,j;
	ll n;
	cin>>n;
	pn(n+n*n+n*n*n);
}

int main()
{
	#ifdef Deeksha
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	solve();/* 
	ll t;
	cin>>t;
	for(ll tt=1;tt<=t;tt++)
	{
		//cout<<"Case #"<<tt<<": ";
		solve();
	}
	//*/
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n, z, w;
int a[2005];
int dp[2100][3];
int sol(int p, int cha) {
  if (dp[p][cha] != -1) return dp[p][cha];
  // end
  if (cha == 1) {
    // want max
    int ret = 0;
    ret = max(ret, abs(a[n + 2 - 1] - a[p]));
    for (int i = p + 1; i + 1 < n + 2; ++i) {
      ret = max(ret, sol(i, 2));
    }
    dp[p][cha] = ret;
    return ret;
  } else {
    // want min
    int ret = INT_MAX;
    ret = min(ret, abs(a[n + 2 - 1] - a[p]));
    for (int i = p + 1; i + 1 < n + 2; ++i) {
      ret = min(ret, sol(i, 1));
    }
    dp[p][cha] = ret;
    return ret;
  }
}
int main() {
  ios::sync_with_stdio(false);
  for(int i = 0; i < 2100; ++i) {
    for(int j = 0; j < 3; ++j) {
      dp[i][j] = -1;
    }
  }
  cin >> n >> z >> w;
  a[0] = z, a[1] = w;
  for (int i = 2; i < n + 2; ++i) {
    cin >> a[i];
  }
  cout << sol(1, 1) << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<char> cs(n);
  for (int i = 0; i < n; i++)
    cin >> cs[i];
  map<char, int> m;
  for (int i = 0; i < n; i++)
    m[cs[i]]++;
  if (m.size() == 3)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
  return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

const int N = 1e3 + 10 ;

char v[N][N] ;
int n , m ;

void read ()
{
    cin >> n >> m ;

    for ( int i = 1 ; i <= n ; i ++ )
    {
        for ( int j = 1 ; j <= m ; j ++ )
            cin >> v[i][j] ;
    }
}

int dp[N][N] ;

void hard_code_row ()
{
    for ( int j = 1 ; j <= m ; j ++ )
    {
        if ( v[1][j] == '.' )
            dp[1][j] = 1 ;

        else break ;
    }
}

void hard_code_col ()
{
    for ( int i = 1 ; i <= n ; i ++ )
    {
        if ( v[i][1] == '.' )
            dp[i][1] = 1 ;

        else break ;
    }
}

void solve ( int test_case )
{
    read () ;

    hard_code_row () ;
    hard_code_col() ;

    for ( int i = 2 ; i <= n ; i ++ )
    {
        for ( int j = 2 ; j <= m ; j ++ )
        {
            if ( v[i][j] != '.' ) C ;

            dp[i][j] += dp[i][j - 1] + dp[i - 1][j] ;
            dp[i][j] %= mod ;
        }
    }

    cout << dp[n][m] ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 5248
from bisect import bisect_left
N, M = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort(reverse=True)

matchNum = {
    1 : 2,
    2 : 5,
    3 : 5,
    4 : 4,
    5 : 5,
    6 : 6,
    7 : 3,
    8 : 7,
    9 : 6,
}

makeDigit = [-float('inf')] * (N + 1)
makeDigit[0] = 0
for n in range(1, N + 1):
    d = makeDigit[n]
    for k in nums:
        cnt = n - matchNum[k]
        if cnt >= 0:
            d = max(d, makeDigit[cnt] + 1)
    if makeDigit[n] < d:
        makeDigit[n] = d

ans = []
for d in range(makeDigit[N])[:: -1]:
    for k in nums:
        cnt = N - matchNum[k]
        if cnt >= 0 and makeDigit[cnt] == d:
            ans.append(k)
            N = cnt
            break

ans.sort(reverse=True)
print(int(''.join(map(str, ans))))


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

using namespace std;

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


Measured memory_bytes: 256
// 2020.4.16

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <stdlib.h>

using namespace std;

int main() {
    char S[4];
    cin >> S;

    // cout << S << endl;

    if ((S[0] == S[1] and S[1] == S[2]) or (S[1] == S[2] and S[2] == S[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static int[] ToInt(this string[] strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ToLong(this string[] strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] SpInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long[] SpLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int Diff(int a, int b) => (int)Diff(a, (long)b);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Sign(this int i) => Math.Sign(i);
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new int[] { 0, -1, 0, 1 };
    public static int[] dy = new int[] { -1, 0, 1, 0 };
    public static int Gcd(int a, int b) => (int)Gcd(a, (long)b);
    public static long Gcd(long a, long b)
    {
        if (b == 0)
        {
            return a;
        }

        return Gcd(b, a % b);
    }                       //最大公約数
    public static int Lcm(int a, int b) => (int)Lcm(a, (long)b);
    public static long Lcm(long a, long b) => a / Gcd(a, b) * b;    //最小公倍数
    //テンプレここまで
}

public static partial class Program
{
    static void Main()
    {
        var b = CRL();
        switch (b)
        {
            case "A":
                CWL("T");
                return;
            case "T":
                CWL("A");
                return;
            case "G":
                CWL("C");
                return;
            case "C":
                CWL("G");
                return;
        }
    }
}


Measured memory_bytes: 11092
n=int(input())
a=list(map(int,input().split()))
dp=[[float("inf")]*(n+1) for _ in range(n)]
z=0
for l in range(n):
    dp[l][l]=0
for k in range(1,n+1):
    for i in range(n-k+1):
        j=i+k
        if 0<=i<=n-2 and 1<=j<=n:
            if (n-(i+j))%2==0: #先手
                dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1])
            else:
                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1])
        else:
            dp[i][j]=dp[i][j-1]+a[j-1]
print(dp[0][n])

Measured memory_bytes: 307336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int mp[11000000];

int main() {
    int64_t n;
    cin >> n;
    Int ans = 0;
    // map<Int, Int> mp;
    for (Int k = 1; k <= n; k++) {
        for (int i = 1; i * k <= n; i++) {
            mp[i*k]++;
        }
    }
    for (Int k = 1; k <= n; k++) {
        ans += k * mp[k];
    }
    cout << ans << endl;
}

Measured memory_bytes: 81648
#include<cstring>
#include<cstdlib>
#include<cstdio>

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
	Node *cur = nil->next; //晩兵の次の要素からたどる
	while ( cur != nil && cur->key !=key) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while( 1 ) {
		if( cur == nil) break;
		if( isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if( t == nil ) return; // t が晩兵の場合は処理しない
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	// 検索したノードを削除
	deleteNode(listSearch(key));
}

void insert(int key) {
	Node *x = (Node*)malloc(sizeof(Node));
	x->key = key;
	// 番兵の直後に要素を追加
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main() {
	int key, n, i;
	int size = 0; 
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i=0; i<n; i++) {
		scanf("%s%d", com, &key); // より高速な入力関数を使用
		if(com[0] == 'i') { insert(key); np++; size++; }
		else if ( com[0] = 'd' ) {
			if( strlen(com) > 6) {
				if(com[6] == 'F') deleteFirst();
				else if(com[6] == 'L') deleteLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}

	printList();

	return 0;
}



Measured memory_bytes: 33948
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ll a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f >> g;
    ll ans = b + a + d + e;
    ll cnt = a % 2 + d % 2 + e % 2;
    if (cnt==0 || cnt==3){
        cout << ans << endl;
    }
    else if (cnt==2 && (a==0 || d==0 || e==0)){
        cout << ans - 2 << endl;
    }
    else {
        cout << ans - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MOD (1000000007)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

int N, T, Ans;

int main() {
	int s = 0, e = 0;
	for(scanf("%d%d", &N, &T); N--;) {
		int c; scanf("%d", &c);
		if(c <= e) e = c+T;
		else { Ans += e-s; s = c; e = c+T; }
	}
	Ans += e-s;
	printf("%d\n", Ans);
	return 0;
}

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

/*define*/
double N;
double t_sum, f_sum, b_sum, fb_sum;

int main(){
    /*inpus*/
    std::cin >> N;

    /*syori*/
    t_sum = (N+1)*N/2;
    f_sum = floor(N/3)*(3 + floor(N/3)*3)/2;
    b_sum = floor(N/5)*(5 + floor(N/5)*5)/2;
    fb_sum = floor(N/15)*(15 + floor(N/15)*15)/2;
    t_sum = t_sum - f_sum - b_sum + fb_sum;
    std::cout << (int64_t)t_sum;
}    


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

using namespace std;

int w, h;

vector<vector<int>> makearea(void) {
	vector<vector<int>> area(h);

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			int tmp;
			cin >> tmp;
			area[i].push_back(tmp);
		}
	}
	
	/*for(auto i : area) {
		for(auto j : i) {
			cout << j << " ";
		}
		cout << endl;
	}*/

	return area;
}

void dfs(int y, int x, vector<vector<int>>& area, vector<vector<bool>>& checker) {
	if(x != w - 1) {
		if(area[y][x + 1] == 1 and checker[y][x + 1] == true) {
			checker[y][x + 1] = false;
			dfs(y, x + 1, area, checker);
		}
	}
	if(x != w - 1 and y != h - 1){
		if(area[y + 1][x + 1] == 1 and checker[y + 1][x + 1]) {
			checker[y + 1][x + 1] = false;
			dfs(y + 1, x + 1, area, checker);
		}
	}
	if(y != h - 1){
		if(area[y + 1][x] == 1 and checker[y + 1][x]) {
			checker[y + 1][x] = false;
			dfs(y + 1, x, area, checker);
		}
	}
	if(x != 0 and y != h - 1){
		if(area[y + 1][x - 1] == 1 and checker[y + 1][x - 1]) {
			checker[y + 1][x - 1] = false;
			dfs(y + 1, x - 1, area, checker);
		}
	}
	if(x != 0){
		if(area[y][x - 1] == 1 and checker[y][x - 1]) {
			checker[y][x - 1] = false;
			dfs(y, x - 1, area, checker);
		}
	}
	if(x != 0 and y != 0){
		if(area[y - 1][x - 1] == 1 and checker[y - 1][x - 1]) {
			checker[y - 1][x - 1] = false;
			dfs(y - 1, x - 1, area, checker);
		}
	}
	if(y != 0){
		if(area[y - 1][x] == 1 and checker[y - 1][x]) {
			checker[y - 1][x] = false;
			dfs(y - 1, x, area, checker);
		}
	}
	if(x != w - 1 and y != 0){
		if(area[y - 1][x + 1] == 1 and checker[y - 1][x + 1]) {
			checker[y - 1][x + 1] = false;
			dfs(y - 1, x + 1, area, checker);
		}
	}
}

int search(vector<vector<int>>& area) {
	int sum = 0;
	vector<vector<bool>> checker;
	checker = vector<vector<bool>>(area.size(), vector<bool>(area[0].size(), true));

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j ++) {
			if(area[i][j] == 1 and checker[i][j]) {
				checker[i][j] = false;
				dfs(i, j, area, checker);
				sum++;
			}
		}
	}
	return sum;
}

int main(void) {
	while(1) { 
		cin >> w >> h;
		if(w == 0 and h == 0) {
			break;
		}

		vector<vector<int>> area = makearea();
		int sum = search(area);

		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;
using mii=map<int, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

signed main() {
	makei(n);
	makei(k);
	vi h(n + k + 1,0);
	rep(n)cin >> h[i];
	vi ans(n + k + 100,INT_MAX);
	ans[0] = 0;
	rep(n) {
		For(j, k+1) {
			mini(ans[i + j], ans[i] + abs(h[i] - h[i + j]));
		}
	}
	say(ans[n - 1]);
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int n, r;

    while (cin >> n >> r, n || r) {
        int card[51], tmp[51];

        for (int i = 1; i <= 50; i++) 
            card[i] = i;


        for (int i = 0; i < r; i++) {
            int p, c;
            
            cin >> p >> c;
            for (int j = 0; j < c; j++) 
                tmp[j] = card[n - p - c + 2 + j];

            for (int j = 0; j < p - 1; j++) 
                card[n - p - c + 2 + j] = card[n - p + 2 + j];
            for (int j = 0; j < c; j++)
                card[n - c + 1 + j] = tmp[j];
        }
        
        cout << card[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
// #include <vector>
typedef long long ll;
const int tt=1e9+7;
int N,A[200005],F[200005],Ans=1;
// std::vector<int> E[200005];
int main(){
	scanf("%d",&N);
	for (int i=1;i<=N;++i) scanf("%d",A+i);
	for (int i=1;i<=N;++i) if (A[i]^A[i-1]) Ans=F[A[i]]=(Ans+F[A[i]])%tt;
	return printf("%d",Ans),0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

int64_t solve(vector<vector<int64_t>> &memo, vector<array<int, 2>> &wv, int i, int j) {
    if (memo[i][j] != -1) return memo[i][j];

    if (j < wv[i - 1][0]) {
        return memo[i][j] = solve(memo, wv, i - 1, j);
    }

    return memo[i][j] = max(
        solve(memo, wv, i - 1, j),
        solve(memo, wv, i - 1, j - wv[i - 1][0]) + wv[i - 1][1]
    );
}

int main() {
    int n, w; cin >> n >> w;
    vector<array<int, 2>> wv(n);
    for (auto &e1 : wv) for (auto &e2 : e1) cin >> e2;

    vector<vector<int64_t>> memo(n + 1, vector<int64_t>(w + 1, -1));
    fill(begin(memo[0]), end(memo[0]), 0);

    cout << solve(memo, wv, n, w) << endl;
}



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

using namespace std;

const int MAXN = 305;
double p[MAXN][MAXN][MAXN], ev[MAXN][MAXN][MAXN];

int main() {
    int n;
    cin >> n;
    vector<int> cnt(3);
    for(int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ++cnt[x-1];
    }
    p[cnt[0]][cnt[1]][cnt[2]] = 1;
    for(int c=n; c>=0; --c) {
        for(int b=n; b>=0; --b) {
            for(int a=n; a>=0; --a) {
                if((!a && !b && !c) || a + b + c > n)
                    continue;
                double p_miss = (double) (n - a - b - c) / n;
                double ev_miss = 1/(1-p_miss);
                ev[a][b][c] += ev_miss * p[a][b][c];

                if(a) {
                    double p_transition = (double) a / (a + b + c);
                    p[a-1][b][c] += p[a][b][c] * p_transition;
                    ev[a-1][b][c] += ev[a][b][c] * p_transition;
                }

                if(b) {
                    double p_transition = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * p_transition;
                    ev[a+1][b-1][c] += ev[a][b][c] * p_transition;
                }

                if(c) {
                    double p_transition = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * p_transition;
                    ev[a][b+1][c-1] += ev[a][b][c] * p_transition;
                }
            }
        }
    }
    cout.precision(10);
    cout << ev[0][0][0] << '\n';
}


Measured memory_bytes: 438528
#include <stdio.h>

int main (int argc, const char * argv[]) {
    int month, day, day_plus, i, word;
	int month_def[12];
	
	month_def[0] = 31;
	month_def[1] = 29;
	month_def[2] = 31;
	month_def[3] = 30;
	month_def[4] = 31;
	month_def[5] = 30;
	month_def[6] = 31;
	month_def[7] = 31;
	month_def[8] = 30;
	month_def[9] = 31;
	month_def[10] = 30;
	month_def[11] = 31;
	
	while (scanf("%d%d", &month, &day)) {
		if (month == 0) {
			return 0;
		}
		day_plus = 0;
		for (i=0; i<month-1; i++) {
			day_plus += month_def[i];
		}
		day_plus += day;
		word = day_plus%7;
		switch (word) {
			case 0:
				printf("Wednesday\n");
				break;
			case 1:
				printf("Thursday\n");
				break;
			case 2:
				printf("Friday\n");
				break;
			case 3:
				printf("Saturday\n");
				break;
			case 4:
				printf("Sunday\n");
				break;
			case 5:
				printf("Monday\n");
				break;
			case 6:
				printf("Tuesday\n");
				break;
			default:
				break;
		}
	}
    return 0;
}

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

using namespace std;

int main(){
        int x ,y;
        cin >> x >> y;

        if (2 * x <= y && y <= 4 * x && y % 2 == 0){
                cout << "Yes" << endl;
                }
        else {
                cout << "No" << endl;
        }

        return 0;
}

Measured memory_bytes: 3568
package main

import (
	"bufio"
	"fmt"
	"os"
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

var dict = map[rune]bool{
	'A': true,
	'C': true,
	'T': true,
	'G': true,
}

func maxACTGCount(str string) int {
	maxCount := 0
	count := 0
	for _, c := range str {
		_, ok := dict[c]
		if ok {
			count++
			if maxCount <= count {
				maxCount = count
			}
		} else {
			count = 0
		}
	}
	return maxCount
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	fmt.Println(maxACTGCount(readLine(sc)))
}


Measured memory_bytes: 640
a, b, c, d = map(int, input().split())

if a >= 0:
    if c >= 0:
        print(b * d)
    elif d < 0:
        print(a * d)
    else:
        print(b * d)
else:
    if b < 0:
        if c >= 0:
            print(b * c)
        elif d < 0:
            print(a * c)
        else:
            print(a * c)
    else:
        if c >= 0:
            print(b * d)
        elif d < 0:
            print(a * c)
        else:
            print(max([a*c, b*d]))


Measured memory_bytes: 9220
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) 
{
    int A, B;

    cin >> A >> B;

    if ((A+B) % 2 == 0) 
    {
        cout << (A+B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb emplace_back
#define mp make_pair
#define all(c)  c.begin(), c.end()
#define vb vector<bool>
#define vll vector<ll>
#define vp vector<pair<ll,ll>>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define lb "\n"
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 1000000007
#define MAX LLONG_MAX
#define PI 3.14159265358
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
      #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
ll i,j,k,n,ans,m,t;
cin>>n;
string s;
map<string,ll> f;
rep(i,0,n)
{
    cin>>s;
    f[s]++;
}
cout<<"AC x "<<f["AC"]<<lb;
cout<<"WA x "<<f["WA"]<<lb;
cout<<"TLE x "<<f["TLE"]<<lb;
cout<<"RE x "<<f["RE"]<<lb;
return 0;
}


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

using namespace std;

int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x >= k) ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int ans=0;
    vi v;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        v.pb(k);
    }
    sort(v.begin(),v.end());
    v.pb(-1);
    int t=v[0];
    int count=1;
    for(int i=1;i<=n;i++){
        if(v[i]==t){
            count+=1;
        }
        else{
            t=v[i];
            ans+=(count%2);
            count=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define N_MAX 10000

int main(){

  int a, b, c, d, x, y, ans;
  cin >> a >> b >> c >> d;

  if(b<=c || d<=a){
    cout << 0 << endl;
  } else {
    if(a<c){
      x = c;
    } else if(a>c){
      x = a;
    } else if(a==c){
      x = a;
    }
    if(b<d){
      y = b;
    } else if(b>d){
      y = d;
    } else if(b==d){
      y = b;
    }
    ans = abs(x-y);
    cout <<  ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<int, int> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)1000000000000

int main() {
  int H,W,K;
  cin>>H>>W>>K;
  char memo[H][W];
  rep(i,H){rep(j,W){cin>>memo[i][j];}}
  ll ans=0ll;
 for (ll tmph = 0; tmph < (1 << H); tmph++) {
    for(ll tmpw=0;tmpw<(1<<W);tmpw++){
      bitset<6> sh(tmph); 
      bitset<6> sw(tmpw);
      ll kk=0ll;
      rep(i,H){
        rep(j,W){
          if(sh.test(i)&&sw.test(j)&&memo[i][j]=='#'){
          kk++;
          }
        }
      }
      if(kk==K){ans++;}
    }
 }
  cout<<ans;
  
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ress(ll a,ll b)
{
    if(a%b==0)
        return a/b;
    else
        return(a/b)+1;
}
int main()
{
    ll n;
    cin>>n;
    ll s[6],s1[6];
    for(int i=0;i<5;i++)
    {
        cin>>s[i];
        s1[i]=ress(n,s[i]);
    }
    sort(s1,s1+5);
    cout<<s1[4]+4<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define ppll pair<pll,ll>
#define vi vector <ll>
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define f(i,x,n) for(ll i=x;i<n;i++)
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;} 
const ll N = 2e5 + 5, M = 1e9 + 7;

int main(){
    FAST;
    ll n, x = 0, m, k, i, t, ans = 0, j, y = 0, z = 0, c = 0;
    string s;
    cin >> s;
    n = s.size();
    if(n < 6) out("No");
    if(s[2] == s[3] && s[4] == s[5]) out("Yes");
    cout << "No";
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

a,b,c=MI()
if b-a==c-b:
    print("YES")
else:
    print("NO")

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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const int INF = 1 << 29;

signed main() {
	int n;
	while (cin >> n && n) {
		int m; cin >> m;
		V hana(n), taro(m);
		input(hana); input(taro);
		int hs = accumulate(all(hana), 0), ts = accumulate(all(taro), 0);
		int part = (hs + ts) / 2;
		bool ok = false;
		rep(i, n) rep(j, m) breakif(ok) {
			int h = hana[i], t = taro[j];
			if (t - h == part - hs && h - t == part - ts) {
				cout << h << " " << t << endl;
				ok = true;
			}
		}

		if (!ok) cout << -1 << endl;
	}
}

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

int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

int main() {
    long long N;
    cin >> N;
    int res = (1<<29); 
    for (long long A = 1; A * A <= N; ++A) {
        if (N % A == 0) {
            long long B = N / A;
            int F = max(calc_digit(A), calc_digit(B));
            res = min(res, F);
        }
    }
    cout << res << endl;
}

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

int num[107];

int main ()
{
	int n, m, u, v, ans = 0;
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d",&u);
		for(int j = 1; j <= u; j++)
		{
			scanf("%d",&v);
			num[v]++;
		}
	}
	for(int i = 1; i <= m; i++) if(num[i] == n) ans++;
	printf("%d\n",ans);
	return 0;
}


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

int main ()
{
    ll a,v,b,w,t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    ll ans;
    ans=(a<=b)?(a+v*t-(b+w*t)):((b-w*t)-(a-v*t));
    ans>=0?cout<<"YES":cout<<"NO";
	return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

const int N = 1e5;

int prime[N + 1], f[N + 1];

void MAIN() {
  for (int i = 2; i <= N; i++) {
    prime[i] = 1;
  }
  for (int i = 2; i <= N; i++) {
    if (prime[i]) {
      for (int j = i * 2; j <= N; j += i) {
        prime[j] = 0;
      }
    }
  }
  for (int i = 2; i <= N; i++) {
    if (prime[i] && prime[(i + 1) / 2]) f[i] = 1;
    f[i] += f[i - 1];
  }
  int q; cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << f[r] - f[l - 1] << '\n';
  }
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 5104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

int main(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        x = max(x, a);
    }
    for(int i=0; i<m; i++){
        int a;
        cin >> a;
        y = min(y, a);
    }

    if(x < y){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.readline

def main():
    n=int(input())
    b=list(map(int,input().split()))
    a=[0]*n
    a[0]=b[0]
    a[1]=b[0]
    for i in range(n-1):
        if a[i]<b[i]:
            a[i+1]=b[i]
        else:
            a[i]=b[i]
            a[i+1]=b[i]
    print(sum(a))    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
/**
 * Created by hiramekun at 20:56 on 2019-09-28.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, k;
    cin >> n >> k;

    vl h(n);
    cin >> h;
    
    ll ans  = 0;
    rep(i, n) {
        if (h[i] >= k) ans++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    X = [int(x) for x in input().split()]
    ans = []
    mini = min(X)
    maxi = max(X)
    if mini != maxi:
        for i in range(mini, maxi):
            a = map(lambda x: (x-i)**2, X)
            ans.append(sum(a))
    else:
        ans.append(0)
    return print(min(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n = int(input())
a_lst = list(map(int, input().split()))

a_lst.reverse()
tmp = a_lst[0]
lst = []
for i in range(1, n):
    lst.append(tmp)
    tmp += a_lst[i]
    tmp %= (10 ** 9 + 7)
lst.reverse()
a_lst.reverse()

ans = 0
for i in range(n - 1):
    ans += (a_lst[i] * lst[i]) % (10 ** 9 + 7)
ans %= (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 31636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  
  if(A>12){
    cout << B << endl;
  }
  
  else{
    if(A>5){
      cout << B/2 << endl;
    }
    else{
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 256
n = input()
s = raw_input()
n_w = len(filter(lambda c: c=="W", s))
n_e = n - n_w
n_i_w = 0
n_i_e = 0
ans = n
for i in range(n):
    if s[i] == "W":
        n_i_w += 1
    else:
        n_i_e += 1
    cur = n_i_w + n_e - n_i_e
    if s[i] == "W":
        cur -= 1
    ans = min(ans, cur)
print ans

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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  string s;
  int m, h;
  while (true) {
    cin >> s;
    if (s == "-") break;
    cin >> m;
    rep(i, m) {
      cin >> h;
      s = s.substr(h, s.size() - h) + s.substr(0, h);
    }
    cout << s << endl;
  }
  return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll *arr=new ll[n+1];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll *dp=new ll[n+1];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(ll i=2;i<n;i++)
    {
        ll temp=i-k;
        ll temp1=i;
        ll m;
        if(temp>0)
        {
            m=temp;
        }
        else
        {
            m=0;
        }
        ll ans=INT_MAX;
        for(ll j=i-1;j>=m;j--)
        {
            ll option1=abs(arr[temp1]-arr[j])+dp[j];
            ans=min(ans,option1);
        }
        dp[i]=ans;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
// isertion sort
// strategy:obey the text book on AOJ.
//

#include<iostream>

int main(){
	
	int n,i,j,k,a[100],v;

	std::cin >> n;

	// Input
	for (i = 0; i < n; i++) {
		std::cin >> a[i];
	}
		
	// Sorting
	for (i = 1; i < n; i++) {
		
		for (k = 0; k < n; k++) {
			std::cout << a[k];
			 if (k != n - 1)std::cout << " ";
		}

		//std::cout <<"\b"<<std::endl;
		std::cout<<std::endl;

		v = a[i];
		j = i - 1;
		while ((j >= 0) && (a[j] > v)) {  // j>0：サーチ下限リミット　a[j]>v　さらに下へサーチする条件
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	
	}
	for (k = 0; k < n; k++) {
		std::cout << a[k];
	    if (k != n - 1)std::cout << " ";

	}
	std::cout << std::endl;

	return 0;
}


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

int main()
{
	long n = 0, k = 0, ttl = 0;
	int max = 0;

	cin >> n >> k;

	vector<long> w(n);

	for (long i = 0; i < n; i++) {
		int t;
		cin >> t;
		ttl += t;
		w[i] = t;
		if (t > max)
			max = t;
	}

	int s = 0, p = 0;
	long c = 1;

	if (max > ttl / k)
		p = max;
	else
		p = ttl / k;

	for (long i = 0; i < n; i++) {
		if (s + w[i] <= p)
			s += w[i];
		else {
			s = w[i];
			c++;
		}
		if (c > k) {
			s = 0;
			c = 1;
			i = -1;
			p++;
		}
	}

	cout << p << endl;

	return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    let a = if a > 0 { a - 1 } else { a };
    let mut t = b;
    let mut m = 0;
    while t > 0 {
        m += 1;
        t /= 2;
    }
    let mut result = 0;
    for i in 0..m {
        let k = 2usize.pow(i + 1);
        let b_count = (b + 1) / k * k / 2;
        let kb = (b + 1) % k;
        let b_count = if kb > k / 2 {
            b_count + kb - k / 2
        } else {
            b_count
        };
        let a_count = (a + 1) / k * k / 2;
        let ka = (a + 1) % k;
        let a_count = if ka > k / 2 {
            a_count + ka - k / 2
        } else {
            a_count
        };

        // println!("{} {}", b_count, a_count);
        if (b_count - a_count) % 2 == 1 {
            result += k / 2;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
import sys, math

N = int(input())
low = 0
high = N - 1

print(0)
start = input()
tmp = math.ceil((high + low) / 2)
print(tmp)

while True:
    i = input()
    if i == 'Vacant':
        break
        
    else:
        if (tmp % 2 == 0 and i == start) or (tmp % 2 != 0 and i != start):
            low = tmp
        else:
            high = tmp
        
        tmp = math.ceil((high + low) / 2)
        print(tmp)

sys.stdout.flush()

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	vector<int> a(3);
	rep(i,3) cin>>a[i];
	sort(begin(a),end(a));
	int ans=a[2]-a[1];
	a[0]+=(a[2]-a[1]);
	int diff=a[2]-a[0];
	ans+=diff/2;
	if(diff%2){
		ans+=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535

int main(void){
	int meter,kakudo;
	double x=0.0,y=0.0;
	double kaku=0.0;
	
	scanf("%d,%d",&meter,&kakudo);
	y+=meter;
	kaku += kakudo / 180.0 * PI;
	
	while(1){
		scanf("%d,%d",&meter,&kakudo);
		if(meter == 0 && kakudo == 0) break;
		x+=meter * sin(kaku);
		y+=meter * cos(kaku);
		kaku += kakudo / 180.0 * PI;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MOD 1e9+7
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

int dp[100005];

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    int dp[n];

    REP(i, n) dp[i] = INF;
    dp[0] = 0;

    REPN(i, 1, n) REPN(j, 1, k+1) {
        if(i-j >= 0) {
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

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

    return 0;
}

Measured memory_bytes: 1024