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

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>k>>n;
  vector<int> v(n),a(n);
  for(int i=0; i<n; i++)
  {
    cin>>v[i];
  }
  a[0] = min((v[n-1]-v[0]),(k-(v[n-1)-v[0]));
  a[n-1] = min((v[n-1]-v[0]),(k-(v[n-1]-v[n-2])));                           
  for(int i=1 ; i<n-1 ; i++)
  {
    a[1] = min((k-(v[i]-v[i-1])),(k-(v[i+1]-v[i])));
  }
  cout<<*min_element(a.begin(),a.end());
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:37: error: expected ']' before ')' token
   12 |   a[0] = min((v[n-1]-v[0]),(k-(v[n-1)-v[0]));
      |                                     ^
      |                                     ]
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int circle = sc.nextInt();
        int num = sc.nextInt();
        int[] house = new int[num];
        for (int i = 0; i < house.length; i++){
            int moto = sc.nextInt();
            int hiki  = circle - moto;
            if (moto >= hiki){
                house[i] = hiki;
            }else {
                house[i] = moto;
            }
        }
        int sabun = 0;
        for (int j = 0; j < house.length - 1; j++){
            int sabunCheck = Math.abs( house[j] - house[j + 1]);
            if (sabun > sabunCheck){
                sabun = sabunCheck;
            }
        }
        int sabuncheck2 = Math.abs(house[house.length - 1] - house[0]);
        if (sabuncheck2 > sabun){
            System.out.println(circle - sabuncheck2);
        }else {
            System.out.println(circle - sabun);
        }

    }
}


Compiler output:
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C

#include<stdio.h>
int main() {
    long long int k;
    long long int n;
    long long int a=0;
    long long int b=0;
    long long int c;
    long long int max=0;
    long long int p=0;
    long long int q=0;
    scanf("%lld %lld", &k, &n);
    for(int i=1;i<=n;i++) {
        a=b;
        scanf("%lld", &b);
        c=b-a;
        if(max<c) max=c;
        if(i==1) p=b;
        if(i==n) q=b;
        
    }

Compiler output:
main.c: In function 'main':
main.c:20:5: error: expected declaration or statement at end of input
   20 |     }
      |     ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;
int a[MR];
int main() {
	int k,n;
	cin>>k>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
    int maxd=K+a[0]-a[n-1];
    for(int i=0;i<n;i++){
    	maxd=max(maxd,a[i]-a[i-1]);
    }
    printf("%d\n",K-maxd);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: 'K' was not declared in this scope
   17 |     int maxd=K+a[0]-a[n-1];
      |              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int K,N;
int main(){
  cin>>K>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++)cin>>A[i];
/*  for(int i=0;i<N-1;i++)B[i]=A[i+1]-A[i];
  B[N-1]=A[0]+K-A[N-1];
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());*/
  cout<<k-B[0]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'k' was not declared in this scope
   12 |   cout<<k-B[0]<<endl;
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int K,N;
int main(){
  cin>>K>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N-1;i++)B[i]=A[i+1]-A[i];
  B[N-1]=A[0]+K-A[N-1];
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  cout<<k-B[0]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'k' was not declared in this scope
   12 |   cout<<k-B[0]<<endl;
      |         ^
Language: C++

#include<iostream>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    long long k,n,a;
    long long t=0;
    long long q=1e9;
    long long l=0;
    long long h=1e9;
    long long f=0;
    long long g=1e9;
    long long w=0;
    long long e=1e9;
    cin>>k>>n;
    for (long long i=0;i<n;i++){
        cin>>a;
        l=max(a,l);
        h=min(a,h);
        if(a==0)a=k;
        w=max(a,w);
        e=min(a,e);
        if(a>(k/2))
        a=a-k;
        t=max(a,t);
        q=min(a,q);
        if(a==0)a=k;
        f=max(a,f);
        g=min(a,g);
    }
    long long r=w-e;
    long long z=f-g;
    long long d=l-h;
    long long y=t-q;
    long long x=min(d,(y,min(r,z));
    cout <<x;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:35: error: expected ')' before ';' token
   37 |     long long x=min(d,(y,min(r,z));
      |                    ~              ^
      |                                   )
Language: C++

#include<iostream>
using namespace std;

int main()
{
  int k,n;
  cin>>k>>n;
  
  int arr[n];
  
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  
  int brr[n];
  
  for(int i=0;i<n;i++)
  {
    brr[i]=k-arr[i];
  }
  
  int crr[n];
  
  for(int i=0;i<n;i++)
  {
    crr[i]=min(arr[i],brr[i]);
  }
  
  int sum=0;
  
  for(int i=0;i<n;i++)
  {
    sum+=crr[i];
  }
  
  int k=0;
  
  for(int i=0;i<n;i++)
  {
    if(arr[i]==0)
      k++;
  }
  
  if(k>0)
    cout<<sum<<endl;
  else
    cout<<sum/2<<endl;
  
  
  
  return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:7: error: redeclaration of 'int k'
   37 |   int k=0;
      |       ^
a.cc:6:7: note: 'int k' previously declared here
    6 |   int k,n;
      |       ^
Language: C++

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

int main() {
  int K,N;
  cin>>K>>N;
  vector<int> site(N);
  for(int i=0; i<N;i++){
    cin>>site.at(i);
  }
  vector<int> X(N);
  for(int i=0; i<N; i++){
    vector<int> X={site(i+1)-site(i)}
  }
   sort(X.begin(),X.end());
   cout<<K-X.at(N-1)<< endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:24: error: no match for call to '(std::vector<int>) (int)'
   13 |     vector<int> X={site(i+1)-site(i)}
      |                    ~~~~^~~~~
a.cc:13:34: error: no match for call to '(std::vector<int>) (int&)'
   13 |     vector<int> X={site(i+1)-site(i)}
      |                              ~~~~^~~
a.cc:13:37: error: could not convert '{<expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   13 |     vector<int> X={site(i+1)-site(i)}
      |                                     ^
      |                                     |
      |                                     <brace-enclosed initializer list>
a.cc:14:3: error: expected ',' or ';' before '}' token
   14 |   }
      |   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{int p,n;
 cin>>p>>n;
 int a[n];
 for(int i=0;i<n;i++)
   cin>>a[i];
 for(int i=1;i<n;i++)
 {if(a[i]<=(p/2))
   a[i]=a[i]-a[i-1];
  else
    a[i]=d-a[i];}
 int sum=0;
 for(int i=1;i<n;i++)
   sum=sum+a[i];
 cout<<sum;}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: 'd' was not declared in this scope
   13 |     a[i]=d-a[i];}
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{int p,n;
 cin>>p>>n;
 int a[n];
 for(int i=0;i<n;i++)
   cin>>a[i];
 for(int i=1;i<n;i++)
 {if(a[i]<=(d/2))
   a[i]=a[i]-a[i-1];
  else
    a[i]=d-a[i];}
 int sum=0;
 for(int i=1;i<n;i++)
   sum=sum+a[i];
 cout<<sum;}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: 'd' was not declared in this scope
   10 |  {if(a[i]<=(d/2))
      |             ^
Language: C++

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

int K,N;
int A[200001];

void solve(){
  	int kyori=0;
	for(int j=1;j<=N;j++){
    	if(kyori<A[j+1]-A[j]) kyori=A[j+1]-A[j];
    }
  	cout<<K-kyori;
  	return ;
}

int main(){
	cin>>K>>N;
  	for(int i=1;i<=N;i++){
    	cin>>A[i];
    }
  	A[N+1]=A[1]+K
  	solve();
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:22: error: expected ';' before 'solve'
   21 |         A[N+1]=A[1]+K
      |                      ^
      |                      ;
   22 |         solve();
      |         ~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{int p,n;
 cin>>p>>n;
 for(int i=0;i<n;i++)
   cin>>a[i];
 for(int i=1;i<n;i++)
 {if(a[i]<=(d/2))
   a[i]=a[i]-a[i-1];
  else
    a[i]=d-a[i];}
 int sum=0;
 for(int i=1;i<n;i++)
   sum=sum+a[i];
 cout<<sum;}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'a' was not declared in this scope
    7 |    cin>>a[i];
      |         ^
a.cc:9:6: error: 'a' was not declared in this scope
    9 |  {if(a[i]<=(d/2))
      |      ^
a.cc:9:13: error: 'd' was not declared in this scope
    9 |  {if(a[i]<=(d/2))
      |             ^
a.cc:15:12: error: 'a' was not declared in this scope
   15 |    sum=sum+a[i];
      |            ^
Language: C++

int main()
{

    int K, N, i;
    int out = 0;
    int A[200000];

    cin >> K >> N;
    cin >> A[0];
    for(i = 1; i < N; i++){
        cin >> A[i];
        cout << A[i-1] << " " << A[i] << endl;
        out = out + (A[i] - A[i-1]);
    }

    cout << out;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin >> K >> N;
      |     ^~~
a.cc:12:9: error: 'cout' was not declared in this scope; did you mean 'out'?
   12 |         cout << A[i-1] << " " << A[i] << endl;
      |         ^~~~
      |         out
a.cc:12:42: error: 'endl' was not declared in this scope
   12 |         cout << A[i-1] << " " << A[i] << endl;
      |                                          ^~~~
a.cc:16:5: error: 'cout' was not declared in this scope; did you mean 'out'?
   16 |     cout << out;
      |     ^~~~
      |     out
Language: C++

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

int main() {
  int K,N;
  cin>>K>>N;
  vector<int> site(N);
  for(int i=0; i<N;i++){
    cin>>site(i);
  }
  vector<int> X(N);
  for(int i=0; i<N; i++){
    vector<int> X={site(i+1)-site(i)}
  }
   sort(X.begin(),X.end());
   cout<<K-X.at(N-1)<< endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: no match for call to '(std::vector<int>) (int&)'
    9 |     cin>>site(i);
      |          ~~~~^~~
a.cc:13:24: error: no match for call to '(std::vector<int>) (int)'
   13 |     vector<int> X={site(i+1)-site(i)}
      |                    ~~~~^~~~~
a.cc:13:34: error: no match for call to '(std::vector<int>) (int&)'
   13 |     vector<int> X={site(i+1)-site(i)}
      |                              ~~~~^~~
a.cc:13:37: error: could not convert '{<expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   13 |     vector<int> X={site(i+1)-site(i)}
      |                                     ^
      |                                     |
      |                                     <brace-enclosed initializer list>
a.cc:14:3: error: expected ',' or ';' before '}' token
   14 |   }
      |   ^
Language: C++

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

int main() {
  int K,N,;
  cin>>K>>N;
  vecter<int> site(N);
  for(int i=0; i<N;i++){
    cin>>site(i);
  }
  vecter<int> X(N);
  for(int i=0; i<N; i++){
    vecter<int> X={site(i+1)-site(i)}
  }
   sort(X.begin(),X.end());
   cout<<K-X.at(N-1)<< endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:11: error: expected unqualified-id before ';' token
    5 |   int K,N,;
      |           ^
a.cc:7:3: error: 'vecter' was not declared in this scope
    7 |   vecter<int> site(N);
      |   ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vecter<int> site(N);
      |          ^~~
a.cc:9:10: error: 'site' was not declared in this scope
    9 |     cin>>site(i);
      |          ^~~~
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vecter<int> X(N);
      |          ^~~
a.cc:13:12: error: expected primary-expression before 'int'
   13 |     vecter<int> X={site(i+1)-site(i)}
      |            ^~~
a.cc:15:9: error: 'X' was not declared in this scope
   15 |    sort(X.begin(),X.end());
      |         ^
Language: Java

import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc-new Scanner(System.in);
    int k=sc.nextInt();
    int n=sc.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
    {
      arr[i]=sc.nextInt();
    }
    int min=0;int max=arr[o];
    for(int i=0;i<n;i++)
    {
      if(arr[i]<min)
        min=arr[i];
      if(arr[i]>max)
        max=arr[i];
    }
    System.out.println((max-min));
  }
}


Compiler output:
Main.java:6: error: ';' expected
    Scanner sc-new Scanner(System.in);
              ^
1 error
Language: C++

#include <iostream>
using namespace std;




int main() {
	
    
   long int K,n;
    cin>>K>>n;
  
   long int A[n],i,j,B[n];
  for(i=0;i<n;++i)
  {
    cin>>A[i];
    
  }
  
  for(i=0;i<n;++i)
  {
    if(i==0)
    {
    B[i]=K-A[n-1];
    }
    else
    {
      B[i]=A[i]-A[i-1];
    }
  }
  
  sort(B,B+N);
  long int tot=0;
  for(i=0;i<(N-1);++i)
  {
    tot+=B[i];
  }
    
  cout<<tot<<endl;
    
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:12: error: 'N' was not declared in this scope
   32 |   sort(B,B+N);
      |            ^
a.cc:32:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   32 |   sort(B,B+N);
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int k, n, a[200005],b[200005];
int main(){
	cin>>k>>n;
	for(int i=1;i<=n;i++){ 
		cin>>a[i];//顺时针坐标轴
		if(a[i]==0) b[i]=a[i]
		else if (a[i]<k/2) b[i]=-a[i];
		else b[i]=k-a[i]; 
	} 
	
	sort(a+1, a+n+1);
	sort(b+1, b+n+1);
	cout<<min(a[n]-a[1], b[n]-b[1]);
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:10:38: error: expected ';' before 'else'
   10 |                 if(a[i]==0) b[i]=a[i]
      |                                      ^
      |                                      ;
   11 |                 else if (a[i]<k/2) b[i]=-a[i];
      |                 ~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>k>>n;
  vector<int> v(n),d(n);
  for(int i=0; i<n; i++)
  {
    cin>>v[i];
  }
  a[0] = v[n-1]-v[0];
  for(int i=1 ; i<n ; i++)
  {
    a[i] = k + v[i-1] - v[i];
  }
  cout<<*max_element(v.begin(),v.end());
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'a' was not declared in this scope
   12 |   a[0] = v[n-1]-v[0];
      |   ^
Language: C++

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

int main()
{
    int K, N, len = 0;
    cin >> K >> N;
    int A[N];
    vector<int> B(N);

    for(int i = 0; i < N; i++){
        cin >> A[i];
        if (i != 0)
        {
            B[i-1] = A[i] - A[i-1];
        }
        
    }

    B[N-1] = K - A[N-1];

    vector<int>::iterator iter = max_element(B.begin(), B.end());
    size_t index = distance(B.begin(), iter);
    for (int i = 0; i < N; i++)
    {
        if (i != index)
        {
            len += B[i];
        }
        
    }

    cout << len << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:34: error: 'max_element' was not declared in this scope
   23 |     vector<int>::iterator iter = max_element(B.begin(), B.end());
      |                                  ^~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>k>>n;
  vector<int> v(n),d(n);
  for(int i=0; i<n; i++)
  {
    cin>>v[i];
  }
  a[0] = v[n-1]-v[0];
  for(int i=1 ; i<n ; i++)
  {
    a[i] = k + v[i-1] - v[i];
  }
  cout<<*max_element(v.begin(),v.end());
  

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'a' was not declared in this scope
   12 |   a[0] = v[n-1]-v[0];
      |   ^
a.cc:17:41: error: expected '}' at end of input
   17 |   cout<<*max_element(v.begin(),v.end());
      |                                         ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include <iostream>
using namespace std;

int main() {
    int K, N;
    cin >> K >> N ;
    int half = K/2;
    int A[N];
    int counter = 0;
    int rem_num[half];
    for(int i=0;i<half;i++)
        rem_num[i] = 0;
    
    for(int i=0; i<N; i++){
        cin >> A[i] ;
        if(A[i]>half){
            A[i] = K-A[i];
        }
        rem_num[A[i]-1] = rem_num[A[i]-1]+1;
    }
    sort(A,A+N);
    counter = (A[N-1]-A[0]);
    for(int i=0;i<half;i++){
        if (rem_num[i]>1) {
            counter = counter + ((rem_num[i]-1)*(i+1));
        }
    }
    cout << counter << endl;
    return 0;
}



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

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

int main()
{
    int K, N, len = 0;
    cin >> K >> N;
    int A[N];
    vector<int> B(N);

    for(int i = 0; i < N; i++){
        cin >> A[i];
        if (i != 0)
        {
            B[i-1] = A[i] - A[i-1];
        }
        
    }

    B[N-1] = K - A[N-1];

    std::vector<int>::iterator iter = std::max_element(B.begin(), B.end());
    size_t index = std::distance(B.begin(), iter);
    for (int i = 0; i < N; i++)
    {
        if (i != index)
        {
            len += B[i];
        }
        
    }

    cout << len << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:44: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   23 |     std::vector<int>::iterator iter = std::max_element(B.begin(), B.end());
      |                                            ^~~~~~~~~~~
      |                                            tuple_element
Language: C++

#include <iostream>
using namespace std;

int main() {
float x=0,y=0,n=0,k=0;

 cin>>k>>n;
 x=k/2;
 int a[n];y=100000000;
 for(int i=0;i<n;i++)
{ cin>>a[i];
 if(a[i]>y)y=a[i];
    
}
 cout<<x;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: conversion from 'float' to 'long unsigned int' in a converted constant expression
    9 |  int a[n];y=100000000;
      |        ^
a.cc:9:8: error: could not convert 'n' from 'float' to 'long unsigned int'
    9 |  int a[n];y=100000000;
      |        ^
      |        |
      |        float
a.cc:9:8: error: size of array 'a' has non-integral type 'float'
Language: C++

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

int main(int argc, const char * argv[]) {
    int round;
    int houses;
    
    cin >> round;
    cin >> houses;
    int array[houses];
    vector<int> meters(houses);
    for (int i = 0; i < houses; i++) {
        cin >> array[i];
    }
    
    for (int j = 0; j < houses; j++) {
        if (j == (houses-1)) {
            meters.at(j) = (array[0] - 0) + (round - array[j]);
        }else{
            meters.at(j) = array[j+1] - array[j];
        }
    }
    int max = *std::max_element(meters.begin(), meters.end());
    cout << round - max <<endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:25:21: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   25 |     int max = *std::max_element(meters.begin(), meters.end());
      |                     ^~~~~~~~~~~
      |                     tuple_element
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
    int main() {
        int K,N;
        cin >> K >> N;
        vector<int> A(N);
        for (int i=0;i<N;i++){
            cin >> A.at(i);
        }
        vector<int> B(N-1);
        for (int i=0;i<N-1;i++){
            B.at(i) = A.at(i+1)-A.at(i);
        }
        sort(B.begin(),B.end());
        reverse(B.begin(),B.end());
        if(B.at(0)>(A.at(0)+K)-A.at(N-1))
        cout << K-B.at(0) << endl;
        else cout << K((A.at(0)+K)-A.at(N-1)) << endl;
    }
  

Compiler output:
a.cc: In function 'int main()':
a.cc:19:23: error: 'K' cannot be used as a function
   19 |         else cout << K((A.at(0)+K)-A.at(N-1)) << endl;
      |                      ~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
  
  int k,n,a;
  cin >> k >> n >> a;
  
  if (a[0]==0){
    cout << k-(a[n-1]-a[1]) << endl;
  }
  
  else {
    cout << a[n-1]-a[0] << endl;
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: invalid types 'int[int]' for array subscript
    9 |   if (a[0]==0){
      |        ^
a.cc:10:17: error: invalid types 'int[int]' for array subscript
   10 |     cout << k-(a[n-1]-a[1]) << endl;
      |                 ^
a.cc:10:24: error: invalid types 'int[int]' for array subscript
   10 |     cout << k-(a[n-1]-a[1]) << endl;
      |                        ^
a.cc:14:14: error: invalid types 'int[int]' for array subscript
   14 |     cout << a[n-1]-a[0] << endl;
      |              ^
a.cc:14:21: error: invalid types 'int[int]' for array subscript
   14 |     cout << a[n-1]-a[0] << endl;
      |                     ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#include <algorithm>

int main()
{
        int K, N;
        cin >> K >> N;
        vector<int> a(N);
        rep(i,N) cin >> a[i];

        int tmp = 0;
        int min = 10000000;
        int max = 0;
        int diff, index, ans, i;

        rep(i,N) {
                if (i == N -1) {
                        diff = K - a[N-1] + a[0];
                } else {
                        diff = a[i+1] - a[i];
                }

                if (diff > max) {
                        max = diff;
        int max = 0;
        int diff, index, ans, i;

        rep(i,N) {
                if (i == N -1) {
                        diff = K - a[N-1] + a[0];
                } else {
                        diff = a[i+1] - a[i];
                }

                if (diff > max) {
                        max = diff;
                        index = i;
                        //cout << max << " " << index << endl;
                }
        }

        int j = 0;
        if (index == N - 1)
                i = 0;
        else
                i = index + 1;
        while (j != N -1) {
                if (i == N -1) {
                        tmp += K - a[N-1] + a[0];
                        i = 0;
                } else {
                        tmp += a[i+1] - a[i];
                }
                j++;
        }
        cout << tmp << endl;

        return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:20:18: note: to match this '{'
   20 |         rep(i,N) {
      |                  ^
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:9:1: note: to match this '{'
    9 | {
      | ^
Language: Java

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

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Unstoppable solver = new Unstoppable();
	//	int t=in.nextInt();
	//	while(t-->0)
        solver.solve(in, out);
        out.close();
    }
 
    static class Unstoppable {
        public void solve(InputReader in, PrintWriter out) {
          int k=in.nextInt();
          int n=in.nextInt();
          int a[]=new int[n];
          int diff[]=new int[n];
          for(int i=0;i<n;i++) a[i]=in.nextInt();
          for(int i=0;i<n-1;i++){ diff[i] = a[i+1] - a[i]; }
          diff[n-1]=k-a[n-1]; sum+=diff[n-1];
          Arrays.sort(diff);
          out.println(k-diff[n-1]);
        }
 
    }

 
    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 long nextLong(){
            return Long.parseLong(next());
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
 

Compiler output:
Main.java:26: error: cannot find symbol
          diff[n-1]=k-a[n-1]; sum+=diff[n-1];
                              ^
  symbol:   variable sum
  location: class Unstoppable
1 error
Language: C++

#include <iostream>
#include <bitset>
using namespace std;
 
const int INF = 100000000; // 十分大きな値
 
/* 入力 */
int N;
int dist[21][21];

/* メモ再帰 */
int dp[(1<<20) + 1][21]; // dpテーブルは余裕をもったサイズにする
int rec(int bit, int v)
{
    // すでに探索済みだったらリターン
    if (dp[bit][v] != -1) return dp[bit][v];
 
    // 初期値
    if (bit == (1<<v)) {
        return dp[bit][v] = 0;
    }
 
    // 答えを格納する変数
    int res = INF;
 
    // bit の v を除いたもの
    int prev_bit = bit & ~(1<<v);
 
    // v の手前のノードとして u を全探索
    for (int u = 0; u < N; ++u) {
        if (!(prev_bit & (1<<u))) continue; // u が prev_bit になかったらダメ
 
        // 再帰的に探索
        if (res > rec(prev_bit, u) + dist[u][v]) {
            res = rec(prev_bit, u) + dist[u][v];
        }
    }
 
    return dp[bit][v] = res; // メモしながらリターン
}
 
int main()
{
  
    // 入力
  int K, N; cin>>K>>N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin>>a[i];
  
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      dist[i][j] = a[i] - a[j];
    }
  }
 
    // テーブルを全部 -1 にしておく (-1 でなかったところは探索済)
  for (int bit = 0; bit < (1<<N); ++bit) for (int v = 0; v < N; ++v) dp[bit][v] = -1;
 
    // 探索
  int res = INF;
  for (int v = 0; v < N; ++v) {
      if (res > rec((1<<N)-1, v)) {
          res = rec((1<<N)-1, v);
      }
  }
  cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:3: error: 'vector' was not declared in this scope
   47 |   vector<int> a(N);
      |   ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <bitset>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:47:10: error: expected primary-expression before 'int'
   47 |   vector<int> a(N);
      |          ^~~
a.cc:48:31: error: 'a' was not declared in this scope
   48 |   for(int i=0; i<N; i++) cin>>a[i];
      |                               ^
a.cc:52:20: error: 'a' was not declared in this scope
   52 |       dist[i][j] = a[i] - a[j];
      |                    ^
Language: C++

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

const int INF = 100000000; // 十分大きな値

/* 入力 */
int N;
int dist[21][21];
vector<int> a;
/* メモ再帰 */
int dp[(1<<20) + 1][21]; // dpテーブルは余裕をもったサイズにする
int rec(int bit, int v)
{
    // すでに探索済みだったらリターン
    if (dp[bit][v] != -1) return dp[bit][v];

    // 初期値
    if (bit == (1<<v)) {
        return dp[bit][v] = 0;
    }

    // 答えを格納する変数
    int res = INF;

    // bit の v を除いたもの
    int prev_bit = bit & ~(1<<v);

    // v の手前のノードとして u を全探索
    for (int u = 0; u < N; ++u) {
        if (!(prev_bit & (1<<u))) continue; // u が prev_bit になかったらダメ

        // 再帰的に探索
        if (res > rec(prev_bit, u) + dist[u][v]) {
            res = rec(prev_bit, u) + dist[u][v];
        }
    }

    return dp[bit][v] = res; // メモしながらリターン
}

int main()
{
  
    // 入力
  int K, N; cin>>K>>N;
  for(int i=0; i<N; i++) cin>>a[i];
  
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      dist[i][j] = a[i] - a[j];
    }
  }

    // テーブルを全部 -1 にしておく (-1 でなかったところは探索済)
  for (int bit = 0; bit < (1<<N); ++bit) for (int v = 0; v < N; ++v) dp[bit][v] = -1;

    // 探索
  int res = INF;
  for (int v = 0; v < N; ++v) {
      if (res > rec((1<<N)-1, v)) {
          res = rec((1<<N)-1, v);
      }
  }
  cout << res << endl;
}

Compiler output:
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<int> a;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:47:31: error: 'a' was not declared in this scope
   47 |   for(int i=0; i<N; i++) cin>>a[i];
      |                               ^
a.cc:51:20: error: 'a' was not declared in this scope
   51 |       dist[i][j] = a[i] - a[j];
      |                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int K,N,b,ans;
  int max=0;
  cin>>K>>N;

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  for(int i=0;i<N-1;i++){
    int a=vec.at(i)-vec.at(i+1);
    if(a>max){
      max=a;
    }
  }
  int a=k-vec.at(N-1)+vec.at(0);
  if(a>max){
    max=a;
  }
  ans=K-max;
  cout<<ans<<endl;
  
}




Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'k' was not declared in this scope
   19 |   int a=k-vec.at(N-1)+vec.at(0);
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
	int k,n;
	int a[200010];
	cin >> k >> n;
	int ans = 0;
	cin >> a[0];
	for(int i = 1; i < n; i++){
		cin >> a[i];
		ans = max(ans,a[i]-a[i-1]);
	}
	ans = max(ans,(k - a[n-1]) + a[0])
	cout << k-ans << endl;
    return 0;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:43: error: expected ';' before 'cout'
   13 |         ans = max(ans,(k - a[n-1]) + a[0])
      |                                           ^
      |                                           ;
   14 |         cout << k-ans << endl;
      |         ~~~~
Language: C++

#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int x, k, n, s1, s;
int a[100001];
int main()
{
    //freopen("test.inp","r", stdin);
    cin >> k >> n;
    a[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s += a[i]-a[i-1];
    }
    s -= a[i];
    if (a[1] == 0) a[1] = k;
    for (int i = 1; i <= n; i++)
    {
        s = min(s, s+abs(a[1]-a[n])-(a[i+1]-a[i]));
    }
    cout << s;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:12: error: 'i' was not declared in this scope
   17 |     s -= a[i];
      |            ^
Language: C

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

int main(void) {
  int k, n, i, j, tmp;

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

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

  for(i=0; i < n; i++){
    for(j=i + 1; j < n; ++j){
      if(a[i] > a[j]){
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
    }
  }

Compiler output:
main.c: In function 'main':
main.c:22:3: error: expected declaration or statement at end of input
   22 |   }
      |   ^
Language: C++

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

int minimum(int a,int b,int c,int d)
  return min((d - (b - a)),(d - (c - b));
  
int main(){
  int k,n;
  cin >> k >> n;
  vector<int> A[n];
  
  for(int i=0;i<n;++i){
    cin >> A[i];
  }
  
  int answer=0;
  for(int j=0,j<N-2;++j){
    if (answer > minimum(A[j],A[j+1],A[j+2],k));
      answer = minimum(A[j],A[j+1],A[j+2],k);
  }
  if (answer > min(k-A[n-1]+A[n-2],A[n-1]-A[0])){
    answer = min(k-A[n-1]+A[n-2],A[n-1]-A[0]);
  }
  cout << answer << endl;
}

Compiler output:
a.cc:1:10: 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 main() {
  
  int K, N;
  cin >> k >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int time_min;
  
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    if (i == 0){
      B.at(i) = A.at(i) + K - A.at(N - 1);
    }
    else {
      B.at(i) = A.at(i) - A.at(i - 1);
    }
  }
  
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    C.at(i) = K - B.at(i);
  }
  
  sort (C.begin(), C.end());
  
  cout << C.at(0) << endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: 'k' was not declared in this scope
    7 |   cin >> k >> N;
      |          ^
Language: Java

import java.util.*;

/*
問題文


*/

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

        Scanner sc = new Scanner(System.in);
        long k = sc.nextInt();
        long n = sc.nextInt();
        long[] a;

        for (int i = 0; i < n; i ++) {
            a[i] = sc.nextInt();
            if (k/2 <= a[i]) {
                a[i] = a[i] - k/2;
            }
        }

        Arrays.sort(a);
        System.out.println(Math.abs(a[0]) + Math.abs(a[(int)n-1]));
    }
}

Compiler output:
Main.java:18: error: variable a might not have been initialized
            a[i] = sc.nextInt();
            ^
Main.java:24: error: variable a might not have been initialized
        Arrays.sort(a);
                    ^
2 errors
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:18:44: error: expected ')' before ';' token
   18 |         mx = max(mx,a.at(0) + k - a.at(n-1);
      |                 ~                          ^
      |                                            )
Language: C++

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

int main() {
  int K,N;
  cin >> K >>N;
  vector<int> A(N);

  for (int i = 0; i < N; i++) {
    cin >> N.at(i);
  }
  
  int B=N.at(N)-N.at(1);
  cin >> B;
  int C=N.at(2)+K-N.at(N);
  cin >> C;
  
  if (B>C){
    cout << C <<endl;
  }
  else {
    cout << B <<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: request for member 'at' in 'N', which is of non-class type 'int'
   10 |     cin >> N.at(i);
      |              ^~
a.cc:13:11: error: request for member 'at' in 'N', which is of non-class type 'int'
   13 |   int B=N.at(N)-N.at(1);
      |           ^~
a.cc:13:19: error: request for member 'at' in 'N', which is of non-class type 'int'
   13 |   int B=N.at(N)-N.at(1);
      |                   ^~
a.cc:15:11: error: request for member 'at' in 'N', which is of non-class type 'int'
   15 |   int C=N.at(2)+K-N.at(N);
      |           ^~
a.cc:15:21: error: request for member 'at' in 'N', which is of non-class type 'int'
   15 |   int C=N.at(2)+K-N.at(N);
      |                     ^~
Language: C++

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

int main() {
  int K, N;
  cin >> K >> N;
  int arr[N];
  for (int i=0; i<N; i++) cin >> arer[i];
  sort(arr, arr+N);
  int difference[N+1];
  for (int i=0; i<N; i++) {
    if (i == 0) difference[i] = arr[N]-arr[0];
    else difference[i] = arr[i+1]-arr[i];
  } sort(difference, difference+N+1);
  long long total = 0;
  for (int i=0; i<N; i++) total += difference[i];
  cout << total;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:34: error: 'arer' was not declared in this scope; did you mean 'arr'?
    8 |   for (int i=0; i<N; i++) cin >> arer[i];
      |                                  ^~~~
      |                                  arr
Language: Java

import java.util.*;

/*
問題文


*/

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

        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        long n = sc.nextLong();
        long[] a;

        for (int i = 0; i < n; i ++) {
            a[i] = sc.nextInt();
            if (k/2 <= a[i]) {
                a[i] = a[i] - k/2;
            }
        }

        Arrays.sort(a);
        System.out.println(Math.abs(a[0]) + Math.abs(a[(int)n-1]));
    }
}

Compiler output:
Main.java:18: error: variable a might not have been initialized
            a[i] = sc.nextInt();
            ^
Main.java:24: error: variable a might not have been initialized
        Arrays.sort(a);
                    ^
2 errors
Language: C++

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

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    a.push_front(0);
    a.push_back(k);

    vector<int> distance(n);

    for (int i = 0; i < n+1; i++){
        distance[i] = a[i+1] - a[i];
    }

    sort(distance.begin(), distance.end());
    cout << k - distance[n] - distance[0] << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:7: error: 'class std::vector<int>' has no member named 'push_front'
    9 |     a.push_front(0);
      |       ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
        int k,n;
        cin >> k>> n;
        int arr[n];
        for(int i = 0; i< n; i++)
        {
                cin >>arr[i];
        }
        int ans;
        if(k/2 < arr[n-1] - arr[n-2])
        {
                ans =arr[n-2]
                ans += k-arr[n-1];
        }
        else
        {
                ans = arr[n-1] - arr[0];
        }
        cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:30: error: expected ';' before 'ans'
   15 |                 ans =arr[n-2]
      |                              ^
      |                              ;
   16 |                 ans += k-arr[n-1];
      |                 ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define fastIO                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10002
#define MOD 1000000007
#define PI 3.14159265358979323846
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> pr_int;


int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int&x:a) cin >> x;
	sort(all(a))
	cout << max(a[n-1]-a[n-2], a[n-2]);
	
	cout << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:21: error: expected ';' before 'cout'
   30 |         sort(all(a))
      |                     ^
      |                     ;
   31 |         cout << max(a[n-1]-a[n-2], a[n-2]);
      |         ~~~~
Language: Java

import java.util.*;
         
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            int around = Integer.parseInt(sc.next());
            int house = Integer.parseInt(sc.next());

            ArrayList<Integer> houseDis = new List<Integer>();
            for(int i = 0; i < house; i++){
                houseDis.add(Integer.parseInt(sc.next()));
            }

            int maxDis = 0;
            int startPoint = 0;

            for(int j = 0; j < house; j++){
                if(j == house - 1){
                    int dis = (around + houseDis.get(0)) - houseDis.get(j);
                    if(dis > maxDis){
                        maxDis = dis;
                        startPoint = 0;
                    }
                }else{
                    int dis = houseDis.get(j + 1) - houseDis.get(j);
                    if(dis > maxDis){
                        maxDis = dis;
                        startPoint = j;
                    }
                }
            }

            System.out.println(around - maxDis);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Compiler output:
Main.java:11: error: List is abstract; cannot be instantiated
            ArrayList<Integer> houseDis = new List<Integer>();
                                          ^
1 error
Language: C++

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

long main() {
    long K, N;
    long M = N-1;
    cin >> K;
    cin >> N;
    vector<long> vec(N);
    for (long i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    cout << vec.at(M) << endl;
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

int main() {
  int k,n;
  cin >> k >> n;
  for(int i=0; i<n; i++) cin >> vec[i];
  cout << k/(n-1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:33: error: 'vec' was not declared in this scope
    7 |   for(int i=0; i<n; i++) cin >> vec[i];
      |                                 ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int n, k;
int a[200005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> k >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int Ans = a[n] - a[1];
    for (int i = 2; i <= n; i++)
    {
        Ans = min(Ans, k - (a[i] - a[i - 1]));
    }
    cout << Ans;
    re

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 're' was not declared in this scope
   24 |     re
      |     ^~
a.cc:24:7: error: expected '}' at end of input
   24 |     re
      |       ^
a.cc:9:1: note: to match this '{'
    9 | {
      | ^
Language: C++

#include <iostream>
 
using namespace std;
 
int max_house_gap(int K, int Num, int *house){
  int *gaps = new int[Num];
  for(int i = 0; i < Num; i++){
    if(i == Num-1){
      gaps[i] = house[0] + K - house[Num-1];
    }
    gaps[i] = house[i+1] - house[i];
  }
  int maxgap = 0;
  for(int i = 0; i < Num; i++){
    if(gaps[i] > maxgap){
      maxgap = gaps[i];
    }
  }
  return maxgap;
}
 
int main(){
  int K,N;
  cin >> K;
  cin >> N;
  int *A = new int[N];
  for(int i = 0; i < N ; i++){
    cin >> A[i];
  }
  
  //家の間の最大値を求める。
  int gap = max_house_gap();
  
  cout << K - gap << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:26: error: too few arguments to function 'int max_house_gap(int, int, int*)'
   32 |   int gap = max_house_gap();
      |             ~~~~~~~~~~~~~^~
a.cc:5:5: note: declared here
    5 | int max_house_gap(int K, int Num, int *house){
      |     ^~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
typedef vector<vector<ll> > mat;
#define nl "\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size() 


void solve() {
	ll n ,k; cin>>n>>k;
	vll a(k) rep(k) cin>>a[i];
	sort(a.begin(),a.end());
	rep(k) {
		if(a[i]>n/2) a[i] -=n ; 
	}
	sort(a.begin(),a.end());
	ll mid = a[k/2] ; 
	ll s=0;
	for(ll i=mid;i<k-1;++i) s = s + a[i+1]-a[i];
	for(ll i=mid-1;i>0;--i) s = s + a[i] - a[i-1] ;
	cout << s ;
}


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

	ll t=1;
	// cin>>t;
	rep(t) {
		solve() ; 
	}
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:11:16: error: expected ',' or ';' before 'for'
   11 | #define rep(n) for(ll i = 0 ; i<n ; i++)
      |                ^~~
a.cc:27:18: note: in expansion of macro 'rep'
   27 |         vll a(k) rep(k) cin>>a[i];
      |                  ^~~
a.cc:11:31: error: 'i' was not declared in this scope
   11 | #define rep(n) for(ll i = 0 ; i<n ; i++)
      |                               ^
a.cc:27:18: note: in expansion of macro 'rep'
   27 |         vll a(k) rep(k) cin>>a[i];
      |                  ^~~
Language: C++

#include <iostream>
#include <string>
#include <math.h>
#include <cctype>
using namespace std;
int a[1000000];
int answer[1000000];
int main(){
    int n;
    int k;
    long long x;
    cin >> k >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i]
    }
    for(int i=1;i<=n;i++){
        if(i==1){
            if(k-a[n]+a[i] >= a[i+1]-a[i]){
                answer[i] = a[n]-a[i];
            }
            else{
                answer[i] = k - (a[i+1] - a[i]);
            }
        }
        else if(i==n){
            if(k-a[n]+a[1] >= a[i]-a[i-1]){
                answer[i] = a[n]-a[1];
            }
            else{
                answer[i] = k - (a[i] - a[i-1]);
            }
        }
        else{
            if(a[i]-a[i-1] >= a[i+1]-a[i]){
                answer[i] = k - (a[i] - a[i-1]);
            }
            else{
                answer[i] = k - (a[i+1] - a[i]);
            }
        }
    }
    answer[0] = k+1;
    for(int i=1;i<=n;i++){
        if(answer[i] < answer[i-1]){
            x = answer[i];
        }
    }
    cout << x << endl;

    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:20: error: expected ';' before '}' token
   14 |         cin >> a[i]
      |                    ^
      |                    ;
   15 |     }
      |     ~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n,k,i,mx=0,p;
  cin>>k>>n;
  vector<int> V(n);
  for(i=0;i<n;i++)
    cin>>V[i];
  sort(V.begin(),V.end());
  for(i=0;i<n-1;i++)
  {
    if(mx<V[i+1]-V[i])
      mx=V[i+1]-V[i];
  }
  p=V[n-1]-V[0];
  p=k-p;
  mx=max(mx,p);
  cout<<k-mx;
}

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

int main() {
    int K, N;
    int M = N-1;
    cin >> K;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    cout << vec.at(M) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> K;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> vec(N);
      |     ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> vec(N);
      |            ^~~
a.cc:8:16: error: 'vec' was not declared in this scope
    8 |         cin >> vec.at(i);
      |                ^~~
a.cc:10:10: error: 'vec' was not declared in this scope
   10 |     sort(vec.begin(), vec.end());
      |          ^~~
a.cc:10:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |     sort(vec.begin(), vec.end());
      |     ^~~~
      |     short
a.cc:11:5: error: 'cout' was not declared in this scope
   11 |     cout << vec.at(M) << endl;
      |     ^~~~
a.cc:11:26: error: 'endl' was not declared in this scope
   11 |     cout << vec.at(M) << endl;
      |                          ^~~~