criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

typedef vector<bool> vb;

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

    int psr[n+2], ps2[n+1];
    ps2[0] = 0, ps2[1] = a[1];
    for (int i = 2; i <= n; i++) {
        ps2[i] = ps2[i-2] + a[i];
    }
    psr[n+1] = 0;
    for (int i = n; i > 0; i--) {
        psr[i] = psr[i+1] + a[i];
    }

    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        int l = 0, r = n + 1;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            int l2 = 2 * mid - 1 - n;
            if (l2 < 1) {
                l = mid;
                continue;
            }
            
            int r2 = l2 == 1 ? n : lower_bound(a+1, a+n+1, x*2-a[l2-1]) - a - 1;
            if (r2 < mid - 1) {
                r = mid;
            } else {
                l = mid;
            }
        }
        
        cout << psr[l] + ps2[l*2-n-2] << endl;
    }

    return 0;
}

Compiler output:
a.cc:6:9: error: 'vector' does not name a type
    6 | typedef vector<bool> vb;
      |         ^~~~~~
Language: Java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        List<Integer> alist = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            alist.add(a[i]);
        }

        int[] x = new int[q];
        for (int i = 0; i < q; i++) {
            x[i] = sc.nextInt();
        }

        int takahashi = 0;


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

            while (0 < alist.size()) {
                if (a.length % 2 == 1) {
                    int max = a[0];
                    int jj = 0;
                    for (int j = 0; j < a.length; j++) {
                        if (max < a[j]) {
                            max = a[j];
                            jj = j;
                        }
                    }
                    takahashi = takahashi + max;
                    alist.remove(jj);
                } else {
                    int near = a[0];
                    int nn = 0;
                    for (int j = 1; j < a.length; j++) {
                        int no1 = Math.abs(near - x[i]);
                        int no2 = Math.abs(a[j] - x[i]);
                        if (no1 < no2) {
                            near = a[j];
                            nn = j;
                        }
                    }
                    alist.remove(nn);
                }
            }
            System.out.println(takahashi);
        }

    }
}

# メモ










Compiler output:
Main.java:64: error: illegal character: '#'
# ??
^
Main.java:73: error: reached end of file while parsing
2 errors
Language: C

#include <bits/stdc++.h>

int nextInt();

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n, q, i;
int A[100005];
int vt[100005];
void pro(int x) {
	for(int i=1;i<=n;i++) vt[i] = 0;
	for(int i=1;i<=n/2;i++) {
		for(int j=n;j>=1;j--) {
			if(vt[j] == 0) {
				vt[j] = 1;
				cout<<A[j]<<' ';
				break;
			}
		}
		int jidx = -1;
		for(int j=1;j<=n;j++) {
			if(vt[j] == 0) {
				if(jidx == -1) jidx = j;
				else {
					if(abs(x - A[jidx]) > abs(x - A[j])) jidx = j;
				}
			}
		}
		vt[jidx] = 1;
	}
	for(int i=1;i<=n;i++) if(vt[i] == 0) cout<<A[i];
	cout<<'\n';
}
int dp[100005];
ll X[100005];
int main() {
	n = nextInt();
	q = nextInt();
	for(i=1; i<=n;i++){
		A[i] = nextInt();
	}
	sort(A+1,A+n+1);

	int r = n/2 + 1;
	int l = 2;
	if(n%2) l--;
	int cnt=0;
	ll sum = 0;
	for(int i=r;i<=n;i++) sum += (ll)A[i];
	while(l<r) {
		dp[cnt++] = (A[l]+A[r])/2;
		X[cnt-1] = sum;

		sum -= (ll)A[r];
		sum += (ll)A[l];
		l+=2;
		r++;
	}
	X[cnt] = sum;
	while(q--){
		int a = nextInt();
		int idx = lower_bound(dp,dp+cnt,a) - dp;
		cout<<X[idx]<<'\n';
	}
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>                                                                                                                                                                                                                              
using namespace std;                                                                                                    
long calc(int* map, int x, int n);                                                                                                                                                                                                              
int* half, *half2;
int sum = 0;
int main(){
   int n,q;
   cin >> n >> q;
   int *map = new int[n];
   half = new int[n];
   half2 = new int[n];
   sum = 0;
   int halfsum = 0;
   for(int i=0;i<n;i++){
      int a;
      cin >> a;
      map[i] = a;
      half2[i] = -sum;
      sum += a;
      if((i%2==1) ^ (n%2==1)) {
         halfsum+=a;
      }
      half[i] = halfsum;
   }
   for(int i=0;i<q;i++){
      int x;
      cin >> x;
      auto ans = calc(map, x, n);
      cout << ans << endl;
   }
}
long calc(int* map, int x, int n)
{
   int k = x <= map[0] ? 0
      : map[n-1] <= x ?  n-1
      : bs(map, x, 0, n-1);
   int low =k-1, high=k;
   int a = n-k;
   int t = k+a/2;

   //int sc_a = 0;
   int sc_t = sum + half2[k];
   //printf("start:%d, a:%d, low:%d, high:%d\n", sc_t,a, low, high);
   for(int i=0;i<a/2;i++){
      if(low < 0 || map[high] - x < x - map[low]){
         //sc_a += map[high];
         sc_t -= map[high];
         high++;
      }else{
         //sc_a += map[low];
         low--;
         t--;
      }
   }
   // 0~lowまでを分ける
   /*
   for(int i=0;i<=low;i+=2){
      sc_a += map[i];
   }
   */
   //;printf("second:%d\n", sc_t);
   if(low >= 0){
      sc_t += half[low];
   }                                                                                                                                                                                                                                               return sc_t;                                                                                                         }     

Compiler output:
a.cc: In function 'long int calc(int*, int, int)':
a.cc:36:9: error: 'bs' was not declared in this scope; did you mean 'abs'?
   36 |       : bs(map, x, 0, n-1);
      |         ^~
      |         abs
Language: C++

#include <iostream>
#include <vector>
#define ll long long
using namespace std;
vector <int> A(0);
vector <int> B(0);


int main(){
 // cout<<123<<endl;
  int N,Q;
  int aaa;
  int x;
  cin>>N>>Q;
  A.push_back(-1000000010);
   B.push_back(-1000000010);
  for(int i=0;i<N;i++){
    cin>>aaa;
    A.push_back(aaa);
    B.push_back(aaa);
  }
  A.push_back(2000000010);
  B.push_back(2000000010);
  
  ll ans[Q+1];
  
  for(int kurikaesi=1;kurikaesi<=Q;kurikaesi++){
    cin>>x;
    
    ans[kurikaesi] += A[A.size()-2]; A.erase(A.end()-1);
    
    int memo=0;
    
    for(int i=1;i<=A.size()-1;i++){
      if(A[i]>=x){
        if(A[i]-x==min(abs(A[i-1]-x),A[i]-x)) memo=i;
        break;
      }}
      A.erase(A.begin()+memo-1);
      int point = memo;
      
      
    if(A.size()==2) {
      
      A.clear();
      for(int in=0;in<=B.size()-1;in++){
        A.push_back(B[in]);}
        break;
      }
    }
      
      for(;;){
        ans[kurikaesi] +=A[A.size()-2]; A.erase(A.end()-1);
        
        
        if(A.size()==2) break;
        
        point = abs(A[point-1]-x)<abs(A[point]-x) ? point-1 : point ;
        A.erase(A.begin()+point-1);
        
        
        if(A.size()==2) break;
      }
    A.clear();
    for(int in=0;in<=B.size()-1;in++){
      A.push_back(B[in]);
    }
      
    }
  A.clear();
  for(int in=0;in<=B.size()-1;in++){
    A.push_back(B[in]);
    }
  
  
  for(int i=1;i<=Q;i++) cout<<ans[i]<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:13: error: 'kurikaesi' was not declared in this scope
   53 |         ans[kurikaesi] +=A[A.size()-2]; A.erase(A.end()-1);
      |             ^~~~~~~~~
a.cc:58:9: error: 'point' was not declared in this scope
   58 |         point = abs(A[point-1]-x)<abs(A[point]-x) ? point-1 : point ;
      |         ^~~~~
a.cc: At global scope:
a.cc:70:3: error: 'A' does not name a type
   70 |   A.clear();
      |   ^
a.cc:71:3: error: expected unqualified-id before 'for'
   71 |   for(int in=0;in<=B.size()-1;in++){
      |   ^~~
a.cc:71:16: error: 'in' does not name a type; did you mean 'int'?
   71 |   for(int in=0;in<=B.size()-1;in++){
      |                ^~
      |                int
a.cc:71:31: error: 'in' does not name a type; did you mean 'int'?
   71 |   for(int in=0;in<=B.size()-1;in++){
      |                               ^~
      |                               int
a.cc:76:3: error: expected unqualified-id before 'for'
   76 |   for(int i=1;i<=Q;i++) cout<<ans[i]<<endl;
      |   ^~~
a.cc:76:15: error: 'i' does not name a type
   76 |   for(int i=1;i<=Q;i++) cout<<ans[i]<<endl;
      |               ^
a.cc:76:20: error: 'i' does not name a type
   76 |   for(int i=1;i<=Q;i++) cout<<ans[i]<<endl;
      |                    ^
a.cc:78:3: error: expected unqualified-id before 'return'
   78 |   return 0;
      |   ^~~~~~
a.cc:79:1: error: expected declaration before '}' token
   79 | }
      | ^
Language: C++

//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900;

#define int ll

int ret[N][2] , A[N] , n , Ps[N];

bool Check(int x, int id, int f){
      int num1 = n - id + 1 - f;
      int num2 = f;
      int y = A[id + f - 1] - x;
      if(id + f - 1 > n)
            y = 0;
      int xx = lower_bound(A + 1 , A + n + 1 , x - y) - A;
      num2 += id - xx;
      //cout << id << " " << A[id] - y << " " << y << endl;
      if(num2 <= num1)
            return true;
      return false;
}
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int q; cin >> n >> q;
      for(int i = 1; i <= n; i++)
            cin >> A[i];
      sort(A + 1, A + n + 1);
      for(int i = 1 ; i <= n ; i++){
            Ps[i] = Ps[i - 1] + A[i];
            ret[i][0] = ret[i - 1][0];
            ret[i][1] = ret[i - 1][1];
            if(i % 2 == 0)
                  ret[i][0] += A[i];
            else
                  ret[i][1] += A[i];
      }
      for(int i = 1; i <= q; i++){
            int x; cin >> x;
            if(x >= A[n]){
                  cout << ret[n][n % 2] << "\n";
                  continue;
            }
            int id = lower_bound(A + 1, A + n + 1, x) - A;
            int l = 0, r = n - id + 2;
            while(r - l > 1){
                  int mid = (r + l) / 2;
                  if(Check(x, id, mid))
                        l = mid;
                  else
                        r = mid;
            }
            //cout << l << endl << endl;
            long long Ans = Ps[n] - Ps[id + l - 1];
            x = 2 * id - 2 + 2 * l - n;
            Ans += ret[x][x % 2];
            cout << Ans << '\n';
      }
      return 0;
}



Compiler output:
a.cc:13:13: error: 'll' does not name a type
   13 | #define int ll
      |             ^~
a.cc:15:1: note: in expansion of macro 'int'
   15 | int ret[N][2] , A[N] , n , Ps[N];
      | ^~~
a.cc:13:13: error: 'll' was not declared in this scope
   13 | #define int ll
      |             ^~
a.cc:17:12: note: in expansion of macro 'int'
   17 | bool Check(int x, int id, int f){
      |            ^~~
a.cc:13:13: error: 'll' was not declared in this scope
   13 | #define int ll
      |             ^~
a.cc:17:19: note: in expansion of macro 'int'
   17 | bool Check(int x, int id, int f){
      |                   ^~~
a.cc:13:13: error: 'll' was not declared in this scope
   13 | #define int ll
      |             ^~
a.cc:17:27: note: in expansion of macro 'int'
   17 | bool Check(int x, int id, int f){
      |                           ^~~
a.cc:17:32: error: expression list treated as compound expression in initializer [-fpermissive]
   17 | bool Check(int x, int id, int f){
      |                                ^
a.cc:13:13: error: 'll' does not name a type
   13 | #define int ll
      |             ^~
a.cc:30:1: note: in expansion of macro 'int'
   30 | int main(){
      | ^~~
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long n = sc.nextLong();
		long q = Long.parseLong(sc.next());
		List<Long> list = new ArrayList<>();

		for(long i=0;i<n;i++){
			list.add(Long.parseLong(sc.next()));
		}

		
		Map<Long, Long> resultMemo = new HashMap<>();

		for(long j=0; j<q;j++){
			long x = Long.parseLong(sc.next());
			long result = 0;

			long maxTry = n-n/2;
			long preDownBorder =0;
			for(long i=1;i<=maxTry;i++){
				long upBorder =preDownBorder-1;
				if(i==1){
					upBorder = list.get((int)(n-1));
				}

				long downBorder =0;
				if(n-n/2 ==i){
					downBorder =1;
				}else{
					long tmpSUm = list.get((int)(n-2*i-1)) + list.get((int)(n-i-1));
					if(tmpSUm%2==0){
						downBorder=tmpSUm/2+1;
					}else{
						downBorder=tmpSUm/2;
					}
				}
				preDownBorder = downBorder;
				//判定条件おわり

				if(downBorder <= x && x <= upBorder){
					result=calcResult(i,list,n);
				}else{
					continue;
				}
			}
			
			System.out.println(result);
			//xのループが終わり
		}


	}


	static long calcResult(long i,List<Long> list,long n) {
		long sum=0;
		
		for(long k=0;k<n;k++){
			sum += list.get(k);
			k++;
		}

		return sum;
		}
}

Compiler output:
Main.java:62: error: incompatible types: possible lossy conversion from long to int
			sum += list.get(k);
			                ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C

			c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];


Compiler output:
main.c:1:27: error: 'xy' undeclared here (not in a function)
    1 |                         c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];
      |                           ^~
main.c:1:30: error: 'i' undeclared here (not in a function)
    1 |                         c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];
      |                              ^
main.c:1:25: warning: data definition has no type or storage class
    1 |                         c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];
      |                         ^
main.c:1:25: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
main.c:1:38: error: 'acc' undeclared here (not in a function)
    1 |                         c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];
      |                                      ^~~
main.c:1:42: error: 'n' undeclared here (not in a function)
    1 |                         c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];
      |                                          ^
main.c:1:46: error: 'len' undeclared here (not in a function)
    1 |                         c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];
      |                                              ^~~
main.c:1:61: error: 'bcc' undeclared here (not in a function)
    1 |                         c[xy[i].b] = acc[n - len * 2 - 1] + bcc[n - len];
      |                                                             ^~~
Language: C++

#include"bits/stdc++.h"
using namespace std;
#define MOD 1000000007

long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}
long long int gcd(long long int a, long long int b) {
	if (a > b) {
		swap(a, b);
	}
	while (a) {
		swap(a, b);
		a %= b;
	}
	return b;
}
long long int lcm(long long int a, long long int b) {
	return a / gcd(a, b)*b;
}
int n;
vector<long long int> v;

long long int im[100002];
long long int im2[100002][2];

long long int su = 0;

bool ok(long long int til, long long int pos) {  //takahashi over or equal
	long long int lef = pos - til / 2LL;
	long long int rig = pos + til / 2LL;
	if (til & 1LL) {

	}
	else {
		if (lef < rig) {
			rig--;
		}
	}
	int f = lower_bound(v.begin(), v.end(), lef) - v.begin();
	int s = upper_bound(v.begin() + f, v.end(), rig) - v.begin();
	if (f == s)return true;
	int rng = s - f;
	int tak = v.size() - s;
	su = im[v.size() - 1];
	if (s)su -= im[s - 1];
	f--;
	if (tak == rng) {
		if (f >= 0) {
			su += im2[f][f % 2];
		}
	}
	else {
		if (f >= 1) {
			su += im2[f - 1][(f - 1) % 2];
		}
	}
	if (tak >= rng) {
		return true;
	}
	return false;
}

vector<long long int> pr;
int main() {
	print("hello!!!");
	int q;
	cin >> n >> q;
	assert(n <= 100000);
	assert(q <= 100000);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	im[0] = v[0];
	for (int i = 1; i < v.size(); i++) {
		im[i] = v[i];
		im[i] += im[i - 1];
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < 2; j++) {
			if (i)im2[i][j] += im2[i - 1][j];
			if (i % 2 == j) {
				im2[i][j] += v[i];
			}
		}
	}
	pr = v;
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	if (pr != v) {
		exit(1);
	}
	if (v[0] < 1) {
		exit(1);
	}
	if (v.back() > 1000000000) {
		exit(1);
	}
	while (q--) {
		int x;
		scanf("%d", &x);
		int mint = 0;
		int maxt = 1000000000;
		if (v.back() <= x) {
			printf("%lld\n", im2[v.size() - 1][(v.size() - 1) % 2]);
			continue;
		}
		while (mint + 1 < maxt) {
			int mid = (mint + maxt) >> 1;
			if (ok(mid, x)) {
				mint = mid;
			}
			else {
				maxt = mid;
			}
		}
		if (ok(maxt, x)) {
			mint = maxt;
		}
		else {
			maxt = mint;
		}
		ok(mint, x);
		printf("%lld\n", su);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:9: error: 'print' was not declared in this scope; did you mean 'rint'?
   80 |         print("hello!!!");
      |         ^~~~~
      |         rint
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;

int N, Q;
int A[100002];
ll sum[100002];
ll sumUpper[100002];
int X;

int getTakahashi() {
  int lo = 1, hi = N / 2 + (N % 2);

  while (lo < hi) {
    int med = (lo + hi) / 2;
    //cerr<<"lo,hi,med:"<<lo<<","<<hi<<","<<med<<endl;

    if (A[med] < X) {
      if (A[med - 1] > X && A[med - 1] - X >= X - A[med] && med <= 2) {
        lo = hi = med;
        break;
      } else {
        hi = med - 1;
        continue;
      }
    }
    
    if (A[med] < X) {
      hi = med - 1;
      continue;
    }

    int diff = A[med] - X;
    int target = X - diff;
    int idx = upper_bound(A, A + N, target, greater<int>()) - A;
    int aoki = idx - med + 1;
    //cerr<<"aoki:" << aoki<<endl;

    if (aoki > med) {
      lo = med + 1;
    } else if (aoki == med || aoki + 1 == med) {
      lo = hi = med;
      break;
    } else {
      hi = med - 1;
    }
  }

  return lo;
}

ll solve() {
  if (A[0] <= X) {
    return sum[0];
  } else {
    int takahashi = getTakahashi();
    //cerr<<"takahashi:" << takahashi << endl;
    ll res = sumUpper[takahashi - 1];
    res += sum[takahashi * 2];
    return res;
  }
}

int main() {
  while (cin >> N >> Q) {
    memset(A, 0, sizeof(A));
    memset(sum, 0, sizeof(sum));
    memset(sumUpper, 0, sizeof(sumUpper));
    
    for (int i = 0; i < N; i++) {
      cin >> A[i];
    }
    reverse(A, A + N);
    
    sum[N - 1] = A[N - 1];
    sum[N - 2] = A[N - 2];
    for (int i = N - 3; i >= 0; i--) {
      sum[i] = sum[i + 2] + A[i];
    }

    sumUpper[0] = A[0];
    for (int i = 1; i < N; i++) {
      sumUpper[i] = sumUpper[i - 1] + A[i];
    }
    
    for (int i = 0; i < Q; i++) {
      cin >> X;
      cout << solve() << endl;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:68:5: error: 'memset' was not declared in this scope
   68 |     memset(A, 0, sizeof(A));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include<cstdio>
#include<iostream>
#include<algorithm>
#define oo 19999999987654321LL
using namespace std;
long long a[111111],sum[111111],even[111111];
long long n,T,x;
long long dist(long long q)
{
	if(q<0) return oo;
	long long Q=x-a[q];
	return Q>0?Q:-Q;
}
int main()
{
	cin>>n>>T;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sum[0]=even[0]=a[0];
	for(int i=1;i<n;i++)
	{
		sum[i]=sum[i-1]+a[i];
		even[i]=even[i-1]+(i%2?0:a[i]);
	}
	while(T--)
	{
		cin>>x;
		long long l=1,r=(n+1)/2,ans,mod=0;
		long long int Ans=0;
		bool chk2=true;

		if(x<a[0])
        {
            cout<<(long long)(sum[n-1]-sum[(n-2)/2])<<'\n';
        }
        else if(n<=2)
        {
            cout<<(long long)a[n-1]<<'\n';
        }
        else if(x>=a[n-2])
        {
            cout<<(long long)n%2?even[n-1]:sum[n-1]-even[n-1])<<'\n';
        }
        else if(max(dist(n/2-1),dist(0))<dist(n/2)||dist(0)==dist(n/2))
        {
            cout<<(long long)(sum[n-1]-sum[(n-2)/2])<<'\n';
        }
        else{
		while(l<=r&&chk2)
		{
            //printf("%d %d\n",l,r);
			long long mid=(l+r)/2;
			long long k=mid;
			//printf("k: %d\n",k);
			if(n-2*k+1<0||(dist(n-2*k+1)>dist(n-mid))) r=mid-1;
			else if(k>0&&max(dist(n-2*k+1),dist(n-k-1))<min(dist(n-2*k),dist(n-k))) ans=l=r=k,chk2=false;
			else if(k>0&&max(dist(n-2*k+1),dist(n-k-1))==min(dist(n-2*k),dist(n-k))&&dist(n-2*k+1)==dist(n-k)) ans=l=r=k,chk2=false;
			else if(max(dist(n-2*k),dist(n-k-1))<min(dist(n-2*k-1),dist(n-k))) ans=l=r=k,chk2=false;
			else if(max(dist(n-2*k),dist(n-k-1))==min(dist(n-2*k-1),dist(n-k))&&dist(n-2*k)==dist(n-k)) ans=l=r=k,chk2=false;
			else l=mid+1;
		}
		//printf("ans: %d\n",ans);
			Ans=sum[n-1]-sum[n-ans-1];
			if((n-2*ans-1)%2==0) Ans+=even[(n-2*ans-1)];
			else Ans+=sum[(n-2*ans-1)];
			cout<<(long long)Ans<<'\n';
        }
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:62: error: expected ';' before ')' token
   44 |             cout<<(long long)n%2?even[n-1]:sum[n-1]-even[n-1])<<'\n';
      |                                                              ^
      |                                                              ;
Language: C++

#include <cstring>
#include <cstring>
#include <vector>
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <cstring>
#include <unordered_set>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, q;
	cin >> n >> q;
	unordered_set<int> Q;
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		Q.insert(p);
	}
	
	
	while (q--)
	{
		unordered_set<int>S = Q;
		int x;
		cin >> x;
		ll ans = 0;
		while (1)
		{
			if (S.empty())break;
			auto i = S.end();
			i--;
			ans += *i;
			S.erase(i);
			if (S.empty())break;
			auto it = S.lower_bound(x);
			if (it == S.end()) {
				it--;
				S.erase(it);
				continue;
			}
			else if (it == S.begin()) {
				S.erase(it);
				continue;
			}
			else
			{
				auto p1 = it;
				auto p2 = --it;
				if (abs(*p1 - x) < abs(*p2 - x)) {
					S.erase(p1);
					continue;
				}
				if (abs(*p1 - x) >= abs(*p2 - x)) {
					S.erase(p2);
					continue;
				}
			}

			
		}
		cout << ans << '\n';
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:26: error: no 'operator--(int)' declared for postfix '--' [-fpermissive]
   38 |                         i--;
      |                         ~^~
a.cc:42:37: error: 'class std::unordered_set<int>' has no member named 'lower_bound'
   42 |                         auto it = S.lower_bound(x);
      |                                     ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<stdint>
using namespace std; // 575

const int MAX = 100001;
int main() {
	int N, Q;
	static int A[MAX], X[MAX];
	cin >> N >> Q;
	for (int i = 0;i < N;++ i) cin >> A[i];
	for (int i = 0;i < Q;++ i) cin >> X[i];
	
	static int64_t sum = 0;
	static pair<int, int64_t> ans[MAX];
	for (int i = N / 2;i < N;++ i) sum += A[i];
	ans[0] = make_pair(0, sum);
	for (int i = 0, l = (N + 1) % 2, r = N / 2;i < N;++ i, l += 2, ++ r) { // 区間(l, r]ですね
		ans[i + 1] = make_pair(A[l] + (A[r] - A[l] + 1) / 2, sum -= A[r] - A[l]);
	}
	
	for (int i = 0, min, mid, max, halfDiff;i < Q;++ i) {
		min = 0;
		max = N;
		while(halfDiff = max - min >> 1) (ans[mid = min + halfDiff].first < X[i] ? min : max) = mid;
		cout << ans[min].second << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、まともにシミュレートするとO(NQ)で話にならない
当然だけどこれは下準備を行うことでクエリ高速化を行う問題だね
さて、まずどこで高橋くんと青木くんの取る候補が被るかは求められるか？
あるカードを考えたとき、そのカードを高橋くんが何手目で取るかはO(1)、青木くんが何手目でとるかはO(N)だがしゃくとりでO(1)に持ち込める
……尺取り法が有効っぽいね？
左から順に考えていこう
まず、A_1≧xなら簡単だ、答えは後半半分になる
そこから順にxを増やして、答えの変化を見ていこう(単調減少になるはずだよ！)
サンプル1の 3 5 7 11 13 で考えると、
x≦5 ... 31 (青木くんは5, 3の2枚)
5<x≦9 ... 27(青木くんは7, 5の2枚)
9<x ... 23(青木くんは11, 5の2枚)
みたいな変化を行うわけだね
さて、これをどのように求めるか考えていこう(O(A)も遅いからね！)
まず、この変化が発生する候補ではxの優先順位が変わったとき、すなわちxの範囲に入ってる値が切り替わるとき(O(N)だね)
次に、この時に結果はどのように変わるか？
ある地点で高橋くんと青木くんの結果がぶつかるね
で、そこからどうとるかを考えてみると、必ず大きいほうから互いに交互に取ることがわかるので、累積和作っておけばO(1)
ぶつかる地点は……長くなるので解説ブログに任せます
*/

Compiler output:
a.cc:2:9: fatal error: stdint: No such file or directory
    2 | #include<stdint>
      |         ^~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include <cstdlib>
using namespace std;
int main(void){
	ios::sync_with_stdio(false);
	int n,q,j,i;
	cin>>n>>q;
	int a[n],x[q],b[n];
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<q;i++)cin>>x[i];
	memcpy(b, a, n*4);
	short int turn;
	int player,sum,min,dig;
	for(j=0;j<q;j++){
		player=1;
		turn=0;
		sum=0;
		while(turn!=n){
			player=1-player;
			if(player==0){
				for(i=n-1-turn/2;i>=0;i--){
					if(a[i]!=0)break;
				}
				sum+=a[i];
				a[i]=0;
			}
			min=1000000001;
			if(player==1){
				for(i=0;i<n;i++){
					if(a[i]!=0&&abs(a[i]-x[j])<min){
						min=abs(a[i]-x[j]);
						dig=i;
					}
				}
				a[dig]=0;
			}
			turn++;
		}
		cout<<sum<<"\n";
		memcpy(a, b, n*4);
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'memcpy' was not declared in this scope
   11 |         memcpy(b, a, n*4);
      |         ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdlib>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=1e5+5;
int n,m;
ll a[maxn],ans=0,p[maxn],ss=0;
ll get[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	n=rd(); m=rd();
	go(i,n+1,1) a[i]=rd(),ss+=a[i];
	sort(a+1,a+n+1);	
	go(i,n+1,1){
		p[i]=p[i-1]+a[i];
		get[i]= i>=2?get[i-2]+a[i]:a[i];
	}
	go(i,m+1,1){
		ans=0;
		ll x=rd(); int pos=lower_bound(a+1,a+n+1,x)-a,p1,p2;
		if(x >= a[n]){
			printf("%lld\n",get[n]); continue;
		}
		ll l,r,ql=0,qr=inf,mid=(ql+qr)/2;
		while(1){
			mid=(ql+qr)/2;
			l=x-mid; r=x+mid-1;
			if(mid == 0){
				p1=p2=a[pos]==x?pos:pos-1; break;
			}
			p1=lower_bound(a+1,a+n+1,l)-a,p2=lower_bound(a+1,a+n+1,r+1)-a-1;
			if(p2-p1+1 == n-p2 || p2-p1+2 == n-p2 || ql > qr) break;
			if(p2-p1+1 < n-p2) ql=mid+1;
			else qr=mid-1;
		}
		if(p2 < p1) p2=p1;
		ans=p[n]-p[p2];
		if(p2-p1+1 == n-p2) ans+=get[p1-1];
		else ans+=get[p1-2];
		printf("%lld\n",ans);
	}
	return 0;
}//Faze


Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
# define ll long long int
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
	ll n,q,i,s,h;
	cin>>n>>q;
	vector<ll>v(n);
	for(i=0;i<n;i++){
		cin>>v[i];
	}sort(v.begin(),v.end());
	while(q--){
		s=0;
		cin>>h;
		while(1){
			if(v.size()==0){
				break;
			}
			s+=v[v,size()-1];
			auto p=upper_bound(v.begin(),v.end(),h);
			auto it=p;
			p--;
			if(*it-h>=h-*p){
				v.erase(p);
			}else{
				v.erase(it);
			}
		}cout<<s;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:36: error: no matching function for call to 'size()'
   20 |                         s+=v[v,size()-1];
      |                                ~~~~^~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   candidate expects 1 argument, 0 provided
Language: C++

「逆にケーブルを出来るだけ繋ぐ」と考えると、負集合は明らかに固めれば良くて、木なので正集合も出来るだけ固めて良いことが分かる。後はこれらをいい感じに繋いでいきたいんですけど...
  木じゃなくて一次元だったらDP出来るけど、木DPに落とせなくて悲しい

Compiler output:
a.cc:1:1: error: extended character 「 is not valid in an identifier
    1 | 「逆にケーブルを出来るだけ繋ぐ」と考えると、負集合は明らかに固めれば良くて、木なので正集合も出来るだけ固めて良いことが分かる。後はこれらをいい感じに繋いでいきたいんですけど...
      | ^
a.cc:1:1: error: extended character 」 is not valid in an identifier
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:1: error: extended character 。 is not valid in an identifier
a.cc:2:3: error: extended character 、 is not valid in an identifier
    2 |   木じゃなくて一次元だったらDP出来るけど、木DPに落とせなくて悲しい
      |   ^
a.cc:1:1: error: '\U0000300c\U00009006\U0000306b\U000030b1\U000030fc\U000030d6\U000030eb\U00003092\U000051fa\U00006765\U0000308b\U00003060\U00003051\U00007e4b\U00003050\U0000300d\U00003068\U00008003\U00003048\U0000308b\U00003068\U00003001\U00008ca0\U000096c6\U00005408\U0000306f\U0000660e\U00003089\U0000304b\U0000306b\U000056fa\U00003081\U0000308c\U00003070\U0000826f\U0000304f\U00003066\U00003001\U00006728\U0000306a\U0000306e\U00003067\U00006b63\U000096c6\U00005408\U00003082\U000051fa\U00006765\U0000308b\U00003060\U00003051\U000056fa\U00003081\U00003066\U0000826f\U00003044\U00003053\U00003068\U0000304c\U00005206\U0000304b\U0000308b\U00003002\U00005f8c\U0000306f\U00003053\U0000308c\U00003089\U00003092\U00003044\U00003044\U0000611f\U00003058\U0000306b\U00007e4b\U00003044\U00003067\U00003044\U0000304d\U0000305f\U00003044\U00003093\U00003067\U00003059\U00003051\U00003069' does not name a type
    1 | 「逆にケーブルを出来るだけ繋ぐ」と考えると、負集合は明らかに固めれば良くて、木なので正集合も出来るだけ固めて良いことが分かる。後はこれらをいい感じに繋いでいきたいんですけど...
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

using namespace std;
int main() {
	int s;
  cin >> s;
  int arr[s];
  int cost[s];
  for (int i = 0; i < s; i++) {
    cin >> arr[i];
  }
  cost[0] = 0;
  cost[1] = abs(arr[1] - arr[0]);
  for (int i = 2; i < s; i++) {
	    cost[i] = min(cost[i-1] + abs(arr[i-1] - arr[i]), cost[i-2] + abs(arr[i-2] - arr[i]));
    
    
  }
  
  
  
  return cost[s-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin >> s;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:11:13: error: 'abs' was not declared in this scope
   11 |   cost[1] = abs(arr[1] - arr[0]);
      |             ^~~
a.cc:13:23: error: 'min' was not declared in this scope; did you mean 'main'?
   13 |             cost[i] = min(cost[i-1] + abs(arr[i-1] - arr[i]), cost[i-2] + abs(arr[i-2] - arr[i]));
      |                       ^~~
      |                       main
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	int s;
  cin >> s;
  int arr[s];
  int cost[s];
  for (int i = 0; i < s; i++) {
    cin >> arr[i];
  }
  cost[0] = 0;
  cost[1] = abs(arr[1] - arr[0]);
  for (int i = 2; i < s; i++) {
	    cost[i] = min(cost[i-1] + abs(arr[i-1] - arr[i]), cost[i-2] + abs(arr[i-2] - arr[i]);
    
    
  }
  
  
  
  return cost[s-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:97: error: expected ')' before ';' token
   14 |             cost[i] = min(cost[i-1] + abs(arr[i-1] - arr[i]), cost[i-2] + abs(arr[i-2] - arr[i]);
      |                          ~                                                                      ^
      |                                                                                                 )
Language: C++

#include <bits/stdc++.h>

int main() {
	int s;
  cin >> s;
  int arr[s];
  int cost[s];
  for (int i = 0; i < s; i++) {
    cin >> arr[i];
  }
  cost[0] = 0;
  cost[1] = abs(arr[1] - arr[0]);
  for (int i = 2; i < s; i++) {
	    cost[i] = min(cost[i-1] + abs(arr[i-1] - arr[i]), cost[i-2] + abs(arr[i-2] - arr[i]);
    
    
  }
  
  
  
  return cost[s-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   cin >> s;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:14:97: error: expected ')' before ';' token
   14 |             cost[i] = min(cost[i-1] + abs(arr[i-1] - arr[i]), cost[i-2] + abs(arr[i-2] - arr[i]);
      |                          ~                                                                      ^
      |                                                                                                 )
Language: C

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define fast ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define umll unordered_map<ll,ll>
#define mll map<ll,ll>
#define forr(i,p,n) for(ll i=p;i<(ll)n;i++)
#define fore(i,n,k) for(ll i=n-1;i>=k;i--)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a, ll b, ll p = MOD) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = MOD) {return (a % p + b % p) % p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD) {ll m0 = m; ll y = 0, x = 1; if (m == 1)return 0; while (a > 1) {ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t;} if (x < 0)x += m0; return x;}
using namespace __gnu_pbds;
typedef tree<ll, null_type, less< ll>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
void functiontosolve()
{
    ll n;
    cin >> n;
    ll a[n];
    forr(i, 0, n) cin >> a[i];
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    forr(i, 2, n) {
        dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
    }
    cout << dp[n - 1] << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int test;
    test  = 1;
    forr(i, 1, test + 1) {
        functiontosolve();
    }
    return 0;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int solve(vector<int>&v,int n,int start)
{
if(start==n)
return 0;
if(start==n-1)
return abs(v[start-1]-v[n-1]];
return min(abs(v[start-1]-v[start+1])+solve(v,n,start+2) ,abs(v[start-1]-v[start])+solve(v,n,start+1));
}
int main(){
   int n;
   cin>>n;
   vector<int>v(n);
   for (int i = 0; i < n; i++) {
      cin>>v[i];
   }
   int r=solve(v,n,1);
   cout<<r<<endl;
   return 0;
}

Compiler output:
a.cc: In function 'int solve(std::vector<int>&, int, int)':
a.cc:8:29: error: expected ')' before ']' token
    8 | return abs(v[start-1]-v[n-1]];
      |           ~                 ^
      |                             )
a.cc:8:29: error: expected ';' before ']' token
    8 | return abs(v[start-1]-v[n-1]];
      |                             ^
      |                             ;
a.cc:8:29: error: expected primary-expression before ']' token
Language: C++

#include <bits/stdc++.h>
using namespace std;

int compute(int arr[], int n, int i){
  if(i == n-1){
  	return 0;
  }
  
  int c1 = abs(arr[i] - arr[i+1]) + compute(arr, i+1);
  int c2 = INT_MAX;
  if(i+2 <=n-1){
    c2 = abs (arr[i]-arr[i+2]) + compute(arr, i+2);
  }
   

  return min(c1, c2);
}


int main() {
 	
  int n;
  cin >> n;
  int arr[n];
  
  for(int i = 0; i < n; i++){
  	cin >> arr[i];
  }
  
  cout<< compute(arr, n, 0);
  
  return 0;
}

Compiler output:
a.cc: In function 'int compute(int*, int, int)':
a.cc:9:44: error: too few arguments to function 'int compute(int*, int, int)'
    9 |   int c1 = abs(arr[i] - arr[i+1]) + compute(arr, i+1);
      |                                     ~~~~~~~^~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int compute(int arr[], int n, int i){
      |     ^~~~~~~
a.cc:12:41: error: too few arguments to function 'int compute(int*, int, int)'
   12 |     c2 = abs (arr[i]-arr[i+2]) + compute(arr, i+2);
      |                                  ~~~~~~~^~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int compute(int arr[], int n, int i){
      |     ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int compute(int arr[], int i){
  if(i == n-1){
  	return 0;
  }
  
  int c1 = abs(arr[i] - arr[i+1]) + compute(arr, i+1);
  int c2 = INT_MAX;
  if(i+2 <=n-1){
    c2 = abs (arr[i]-arr[i+2]) + compute(arr, i+2);
  }
   

  return min(c1, c2);
}


int main() {
 	
  int n;
  cin >> n;
  int arr[n];
  
  for(int i = 0; i < n; i++){
  	cin >> arr[i];
  }
  
  cout<< compute(arr, 0);
  
  return 0;
}

Compiler output:
a.cc: In function 'int compute(int*, int)':
a.cc:5:11: error: 'n' was not declared in this scope
    5 |   if(i == n-1){
      |           ^
a.cc:11:12: error: 'n' was not declared in this scope
   11 |   if(i+2 <=n-1){
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vec;


int main(){
    ll N; cin >> N;
    vec h(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    vec dp(N,1e+15);    
    dp[0] = 0;

    for (ll i = 0; i < N; i++)
    {
        if( i+1 < N )
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]);        
        if( i+2 < N )
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]);
    }
    cout << dp[N-1] << endl;
    


}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:58: error: expected ')' before ';' token
   22 |         dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]);
      |                      ~                                   ^
      |                                                          )
a.cc:24:58: error: expected ')' before ';' token
   24 |         dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]);
      |                      ~                                   ^
      |                                                          )
Language: C

#include <stdio.h>
#int <math.h>
int H[10010];
int N;
int min(int a,int b){
  if(a>b){
    return b;
  }
  else{
    return a;
  }
}
int solve(int curr,int next){
  int cost = 0;
  curr--;
  next--;
  if(next==N){
    return 10000000000;
  }
  else{
    if(solve(curr,curr+1)<=solve(curr,curr+2)){
      cost = abs(H[curr] - H[curr+1]);
      }
      else{
        cost = abs(H[curr] - H[curr+2]);
      }
  }
  return cost;
}
    
  
int main(void){
  
  scanf("%d" , &N);
  int i = 0;
  for(i=0;i<N;i++){
    scanf("%d", &H[i]);
  }
  solve(1);
  
  
  return 0;
}
  
  

Compiler output:
main.c:2:2: error: invalid preprocessing directive #int
    2 | #int <math.h>
      |  ^~~
main.c: In function 'solve':
main.c:18:12: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   18 |     return 10000000000;
      |            ^~~~~~~~~~~
main.c:22:14: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   22 |       cost = abs(H[curr] - H[curr+1]);
      |              ^~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | #int <math.h>
main.c: In function 'main':
main.c:39:3: error: too few arguments to function 'solve'
   39 |   solve(1);
      |   ^~~~~
main.c:13:5: note: declared here
   13 | int solve(int curr,int next){
      |     ^~~~~
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * @author radhakm
 * https://atcoder.jp/contests/dp/tasks/dp_a
 */
public class FrogJumping {
    static int[] h;
    static int n;
    static Integer[] dp;
    public static void main(String[] args) {
        InputReader reader = new InputReader(System.in);
        n = reader.nextInt();
        h = new int[n];
        dp = new Integer[n];
        for(int i=0;i<n;i++){
            h[i] = reader.nextInt();
        }
        System.out.println(frogJump(0));
    }

    static int frogJump(int idx){
        if(idx == n-1){
            return 0;
        }
        if(dp[idx]!=null){
            return dp[idx];
        }

        int minCost = Math.abs(h[idx] - h[idx+1]) + frogJump(idx+1);
        if(idx+2<n) {
            int cost = Math.abs(h[idx] - h[idx+2]) + frogJump(idx+2);
            minCost = Math.min(minCost,cost);
        }
        dp[idx] = minCost;
        return minCost;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Compiler output:
Main.java:11: error: class FrogJumping is public, should be declared in a file named FrogJumping.java
public class FrogJumping {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
}

public class FrogJumping {
    static int[] h;
    static int n;
    static Integer[] dp;
    public static void main(String[] args) {
        InputReader reader = new InputReader(System.in);
        n = reader.nextInt();
        h = new int[n];
        dp = new Integer[n];
        for(int i=0;i<n;i++){
            h[i] = reader.nextInt();
        }
        System.out.println(frogJump(0));
    }

    static int frogJump(int idx){
        if(idx == n-1){
            return 0;
        }
        if(dp[idx]!=null){
            return dp[idx];
        }

        int minCost = Math.abs(h[idx] - h[idx+1]) + frogJump(idx+1);
        if(idx+2<n) {
            int cost = Math.abs(h[idx] - h[idx+2]) + frogJump(idx+2);
            minCost = Math.min(minCost,cost);
        }
        dp[idx] = minCost;
        return minCost;
    }
}



Compiler output:
Main.java:32: error: class FrogJumping is public, should be declared in a file named FrogJumping.java
public class FrogJumping {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class FrogJumping {
    static int[] h;
    static int n;
    static Integer[] dp;
    public static void main(String[] args) {
        InputReader reader = new InputReader(System.in);
        n = reader.nextInt();
        h = new int[n];
        dp = new Integer[n];
        for(int i=0;i<n;i++){
            h[i] = reader.nextInt();
        }
        System.out.println(frogJump(0));
    }

    static int frogJump(int idx){
        if(idx == n-1){
            return 0;
        }
        if(dp[idx]!=null){
            return dp[idx];
        }

        int minCost = Math.abs(h[idx] - h[idx+1]) + frogJump(idx+1);
        if(idx+2<n) {
            int cost = Math.abs(h[idx] - h[idx+2]) + frogJump(idx+2);
            minCost = Math.min(minCost,cost);
        }
        dp[idx] = minCost;
        return minCost;
    }
}


public class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
}

Compiler output:
Main.java:8: error: class FrogJumping is public, should be declared in a file named FrogJumping.java
public class FrogJumping {
       ^
Main.java:42: error: class InputReader is public, should be declared in a file named InputReader.java
public class InputReader {
       ^
2 errors