stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <stdio.h>

#include <string>

#include <cstring>

#include <stdlib.h>

#include <math.h>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <list>

#include <iterator>

#include <assert.h>

#pragma warning(disable:4996) 



typedef long long ll;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF 9223300000000000000

#define INF 2140000000

const long long MOD = 1000000007;

using namespace std;





ll a[16][16];



int main(int argc, char* argv[])

{

    int n;

    scanf("%d", &n);



    int i,j;

    for(i=0; i<n; i++) {

        for(j=0; j<n; j++) {

            scanf("%lld", &a[i][j]);

        }

    }



    vector<ll> dp(1<<n);

    int k;

    for(k=0; k<(1<<n); k++) {

        vector<int> z;

        for(i=0; i<n; i++) {

            if(k & (1<<i)) z.push_back(i); 

        }

        int siz=(int)z.size();



        dp[k]=0;

        for(i=0; i<siz; i++) {

            for(j=i+1; j<siz; j++) {

                dp[k] += a[z[i]][z[j]];

            }

        }



        ll max=0;

        for(i=0; i<(1<<siz); i++) {

            int tmp0=0;

            for(j=0; j<siz; j++) {

                if(i & (1<<j)) tmp0 |= (1<<z[j]);

            }

            ll val = dp[tmp0]+dp[k-tmp0];

            max = MAX(max, val);

        }

        dp[k] = max;

    }

    printf("%lld\n", dp[(1<<n)-1]);



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.81236347892013x):
#include <stdio.h>

#include <string>

#include <cstring>

#include <stdlib.h>

#include <math.h>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <list>

#include <iterator>

#include <assert.h>

#pragma warning(disable:4996) 



typedef long long ll;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF 9223300000000000000

#define INF 2140000000

const long long MOD = 1000000007;

using namespace std;





ll a[16][16];

ll dp[1<<16];



int main(int argc, char* argv[])

{

    int n;

    scanf("%d", &n);



    int i,j;

    for(i=0; i<n; i++) {

        for(j=0; j<n; j++) {

            scanf("%lld", &a[i][j]);

        }

    }



    int mm=(1<<n);

    int z[17];

    int k;

    for(k=0; k<mm; k++) {

        int siz=0;

        for(i=0; i<n; i++) {

            if(k & (1<<i)) z[siz++]=i;

        }



        dp[k]=0;

        for(i=0; i<siz; i++) {

            for(j=i+1; j<siz; j++) {

                dp[k] += a[z[i]][z[j]];

            }

        }

    }



    for(k=0; k<mm; k++) {

        int siz=0;

        for(i=0; i<n; i++) {

            if(k & (1<<i)) z[siz++]=i;

        }

        ll max=0;

        int MM=(1<<siz);

        for(i=0; i<MM; i++) {

            int tmp0=0;

            for(j=0; j<siz; j++) {

                if(i & (1<<j)) tmp0 |= (1<<z[j]);

            }

            ll val = dp[tmp0]+dp[k^tmp0];

            max = MAX(max, val);

        }

        dp[k] = max;

    }

    printf("%lld\n", dp[mm-1]);



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int N = 330000;



int a[N];



vector<int> dp[N];



void insert(vector<int> &lhs, const vector<int> &rhs) {

	for (int x : rhs) lhs.push_back(x);

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

	reverse(lhs.begin(), lhs.end());

	lhs.resize(2);

}



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	int n; cin >> n; int m = 1 << n;

	for (int i = 0; i < m; i++) cin >> a[i];

	for (int i = 0; i < m; i++) dp[i].push_back(a[i]);

	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (j & (1 << i)) insert(dp[j], dp[j ^ (1 << i)]);

	int ans = 0;

	for (int i = 1; i < m; i++) {

		ans = max(ans, dp[i][0] + dp[i][1]);

		cout << ans << "\n";

	}

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 9.982442897017199x):
#include<bits/stdc++.h>

using namespace std;

#define all(v) ((v).begin()),((v).end())

#define ll long long

#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

double const EPS = 1e-12, PI = acos(-1);

const int N = 4e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;

const ll inf = 1e18;



int arr[N];

pair<int, int> DP[N];



pair<int, int> merge(pair<int, int> A, pair<int, int> B) {

  set<pair<int, int>> st; // maximum Val, without repeat index

  st.insert({-arr[A.first], A.first});

  st.insert({-arr[A.second], A.second});

  st.insert({-arr[B.first], B.first});

  st.insert({-arr[B.second], B.second});

  pair<int, int> ans;

  ans.first = (*st.begin()).second;

  st.erase(st.begin());

  ans.second = (*st.begin()).second;

  return ans;

}



int main() {

  fastIO;

#ifdef LOCAL

  freopen("input.in", "rt", stdin);

#endif

  // problem on SOS DP

  int n;

  cin >> n;

  for (int i = 0; i < (1 << n); ++i) {

    cin >> arr[i];

    DP[i] = {i, (1 << n)};

  }

  for (int i = 0; i < n; ++i) {

    for (int mask = 0; mask < (1 << n); ++mask) {

      if(mask & (1 << i)) {

        DP[mask] = merge(DP[mask], DP[mask ^ (1 << i)]); // SOS

      }

    }

  }

  int best = 0;

  for (int i = 0; i < (1 << n); ++i) {

    best = max(best, arr[DP[i].first] + arr[DP[i].second]);

    if(i)

      cout << best << '\n';

  }

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define taskname "OrPlusMax"

#define int long long

using namespace std;



vector<int> a;

void update(int i, pair<int, int> &p)

{

    if (i == p.first || i == -1) return;

    if (p.first == -1 || a[i] > a[p.first])

    {

        swap(p.first, p.second);

        p.first = i;

    }

    else if (p.second == -1 || a[i] > a[p.second]) p.second = i;

}



main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);   cout.tie(nullptr);

    if (ifstream("test.inp"))

    {

        freopen("test.inp", "r", stdin);

        #ifdef CHECKING

            freopen(taskname".out", "w", stdout);

        #else

            freopen("test.out", "w", stdout);

        #endif //CHECKING

    }

    else if (ifstream(taskname".inp"))

    {

        freopen(taskname".inp", "r", stdin);

        freopen(taskname".out", "w", stdout);

    }



    int n;  cin >> n;

    a.resize(1 << n);

    for (int &i : a) cin >> i;

    vector<pair<int, int>> v(1 << n, {-1, -1});

    vector<int> ans(1 << n, 0);

    for (int i = 0; i < 1 << n; ++i)

    {

        update(i, v[i]);

        for (int j = 1; j <= n; ++j)

            if (((i >> (j - 1)) & 1) == 0)

            {

                int x = i ^ (1 << (j - 1));

                update(v[i].first, v[x]);

                update(v[i].second, v[x]);

            }

        if (i)

        {

            ans[i] = max(ans[i - 1], a[v[i].first] + a[v[i].second]);

            cout << ans[i] << '\n';

        }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.298603301120887x):
#include<cstdio>

#include<algorithm>

#define rep(i,l,r) for (int i=(l); i<=(r); i++)

using namespace std;



const int N=300010;

int n,m,a[N],r[N],mx[N];



int main(){

    scanf("%d",&m); int n=1<<m;

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

    for (int i=0; i<n; i++)

        for (int j=i; j<n; j=(j+1)|i)

            r[j]=max(r[j],a[i]+mx[j]),mx[j]=max(mx[j],a[i]);

    for (int i=1; i<n; i++) printf("%d\n",r[i]=max(r[i],r[i-1]));

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

//freopen("transmitters.in","r",stdin);

//cout<<fixed<<setprecision(6)<<n<<endl;

// transform(s.begin(), s.end(), s.begin(), ::tolower);

//double PI=3.14159265359,c=0;

#define all(v) v.begin(),v.end()

#define endl '\n'

#define ll long long

//#define f(n) for(int i=;i<n;i++)

double PI = acos(-1);

using namespace std;

void fast()

{

    std::ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

ll arr[10000000],n,k;

vector<ll>v(1e6,-1);

ll minCost(ll indx)

{

    ll path1=LLONG_MAX;

    if(indx==n-1)

        return 0;

        

    if(v[indx]!=-1)

        return v[indx];

    for(int i=0;i<k;i++)

    {

      if((indx+1+i)<n)

          path1=min(path1,(abs(arr[indx]-arr[indx+1+i])+minCost(indx+1+i)));

    }

    return v[indx]=path1;

}

int main()

{

    fast();

    cin>>n>>k;

    for(int i=0; i<n; i++)

        cin>>arr[i];



    cout<<minCost(0)<<endl;



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.167804085644107x):
/*

				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "

*/





#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#define f for

#define ll long long

#define ull unsigned long long

#define endl "\n"

using namespace std;

#define BI  acos(-1)

#define all(a) a.begin(), a.end()

void Open()

{

#ifndef ONLINE_JUDGE

	freopen("Input.txt", "r", stdin);

	freopen("Output.txt", "w", stdout);

#endif

}

ll gcd(ll a, ll b)

{

	return b == 0 ? a : gcd(b, a % b);

}

void madesetprobblem()

{

	//$ $

	//less than or equal => $ 1 \leq 100 $

	//  $(1 \le A,B \le 10^5 )$

	// a[i] => $a_i$

	// a[i][j] => $a_{i,j}$

	// double qoutes ''yext''

	/*

		image

		\begine{center}

		\includegraphics{image.jpg}

		\end{center}

	*/

	/*

		list

		\begin{itemize}

			\item first one

			\item second one

		\end{itemize}

	*/

}

int n,k;

vector<int>a(1e5 + 2),dp(1e5+2,-1);

int ans(int c = 0)

{

	if (c == n-1)

		return 0;

	int ans1 = INT_MAX, ans2 = INT_MAX;

	if (dp[c] != -1)

		ans1 = dp[c];

	else

	{

		f(int i = 1; i <= k; i++)

		{

			if (c + i < n)

				ans1 = min(ans1,(abs(a[c] - a[c + i]) + ans(c + i)));

		}

		dp[c] = ans1;

	}

	//cout <<c<<" "<< ans1 << " " << ans2 << endl;

	return ans1	;

}

int main()

{

	// توكلت علي الله 

//Open();

	ios::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	cin >> n>>k;

	f(int i = 0; i < n; i++)

	{

		cin >> a[i];

	}

	cout << ans();

}
// Slower C++ solution:
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする

#include <math.h> //数学関数と数学定数を利用する

using namespace std;

typedef long long int ll;



int N;

int K;

int h[100010];

ll dp[100010];



ll INF = 1LL << 60;



void chmin(ll &a, ll b){

  if (a > b){

    a = b;

  }

}



int main(){



  cin >> N >> K;

  

  for (int i = 0; i < N; i++){

    cin >> h[i];

  }

  

  for (int i = 0; i < 100010; i++){

    dp[i] = INF;

  }

  

  //初期条件

  dp[0] = 0;

  

  //ループ

  for (int i = 0; i < N; i++){

    for(int j = 1; j <= K; j++){

      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));    

    }

  }



  cout << dp[N-1];        

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2854371904477595x):
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする

#include <math.h> //数学関数と数学定数を利用する

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

#define PI 3.141592653589793

using namespace std;

typedef long long ll;

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

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

int gcd(int a, int b){//ユークリッドの互除法

  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提

  if (b == 0) return a; //aをbで割り切れたらreturn

  else gcd(b, a % b);

}



const int MOD = 1000000007;

const int INF = 1 << 30;

int dp[100005],h[100005];



int main(){

  int n,k; cin >> n >> k;

  rep(i,n){

    cin >> h[i];

  }

  

  rep(i,100005) dp[i] = INF;

  

  dp[0] = 0;

  

  for(int i = 0; i < n; i++){

    for(int j = 1; j <= k; j++){

      if(i+j < n){

        chmin(dp[i+j], dp[i] + abs(h[i]-h[i+j]));

      }

    }

  }

  

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

  

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std ;



const int nmax = 102000;

const int inf =999999999;



int h[nmax];

int dp[nmax];



int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    int n,k;cin>>n>>k;

    vector<int>mov;

    for(int i=1;i<=k;++i)mov.push_back(i);





    for(int i=1;i<=n;++i){cin>>h[i];dp[i]=inf;}

    dp[1]=0;

    dp[0]=inf;



    for(int i=2;i<=n;++i)

    {

        for(auto j:mov)

        {

            if(i-j<=0)break;

            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

        }

    }

    cout<<dp[n];



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3385395888611615x):
#include<cstdio>

#include<algorithm>

using namespace std;



#define ll long long 



#define file_io 0



ll i,t,j;

ll n,k,h[100005],dp[100005];



int main(){

	if (file_io){

		freopen(".in","r",stdin);

		freopen(".out","w",stdout);

	}

	

	scanf("%lld%lld",&n,&k);

	

	for (i=1; i<=n; ++i){

		scanf("%lld",&h[i]);

	}

	

	dp[1]=0;

	for (i=2; i<=n; ++i){

		dp[i]=2e9;

		for (t=max(1ll,i-k); t<i; ++t){

			dp[i]=min(dp[t]+abs(h[i]-h[t]),dp[i]);

		}

	}

	

	printf("%lld\n",dp[n]);

	

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <climits>

#define SIZE 100001

#define INF INT_MAX >> 1

 

using namespace std;

 

int dp[SIZE];

 

int main(void){

	int n, k; cin >> n >> k;

	int h[SIZE] ={0};

	for(int i=0; i<n; i++){

		cin >> h[i];

	}

 

	fill(dp, dp+n, INF);

	dp[0] = 0;

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

		for(int j=1; j<=k; j++){

			if(i-j >= 0) dp[i] = min(dp[i], dp[i-j] + abs(h[i-j]-h[i]));

		}

	}

 

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

}

// Faster C++ solution for the same problem (measured speedup: 1.3788643139529466x):
#include <bits/stdc++.h>

#define INF 100000000000000

using namespace std;



int main(){

    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);

    int n, k;  cin >> n >> k;   vector<long long int> vec(n), dp(n, INF);

    for(int i=0;n>i;i++){

        cin >> vec[i];

    }

    dp[0]=0;

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

        for(int j=1;min(i, k)>=j;j++){

            dp[i]=min(dp[i], dp[i-j]+abs(vec[i]-vec[i-j]));

        }

    }

    cout << dp[n-1];

}
// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <queue>

#include <vector>

#include <map>

#define mem(u, v) memset(u, v, sizeof(u))

#define INF 0x3f3f3f3f

#define pii pair<int, int >

#define LL long long

#define mid (l + r) / 2

#define lowbit(x) x & -x

using namespace std;

const int MAXN = 1e6 + 7,  MAXM = 1e6 + 7, MAXK = 1e6 + 7;



int a[MAXN], b[MAXN], sum[MAXN], c[MAXN], n;

LL ans0;



void add(int x){

	while (x <= 5 * n){

		c[x] += 1;

		x += lowbit(x);

	}

}



int get(int x){

	int y = 0;

	while (x > 0){

		y += c[x];

		x -= lowbit(x);

	}

	return y;

}



bool judge(int x){

	sum[0] = 0;

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

		if (a[i] >= x) sum[i] = sum[i - 1] + 1;

		else sum[i] = sum[i - 1];

	}

	for (int i = 0; i <= n; i++) sum[i] = 2 * sum[i] - i + n + 1;

	LL ans1 = 0;

	mem(c, 0);

	for (int i = 0; i <= n; i++){

		ans1 += get(sum[i]);

		add(sum[i]);

	}

	if (ans1 >= ans0) return true;

	return false;

}



int main(){

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];

	sort(b + 1, b + n + 1);

	int l = 1, r = n, ans = 0;

	ans0 = (1LL * n * (n - 1) / 2 + n + 1) / 2LL;

	while (l <= r){

		if (judge(b[mid])) ans = mid, l = mid + 1;

		else r = mid - 1;

	}

	printf("%d\n", b[ans]);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.136997220075087x):
#include<iostream>

#include<cstdio>

#include<math.h>

#include<algorithm>

#include<map>

#include<set>

#include<bitset>

#include<stack>

#include<queue>

#include<string>

#include<cstring>





using namespace std;

typedef long long LL;

const int maxn=1e6+7;

LL n;

LL tot=0;

LL mn=0x3f,mx=-0x3f;

LL a[maxn];

LL bit[maxn];



struct node {

LL val,pos;

}arr[maxn];



bool cmp(node n1,node n2)

{

    return n1.val==n2.val?n1.pos<n2.pos:n1.val<n2.val;

}



void update(LL x,LL val)

{

    for(; x< maxn ;x+=(x & -x))

    {

        bit[x]+=val;

    }

}



LL getsum(LL x)

{

    LL ans=0;

    for(;x>0;x-=(x & -x))

    {

        ans += bit[x];

    }

    return ans;

}







bool check(LL x){

    memset(bit,0,sizeof(bit));

     memset(arr,0,sizeof(arr));





	for(int i=1;i<=n;i++)

    {

        if(a[i]<=x)arr[i].val=-1;

        else arr[i].val=1;

        arr[i].pos=i+1;

    }



    arr[0].val=-1;

	arr[0].pos=1;



	for(int i=1;i<=n;i++)

	arr[i].val+=arr[i-1].val;

	sort(arr,arr+n+1,cmp);



	LL ans=0;

	for(int i=0;i<=n;i++)

    {

        ans+=(i-getsum(arr[i].pos));

        update(arr[i].pos,1);

    }

	return ans*2 > tot;

}





int main(){

   scanf("%lld",&n);



   for(int i=1;i<=n;i++)

    {

   	 scanf("%lld",&a[i]);

   	 mn=min(mn,a[i]);

   	 mx=max(mx,a[i]);

   	 tot+=i;

   }



   LL l=mn,r=mx;

   while(r-l>1)

    {

   	  LL mid=(l+r)/2;

   	 if(check(mid)) r=mid;

   	 else l=mid;

   	 //printf("s%d",mid);

   }

   printf("%lld\n",r);



   return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

#define maxn 100010

int n,k;

int a[maxn];

int main()

{

	cin>>n>>k;

	int cnt=0;

	for(int i=1;i<=n;i++)

	{

		cin>>a[i];

		if(a[i]>=k)

		{

			cnt++;

		}

	}

	cout<<cnt<<endl;

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 5.251933354272648x):
#include <stdio.h>



int main()

{

    int n,k,ans=0;

    scanf("%d%d",&n,&k);

    for(int i=0;i<n;++i)

    {

        int x;

        scanf("%d",&x);

        if(x>=k)ans++;

    }

    printf("%d\n", ans);

    return 0;

}
// Slower C++ solution:
#include<iostream>



using namespace std;



int main()

{

	int x, y;



	cin >> x >> y;



	if (x + y < 10) {

		cout << x + y;

	}

	else {

		cout << "error";

	}

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.253847677679224x):
#include<cstdio>

int main(){

	int a,b;

	scanf("%d%d",&a,&b);

	if(a+b<10){printf("%d\n",a+b);}

	else {printf("error\n");}

	return 0;

	}
// Slower C++ solution:
#include<bits/stdc++.h>

#include<array>

using namespace std;

const int mx = 1e5+5;

int a[mx];

array<int,100005>dp;

void memo(int i,int n,int k)

{

     if(i>n) return;

     for(int m=1;m<=k;m++)

     {

     	dp[i+m] = min(dp[i+m],dp[i]+abs(a[i+m]-a[i]));

     }

     memo(i+1,n,k);

}

int main()

{

	int n,k;cin>>n>>k;

	for(int i=1;i<=n;i++)

		cin>>a[i];

	dp.fill(INT_MAX);

	dp[0] = 0;

	dp[1] = 0;

	memo(1,n,k);

	cout<<dp[n]<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4183611066740736x):
#include<bits/stdc++.h>

using namespace std;

long long n,h[100010],dp[100010],k;



int main()

{

	scanf("%lld %lld",&n,&k);

	for(int i=1;i<=n;i++)

	{

		scanf("%lld",&h[i]);

	}

	for(int i=2;i<=n;i++)

	{

		for(int j=1;j<=k;j++)

		{

			if(i>j)

			{

				if(j==1)dp[i] = dp[i-j]+abs(h[i-j]-h[i]);

				else dp[i] = min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));

			}

		}

	}

	printf("%lld\n",dp[n]);

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<cctype>

#include<cmath>

#include<iostream>

#include<algorithm>

#include<queue>

#include<set>

#include<map>

#include<vector>

#include<stack>

#define INF 1000000000

#define M 10005

#define LL long long

using namespace std;

struct node{

    int x,y;

    double z;

};

node B[M];

vector<node>A;

int fa[M];

double dis(int x,int y){

    int dx=B[x].x-B[y].x,dy=B[x].y-B[y].y;

    return sqrt(dx*dx+dy*dy);

}

int get(int x){

    if(fa[x]==x) return x;

    else return fa[x]=get(fa[x]);

}

bool cmp(node a,node b){

    return a.z>b.z;

}

int main(){

    int n,m;

    while(scanf("%d%d",&n,&m)!=EOF){

        int j,k;

        A.clear();

        for(j=1;j<=n;j++){

            fa[j]=j;

        }

        for(j=1;j<=n;j++) scanf("%d%d",&B[j].x,&B[j].y);

        double ans=0;

        for(j=1;j<=m;j++){

            int x,y;

            scanf("%d%d",&x,&y);

            double z=dis(x,y);

            //printf("%f\n",z);

            ans+=z;

            A.push_back((node){x,y,z});

        }

        sort(A.begin(),A.end(),cmp);

        for(j=0;j<A.size();j++){

            int a=get(A[j].x),b=get(A[j].y);

            if(a!=b){

                fa[a]=b;

                ans-=A[j].z;

            }

        }

        printf("%.3f\n",ans);

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.535001323220493x):
#include<stdio.h>

#include<string.h>

#include<math.h>

#include<algorithm>

using namespace std;

#define N 10000+10

int per[N];

struct Point

{

	double x,y;

}p[N];

struct Edge

{

	int s,e;

	double w;

}a[N*N];

double ma(Point a,Point b)

{

	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));

}

bool cmp(Edge a,Edge b)

{

	return a.w>b.w;

}

int Find(int x)

{

	while(x!=per[x])

		x=per[x];

	return x;

}

int Judge(int x,int y)

{

	int fx=Find(x);

	int fy=Find(y);

	if(fx!=fy)

	{

		per[fx]=fy;

		return 1;

	}

	return 0;

}

int main()

{

	int i,n,m,x,y;

	while(~scanf("%d%d",&n,&m))

	{

		for(i=1;i<=n;i++)

		{

			per[i]=i;

			scanf("%lf%lf",&p[i].x,&p[i].y);

		}

		double sum=0;

		for(i=0;i<m;i++)

		{

			scanf("%d%d",&x,&y);

			a[i].s=x;a[i].e=y;

			a[i].w=ma(p[x],p[y]);

			sum+=a[i].w;

		}

		sort(a,a+m,cmp);

		double tmp=0;

		for(i=0;i<m;i++)

		{

			if(Judge(a[i].s,a[i].e))

				tmp+=a[i].w;

		}

		printf("%.3lf\n",sum-tmp);

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <string>

#include <algorithm>

#include<climits>

using namespace std;



#define ll long long

#define tc                int T;cin>>T;while(T--)

int a[100000];

int main()

{

	int n, c, b, k ; cin >> n >> k;

	for (int& e : a)cin >> e;

	vector<int> dp(n, INT_MAX);

	dp[0] = 0;

	for (int i = 0; i < n; ++i) {

		for (int e = i + 1; e <= i + k; ++e) {

			if (e < n)

				if ((dp[i] + abs(a[e] - a[i])) < dp[e])

					dp[e] = dp[i] + abs(a[e] - a[i]);

		}

	}

	cout << dp[n - 1] << '\n';

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.2085734175674827x):
#include <iostream>

#include <vector>

#include <string>

#include <algorithm>

#include<climits>

using namespace std;



#define ll long long

#define tc                int T;cin>>T;while(T--)

int main()

{

	int n, c, b, k ; cin >> n >> k;

  vector<int> a(n);

	for (int& e : a)cin >> e;

	vector<int> dp(n, INT_MAX);

	dp[0] = 0;

	for (int i = 0; i < n; ++i) {

		for (int e = i + 1; e <= i + k; ++e) {

			if (e < n)

				if ((dp[i] + abs(a[e] - a[i])) < dp[e])

					dp[e] = dp[i] + abs(a[e] - a[i]);

		}

	}

	cout << dp[n - 1] << '\n';

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <iostream>



using namespace std;



#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)

#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)

#define ll long long

#define pb push_back

#define mp make_pair

#define F first

#define S second

#define clr(x) memset(x, 0, sizeof(x))

#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)

#define PI 3.1415926535897932384626

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef vector<pii> vpii;

typedef vector<pll> vpll;

typedef vector<vi> vvi;

typedef vector<vl> vvl;



int t=1;

const int mxN=1e5, mxH=1e4;

int n,k;

vi h(mxN+1), dp(mxN+1, INT_MAX);



void test_case(){

    cin>>n>>k;

    fo(i,n)cin>>h[i+1];

    dp[1]=0,dp[2]=abs(h[2]-h[1]);

    Fo(i,3,n+1){

        Fo(j,1,k+1){

            if(i-j<1)continue;

            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

        }

    }

    cout<<dp[n]<<endl;

}



int main() {

    ios_base::sync_with_stdio(false);

	cin.tie(NULL);



    // cin>>t;

    while(t--){

        test_case();

    }

    

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.805263086188442x):
#include <iostream>

#include <bits/stdc++.h>



using namespace std;



const int INF = 1e9+5;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(NULL);



    int n,k;

    cin>>n>>k;

    vector<int>h(n),dp(n,INF);

    for(int i=0; i<n; i++)cin>>h[i];

    dp[0]=0;

    for(int i=0; i<n; i++){

        for(int step=1; step<=k; step++){

            if(i+step<n){

                dp[i+step]=min(dp[i+step],dp[i]+abs(h[i]-h[i+step]));

            }

        }

    }

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



    return 0;

}