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

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

int T,card[10];
string str;

bool check1(int a,int b,int c){
    if(a == b && b == c) return true;
    return false;
}

bool check2(int a,int b,int c){
    if(a+2 == b+1 && b+1 == c) return true;
    return false;
}

bool check3(int a,int b,int c){
    return check1(a,b,c) || check2(a,b,c);
}

bool check4(int card[10]){
    return check3(card[0],card[1],card[2])&&check3(card[3],card[4],card[5])
           &&check3(card[6],card[7],card[8]);
}

int judge(){
    sort(card,card+9);
    do{
        if(check4(card)) return 1;
        
    }while(next_permutation(card,card+9));
    return 0;
}

int main(){
    cin >> T;
    while(T--){
        for(int i = 0 ; i < 9 ; i++){
            cin >> card[i];
        }
        for(int i = 0 ; i < 9 ; i++){
            cin >> str;
            if(str == "G") card[i] += 10;
            else if(str == "B") card[i] += 20;
        }
        cout << judge() << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int judge()':
a.cc:28:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   28 |     sort(card,card+9);
      |     ^~~~
      |     short
a.cc:32:12: error: 'next_permutation' was not declared in this scope
   32 |     }while(next_permutation(card,card+9));
      |            ^~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
int T, card[16];
bool is_same_number(int a, int b, int c){
	return a == b && b == c;
}
bool is_sequence(int a, int b, int c){
	return a+2 == b+1 && b+1 == c;
}
bool is_good_set(int a, int b, int c){
	return is_same_number(a, b, c) || is_sequence(a, b, c);
}
bool is_all_good_set(){
	return is_good_set(card[0], card[1], card[2]) && 
		is_good_set(card[3], card[4], card[5]) &&
		is_good_set(card[6], card[7], card[8]);
}
int win(){
	sort(card, card+9);
	do{
		if(is_all_good_set()) return 1;
	}while(next_permutation(card, card+9));
	return 0;
}
int main(){
	cin >> T;
	for(int t=0; t<T; ++t){
		for(int i=0; i<9; ++i){
			cin >> card[i];
		}
		string color;
		for(int i=0; i<9; ++i){
			cin >> color;
			if(color =="G") card[i]+=10;
			else if(color == "B") card[i]+=20;
		}
		cout << win() <<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int win()':
a.cc:20:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |         sort(card, card+9);
      |         ^~~~
      |         short
a.cc:23:16: error: 'next_permutation' was not declared in this scope
   23 |         }while(next_permutation(card, card+9));
      |                ^~~~~~~~~~~~~~~~
Language: C++


import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	
	int[] c, n;
	boolean[] used;
	void run() {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for (;t>0;t--) {
			c = new int[9]; n = new int[9];
			for (int i=0;i<9;i++) n[i] = sc.nextInt();
			for (int i=0;i<9;i++) {
				char color = sc.next().charAt(0);
				c[i] = color == 'R' ? 0 : ( color == 'G' ? 1 : 2);
			}
			ok = new int[1<<9]; fill(ok, -1);
			System.out.println(solve(0));
		}
	}
	
	int[] ok;
	int solve(int S) {
		if (S == (1<<9)-1) return 1;
		if (ok[S] >= 0) return ok[S];
		
		int ret = 0;
		for (int i=0;i<9;i++) if (((S>>i)&1) == 0)
		for (int j=i+1;j<9;j++) if (((S>>j)&1) == 0) 
		for (int k=j+1;k<9;k++) if (((S>>k)&1) == 0)
			if (is_set(i, j, k)) {
				ret |= solve(S | (1<<i) | (1<<j) | (1<<k));
				if (ret == 1) return ok[S] = ret;
			}
		
		return ok[S] = ret;
	}
	
	boolean is_set(int i, int j, int k) {
		if (c[i] != c[j] || c[j] != c[k]) return false;
		if (n[i] == n[j] && n[j] == n[k]) return true;
		int[] a = {n[i], n[j], n[k]}; sort(a);
		return a[0] + 1 == a[1] && a[1] +1 == a[2];
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import static java.util.Arrays.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import static java.util.Collections.*;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import static java.lang.Math.*;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: expected unqualified-id before 'public'
    8 | public class Main {
      | ^~~~~~
Language: Java

package BattleTown;

public class BattleTown {
	
	public static void main(String args[]){
		
	}

}

class tank {

	// 戦車の位置
	private String[][] position = null;
	// 戦車の向き
	private String situation = null;

	// セッター
	public void setPosition(String[][] p) {
		position = p;
	}

	public void setSituation(String s) {
		situation = s;
	}

	// ゲッター
	public String[][] getPosition() {
		return position;
	}

	public String getSituation() {
		return situation;
	}

	// 上向きに移動
	public void up() {
		position = position;
	}

}

class map {

	// 現在のマップ
	String[][] map = null;

	// マップを作る
	public void createMap(int height_i, int width_i, String m) {
		map[height_i][width_i] = m;
	}

	// 砲弾によるマップ変更 現在位置 向き
	public void shuttGun(String[][] p,String s){
		//左向き
		if(s.equals("<")){
			//
			for(int i =0; i < p[0].length;i++){
				if(map[p.][p.-1].equals("*") || map[p.][p.-1].equals("#")){
					break;
				}
			}
		}
		//右向き
		if(s.equals(">")){
			
		}
		//上向き
		if(s.equals("^")){
			
		}
		//下向き
		if(s.equals("v")){
			
		}
		
	}

	// 戦車の移動によるマップ変更 現在位置 向き
	public void move_tank(String[][] p, String s) {
		
	}

	// セッター
	public void setMap(int height, int width) {
		map = new String[height][width];
	}

	// ゲッター
	public String[][] getMap() {
		return map;
	}

}

Compiler output:
Main.java:59: error: <identifier> expected
				if(map[p.][p.-1].equals("*") || map[p.][p.-1].equals("#")){
				         ^
Main.java:59: error: <identifier> expected
				if(map[p.][p.-1].equals("*") || map[p.][p.-1].equals("#")){
				             ^
Main.java:59: error: <identifier> expected
				if(map[p.][p.-1].equals("*") || map[p.][p.-1].equals("#")){
				                                      ^
Main.java:59: error: <identifier> expected
				if(map[p.][p.-1].equals("*") || map[p.][p.-1].equals("#")){
				                                          ^
4 errors
Language: C

#include <cstdio>
#include <iostream>
#include <utility>
#include <string>
#define rep(i,n) for(int i=0; i<(n); i++)
#define dm(x) cerr << #x << " = " << x << endl;
using namespace std;

char map[20][21];
int H,W,N;

struct po{
  int x;
  int y;
  po operator+(po &p){
    po t={x+p.x, y+p.y};
    return t;
  }
  char &l(){return map[x][y];}
  bool v(){return 0<=x && x<H && 0<=y && y<W;}
  void d(){dm(x);dm(y);}
};

po mp(int x,int y){
  po t={x, y};
  return t;
}

int main()
{
  int T;
  scanf("%d", &T);
  rep(datasetindex, T){
    po p={0,0},d={0,0};
    char c[101];
    scanf("%d %d", &H, &W);
    rep(i,H) scanf("%s", map[i]);
    scanf("%d", &N);
    scanf("%s", c);
    dm(H);dm(W);
    rep(j,W) rep(i,H){
      switch(map[i][j]){
      case '^':p=mp(i,j);d=mp(-1,0);break;
      case '>':p=mp(i,j);d=mp(0,1);break;
      case 'v':p=mp(i,j);d=mp(1,0);break;
      case '<':p=mp(i,j);d=mp(0,-1);break;
      }
    }
    rep(i,H) printf("%d : %s\n", i, map[i]);
    p.d();d.d();
    rep(i,N){
      dm(c[i]);
      switch(c[i]){
      case 'S':{
        po s=p;
        do{s=s+d;}while(s.v() && s.l()!='*' && s.l()!='#');
        if(s.v() && s.l()=='*')
          s.l()='.';
        break;
      }
      case 'U':
        p.l()='.';
        d=mp(-1,0);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='^';
        break;
      case 'R':
        p.l()='.';
        d=mp(0,1);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='>';
        break;
      case 'D':
        p.l()='.';
        d=mp(1,0);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='v';
        break;
      case 'L':
        p.l()='.';
        d=mp(0,-1);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='<';
        break;
      }
      rep(i,H) printf("%d : %s\n", i, map[i]);
    }
  }
}
  

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

#include<stdio.h>
#include<string.h>

int main(void){
  int i,n,j,k,h,w,N,a=0,b=0; 
  char map[22][22],mapf[20][20],command[105];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    
    //初期化
    for(j=0;j<22;j++){
      for(k=0;k<22;k++){
	map[j][k]='#';
      }
    }
    scanf("%d %d",&h,&w);

   //初期化
    for(j=0;j<20;j++){
      for(k=0;k<20;k++){
	mapf[j][k]='#';
      }
    }


    for(j=0;j<h;j++){
	scanf("%s%*c",mapf[j]);
    }

    for(j=0;j<h;j++){
      for(k=0;k<w;k++){
	map[j+1][k+1]=mapf[j][k];
      }
    }
    //map 完成 以下命令

    scanf("%d",&N);
    scanf("%s",command);
    /*for(j=0;j<N;j++){
      printf("%c",command[j]);
    }
    printf("\n");*/

    //以下処理

    //現在地把握
    for(j=0;j<22;j++){
      for(k=0;k<22;k++){
	if((map[j][k]=='^') || (map[j][k]=='v') ||( map[j][k]=='>') || (map[j][k]=='<')){
	  a=j;
	  b=k;
	  break;
	}
      }
     if(a!=0) break;
    }
   

    for(j=0;j<N;j++){
	//上に移動
      if(command[j]=='U'){
	if(map[a-1][b]=='.'){
	  map[a-1][b]='^';
	  map[a][b]='.';
	  a--;
	}else{
	  map[a][b]='^';
	}
      }
      //下に移動
      if(command[j]=='D'){
	if(map[a+1][b]=='.'){
	  map[a+1][b]='v';
	  map[a][b]='.';
	  a++;
	}else{
	  map[a][b]='v';
	}
      }
      //左に移動
      if(command[j]=='L'){
	if(map[a][b-1]=='.'){
	  map[a][b-1]='<';
	  map[a][b]='.';
	  b--;
	}else{
	  map[a][b]='<';
	}
      }
      //右に移動
      if(command[j]=='R'){
	if(map[a][b+1]=='.'){
	  map[a][b+1]='>';
	  map[a][b]='.';
	  b++;
	}else{
	  map[a][b]='>';
	}

      }

      //ショットの処理
      if(command[j]=='S'){

	if(map[a][b]=='^'){
	  for(k=a;;k--){
	    if(map[k][b]=='*'){
	      map[k][b]='.';
	      break;
	    }else if(map[k][b]=='#'){
	      break;
	    }
	    
	  }
	}


	if(map[a][b]=='v'){
	  for(k=a;;k++){
	    if(map[k][b]=='*'){
	      map[k][b]='.';
	      break;
	    }else if(map[k][b]=='#'){
	      break;
	    }
	    
	  }
	}


	if(map[a][b]=='>'){
	  for(k=b;;k++){
	    if(map[a][k]=='*'){
	      map[a][k]='.';
	      break;
	    }else if(map[a][k]=='#'){
	      break;
	    }
	    
	  }
	}


	if(map[a][b]=='<'){
	  for(k=b;;k--){
	    if(map[a][k]=='*'){
	      map[a][k]='.';
	      break;
	    }else if(map[a][k]=='#'){
	      break;
	    }
	    
	  }
	}
      }
    }

    //以下出力    
    for(j=0;j<h;j++){
      for(k=0;k<w;k++){
	printf("%c",map[j+1][k+1]);
      }
      printf("\n");
    }
    if(j!=N-1)　printf("\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:166:15: error: stray '\343' in program
  166 |     if(j!=N-1)<U+3000>printf("\n");
      |               ^~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
string mp[20],str;
int dir[256],h,w,m;
char ch[4]={'^','>','v','<'};
int dx[]={0,1,0,-1},dy[]={-1,0,1,0};

int get_d(char a){
  if(a=='U') return 0;
  if(a=='R') return 1;
  if(a=='D') return 2;
  if(a=='L') return 3;
  return -1;
}

void shoot(int x,int y,int d){
  while(1){
    x+=dx[d],y+=dy[d];
    if(x<0||y<0||x>=w||y>=h||mp[y][x]=='#')return;
    if(mp[y][x]=='*'){
      mp[y][x]='.';
      return;
    }
  }

}

void update(int x,int y,int d){
  mp[y][x]='.';
  for(int i=0;i<m;i++){
    cout <<i<<endl;
    int pd=d,nx,ny;
    d=get_d(str[i]);
    if(d==-1){d=pd,shoot(x,y,d);continue;}

    nx=x+dx[d],ny=y+dy[d];
    if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]!='.')nx=x,ny=y;
    y=ny,x=nx;
  }
  mp[y][x]=ch[d];
}

int main(){
  memset(dir,-1,sizeof(dir));
  dir['^']=0,dir['>']=1,dir['v']=2,dir['<']=3;

  int q;
  cin>>q;
  while(q--){
    cin>>h>>w;
    for(int i=0;i<h;i++) cin>>mp[i];
    cin>>m>> str;

    for(int i=0;i<h;i++){
      int f=0;
      for(int j=0;j<w;j++) 
	if(dir[mp[i][j]]!=-1) {
	  update(j,i,dir[mp[i][j]]);
	  f=1;
	  break;
	}
      if(f)break
    }

    for(int i=0;i<h;i++)cout <<mp[i]<<endl;
    if(q) cout<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:17: error: expected ';' before '}' token
   62 |       if(f)break
      |                 ^
      |                 ;
   63 |     }
      |     ~
Language: C++

#include<iostream>
#include<string>

#define N 32
#define PLANE '.'
#define BLOCK '*'
#define STEEL '#'
#define WATER '-'
const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};
const char *tank_dir = "^>v<";
int conv[256]={0,};

using namespace std;

bool isinside(int i, int j, int h, int w){
  return 0<=i&&i<h&&0<=j&&j<w;
}

void simulate(char M[][N], int h, int w, const string &v)
{
  int ti;
  int tj;
  int dir;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      for(int k = 0; k < 4; ++k){
	if( tank_dir[k] == M[i][j] ){
	  ti = i;
	  tj = j;
	  dir = k;
	  M[i][j]=PLANE;
	}
      }
    }
  }
  conv['U']=0;
  conv['R']=1;
  conv['D']=2;
  conv['L']=3;

  for(int s=0;s<v.length();++s){
    switch(v[s]){
    case 'U':case'D':case 'L':case 'R':
      int ni = ti+di[conv[v[s]]];
      int nj = tj+dj[conv[v[s]]];
      dir = conv[v[s]];
      if( isinside(ni,nj,h,w) ){
	if( M[ni][nj] == PLANE ){
	  ti = ni;
	  tj = nj;
	}
      }
      break;
    case 'S':
      {
	int ai=ti,aj=tj;
	while(true){
	  ai += di[dir];
	  aj += dj[dir];
	  
	  if( isinside(ai,aj,h,w) ){
	    if( M[ai][aj] == PLANE || M[ai][aj] == WATER ) continue;
	    else break;
	  }else break;
	  
	}
	if( M[ai][aj] == BLOCK ){
	  M[ai][aj] = PLANE;
	}
      }
      break;
    }
  }
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if( i == ti && j == tj ){
	putchar(tank_dir[ dir ]);
      }else{
	putchar(M[i][j]);
      }
    }
    putchar('\n');
  }
  return ;
}

int main()
{
  int T;
  cin >> T;
  for(int tc=1;tc<=T;++tc){
    int h,w;
    char M[N][N];
    string cmd;
    cin >> h >> w;
    if( tc > 1 )putchar('\n');
    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
	cin >> M[i][j];
      }
    }
    int vlen;
    cin >> vlen;
    cin >> cmd;
    
    simulate( M, h, w, cmd );
  }
  return 0;
}

Compiler output:
a.cc: In function 'void simulate(char (*)[32], int, int, const std::string&)':
a.cc:55:10: error: jump to case label
   55 |     case 'S':
      |          ^~~
a.cc:46:11: note:   crosses initialization of 'int nj'
   46 |       int nj = tj+dj[conv[v[s]]];
      |           ^~
a.cc:45:11: note:   crosses initialization of 'int ni'
   45 |       int ni = ti+di[conv[v[s]]];
      |           ^~
Language: Java

#include<bits/stdc++.h>

int t, n, k;
int x[100010];
int d[100010];
int main(){
    cin >> t;
    while(t){
	t--;
	cin >> n >> k;
	for(int i=0;i<n;i++){
	    cin << x[i];
	}
	int ans = x[n-1] - x[n];
	for(int i=1;i<n;i++){
	    d[i-1] = x[i] - x[i-1];
	}
	sort(d,d+n-1);
	if(n>=k){
	    ans = 0;
	}else{
	    for(int i=0;i<k-1;i++){
	        ans -= d[i];
	    }
	}
	cout << ans << endl;
	
    }
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include<bits/stdc++.h>
        ^
Main.java:4: error: class, interface, enum, or record expected
int x[100010];
^
Main.java:5: error: class, interface, enum, or record expected
int d[100010];
^
Main.java:7: error: not a statement
    cin >> t;
        ^
Main.java:10: error: not a statement
	cin >> n >> k;
	         ^
Main.java:12: error: not a statement
	    cin << x[i];
	        ^
Main.java:26: error: not a statement
	cout << ans << endl;
	            ^
Main.java:6: error: unnamed classes are a preview feature and are disabled by default.
int main(){
^
  (use --enable-preview to enable unnamed classes)
9 errors
Language: Java

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

int t, n, k;
int x[100010];
int d[100010];
int main(){
    cin >> t;
    while(t){
	t--;
	cin >> n >> k;
	for(int i=0;i<n;i++){
	    cin >> x[i];
	}
	int ans = x[n-1] - x[0];
	for(int i=1;i<n;i++){
	    d[i-1] = x[i] - x[i-1];
	}
	sort(d,d+n-1);
	if(n<=k){
	    ans = 0;
	}else{
	    for(int i=0;i<k-1;i++){
	        ans -= d[n-2-i];
	    }
	}
	cout << ans << endl;
    }
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <algorithm>
^
Main.java:5: error: class, interface, enum, or record expected
int t, n, k;
^
Main.java:6: error: class, interface, enum, or record expected
int x[100010];
^
Main.java:7: error: class, interface, enum, or record expected
int d[100010];
^
Main.java:9: error: not a statement
    cin >> t;
        ^
Main.java:12: error: not a statement
	cin >> n >> k;
	         ^
Main.java:14: error: not a statement
	    cin >> x[i];
	        ^
Main.java:28: error: not a statement
	cout << ans << endl;
	            ^
Main.java:8: error: unnamed classes are a preview feature and are disabled by default.
int main(){
^
  (use --enable-preview to enable unnamed classes)
10 errors
Language: Java

import java.io.*;
import java.util.*;

public class CantryRoad { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		int t = Integer.parseInt(scr.nextLine());
		for(int step=0; step<t; step++){
			//System.out.println(" step:" + step);
		    //try{
				String[] str = scr.nextLine().split(" ", 0);
				//System.out.println(str.length);
				int n = Integer.parseInt(str[0]);
				int k = Integer.parseInt(str[1]);
				ArrayList<Integer> xs = new ArrayList<Integer>();
				String[] strs = scr.nextLine().split(" ", 0);
				for(int i=0; i<n; i++){
					xs.add(Integer.parseInt(strs[i]));
				}
				//System.out.println(xs);
				//System.out.println(xs.get(0));
				if (n==0 && k==0) break; //??\?????????
				System.out.println( SetDinamo(k, xs) );
			//}catch(Exception e){
				//System.err.println("TyialException");
				//break;
			//}
        }
		scr.close();
	}
	
	
	/*private static int SetDinamo(int k, ArrayList<Integer> xs){
		if(xs.size()==0 || k==0) return 0;
		int mlen = Integer.MAX_VALUE;
		//int tlen = Integer.MAX_VALUE;
		int n = xs.size();
		System.out.println(n);
		int a = xs.get(n-1);
		xs.remove(xs.size()-1);
		for(int i=n-2; i>=0; i--){
			System.out.println(k+":"+i);
			int u = xs.get(i);
			xs.remove(i);
			int t = SetDinamo(k-1, xs);
			if(a-u+t<mlen) mlen = a-u+t;
		}
	    return mlen;
	}*/
	private static int SetDinamo(int k, ArrayList<Integer> xs){
		//System.out.print("Input:" + k + ":" + xs);
		if(xs.size()==0 || k==1){
			if(xs.size()==0){
				//.out.print("No_House ");
				return 0;
			}else{
				//System.out.print("No_Dinamo ");
				return xs.get(xs.size()-1) - xs.get(0);
			}
		}else{
			int minlen = Integer.MAX_VALUE;
			int n = xs.size();
			for(int i=0; i<n; i++){
				int firlen = xs.get(i) - xs.get(0);
				//System.out.print(" fir:" + firlen + " ");
				ArrayList<Integer> xsp = new ArrayList<Integer>();
				for(int j=i+1; j<n; j++){
					xsp.add(xs.get(j));
				}
				int reslen = SetDinamo(k-1, xsp);
				//System.out.print(" res:" + reslen);
				int sumlen = firlen + reslen;
				//System.out.println(" sum:" + sumlen);
				if(minlen > sumlen) minlen = sumlen;
			}
			//System.out.println(" min:" + minlen);
			return minlen;
		}
	}
	
}

Compiler output:
Main.java:4: error: class CantryRoad is public, should be declared in a file named CantryRoad.java
public class CantryRoad { 
       ^
1 error
Language: C

#include<stdio.h>
#include<stdlib.h>

int comp(const void* a, const void* b);

int main() {
	int t;
	int* x;
	int n, k;
	int i, j;
	int* ans;
	int* bou;
	scanf_s("%d", &t);
	ans = (int*)malloc(t * sizeof(int));
	for (i = 0; i < t; i++) {
		ans[i] = 0;
		scanf_s("%d%d", &n, &k);
		x = (int*)malloc(n * sizeof(int));
		bou = (int*)malloc((n - 1) * sizeof(int));
		for(j=0;j<n;j++)scanf_s("%d", &x[j]);
		if (k >= n)ans[i] = 0;
		else {
			for (j = 0; j < n - 1; j++) {
				bou[j] = x[j + 1] - x[j];
			}
			qsort(bou, n - 1, sizeof(int), comp);
			for (j = k-1 ; j < n - 1; j++)ans[i] += bou[j];
		}
	}
	for (i = 0; i < t; i++) {
		printf("%d", ans[i]);
		if (i < t - 1)printf(" ");
		else printf("\n");
	}

	return 0;
}

int comp(const void* a, const void* b) {
	return *((int*)b) - *((int*)a);
}

Compiler output:
main.c: In function 'main':
main.c:13:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   13 |         scanf_s("%d", &t);
      |         ^~~~~~~
      |         scanf
Language: C

  int d1,d2;
  int i,j,t,l;
  int sam,sa[100000];
  scanf("%d",&g);
  for(l=0;l<g;l++){
    sam=0;
    scanf("%d %d",&n,&k);
    
    for(j=0;j<n;j++){
      scanf("%d",&d2);
      if(j==0)d1=d2;
      else{
	sa[j-1]=d2-d1;
	sam+=d2-d1;
	d1=d2;
      }
    }
    for(i=0;i<n;i++){
      for(j=1;j+i<n;j++){
	if(sa[j]>sa[j-1]){
	  t=sa[j-1];
	  sa[j-1]=sa[j];
	  sa[j]=t;
	}
      }
    }
    for(i=0;i<k-1;i++){
      sam-=sa[i];
    }
    if(sam<0)sam=0;
    printf("%d\n",sam);   
  }
  return 0;
}

Compiler output:
main.c:4:9: error: expected declaration specifiers or '...' before string constant
    4 |   scanf("%d",&g);
      |         ^~~~
main.c:4:14: error: expected declaration specifiers or '...' before '&' token
    4 |   scanf("%d",&g);
      |              ^
main.c:5:3: error: expected identifier or '(' before 'for'
    5 |   for(l=0;l<g;l++){
      |   ^~~
main.c:5:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    5 |   for(l=0;l<g;l++){
      |            ^
main.c:5:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    5 |   for(l=0;l<g;l++){
      |                ^~
main.c:33:3: error: expected identifier or '(' before 'return'
   33 |   return 0;
      |   ^~~~~~
main.c:34:1: error: expected identifier or '(' before '}' token
   34 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cstring>
int T, N, K, X[100000 + 10], A[100000 + 10];
using namespace std;
int main()
{
    cin >> T;
    for (int t = 0; t < T; ++t)
    {
        cin >> N;
        cin >> K;
        for (int i = 0; i < N; ++i)
            cin >> X[i];
        int end;
        for (int i = 0; i + 1 < N; ++i)
        {
            A[i] = X[i + 1] - X[i];
            if (i + 1 == N)
                end = i + 1;
        }
        sort(A[0], A[i + 1]);
        int result = 0;
        if (N > K)
        {
            for (int i = 0; i < n - k; i++)
            {
                result += A[i];
            }
        }
        cout << endl
             << result;
    }
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:22: error: 'i' was not declared in this scope
   22 |         sort(A[0], A[i + 1]);
      |                      ^
a.cc:26:33: error: 'n' was not declared in this scope
   26 |             for (int i = 0; i < n - k; i++)
      |                                 ^
a.cc:26:37: error: 'k' was not declared in this scope
   26 |             for (int i = 0; i < n - k; i++)
      |                                     ^
Language: C++

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

int main(){
  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    int n,k;
    cin >> n >> k;
    vector<int> a(n)
    for(int j=0;j<n;j++){
      cin >>  a.at(j);
    }
    sort(a.bigin(),a.end());
    int c=n-k-1
      for(int k=0;k<c;k++){
	sum+=a.at(k)
	cout << sum << endl;
      }
      }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: expected ',' or ';' before 'for'
   11 |     for(int j=0;j<n;j++){
      |     ^~~
a.cc:11:17: error: 'j' was not declared in this scope
   11 |     for(int j=0;j<n;j++){
      |                 ^
a.cc:14:12: error: 'class std::vector<int>' has no member named 'bigin'; did you mean 'begin'?
   14 |     sort(a.bigin(),a.end());
      |            ^~~~~
      |            begin
a.cc:16:7: error: expected ',' or ';' before 'for'
   16 |       for(int k=0;k<c;k++){
      |       ^~~
a.cc:16:26: error: expected ';' before ')' token
   16 |       for(int k=0;k<c;k++){
      |                          ^
      |                          ;
Language: C++

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

int main(){
  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    int n,k;
    cin >> n >> k;
    vector<int> a(n)
    for(int j=0;j<n;j++){
      cin >>  a.at(j);
    }
    sort(a.begin(),a.end());
    int c=n-k-1
      for(int k=0;k<c;k++){
	sum+=a.at(k);
	cout << sum << endl;
      }
      }
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: expected ',' or ';' before 'for'
   11 |     for(int j=0;j<n;j++){
      |     ^~~
a.cc:11:17: error: 'j' was not declared in this scope
   11 |     for(int j=0;j<n;j++){
      |                 ^
a.cc:16:7: error: expected ',' or ';' before 'for'
   16 |       for(int k=0;k<c;k++){
      |       ^~~
a.cc:16:26: error: expected ';' before ')' token
   16 |       for(int k=0;k<c;k++){
      |                          ^
      |                          ;
Language: C++

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

int main(){
  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int j=0;j<n;j++){
      cin >>  a.at(j);
    }
    sort(a.begin(),a.end());
    int c=n-k-1
      for(int k=0;k<c;k++){
	sum+=a.at(k);
	cout << sum << endl;
      }
      }
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:16:7: error: expected ',' or ';' before 'for'
   16 |       for(int k=0;k<c;k++){
      |       ^~~
a.cc:16:26: error: expected ';' before ')' token
   16 |       for(int k=0;k<c;k++){
      |                          ^
      |                          ;
Language: C++

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

int main(){
  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int j=0;j<n;j++){
      cin >>  a.at(j);
    }
    sort(a.begin(),a.end());
    int c=n-k-1;
      for(int k=0;k<c;k++){
	sum+=a.at(k);
	cout << sum << endl;
      }
      }
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'sum' was not declared in this scope
   17 |         sum+=a.at(k);
      |         ^~~
Language: C++

#include<bits/stdc++.h>

int t, n, k;
int x[100010];
int d[100010];
int main(){
    cin >> t;
    while(t){
	t--;
	cin >> n >> k;
	for(int i=0;i<n;i++){
	    cin << x[i];
	}
	int ans = x[n-1] - x[n];
	for(int i=1;i<n;i++){
	    d[i-1] = x[i] - x[i-1];
	}
	sort(d,d+n-1);
	if(n>=k){
	    ans = 0;
	}else{
	    for(int i=0;i<k-1;i++){
	        ans -= d[i];
	    }
	}
	cout << ans << endl;
	
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |     cin >> t;
      |     ^~~
      |     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:18:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   18 |         sort(d,d+n-1);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:26:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |         cout << ans << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:26:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |         cout << ans << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<bits/stdc++.h>

int t, n, k;
int x[100010];
int d[100010];
int main(){
    cin >> t;
    while(t){
	t--;
	cin >> n >> k;
	for(int i=0;i<n;i++){
	    cin >>  x[i];
	}
	int ans = x[n-1] - x[n];
	for(int i=1;i<n;i++){
	    d[i-1] = x[i] - x[i-1];
	}
	sort(d,d+n-1);
	if(n>=k){
	    ans = 0;
	}else{
	    for(int i=0;i<k-1;i++){
	        ans -= d[i];
	    }
	}
	cout << ans << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |     cin >> t;
      |     ^~~
      |     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:18:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   18 |         sort(d,d+n-1);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:26:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |         cout << ans << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:26:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |         cout << ans << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>

int t, n, k;
int x[100010];
int d[100010];
int main(){
    cin >> t;
    while(t){
	t--;
	cin >> n >> k;
	for(int i=0;i<n;i++){
	    cin >> x[i];
	}
	int ans = x[n-1] - x[n];
	for(int i=1;i<n;i++){
	    d[i-1] = x[i] - x[i-1];
	}
	sort(d,d+n-1);
	if(n>=k){
	    ans = 0;
	}else{
	    for(int i=0;i<k-1;i++){
	        ans -= d[i];
	    }
	}
	cout << ans << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |     cin >> t;
      |     ^~~
      |     std::cin
In file included 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:19:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   19 |         sort(d,d+n-1);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:27:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |         cout << ans << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:27:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   27 |         cout << ans << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

int t, N, K, num;
const int max1 = (10e+5) + 1;
vector<int> h(max1), range(max1);
int ans;


int main() {
  cin >> t ;
  for(int p = 0; p < t; p++) {
    cin >> N >> K;
    for(int i = 0; i < max1; i++) {
      h.at(i) = 0;
    }
    for(int i = 0; i < N; i++) {
      cin >> h.at(i);
    }
    for(int i = 0; i < N-1; i++) {
      range.at(i) = h.at(i+1) - h.at(i);
    }
    sort(range.begin(),range.end());
	reverse(range.begin(),range.end());
    num = N - K;
	if(num <= 0) {
	  cout << 0 << endl;
	  continue;
	}
	ans = h.at(N-1) - h.at(0);
	for(int i = 0; i < K-1; i++) {
	  ans -= range.at(i);
	}
	cout << ans << endl;
  }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |     sort(range.begin(),range.end());
      |     ^~~~
      |     short
a.cc:25:9: error: 'reverse' was not declared in this scope
   25 |         reverse(range.begin(),range.end());
      |         ^~~~~~~
Language: C++

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

int t, N, K, num;
const int max1 = (10e+5) + 1;
vector<int> h(max1), range(max1);
int ans;


int main() {
  cin >> t ;
  for(int p = 0; p < t; p++) {
    cin >> N >> K;
    for(int i = 0; i < max1; i++) {
      h.at(i) = 0;
    }
    for(int i = 0; i < N; i++) {
      cin >> h.at(i);
    }
    for(int i = 0; i < N-1; i++) {
      range.at(i) = h.at(i+1) - h.at(i);
    }
    sort(range.begin(),range.end());
    reverse(range.begin(),range.end());
    num = N - K;
    if(num <= 0) {
      cout << 0 << endl;
      continue;
    }
    ans = h.at(N-1) - h.at(0);
    for(int i = 0; i < K-1; i++) {
      ans -= range.at(i);
    }
    cout << ans << endl;
  }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |     sort(range.begin(),range.end());
      |     ^~~~
      |     short
a.cc:25:5: error: 'reverse' was not declared in this scope
   25 |     reverse(range.begin(),range.end());
      |     ^~~~~~~
Language: C++

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

int t, N, K, num;
const int max1 = (10e+5) + 1;
vector<int> h(max1), range(max1);
int ans;


int main() {
  cin >> t ;
  for(int p = 0; p < t; p++) {
    cin >> N >> K;
    for(int i = 0; i < max1; i++) {
      h.at(i) = 0;
      range.at(i) = 0;
    }
    for(int i = 0; i < N; i++) {
      cin >> h.at(i);
    }
    for(int i = 0; i < N-1; i++) {
      range.at(i) = h.at(i+1) - h.at(i);
    }
    sort(range.begin(),range.end());
    reverse(range.begin(),range.end());
    num = N - K;
    if(num <= 0) {
      cout << 0 << endl;
      continue;
    }
    ans = h.at(N-1) - h.at(0);
    for(int i = 0; i < K-1; i++) {
      ans -= range.at(i);
    }
    cout << ans << endl;
  }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |     sort(range.begin(),range.end());
      |     ^~~~
      |     short
a.cc:26:5: error: 'reverse' was not declared in this scope
   26 |     reverse(range.begin(),range.end());
      |     ^~~~~~~
Language: C++

#include<iostream>
#include<vector>

using std::cout;
using std::cin;
using std::vector;
using std::sort;

#define INF 999999999;


long long int T, N, K;
vector<long long int> X, dis;
long long int ans;

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

	cin >> T;
	for(int i = 0; i < T; i++){
		cin >> N >> K;
		for(int j = 0; j < N; j++){
			int inn;
			cin >> inn;
			X.push_back(inn);
			if(j > 0){
				ans += X[j] - X[j - 1];
				dis.push_back(X[j] - X[j - 1]);
			}
		}
		ans = X[X.size() - 1] - X[0];
		sort(dis.begin(), dis.end(), [](int a, int b){return a > b;});
		for(int j = 0; j < N-1 && j < K-1; j++){
			ans -= dis[j];
		}
		cout << ans << "\n";
		ans = 0;
		X.clear();
		dis.clear();
	}
	return 0;
}


Compiler output:
a.cc:7:12: error: 'sort' has not been declared in 'std'
    7 | using std::sort;
      |            ^~~~
a.cc: In function 'int main()':
a.cc:33:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |                 sort(dis.begin(), dis.end(), [](int a, int b){return a > b;});
      |                 ^~~~
      |                 short
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int kusa;
int ki;
int ushi;
int uma;
long int yagi[100010];
long int shika[100010];
int kaba;
int i;
int j;
int kame;
int main(){
  cin>>kusa;
  for(int ki;ki<kusa;ki++){
  cin>>ushi;
  cin>>uma;
  uma=uma-1;
  for(int i=0;i<ushi;i++){
    cin>>yagi[i];
  }
      if(ushi<uma+1){
          cout<<0<<endl;
      }else{
  for(int j=0;j<ushi-1;j++){
    shika[j]=yagi[j+1]-yagi[j];
    kaba=kaba+shika[j];
  }
  sort(shika,shika+ushi-1);
  for(int kame=0;kame<uma;kame++){
    kaba=kaba-shika[ushi-2-kame];
  }
          cout<<kaba<<endl;
      }
  ushi=0;
  uma=0;
  kaba=0;
  long int yagi[100010]={0};
  long int shika[100010]={0};
  i=0;
  j=0;
  kame=0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:48:4: error: expected '}' at end of input
   48 |   }
      |    ^
a.cc:18:11: note: to match this '{'
   18 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;

int t, n, k;
int a[100000];

int main(){
  cin >> t;
  for(int i=0; i<t; i++){
    cin >> n >> k;
    for(int j=0; j<n; j++){
      cin >> a[j];
    }
    int b[100000];
    for(int l=0; l<n-1; l++){
      b[l]=a[l+1]-a[l];
      
    }
    
    sort(b, b+n-1);
    int sum=0;
    for(int m=0; m<n-k; m++){
      sum +=b[m];
    }    
    cout << sum << endl;
  }

  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |     sort(b, b+n-1);
      |     ^~~~
      |     short
Language: C++

#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main(){

    int Ad = 0;
    int Hs = 0;
    int Ds = 0;
    int* Hp;
    int* C;
    int Sc = 0;

    cin >> Ad;
    for (int eD = 0; eD < Ad; ++ed){
        cin >> Hs;
        cin >> Ds;
        Hp = new int[Hs];
        for (int i = 0; i < Hs; ++i){
            cin >> Hp[i];
        }

        if (Hs <= Ds){
            cout << 0 << endl;
            continue;
        }

        C = new int[Hs - 1];
        for (int i = 0; i < Hs - 1; ++i){
            C[i] = Hp[i + 1] - Hp[i];
        }
        Sc = Hp[Hs - 1] - Hn[0];
 
        sort(&C[0], &C[0] + Hs - 1);

        for (int i = 0; i < Ds - 1; ++i){
            Sc -= C[Hs - i - 2];
            C[Hs - i - 2] = 0;
        }

        cout << Sc << endl;
 
        delete[] C;
        delete[] Hp;
    }
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:33: error: 'ed' was not declared in this scope; did you mean 'eD'?
   16 |     for (int eD = 0; eD < Ad; ++ed){
      |                                 ^~
      |                                 eD
a.cc:33:27: error: 'Hn' was not declared in this scope; did you mean 'Hp'?
   33 |         Sc = Hp[Hs - 1] - Hn[0];
      |                           ^~
      |                           Hp
Language: C++

#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main(){

    int Ad = 0;
    int Hs = 0;
    int Ds = 0;
    int* Hp;
    int* C;
    int Sc = 0;

    cin >> Ad;
    for (int eD = 0; eD < Ad; ++eD){
        cin >> Hs;
        cin >> Ds;
        Hp = new int[Hs];
        for (int i = 0; i < Hs; ++i){
            cin >> Hp[i];
        }

        if (Hs <= Ds){
            cout << 0 << endl;
            continue;
        }

        C = new int[Hs - 1];
        for (int i = 0; i < Hs - 1; ++i){
            C[i] = Hp[i + 1] - Hp[i];
        }
        Sc = Hp[Hs - 1] - Hn[0];
 
        sort(&C[0], &C[0] + Hs - 1);

        for (int i = 0; i < Ds - 1; ++i){
            Sc -= C[Hs - i - 2];
            C[Hs - i - 2] = 0;
        }

        cout << Sc << endl;
 
        delete[] C;
        delete[] Hp;
    }
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:27: error: 'Hn' was not declared in this scope; did you mean 'Hp'?
   33 |         Sc = Hp[Hs - 1] - Hn[0];
      |                           ^~
      |                           Hp
Language: C++

#include <iostream>
#include <vector>
#include <algorithm> 
#include <map> 
#include <math.h>
#include <string>
using namespace std;



int main(){
	int t;
	cin >> t;
	for(int i = 0; i < t; i++){
		int n, k;
		cin >> n >> k;

		if(n <= k){
			cout << 0 << endl;
			for(int j = 0; j < n; j++){
				cin >> x[j];
			}
		}else{
			int x[n];
			for(int j = 0; j < n; j++){
				cin >> x[j];
			}


			sort(x, x + n);
			reverse(x, x + n);

			int ans = x[0] - x[n - 1];

			int y[n - 1];
			for(int j = 0; j < n - 1; j++){
				y[j] = x[j] - x[j + 1];
			}
			sort(y, y + n - 1);
			reverse(y, y + n - 1);
			for(int j = 0; j < k; j++){
				ans = ans - y[j];
			}
			cout << ans << endl;
		}
		
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:40: error: 'x' was not declared in this scope
   21 |                                 cin >> x[j];
      |                                        ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm> 
#include <map> 
#include <math.h>
#include <string>
using namespace std;



int main(){
	int t;
	cin >> t;
	for(int i = 0; i < t; i++){
		int n, k;
		cin >> n >> k;

		if(n <= k){
			cout << 0 << endl;
			for(int j = 0; j < n; j++){
				cin >> x[j];
			}
		}else{
			int x[n];
			for(int j = 0; j < n; j++){
				cin >> x[j];
			}


			sort(x, x + n);
			reverse(x, x + n);

			int ans = x[0] - x[n - 1];

			int y[n - 1];
			for(int j = 0; j < n - 1; j++){
				y[j] = x[j] - x[j + 1];
			}
			sort(y, y + n - 1);
			reverse(y, y + n - 1);
			for(int j = 0; j < k - 1; j++){
				ans = ans - y[j];
			}
			cout << ans << endl;
		}
		
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:40: error: 'x' was not declared in this scope
   21 |                                 cin >> x[j];
      |                                        ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, k, a[1000000];
vector<int>vec;
int main() {
	while (true) {
		vec.clear();
		cin >> n >> k;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		for (int i = 0; i < n - 1; i++) {
			vec.push_back(a[i + 1] - a[i]);
		}
		sort(vec.begin(), vec.end());
		int sum = 0, cnt = 1;
		for (int i = vec.size() - 1; i >= 0; i--) {
			if (cnt >= k)sum += b[i];
			cnt++;
		}
		cout << sum << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:45: error: 'b' was not declared in this scope
   21 |                         if (cnt >= k)sum += b[i];
      |                                             ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int q, n, m, a[100000], b[99999];
int main() {
	cin >> q;
	for(int i = 0; i < q; i++) {
		cin >> n >> m;
		for(int i = 0; i < n; i++) cin >> a[i];
		for(int i = 1; i < n; i++) b[i - 1] = a[i] - a[i - 1];
		sort(b, b + n - 1)
		int ret = a[n - 1] - a[0];
		for(int i = n - 2; i >= n - m - 1 && i >= 0; i--) ret -= b[i];
		cout << ret << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:35: error: expected ';' before 'int'
   11 |                 sort(b, b + n - 1)
      |                                   ^
      |                                   ;
   12 |                 int ret = a[n - 1] - a[0];
      |                 ~~~                
a.cc:13:67: error: 'ret' was not declared in this scope
   13 |                 for(int i = n - 2; i >= n - m - 1 && i >= 0; i--) ret -= b[i];
      |                                                                   ^~~
a.cc:14:25: error: 'ret' was not declared in this scope
   14 |                 cout << ret << endl;
      |                         ^~~
Language: C++

#include <algorithm>
#include <iostream>
using namespace std;
int main(void){
    int datas;
    cin>>datas;
    for(int i = 0; i < datas; i++)
    {
        int n;
        int k;
        cin >> n;
        cin >> k;
        int houses[n]???
        if(n < k){
            k = n;
        }
        for(int j = 0; j < n;j++){
            cin >> houses[j];
        }
        sort(houses,houses+n);
        int distances[n-1];
        for(int j = 0;j < n-1;j++){
            distances[j] = houses[j+1]-houses[j];
        }
        sort(distances,distances+n-1);
        int length = 0;
        for(int j = n-2;j >= k-1; j--){
            length += distances[j];
        }
        cout << length << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: expected initializer before '?' token
   13 |         int houses[n]???
      |                      ^
a.cc:18:20: error: 'houses' was not declared in this scope
   18 |             cin >> houses[j];
      |                    ^~~~~~
a.cc:20:14: error: 'houses' was not declared in this scope
   20 |         sort(houses,houses+n);
      |              ^~~~~~
Language: C++


#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int T,N,K,X[1000000+10],A[1000000+10];
int main(){
    cin>>T;
    for(int t=0;t<T;++t){
        int sum=0;
        cin>>N>>K;
        for(int i=0;i<N;++i){cin>>X[i];}
        for(int i=0;i<N-1;++i){A[i]=X[i+1]-X[i];}
        sort(A,A+N-1);
        for (int j=0;j<N-K;++j){sum=sum+A[j];}
        cout<<sum<<endl;
    }
    return 0;
}




#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int T,N,K,X[1000000+10],A[1000000+10];
int main(){
    cin>>T;
    for(int t=0;t<T;++t){
        int sum=0;
        cin>>N>>K;
        for(int i=0;i<N;++i){cin>>X[i];}
        for(int i=0;i<N-1;++i){A[i]=X[i+1]-X[i];}
        sort(A,A+N-1);
        for (int j=0;j<N-K;++j){sum=sum+A[j];}
        cout<<sum<<endl;
    }
    return 0;
}

Compiler output:
a.cc:28:5: error: redefinition of 'int T'
   28 | int T,N,K,X[1000000+10],A[1000000+10];
      |     ^
a.cc:6:5: note: 'int T' previously declared here
    6 | int T,N,K,X[1000000+10],A[1000000+10];
      |     ^
a.cc:28:7: error: redefinition of 'int N'
   28 | int T,N,K,X[1000000+10],A[1000000+10];
      |       ^
a.cc:6:7: note: 'int N' previously declared here
    6 | int T,N,K,X[1000000+10],A[1000000+10];
      |       ^
a.cc:28:9: error: redefinition of 'int K'
   28 | int T,N,K,X[1000000+10],A[1000000+10];
      |         ^
a.cc:6:9: note: 'int K' previously declared here
    6 | int T,N,K,X[1000000+10],A[1000000+10];
      |         ^
a.cc:28:11: error: redefinition of 'int X [1000010]'
   28 | int T,N,K,X[1000000+10],A[1000000+10];
      |           ^
a.cc:6:11: note: 'int X [1000010]' previously declared here
    6 | int T,N,K,X[1000000+10],A[1000000+10];
      |           ^
a.cc:28:25: error: redefinition of 'int A [1000010]'
   28 | int T,N,K,X[1000000+10],A[1000000+10];
      |                         ^
a.cc:6:25: note: 'int A [1000010]' previously declared here
    6 | int T,N,K,X[1000000+10],A[1000000+10];
      |                         ^
a.cc:29:5: error: redefinition of 'int main()'
   29 | int main(){
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main(){
      |     ^~~~