akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools
import math

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    X = [0] * N
    Y = [0] * N

    for i in range(N):
        X[i], Y[i] = map(int, input().split())

    load = list(itertools.permutations(range(N), N))

    # print(load)

    ans = 0
    for l in load:
        for i in range(N - 1):
            s = l[i]
            g = l[i + 1]
            ans += math.sqrt(pow(X[s] - X[g], 2) + pow(Y[s] - Y[g], 2))

    ans /= len(load)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz=1e6;

int a[sz];

int main()
{
    ll i,j,n,d;
    cin >> n >> d;
    for(i=0; i<n; i++) scanf("%d", &a[i]);
    for(i=0; i<n; i++) {
        if(a[i]==1) break;
    }
    j=i+1;
    d--;
    ll ans=(j-1+d-1)/d;
    ll x=n-ans*d-1;
    if(x>0) {
        ans+=(n-ans*d-1+d-1)/d;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)



int main() {
	int h, w, k;
	cin >> h >> w >> k;

	vector<string> s(h);
	REP(i, h) cin >> s[i];

	int ans = 0;
	REP(is, 1 << h) REP (js, 1 << w) {
		int cnt = 0;
		REP(i, h) REP(j, w) {
			if ((is >> i) & 1) continue;
			if ((js >> j) & 1) continue;
			if (s[i][j] == '#') cnt++;
		}
		if (cnt == k) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N,M;
    cin >> N >> M;
    int x[M];
    for (int i = 0;i<M;i++){
        cin >> x[i];
    }
    sort(x,x+M);
    int y[M-1];
    for (int i = 0;i<M-1;i++){
        y[i] = x[i + 1]- x[i];
    }
    sort(y,y+M-1);
    int p = 0;
    for(int i = 0;i<(M-N);i++){
        p = p + y[i];
    }
    cout << p << endl;
}

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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

///returns the longest proper prefix array of pattern p
///where lps[i]=longest proper prefix which is also suffix of p[0...i]
vector<int> build_lps(vector<int> p)
{
    int sz = p.size();
    vector<int> lps;
    lps.assign(sz + 1, 0);
    int j = 0;
    lps[0] = 0;
    for(int i = 1; i < sz; i++)
    {
        while(j >= 0 && p[i] != p[j])
        {
            if(j >= 1) j = lps[j - 1];
            else j = -1;
        }
        j++;
        lps[i] = j;
    }

    return lps;
}
vector<int>ans;
///returns matches in vector ans in 0-indexed
void kmp(vector<int> lps, vector<int> s, vector<int> p)
{
	int psz = p.size(), sz = s.size();
	int j = 0;
	for(int i = 0; i < sz; i++)
	{
		while(j >= 0 && p[j] != s[i])
			if(j >= 1) j = lps[j - 1];
			else j = -1;

		j++;
		if(j == psz)
		{
			j = lps[j - 1];
			///pattern found in vector<int> s at position i-psz+1
            ans.eb(i-psz+1);
		}
		///after each loop we have j=longest common suffix of s[0..i] which is also prefix of p
	}
}

int a[N], b[N];
vector<int> c, d;
int32_t main()
{
    int n=in();
    for(int i=0; i<n; i++) a[i]=in();
    for(int i=0; i<n; i++) b[i]=in();
    for(int i=0; i<n; i++) c.eb(a[i]^a[(i+1)%n]);
    for(int i=0; i<n; i++) d.eb(b[i]^b[(i+1)%n]);
//    for(auto x: c) cout<<x<<' ';
//    cout<<nl;
//    for(auto x: d) cout<<x<<' ';
//    cout<<nl;
    auto p=d;
    for(auto x: p) d.eb(x);
    vector<int> lps=build_lps(c);
    kmp(lps, d, c);
    reverse(ans.begin(), ans.end());
    for(auto x: ans){
        if(x){
            cout<<n-x<<' '<<(a[0]^b[x%n])<<nl;
        }
    }
    return 0;
}


Measured memory_bytes: 12244
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        char[][] board = new char[H][W];
        for(int h=0; h<H; h++){
            board[h] = sc.next().toCharArray();
        }

        int[][] shortest = new int[H][W];
        shortest[0][0] = board[0][0] == '.' ? 0 : 1;
        for(int h=1; h<H; h++){
            if(board[h-1][0]=='.' && board[h][0]=='#') shortest[h][0] = 1+shortest[h-1][0];
            else shortest[h][0] = shortest[h-1][0];
        }
        for(int w=1; w<W; w++){
            if(board[0][w-1]=='.' && board[0][w]=='#') shortest[0][w] = 1+shortest[0][w-1];
            else shortest[0][w] = shortest[0][w-1];
        }
        for(int h=1; h<H; h++) for(int w=1; w<W; w++){
            int d = board[h-1][w]=='.' && board[h][w]=='#' ? 1+shortest[h-1][w] : shortest[h-1][w];
            int r = board[h][w-1]=='.' && board[h][w]=='#' ? 1+shortest[h][w-1] : shortest[h][w-1];
            shortest[h][w] = Math.min(d,r);
        }

        System.out.println(shortest[H-1][W-1]);
    }
}


Measured memory_bytes: 37388
// ABC073_A
// ABC074_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    string N;
    cin >> N;
    
    if (N[0] == '9' || N[1] == '9') {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    
    // calculation
    
    
    return 0;
}


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    cout << (b-a>=0?(!(n==1&&a!=b)?(n-2)*(b-a)+1:0):0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
ll a, b, c, k;
int main() {
	read(a), read(b), read(c), read(k);
	if (k % 2) writeln(b - a);
	else writeln(a - b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,p[100],i,j,a;
main(){
  cin>>n;
  for(;i<n;)cin>>p[i++];
  sort(p,p+n);
  for(;!a;)n-j<=p[j++]&&(a=n-j+1);
  cout<<a<<endl;
}

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

int main(){
  char fg[1001];
  int ans = 0;
  while(1){
  cin >> fg;
    for(int i=0;i < strlen(fg);i++){
      if(fg[0] == '0')break;
      ans += (fg[i] - '0');
    }
    if(fg[0] == '0')break;
    cout << ans << endl;
    ans = 0;
  }
}


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

void CountingSort(int);

#define MAX 10000
int *A,*B,C[MAX+1];
int N;

int main(){
  int i,j;
  scanf("%d",&N);
  A=(int*)malloc(sizeof(int) * N+1);
  for(i=0;i<N;i++){
    scanf("%d",&A[i+1]);
  }
  B=(int*)malloc(sizeof(int) * N+1);


  CountingSort(MAX);

  for (i=1;i<=N;i++){
    if (i>1){
      printf(" ");
    }
    printf("%d", B[i]);
  }
  printf("\n");

  free(A);
  free(B);

  return 0;
}

void CountingSort(int k){
  int i,j;

  for(i=0;i<k;i++){
    C[i] = 0;
  }
  /* C[i] ??? i ???????????°????¨?????????? */
  for(j=1;j<=N;j++){
    C[A[j]]++;
  }

  /* C[i] ??? i ??\????????°???????????°????¨??????????*/
  for( i = 1; i <=k; i++ )
  {
    C[i] = C[i] + C[i-1];
  }
  for ( j = N; j >= 1; j-- ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16124
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

vector<ll> d(10, 1000000);
int c[10][10];

void func(int s, int cr, vector<int>& v){
  if(cr == 1){
    ll sum = 0;
    for(int i = 1; i < v.size(); i++){
      //cout << c[v[i - 1]][v[i]] << endl;
      sum += c[v[i - 1]][v[i]];
      //cout << v[i] << " ";
    }
    d[s] = min(d[s], sum);
    //cout << " : " << sum << endl;
    return;
  }
  for(int i = 0; i < 10; i++){
    int j;
    for(j = 0; j < v.size(); j++){
      if(v[j] == i) break;
    }
    if(j < v.size()) continue;
    v.push_back(i);
    func(s, i, v);
    v.pop_back();
  }
  return;
}

void solve(){
  int h, w; cin >> h >> w;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }

  for(int i = 0; i < 10; i++){
    vector<int> v;
    if(i == 1) continue;
    v.push_back(i);
    func(i, i, v);
  }

  ll ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      int x; cin >> x;
      if(x == -1 || x == 1) continue;
      ans += d[x];
    }
  }
  cout << ans << endl;

  /*for(int i = 0; i < 10; i++){
    cout << d[i] << endl;
  }*/

  return;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int mario[n];
    for(int i=0;i<n;i++){
        cin>>mario[i];
    }
    int m = sizeof(mario)/sizeof(mario[0]);
    sort(mario,mario+m);
    
    for(int i=0;i<n-1;i++){
       if(mario[i]==mario[i+1]){
            cout<<"NO";
            return 0;
        }
       // cout<<mario[i];
    }
    cout<<"YES";
}


Measured memory_bytes: 4356
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    cin >> n;
    int count[100005];
    fill(count, count+100005, 0);
    int sgl = 0;
    int dbl = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (count[a] == 0) {
            count[a]++;
            sgl++;
        } else if (count[a] == 1) {
            count[a]++;
            sgl--;
            dbl++;
        } else if (count[a] == 2) {
            count[a]--;
            dbl--;
            sgl++;
        }
    }

    if (dbl % 2 == 1) {
        sgl--;
    }

    cout << sgl + dbl << "\n";
    return 0;
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    double l;
    const double PI=3.14159265;
    cin >> n;
    l = 2*n*PI;
    cout << fixed << setprecision(8);
    cout << l << endl;


}

Measured memory_bytes: 3796
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll power(ll x,ll y,ll p) 
{ 
    ll r = 1;
  
    x = x % p;
    while (y > 0) {
        if (y & 1) 
            r = (r * x) % p;
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return r; 
}  
ll modInverse(ll n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
ll nCrModP(ll n,ll r, ll p) 
{ 
    ll fac[100005];
    if (r == 0) 
        return 1; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,k,m,maxi,d,x;
	cin>>n;
	if(n<=1)
		cout<<0;
	else
	{
		c=1;
		ll ans=1,k=1;
		for(i=1;i<=n;i++)
		{
			c=(c*10)%MOD;
			ans=(ans*8)%MOD;
			k=(k*9)%MOD;
		}
		k=(2*k)%MOD;
		cout<<(c+ans-k+MOD)%MOD;
		
	}
	
}



	

		

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef struct node
{
	long long w,s;
	bool operator < (const struct node & n)const
	{
		return w<n.w;
	}
}NODE,*PNODE;
NODE a[100001];
int main()
{
	int n,m,i;
	long long ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].w,&a[i].s);
	}
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
	{
		if(m>=a[i].s)
		{
			m-=a[i].s;
			ans+=a[i].w*a[i].s;
		}
		else
		{
			ans+=m*a[i].w;
			break;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
use std::collections::HashMap;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let a: Vec<usize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut h: HashMap<usize, usize> = HashMap::new();
    let mut p = std::usize::MAX;
    let mut q = 0;
    for i in &a {
        let x = match h.get(i) {Some(x) => *x, None => 0};
        h.insert(*i, x+1);
        if *i < p {p = *i;}
        if *i > q {q = *i;}
    }

    let mut x = 0;
    if p < std::usize::MAX {p += 1;}
    if q > 0 {q -= 1;}
    for i in std::cmp::min(p, q)..std::cmp::max(p, q)+1 {
        let mut y = 0;
        y += match h.get(&i) {Some(x) => *x, None => 0};
        y += match h.get(&(i-1)) {Some(x) => *x, None => 0};
        y += match h.get(&(i+1)) {Some(x) => *x, None => 0};
        if y > x {x = y;}
    }

    println!("{}", x);
}



Measured memory_bytes: 14588
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int gcd(int n,int m){return m?gcd(m,n%m):n;}

int main(){
    int N;
    cin >> N;
    map<int,int> mp;
    rep(i, N){
        int a; cin >> a;
        mp[a]++;
    }

    if(mp.size() < N) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 10496
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    long a = Long.parseLong(s[1]);
    long b = Long.parseLong(s[2]);

    long[] arr = new long[n];
    
    long sum = 0;
    for (int i=0; i<n; i++) {
      arr[i] = Long.parseLong(br.readLine());
      sum += arr[i];
    }
    long diff = a-b;
    long lo = 1; 
    long hi = 1_000_000_009;
    long result = -1;
    while (lo<hi) {
      long mid = lo + (hi-lo)/2;
      boolean good = isGood(mid, arr,a,b);
      if (good) {
        result = mid;
        hi = mid-1;
      } else {
        lo = mid+1;
      }
    }
    long mid = lo + (hi-lo)/2;
    boolean good = isGood(mid, arr,a,b);
    if (good)
      result = mid;
    System.out.println(result);
  }
  static boolean isGood(long k, long[] arr, long a, long b) {
    long offset = k*b;
    long diff = a-b;
    long nCentres = 0;
    int n = arr.length;
    for (int i=0; i<n; i++) {
      long rem = arr[i]-offset;
      if (rem>0) {
        nCentres += rem/diff + ((rem%diff==0) ? 0 : 1);
      }
    }
    return nCentres<=k;
  }
}


Measured memory_bytes: 30804
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    int N;
    cin >> N;
    int a,b;
    vector<P> p(N);
    rep(i,N){
        cin >> a >> b;
        p[i] = make_pair(b,a);
    }

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

    int workday = 0;
    string ans = "Yes";
    rep(i,N){
        workday += p[i].second;
        if(workday > p[i].first) ans = "No";
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 1792
/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

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

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll H1, M1, H2, M2, K, cnt;

int main() {
    scanf("%lld%lld%lld%lld%lld", &H1, &M1, &H2, &M2, &K);
    cnt = (H2 - H1) * 60 + (M2 - M1);
    printf("%lld\n", cnt - K);
    return 0;
}



Measured memory_bytes: 3828
import sys
import itertools as it
from collections import defaultdict
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N=ii()
    x=[]
    y=[]
    dec=defaultdict(list)
    dec_sum=0
    dec_ave=0
    cnt=0
    for i in range(N):
        X,Y=mis()
        x.append(X)
        y.append(Y)
    for i in range(N):
        for j in range(N):
            dec[i].append(((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5)
    for ll in it.permutations(range(N)):
        now=ll[0]
        cnt+=1
        for i in ll[1:]:
            dec_sum+=dec[now][i]
            now=i
    print(dec_sum/cnt)

    


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
'use strict'

const main = (input) => {
    input = input.split('\n')
    const X = parseInt(input[0].split(' ')[2])
    const Y = parseInt(input[0].split(' ')[3])
    const Xs = input[1].split(' ').map(i => parseInt(i))
    const Ys = input[2].split(' ').map(i => parseInt(i))

    const MAX_X = Xs.sort((a, b) => b - a).shift()
    const MIN_Y = Ys.sort((a, b) => a - b).shift()

    for(let i = X + 1; i <= Y; i++) { 
        if(MAX_X < i && i <= MIN_Y){
            console.log('No War')
            return
        }
    }
    console.log('War')
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();

        if (x <= y) {
            int tmp = x;
            x = y;
            y = tmp;
        }

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

        System.out.println(y);
    }
}


Measured memory_bytes: 26240
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define mp make_pair
using namespace std;
int N=1e6+3;
vi sieve(N,1);
vi vis(N,0);
void sievex(int n)
{
    int i,j;
    sieve[1]=1;
    for(i=2;i<=n;i++)
    {
        if(vis[i])
        continue;
        for(j=i;j<=n;j+=i)
        {
            sieve[j]=i;
            vis[j]=1;
        }
    }
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int32_t main() {
	// your code goes here

	  //cout<<"Case #"<<x++<<":\n";
	 int n,i,j,k,res=1;
cin>>n;
vi a(n);
for(i=0;i<n;i++)
cin>>a[i];
sievex(*max_element(a.begin(),a.end()));
set<int> s;
for(i=0;i<n;i++)
{
    set<int> temp;
    int x=a[i];
    while(x!=1)
    {
        temp.insert(sieve[x]);
        x=x/sieve[x];
    }
    for(auto it:temp)
    {
       // cout<<it<<" ";
        if(s.find(it)!=s.end())
        res=0;
        s.insert(it);
    }
    
}
//for(auto it:s)
//cout<<it<<" ";
if(res==1)
cout<<"pairwise coprime\n";
else
{
    int gc=gcd(a[0],a[1]);
    for(i=2;i<n;i++)
    gc=gcd(gc,a[i]);
    if(gc==1)
    cout<<"setwise coprime\n";
    else cout<<"not coprime\n";
}
	return 0;
}


Measured memory_bytes: 30388
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
l=l1+l2+l3
if l.count(1)>2 or l.count(2)>2 or l.count(3)>2 or l.count(4)>2:
  print('NO')
else:
  print('YES')

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

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

int main() {
	long long int N, M;
	while( cin >> N >> M, N || M ) {
		vector<vector<bool>>d( M - 1, vector<bool>( N ) );
		vector<vector<bool>>e( M, vector<bool>( N - 1 ) );
		for( size_t i = 0; i < M + M - 1; i++ ) {
			if( !(i % 2) ) {
				for( size_t j = 0; j < N - 1; j++ ) {
					int k;
					cin >> k;
					e[i / 2][j] = !k;
				}
			} else {
				for( size_t j = 0; j < N; j++ ) {
					int k;
					cin >> k;
					d[i / 2][j] = !k;
				}
			}
		}
		vector<vector<long long int>>m( M, vector<long long int>( N, INT_MAX / 6 ) );
		m[0][0] = 0;
		priority_queue<PLPLL, vector<PLPLL>, greater<PLPLL>>que;
		que.push( make_pair( 1, make_pair( 0, 0 ) ) );
		[&] () {
			while( que.size() ) {
				auto now = que.top(); que.pop();
				auto nowp = now.second;
				if( nowp.first == M - 1 && nowp.second == N - 1 ) {
					cout << now.first << endl;
					return;
				}
				if( nowp.first != M - 1 ) {
					if( d[nowp.first][nowp.second] ) {
						auto next = now;
						next.first++;
						next.second.first++;
						if( m[next.second.first][next.second.second] > next.first ) {
							m[next.second.first][next.second.second] = next.first;
							que.push( next );
						}
					}
				}
				if( nowp.second != N - 1 ) {
					if( e[nowp.first][nowp.second] ) {
						auto next = now;
						next.first++;
						next.second.second++;
						if( m[next.second.first][next.second.second] > next.first ) {
							m[next.second.first][next.second.second] = next.first;
							que.push( next );
						}
					}
				}
				if( nowp.first != 0 ) {
					if( d[nowp.first - 1][nowp.second] ) {
						auto next = now;
						next.first++;
						next.second.first--;
						if( m[next.second.first][next.second.second] > next.first ) {
							m[next.second.first][next.second.second] = next.first;
							que.push( next );
						}
					}
				}
				if( nowp.second != 0 ) {
					if( e[nowp.first][nowp.second - 1] ) {
						auto next = now;
						next.first++;
						next.second.second--;
						if( m[next.second.first][next.second.second] > next.first ) {
							m[next.second.first][next.second.second] = next.first;
							que.push( next );
						}
					}
				}
			}
			cout << 0 << endl;
			return;
		}();
	}
}

Measured memory_bytes: 3112
h,w = [],[]
while True:
    (h,w) = [int(x) for x in input().split()]
    if h == w == 0:
        break
    for x in range(h):
        for y in range(w):
            if x == 0 or y == 0 or x == h-1 or y == w-1:
                print('#',end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 6808
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    if (n%2==1){
        for (int i=n-1;i>=0;i-=2){
            cout << a[i] << " ";
        }
        for (int i=1;i<n;i+=2){
            cout << a[i];
            if (i!=n-2) cout << " ";
        }
        cout << endl;
    }
    else {
        for (int i=n-1;i>=1;i-=2){
            cout << a[i] << " ";
        }
        for (int i=0;i<n;i+=2){
            cout << a[i];
            if (i!=n-2) cout << " ";
        }
        cout << endl;
    }    
}

Measured memory_bytes: 2944
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define entire(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
void solve()
{
  int n,x,t;
  cin>>n>>x>>t;
  int q=(n)/x;
  if((n)%x!=0)q++;
  cout<<q*t<<endl;
}


int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fast
  int T=1;
  // cin >> T;
  while (T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,i,j;
    cin>>a>>b;
    if(a==1 && b==31)printf("1\n");
    else if(a==2 && b==28)printf("1\n");
    else if(a==3 && b==31)printf("1\n");
    else if(a==4 && b==30)printf("1\n");
    else if(a==5 && b==31)printf("1\n");
    else if(a==6 && b==30)printf("1\n");
    else if(a==7 && b==31)printf("1\n");
    else if(a==8 && b==31)printf("1\n");
    else if(a==9 && b==30)printf("1\n");
    else if(a==10 && b==31)printf("1\n");
    else if(a==11&& b==30)printf("1\n");
    else if(a==12 && b==31)printf("1\n");
    else printf("0\n");
    return 0;
}


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

int N,R,p,c;
int main() {
  while (cin >> N >> R && N) {
  array<int,50> A = {};
  for (int i=0;i<N;i++) {
    A[i] = N-i;
  }
  /*  for (int i=0;i<N;i++) {
    cout << A[i];
  }
  cout << endl; */
  for (int i=0;i<R;i++) {
    cin >> p >> c;
    rotate(A.begin(),A.begin()+p-1,A.begin()+p-1+c);
    /*    for (int i=0;i<N;i++) {
      cout << A[i];
    }
    cout << endl; */
  }
  cout << A[0] << endl;
}
}

Measured memory_bytes: 1180
N = int(input())
A = list(map(int, input().split()))

even = 0
multiple4 = 0
for a in A:
    if a % 4 == 0:
        multiple4 += 1
    elif a % 2 == 0:
        even += 1

N -= ((even//2)*2)+multiple4
if N <= multiple4+1:
    print('Yes')
else:
    print('No')


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

int main()
{
  unsigned N, M, Q;
  std::cin >> N >> M >> Q;
  
  std::vector<unsigned> L(M), R(M);
  for (unsigned m = 0; m < M; ++m) {
    std::cin >> L[m] >> R[m];
  }
  
  std::vector< std::vector<unsigned> > cnt(N);
  for (unsigned l = 0; l < N; ++l) {
    cnt[l] = std::vector<unsigned>(N, 0);
  }
  
  for (unsigned m = 0; m < M; ++m) {
    ++cnt[L[m] - 1][R[m] - 1];
  }
  
  std::vector< std::vector<unsigned> > sum(N + 1);
  for (unsigned l = 0; l <= N; ++l) {
    sum[l] = std::vector<unsigned>(N + 1, 0);
  }
  
  for (unsigned l = 1; l <= N; ++l) {
    for (unsigned r = 1; r <= N; ++r) {
      sum[l][r] = cnt[l - 1][r - 1] + sum[l - 1][r] + sum[l][r - 1] - sum[l - 1][r - 1];
    }
  }
  
  for (unsigned i = 0; i < Q; ++i) {
    unsigned p, q, c = 0;
    std::cin >> p >> q;
    
    c = sum[q][q] + sum[p - 1][p - 1] - sum[p - 1][q] - sum[q][p - 1];
    
    std::cout << c << std::endl;
  }
  
  return 0;
}

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

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        s: chars,
    }

    if s == {
        let mut s = s.clone();
        s.reverse();
        s
    } && &s[..s.len() / 2] == &s[s.len() / 2 + 1..]
    {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int x;
    cin >> x;
    if(x==0)cout << "1" << endl;
    else if(x==1)cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 3628
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a > k :
  print(":(")
elif e-a <= k:
  print("Yay!")
elif e-b > k:
  print(":(")
elif e-b <= k:
  print("Yay!")
elif e-c > k:
  print(":(")
elif e-c <= k:
  print("Yay!")
elif e-d > k:
  print(":(")
elif e-d <= k:
  print("Yay!")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  string w;
  cin >> w;
  bool flag = true;
  int count = 1;
  sort(ALL(w));
  if (w.size() == 1) {
    cout << "No" << endl; 
    return 0;
  }
  REP(i, w.size() - 1) {
    if (w[i] == w[i + 1]) count++;
    else {
      if (count % 2 == 1) {
        flag = false;
        break;
      }
      count = 1;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3 && (a>=1 && b>=1 && c>=1)){
        if(a==b && a==c){
            printf("1\n");
        }
        else if(((a==b || a==c)&& b!=c)||((b==c || b==a) && a!=c)
            ||((b==c || c==a) && a!=b)){
            printf("2\n");
        }
        else {
            printf("3\n");
        }

    }
}


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

    vector<long long> l(n+1);
    l[0] = 2;
    l[1] = 1;
    long long ans = 3; 
    for (int i = 2; i <= n; i++){
         l[i] = l[i -1] + l[i-2];
    }
    cout << l[n];

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python

import re
import sys

PATTERN = re.compile("(dream|dreamer|erase|eraser)+$")

def main(argv):
    for line in sys.stdin:
        s = line.rstrip("\n")
        if PATTERN.match(s):
            print "YES"
        else:
            print "NO"

if __name__ == "__main__":
    main(sys.argv)

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

using namespace std;
typedef long long ll;

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

int main(){
// ここに処理を記述
ll N;
cin >> N;

ll ans = N * (N-1) / 2;

cout << ans << "\n";

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

char get(char a,char b)
{
    if((a=='R' && b=='G') || (a=='G' && b=='R'))return 'B';
    if((a=='R' && b=='B') || (a=='B' && b=='R'))return 'G';
    if((a=='B' && b=='G') || (a=='G' && b=='B'))return 'R';
    return 'a';
}


void solve()
{
    ll n;
    cin >> n;
    string x;
    cin >> x;
    ll ans = 0;

    for (int j = 1; j<n-1; j++)
    {
        bool f = true;
        map<ll , char>h;
        map<char, ll>h1;
        for(int i=0;i<j;i++)
        {
            if(x[i]!=x[j])
            {
                f = false;
                h[j-i] = x[i];
                h1[x[i]]++;
            }
        }    

        if(f)
        {
            continue;
        }

        for(int k=j+1;k<n;k++)
        {
            if(x[k]!=x[j])
            {
                char c = get(x[k], x[j]);
                ans += h1[c];
                if(h[k-j]==c)
                {
                    ans--;
                }
            }
        }
    }

    cout << ans << endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int N;

    std::cin >> N;

    ll sum = 0;

    for (int i = 1; i <= N; ++i) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }

    cout << sum << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner


object Main {


  def read() = {
    val sc = new Scanner(System.in)
    val w, h, x, y = sc.nextLong()
    (w, h, x, y)
  }

  def solve(w: Long, h: Long, x: Long, y: Long): (Double, Int) = {
    val area = w.toDouble * h / 2D
    val flag = if(2 * x == w && 2 * y == h) 1 else 0
    (area, flag)
  }

  def main(args: Array[String]): Unit = {
    val (w, h, x, y) = read()
    val result = solve(w, h, x, y)
    println(s"${result._1} ${result._2}")
  }
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> b;
  for(int i=0;i<n;i++){
    if(i%2==0){
      b.insert(b.begin(),a[i]);
    }
    else b.push_back(a[i]);
  }
  if(n%2==0){
    reverse(b.begin(),b.end());
  }
  for(auto &e: b){
    cout<<e<<" ";
  }
  
}

Measured memory_bytes: 3828
import bisect

n = int(input())
num_list = sorted([ int(v) for v in input().split() ])

x = num_list[-1]
x_half = x / 2
y = bisect.bisect_left(num_list,x_half)
if y != 0:
    if y == n-1:
        y -= 1
    else:
        if abs(num_list[y] - x_half) >= abs(num_list[y-1] - x_half):
            y -= 1
print(x,num_list[y])


Measured memory_bytes: 62704
#include <iostream>
#include <vector>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

struct PARAM {
    Int x;
    Int y;
    Int h;
};
Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int n;
    cin >> n;
    vector<PARAM> v(n);
    PARAM base;
    for (Int i = 0; i < n; ++i) {
        Int x, y, h;
        cin >> x >> y >> h;
        v[i] = {x, y, h};
        if (h != 0) {
            base = {x, y, h};
        }
    }
    for (Int i = 0; i <= 100; ++i) {
        for (Int j = 0; j <= 100; ++j) {
            // (i, j) が中心
            PARAM center = {i, j, base.h + abs(base.x - i) + abs(base.y - j)};
            bool isCenter = true;
            for (Int k = 0; k < n; ++k) {
                Int target_h = center.h - abs(center.x - v[k].x) - abs(center.y - v[k].y);
                target_h = Max(target_h, 0);
                if (v[k].h == target_h) {
                } else {
                    isCenter = false;
                }
            }
            if (isCenter == true) {
                cout << center.x << " " << center.y << " " << center.h << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main(){
	int n, k;
	cin >> n >> k;
  	int* h = new int[n];
  	for(int i = 0; i < n; i++)
      	cin >> h[i];
  	int* dp = new int[n];
  	dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
      	 int val = INT_MAX;
    	 for(int j = 1; j <= k and i - j >= 0 ; j++){
         	if (dp[i - j] + abs(h[i-j] - h[i]) < val)
              	val = dp[i - j] + abs(h[i-j] - h[i]);
         }
      	 dp[i] = val;
    }
  	cout<<dp[n-1];
	return 0;
  
}


Measured memory_bytes: 1024
// 2020-08-28 21:19:42
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  ll k;
  cin >> k;
  ll n = 50, b = n - 1 + k / n, c = k % n;
  vector<ll> ans;
  rep(i, c) ans.push_back(b + n + 1 - c);
  REP(i, c, 50) ans.push_back(b - c);
  cout << n << '\n';
  rep(i, ans.size()) {
    if (i > 0) cout << ' ';
    cout << ans[i];
  }
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(N), B(N); // A は不親切な者 B は正直者
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < a; ++j) {
      int x, y;
      cin >> x >> y;
      if (y == 0) A[i].push_back(x - 1);
      else B[i].push_back(x - 1);
    }
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) S.push_back(i);
    }
    
    bool judge = true;
    for (int i = 0; i < N; ++i) {
      bool now = false; // 正直者か否か
      for (int x : S) {
        if (x == i) now = true;
      }
      for (int j : S) {
        if (now) {
          for (int k : A[j]) {
            if (k == i) judge = false;
          }
        } else {
          for (int k : B[j]) {
            if (k == i) judge = false;
          }
        }
      }
    }
    
    int a = S.size();
    if (judge) ans = max(ans, a);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# Structured Programming
# if 入力: 30, output is " 3 6 9 12 13 15 18 21 23 24 27 30"

integer = int(input())
cout = []

i = 1
while i <= integer:
    x = i
    if x % 3 == 0:
        cout.append(i)
    else:
        while x > 0:
            if x % 10 == 3:
                cout.append(i)
                x = 0
            else:
                x //= 10
    i += 1

for n in cout:
    print(' ' + str(n), end = '')
print()



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


int main()
{
	string A;
	cin >> A;
	for (int i = 0; i < 14; i++) {
		if (A[i] == ',') {
			A[i] = ' ';
		}
	}
	cout << A << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
const int maxn=100005;
const int nil=-1;
struct shu
{
    int p,z,y;
};
shu T[maxn];
int n,D[maxn];
void Printf(int u)
{
    int i,c;
    printf("node %d:",u);
    printf(" parent = %d, ",T[u].p);
    printf("depth = %d, ",D[u]);
    if(T[u].p==nil) printf("root, ");
    else if(T[u].z==nil) printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for (i=0,c=T[u].z;c!=nil;i++,c=T[c].y)
    {
        if(i) printf(", ");
    printf("%d",c);
    }
    printf("]\n");
}
void deapth(int u,int p)
{
    D[u]=p;
    if(T[u].y!=nil) deapth(T[u].y,p);
    if(T[u].z!=nil) deapth(T[u].z,p+1);
}
int main()
{
    int u,d,c,r,huan;
    scanf("%d",&n);
    for (int i=0;i<n;i++) T[i].p=T[i].z=T[i].y=nil;
    for (int i=0;i<n;i++)
    {
        scanf("%d%d",&u,&d);
        for (int j=0;j<d;j++)
        {
            scanf("%d",&c);
            if(j==0) T[u].z=c;
            else T[huan].y=c;
            huan=c;
            T[c].p=u;
        }
    }
    for (int i=0;i<n;i++)
        if(T[i].p==nil) r=i;
    deapth(r,0);
    for (int i=0;i<n;i++) Printf(i);
    return 0;
}

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

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


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

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//










int main(){
        Int n;
        cin >> n;
        list<Int> b;

        Int tmp;
        cin >> tmp;
        b.push_back(tmp);

        Int flg = 1;
        for(Int i = 0; i < n-1; i++)
        {
                Int a;
                cin >> a;

                if(flg){
                        b.push_back(a);
                }
                else{
                        b.push_front(a);
                }

                flg = 1 - flg;
        }


        if(n%2 == 0){
                vector<int> newb(n);
                int j = n-1;
                for(auto itr = b.begin(); itr != b.end(); itr++){
                        newb[j] = *itr;
                        j--;
                }
                for(int i = 0; i < n; i++){
                        cout << newb[i] << " ";
                }
        }
        else{
                for(auto itr = b.begin(); itr != b.end(); itr++){
                        cout << *itr << " ";
                }
        }
        cout << endl;
        return 0;
}


















Measured memory_bytes: 9216