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

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

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int max_house_gap(int, int, int*)':
a.cc:6:15: error: expected ';' before 'gaps'
    6 |   new int[Num] gaps;
      |               ^~~~~
      |               ;
a.cc:9:7: error: 'gaps' was not declared in this scope
    9 |       gaps[i] = house[0] + K - house[Num-1];
      |       ^~~~
a.cc:11:5: error: 'gaps' was not declared in this scope
   11 |     gaps[i] = house[i+1] - house[i];
      |     ^~~~
a.cc:15:8: error: 'gaps' was not declared in this scope
   15 |     if(gaps[i] > maxgap){
      |        ^~~~
a.cc: In function 'int main()':
a.cc:24:3: error: 'cin' was not declared in this scope
   24 |   cin >> K;
      |   ^~~
a.cc:26:13: error: expected ';' before 'A'
   26 |   new int[N] A;
      |             ^~
      |             ;
a.cc:28:12: error: 'A' was not declared in this scope
   28 |     cin >> A[i];
      |            ^
a.cc:32:31: error: 'A' was not declared in this scope
   32 |   int gap = max_house_gap(K,N,A);
      |                               ^
a.cc:34:3: error: 'cout' was not declared in this scope
   34 |   cout << K - gap << endl;
      |   ^~~~
a.cc:34:22: error: 'endl' was not declared in this scope
   34 |   cout << K - gap << endl;
      |                      ^~~~
Language: C++

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

int main(){

    int K, N;
    cin >> K >> N;


    vector<int> dis(N);
    for (auto& val : dis)
        cin >> val;


    int maximum = INT_MIN;
    for (int i = 1; i < N; i++)
        maximum = max(maximum, dis[i]-dis[i-1]);
    maximum = max(maximum, K-dis[N-1]+dis[0]);

    cout << K-maximum << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:19: error: 'INT_MIN' was not declared in this scope
   16 |     int maximum = INT_MIN;
      |                   ^~~~~~~
a.cc:3:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include <iostream>
 
using namespace std;
 
int max_house_gap(int K, int Num, int *house){
  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;
  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 max_house_gap(int, int, int*)':
a.cc:6:3: error: 'gaps' was not declared in this scope
    6 |   gaps = new int[Num];
      |   ^~~~
a.cc: In function 'int main()':
a.cc:26:3: error: 'A' was not declared in this scope
   26 |   A = new int[N];
      |   ^
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>
using namespace std;

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:7:13: error: expected ';' before 'cin'
    7 |     cin >> K
      |             ^
      |             ;
    8 |     cin >> N;
      |     ~~~
Language: C++

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

int main() {
  
  int K, N;
  
  // 100要素の配列で初期化
  vector<int> A(N);

  // 100個の入力を受け取る
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

   vector<int> B(N);
  
   for (int j = 0; j < N-1 ; j++) {
   B.at(j) = A.at(i+1) - A.at(i);
  }
  
  B.at(N-1) = K - A.at(N-1);
  
  int max;
  
  for (int k = 0; k < N-1; k++) {
  if (B.at(k) >= B.at(k+1)){
    max = B.at(k);
  }
  else{
    max = B.at(k+1);
  }
  
    cout << K - max << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: 'i' was not declared in this scope
   19 |    B.at(j) = A.at(i+1) - A.at(i);
      |                   ^
a.cc:36:2: error: expected '}' at end of input
   36 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define re register
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define lb long double
const int N=1e6+10;
const int mod=10086;
const int mod2=19260811;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int a[N];
int main()
{
    int k,n;
    read(k),read(n);
    for(re int i=1;i<=n;i++) read(a[i]);
    int maxn=a[1]+k-a[n];
    for(re int i=2;i<=n;i++) maxn=max(maxn,a[i]-a[i-1]);
    printf("%d\n",k-maxn)
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   30 |     for(re int i=1;i<=n;i++) read(a[i]);
      |                ^
a.cc:32:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |     for(re int i=2;i<=n;i++) maxn=max(maxn,a[i]-a[i-1]);
      |                ^
a.cc:33:26: error: expected ';' before 'return'
   33 |     printf("%d\n",k-maxn)
      |                          ^
      |                          ;
   34 |     return 0;
      |     ~~~~~~
Language: Java

import java.util.Scanner;
public class ABC_042_A {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int max = 0;
        int stac = 0;
        int first = sc.nextInt();
        int next = 0;
        stac = first;
        for(int i=0;i<n-1;i++){
            next = sc.nextInt();
            if((next - first)>max){
                max = next - first;                
            }
            first = next;
        }
        if((k + stac - next)>max){
            max = k + stac - next;
        }
        sc.close();
        System.out.println(max);
    }
}

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

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll K,N,ans=INF;
  cin>>K>>N;
  ll A[2*N+1],;
  RREP(i,N) cin>>A[i];
  for(int i=N+1; i<=2*N; ++i) A[i]=A[i-N]+K;
  
  for(int i=1; i<=N; ++i){
    ll T=A[i+N-1]-A[i];
    if(ans>T) ans=T;
  }
  
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:15: error: expected unqualified-id before ';' token
   34 |   ll A[2*N+1],;
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, N;
  cin >> K >> N;
  vector<int> q(N);
  for(int i = 0; i < N; i++) {
    cin >> q.at(i);
  }
  longlong w = K - q.at(N - 1) + q.at(0);
  int e = w;
  for(int i = 0; i < N - 1; i++) {
    w += q.at(i + 1) - q.at(i);
    if(K - q.at(N - 1) + q.at(0) < q.at(i + 1) - q.at(i)) {
      e = q.at(i + 1) - q.at(i);
    }
  }
  cout << w - e << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'longlong' was not declared in this scope
   11 |   longlong w = K - q.at(N - 1) + q.at(0);
      |   ^~~~~~~~
a.cc:12:11: error: 'w' was not declared in this scope
   12 |   int e = w;
      |           ^
Language: C++

#include <iostream>
using namespace std;
int main(){
  long long k, n;
  cin >> k >> n;
  int b;
  b = n-1;
  long long a[b], c[b];
  for(int i=0; i<n; ++i) {
    cin >> a[i];
  }
  for(int j=0; j<n; ++j) {
    if(j<n-1) {
      b[j] = a[j+1] - a[j];
    }
    if(j==n-1) {
      b[j] = k-a[j+1]+a[j];
    }
  }
  long long max, s;
  max = b[0];
  s=0;
  for(int m=1; m<n; ++m) {
    if(max<b[m]) { 
      max = b[m];
    }
  }
  s = k - max;
  cout << s << endl;
}

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

#include <iostream>

using namespace std;

int max_house_gap(int K, int Num, int *house){
  new int[Num] gaps;
  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;
  new int[N] A;
  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 max_house_gap(int, int, int*)':
a.cc:6:15: error: expected ';' before 'gaps'
    6 |   new int[Num] gaps;
      |               ^~~~~
      |               ;
a.cc:9:7: error: 'gaps' was not declared in this scope
    9 |       gaps[i] = house[0] + K - house[Num-1];
      |       ^~~~
a.cc:11:5: error: 'gaps' was not declared in this scope
   11 |     gaps[i] = house[i+1] - house[i];
      |     ^~~~
a.cc:15:8: error: 'gaps' was not declared in this scope
   15 |     if(gaps[i] > maxgap){
      |        ^~~~
a.cc: In function 'int main()':
a.cc:26:13: error: expected ';' before 'A'
   26 |   new int[N] A;
      |             ^~
      |             ;
a.cc:28:12: error: 'A' was not declared in this scope
   28 |     cin >> A[i];
      |            ^
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 <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void){
  int K,N;
  scanf("%d %d\n",&K,&N);
  if((K>=2 && K<=1000000) && (N>=2 && N<=200000))
  {
    int A[N];
    int i;
    scnaf("%d ",&A[0]);
    if(A[0]<0 || A[0]>=K)
      return 0;
    for(i=1;i<N;i++)
    {
      scanf("%d ",&A[i]);
      if((A[i]<0 || A[i]>=K) || A[i]<=A[i-1])
        return 0;
    }
    int B[N],max=0;
    for(i=0;i<N-1;i++)
    {
      B[i]=A[i+1]-A[i];
      if(B[i]>max)
        max=B[i];
    }
    B[N-1]=A[N-1]-A[0];
    if(B[N-1]>max)
      max=B[N-1];
    int r=K-max;
    printf("%d",r);
  }
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:12:5: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   12 |     scnaf("%d ",&A[0]);
      |     ^~~~~
      |     scanf
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int K,N,sum;
  cin>>K>>N;
  int A[N]:
  cin>>A;
  if(A[N-1]-A[N-2]>=K-A[N-1])
  {
    sum=K-A[N-1]+A[N-2];
  }
  else
  {
    sum=A[N-1]-A[0];
  }
     cout<<sum<<endl;
      return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: expected initializer before ':' token
    7 |   int A[N]:
      |           ^
a.cc:9:6: error: 'A' was not declared in this scope
    9 |   if(A[N-1]-A[N-2]>=K-A[N-1])
      |      ^
Language: Java

import java.util.*;
public 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 sum1=arr[0];
    for(int i=1;i<n;i++){
      sum1 = sum1+arr[i]-arr[i-1];
    }
    int sum2 = (k-arr[arr.length-1])+arr[0];
    for(int i=1;i<n-1;i++){
      sum2 = sum2+arr[i]-arr[i-1];
    }
    System.out.println(Math.min(sum1,sum2));
  }
}

Compiler output:
Main.java:2: error: class, interface, enum, or record expected
public Main{
       ^
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
  public static void main(String[] args){
                ^
  (use --enable-preview to enable unnamed classes)
Main.java:21: error: class, interface, enum, or record expected
}
^
3 errors
Language: C++

#include<bits/stdc++.h>
using namespace std
int main(){
	int n;
  ll k;
  cin >> k >> n;
  vector<ll>  a(n);
  for(auto &i: a)cin >> i;
  sort(a.begin(),a.end());
  ll ans = min({a[n-1]-a[0],a[0]+(k-a[n-1])};
  for(int i = 1; i < n; ++i)ans = min(ans,a[i]-a[i-1]);
  cout << ans;
  return 0;
}


Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
    3 | int main(){
      | ~~~                 
a.cc: In function 'int main()':
a.cc:5:3: error: 'll' was not declared in this scope
    5 |   ll k;
      |   ^~
a.cc:6:10: error: 'k' was not declared in this scope
    6 |   cin >> k >> n;
      |          ^
a.cc:7:12: error: template argument 2 is invalid
    7 |   vector<ll>  a(n);
      |            ^
a.cc:8:16: error: 'begin' was not declared in this scope
    8 |   for(auto &i: a)cin >> i;
      |                ^
a.cc:8:16: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:8:16: error: 'end' was not declared in this scope
    8 |   for(auto &i: a)cin >> i;
      |                ^
a.cc:8:16: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:9:10: error: request for member 'begin' in 'a', which is of non-class type 'int'
    9 |   sort(a.begin(),a.end());
      |          ^~~~~
a.cc:9:20: error: request for member 'end' in 'a', which is of non-class type 'int'
    9 |   sort(a.begin(),a.end());
      |                    ^~~
a.cc:10:5: error: expected ';' before 'ans'
   10 |   ll ans = min({a[n-1]-a[0],a[0]+(k-a[n-1])};
      |     ^~~~
      |     ;
a.cc:11:29: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |   for(int i = 1; i < n; ++i)ans = min(ans,a[i]-a[i-1]);
      |                             ^~~
      |                             abs
a.cc:11:44: error: invalid types 'int[int]' for array subscript
   11 |   for(int i = 1; i < n; ++i)ans = min(ans,a[i]-a[i-1]);
      |                                            ^
a.cc:11:49: error: invalid types 'int[int]' for array subscript
   11 |   for(int i = 1; i < n; ++i)ans = min(ans,a[i]-a[i-1]);
      |                                                 ^
a.cc:12:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |   cout << ans;
      |           ^~~
      |           abs
Language: C++

#include<iostream>
using namespace std;

int main(){
  int K,N,buffer;
  cin >> K >> N;
  int A[N],B[N];
  for(int i=0;i<N;i++){
    cin >>A[i];
  }

  for(int i=0;i<N;i++){
    if(i==0){
      B[0]=K-A[N-1]+A[0];
      continue;
    }
    B[i]=A[i]-A[i-1];
  }
  sort(B,B+N);
  cout << K-B[N-1];

  return 0;
}


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

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

int max(int a,int b){
    return a<b ? b :a;
}

int main(){
    int k,n,a[1000010],i,m;
    cin >> k >> n;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++){
        m=max(m,a[i+1]-a[i]);
    }
    cout << k-(max(m,k-a[n-1]+a[0]) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:37: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   17 |     cout << k-(max(m,k-a[n-1]+a[0]) << endl;
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
a.cc:17:44: error: expected ')' before ';' token
   17 |     cout << k-(max(m,k-a[n-1]+a[0]) << endl;
      |               ~                            ^
      |                                            )
Language: C

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void){
  int K,N;
  scnaf("%d %d\n",&K,&N);
  if((K>=2 && K<=1000000) && (N>=2 && N<=200000))
  {
    int A[N];
    int i;
    scnaf("%d ",&A[0]);
    if(A[0]<0 || A[0]>=K)
      return 0;
    for(i=1;i<N;i++)
    {
      scanf("%d ",&A[i]);
      if((A[i]<0 || A[i]>=K) || A[i]<=A[i-1])
        return 0;
    }
    int B[N],max=0;
    for(i=0;i<N-1;i++)
    {
      B[i]=A[i+1]-A[i];
      if(B[i]>max)
        max=B[i];
    }
    B[N-1]=A[N-1]-A[0];
    if(B[N-1]>max)
      max=B[N-1];
    int r=K-max;
    printf("%d",r);
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:3: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    7 |   scnaf("%d %d\n",&K,&N);
      |   ^~~~~
      |   scanf
Language: Java

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(System.in));
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int len = sc.nextInt();
            int n = sc.nextInt();
            int[] distances = new int[n];
            for (int i = 0; i < n; ++i) {
                distances[i] = sc.nextInt();
            }
            int[] distanceFromPrev = new int[n];
            distanceFromPrev[0] = len - distances[n - 1] + distances[0];
            int max = distanceFromPrev[0];
            for (int i = 1; i < n; ++i) {
                distanceFromPrev[i] = distances[i] - distances[i - 1];
                max = Math.max(max, distanceFromPrev[i]);
            }
            System.out.println(len - max);
        }
    }
}


Compiler output:
Main.java:7: error: incompatible types: InputStream cannot be converted to Reader
        Scanner sc = new Scanner(new BufferedReader(System.in));
                                                          ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C++

#include<iostream>
#include<string>

using namespace std;
 
int main(){
 
  int k, n;
  cin >> k >> n;

  int minA = INT_MAX, maxA = -1, temp, maxdiff = -1, A[n];

  for (int i = 0; i < n; ++i){
	  cin >> temp;
	  A[i] = temp;
	  if (i > 0)
	  maxdiff = max(maxdiff, A[i] - A[i - 1]);
	  minA = min(minA, temp);
	  maxA = max(maxA, temp);
  }

  int mindist = min(maxA - minA, k - (maxdiff) );
  cout << mindist << '\n';
  
  return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: 'INT_MAX' was not declared in this scope
   11 |   int minA = INT_MAX, maxA = -1, temp, maxdiff = -1, A[n];
      |              ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | #include<string>
a.cc:14:18: error: 'temp' was not declared in this scope; did you mean 'tm'?
   14 |           cin >> temp;
      |                  ^~~~
      |                  tm
a.cc:15:11: error: 'A' was not declared in this scope
   15 |           A[i] = temp;
      |           ^
a.cc:17:11: error: 'maxdiff' was not declared in this scope
   17 |           maxdiff = max(maxdiff, A[i] - A[i - 1]);
      |           ^~~~~~~
a.cc:19:11: error: 'maxA' was not declared in this scope
   19 |           maxA = max(maxA, temp);
      |           ^~~~
a.cc:22:21: error: 'maxA' was not declared in this scope
   22 |   int mindist = min(maxA - minA, k - (maxdiff) );
      |                     ^~~~
a.cc:22:39: error: 'maxdiff' was not declared in this scope
   22 |   int mindist = min(maxA - minA, k - (maxdiff) );
      |                                       ^~~~~~~
Language: C++

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

int max(int a,int b){
    return a<b ? b :a;
}

int main(){
    int k,n,a[1000010],i,m;
    cin >> k >> n;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
        m=max(m,a[i+1]-a[i]);
    }
    cout << k-(max(m,k-a[n-1]+a[0]) << endl;
    return 0;
}

Compiler output:
a.cc:17:5: error: 'cout' does not name a type
   17 |     cout << k-(max(m,k-a[n-1]+a[0]) << endl;
      |     ^~~~
a.cc:18:5: error: expected unqualified-id before 'return'
   18 |     return 0;
      |     ^~~~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: Java

import java.util.Scanner;

public class C {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
    Scanner scn= new Scanner(System.in);
    long k=scn.nextLong();
    int n =scn.nextInt();
    long [] arr =new long[n];
    for(int i=0;i<n;i++){
    	arr[i]=scn.nextLong();
    	
    }
    long max=arr[0];
    for(int i=1;i<arr.length;i++){
      max=Math.max(Math.abs(arr[i-1]-arr[i]),max);
      
    }
    System.out.println(k-max);
    }

}

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

using namespace std;
int main(){
  int k,n,c=0,c_max=0;
  cin>>k>>n;
  vector<int> p(n+1);
  p[0]=0;
  for(int i=1;i<n+1;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    if(abs(p[i+1]-p[i])>c){
      c_max=abs(p[i+1]-p[i]);
    }
  }
  cout<<k-c_max<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin>>k>>n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> p(n+1);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> p(n+1);
      |          ^~~
a.cc:6:3: error: 'p' was not declared in this scope
    6 |   p[0]=0;
      |   ^
a.cc:11:8: error: 'abs' was not declared in this scope
   11 |     if(abs(p[i+1]-p[i])>c){
      |        ^~~
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout<<k-c_max<<endl;
      |   ^~~~
a.cc:15:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:18: error: 'endl' was not declared in this scope
   15 |   cout<<k-c_max<<endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int K,N,sum;
  cin>>K>>N;
  int A[N]:
  cin>>A;
  if(A[N-1]-A[N-2]>=K-A[N-1])
  {
    sum=K-A[N-1]+A+A[N-2}
  }
  else
  {
    sum=A[N-1]-A[0];
  }
     cout<<sum<<endl;
      return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: expected initializer before ':' token
    7 |   int A[N]:
      |           ^
a.cc:9:6: error: 'A' was not declared in this scope
    9 |   if(A[N-1]-A[N-2]>=K-A[N-1])
      |      ^
a.cc:11:25: error: expected ']' before '}' token
   11 |     sum=K-A[N-1]+A+A[N-2}
      |                         ^
      |                         ]
a.cc: At global scope:
a.cc:13:3: error: expected unqualified-id before 'else'
   13 |   else
      |   ^~~~
a.cc:17:6: error: 'cout' does not name a type
   17 |      cout<<sum<<endl;
      |      ^~~~
a.cc:18:7: error: expected unqualified-id before 'return'
   18 |       return 0;
      |       ^~~~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: C++

clude<bits/stdc++.h>
using namespace std;
int main()
{
  int k,n;
  cin>>k>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  int maxv = 0;
  for(int i = 1;i<n;i++)
  {
    if(maxv<(a[i]-a[i-1]))
    {
         maxv = (a[i]-a[i-1]);
    }
  }
  a[0]+=k;
  if(maxv<(a[0]-a[n-1]))
  {
  	maxv = a[0]-a[n-1];
  }
  cout<<(k-maxv);
  return 0;
}

Compiler output:
a.cc:1:1: error: 'clude' does not name a type
    1 | clude<bits/stdc++.h>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin>>k>>n;
      |   ^~~
a.cc:8:29: error: 'arr' was not declared in this scope
    8 |   for(int i=0;i<n;i++) cin>>arr[i];
      |                             ^~~
a.cc:22:3: error: 'cout' was not declared in this scope
   22 |   cout<<(k-maxv);
      |   ^~~~
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 = new long[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);
    long ans = 10000000;
    for(int i = 0; i < n-1; i++){
      int temp = a[n-1] - a[i];
      if(temp < ans){
        ans = temp;
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:7: error: incompatible types: possible lossy conversion from long to int
    long[] a = new long[n];
                        ^
Main.java:14: error: incompatible types: possible lossy conversion from long to int
      int temp = a[n-1] - a[i];
                    ^
Main.java:14: error: incompatible types: possible lossy conversion from long to int
      int temp = a[n-1] - a[i];
                        ^
3 errors
Language: C++

using namespace std;
typedef long long ll;

int main() {
  int K,N;
  int A[10],dif,max;
  cin >> K >>N;
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  max = (K - A[N-1]) + A[0];
  for(int i = 0; i < N; i++){
    if(A[i+1]-A[i] > max){
      max = A[i+1] - A[i];
    }
  }
  cout << K - max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> K >>N;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:17:3: error: 'cout' was not declared in this scope
   17 |   cout << K - max << endl;
      |   ^~~~
a.cc:17:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:22: error: 'endl' was not declared in this scope
   17 |   cout << K - max << endl;
      |                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

using namespace std;
int main(){
  int k,n,c=0,c_max=0;
  cin>>k>>n;
  vector<int> p(n+1);
  p[0]=0;
  for(int i=1;i<n+1;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    if(abs(p[i+1]-p[i])>c){
      c_max=abs(p[i+1]-p[i]);
    }
  }
  cout<<k-c_max<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin>>k>>n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> p(n+1);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> p(n+1);
      |          ^~~
a.cc:6:3: error: 'p' was not declared in this scope
    6 |   p[0]=0;
      |   ^
a.cc:11:8: error: 'abs' was not declared in this scope
   11 |     if(abs(p[i+1]-p[i])>c){
      |        ^~~
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout<<k-c_max<<endl;
      |   ^~~~
a.cc:15:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:18: error: 'endl' was not declared in this scope
   15 |   cout<<k-c_max<<endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: Java

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int y = sc.nextInt();

		int[] a = new int[n];
		for( int i=0 ; i<n ; i++ ) {
			a[i] = sc.nextInt();
		}
		Calc res = new Calc(n,y, a);
		System.out.println( res.toString() );
	}
	public static class Calc {
		int K;
		int N;
		
		int[] A;
		
		int start;
		int end;
		
		int dist;
		public Calc(int k, int n, int[] a) {
			K = k;
			N = n;
			A = a;
			
			int dist = a[n-1] - a[0];
			start = 0;
			for( int i=0 ; i<n-1 ; i++ ) {
				if( dist < a[i+1] - a[i] ) {
					start = i+1;
					dist = a[i+1] - a[i];
				}
			}
//			
//			dist = (K + a[start -1] - a[start]) % K;
			
			this.dist = K - dist;
		}



		@Override
		public String toString() {
			return ""+ dist;
		}
		
		

	}
	
}

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

#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;
int n, k;
typedef long long ll;

int main() {
	int k, n, temp, pre, max = INT_MIN;
	int a1;
	ll sum = 0;
	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		if (i == 0) {
			a1 = temp;
		}
		if (i != 0) {
			if (max < temp - pre)
				max = temp - pre;
		}
		pre = temp;
	}
	if (abs((k - temp) + a1) > max)
		max = (k - temp) + a1;
	cout << k - max;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:36: error: 'INT_MIN' was not declared in this scope
   10 |         int k, n, temp, pre, max = INT_MIN;
      |                                    ^~~~~~~
a.cc:4:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<cmath>
  +++ |+#include <climits>
    4 |
Language: C++

using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/
 
int K,N;
int H=0;
int A[1000005];
int B[1000005];

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

  int max = 0;
  for(int i=0; i<N; i++){
    if(max < B[i]) max = B[i];
  }

  cout << K-max << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'cin' was not declared in this scope
    9 |   cin >> K >> N;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/
a.cc:21:3: error: 'cout' was not declared in this scope
   21 |   cout << K-max << endl;
      |   ^~~~
a.cc:21:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:20: error: 'endl' was not declared in this scope
   21 |   cout << K-max << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:29: error: 'arr' was not declared in this scope
    8 |   for(int i=0;i<n;i++) cin>>arr[i];
      |                             ^~~
a.cc:22:11: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator-'
   22 |   cout<<(k-max);
      |          ~^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	int K, N;
	cin >> K >> N;
	
	int d_max = 0;
	int a0;
	cin >> a0;
	int a_last = a0;
	int d_max = 0;
	for(int i = 1; i < K; i++){
		int A;
		cin >> A;
		int d = A - a_last;
		if(d_max < d) d_max = d;
		a_last = A;
	}
	int d = a0 + K - a_last;
	if(d_max < d) d_max = d;
	
	cout << K - d_max << endl;
	
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: redeclaration of 'int d_max'
   13 |         int d_max = 0;
      |             ^~~~~
a.cc:9:13: note: 'int d_max' previously declared here
    9 |         int d_max = 0;
      |             ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,n;
	cin>>k>>n;
	int max,num,a[200005];
	for(int i=0;i<n;i++)
	{
		scaanf("%d",&a[i]);
		if(i!=0)
		{
			num=a[i]-a[i-1];
			if(num>max)max=num;
		}
	}
	num=k-a[n-1]+a[0];
	if(num>max)max=num;
	cout<<k-max;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: 'scaanf' was not declared in this scope; did you mean 'scanf'?
   10 |                 scaanf("%d",&a[i]);
      |                 ^~~~~~
      |                 scanf
Language: C++

#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

  CE

	please AC;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:105:3: error: 'CE' was not declared in this scope
  105 |   CE
      |   ^~
Language: C++

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

int max(int a,int b){
    return a<b ? b :a;
}

int main(){
    int k,n,a[1000010],i,m;
    cin >> k >> n;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
        m=max(m,a[i+1]-a[i]);
    }
    cout << k-(max(m,k-a[n-1]+a[0]) << endl;
    return 0;
}

Compiler output:
a.cc:1:10: fatal error: bits/stdc++: No such file or directory
    1 | #include <bits/stdc++>
      |          ^~~~~~~~~~~~~
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[i];
  int ans = A[N - 1] - A[0];
  for (int i = 0; i < N - 1) {
    int b = A[i + 1] - A[i];
    b = K - b;
    if (ans > b) ans = b;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:28: error: expected ';' before ')' token
    9 |   for (int i = 0; i < N - 1) {
      |                            ^
      |                            ;
Language: C++

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

int main(){
  int K,N,mx=0,ans;
  cin>>K>>N;
  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;i++){
    if(i==N-1){mx=max(K-a.at(N-1)+a.at(0),mx);}
    else{mx=max(a.at(i+1)-a.at(i),mx);}
  }
  
  ans=K-mx;
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin>>K>>N;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:22:3: error: 'cout' was not declared in this scope
   22 |   cout<<ans;
      |   ^~~~
a.cc:22:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#define SZ(x) ((int)(x).size())
#define all(x)  x.begin(),x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define tt int t;cin >> t;while(t--)
#define int3(x,y,z) int x,y,z;cin >> x >> y >> z;
#define int2(x,y) int x,y;cin >> x >>y;
#define int1(x) int x;cin>>x;
#define vi vector<int>
#define vii vector<vector<int>>
typedef long long ll;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//bool cmp(pair<string,int>p1,pair<string,int>p2) {
//    return p1.ss > p2.ss;
//}
//if (s1.find(s2) != std::string::npos) {
//   std::cout << "found!" << '\n';
//}


using namespace std;

int main() {
    fio
    int2(k,n)

    vi ind;
    for (int i = 0; i < n; ++i) {
        int x ;
        cin >> x;
        ind.pb(x);
    }
    sort(all(ind));
    int dist = INT_MIN;
    for (int j = 0; j < n-1; ++j) {
        dist = max(dist,ind[j+1] - ind[j]);
    }
    dist = max(dist,(20-ind[n-1]) + ind[0]);
    cout << k - dist << endl;




    return 0;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:51:16: error: 'INT_MIN' was not declared in this scope
   51 |     int dist = INT_MIN;
      |                ^~~~~~~
a.cc:15:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include <iomanip>
  +++ |+#include <climits>
   15 | #define SZ(x) ((int)(x).size())
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi =vector<vi>;

int main(){
  int K;
  int N;
  cin >>K>>N;
  vi A(N);
  vi B(N);
  for(int i=0;i<n;i++) cin >>A[i];
 
  B[N-1]=K-A[N-1]+A[0];
  for(int i=0;i<n-1;i++) B[i]=A[i+1]-A[i];
  
  sort(B.begin(),B.end());
  int ans=0;
  for(int i=0;i<n-1;i++) ans+=B[i];
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'n' was not declared in this scope
   13 |   for(int i=0;i<n;i++) cin >>A[i];
      |                 ^
a.cc:16:17: error: 'n' was not declared in this scope
   16 |   for(int i=0;i<n-1;i++) B[i]=A[i+1]-A[i];
      |                 ^
a.cc:20:17: error: 'n' was not declared in this scope
   20 |   for(int i=0;i<n-1;i++) ans+=B[i];
      |                 ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    8 |   double a[n];
      |            ^
a.cc:8:12: error: could not convert 'n' from 'double' to 'long unsigned int'
    8 |   double a[n];
      |            ^
      |            |
      |            double
a.cc:8:12: error: size of array 'a' has non-integral type 'double'
a.cc:16:37: error: expected ')' before ';' token
   16 |     maxm = max(maxm,abs(a[i]-a[i-1]);
      |               ~                     ^
      |                                     )
a.cc:18:24: error: invalid types 'double [1][double]' for array subscript
   18 |   maxm = max(maxm,abs(a[n-1]-a[0]));
      |                        ^
Language: C++

#include <iostream>
using namespace std;

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


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

#include <iostream>
using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: 'K' was not declared in this scope
   11 |       if(a[i]-a[i-1]<K-a[i]+a[i-1]){
      |                      ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:37: error: expected ')' before ';' token
   16 |     maxm = max(maxm,abs(a[i]-a[i-1]);
      |               ~                     ^
      |                                     )
a.cc:18:35: error: expected ')' before ';' token
   18 |   maxm = max(maxm,abs(a[n-1]-a[0]);
      |             ~                     ^
      |                                   )
Language: C++

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

ll k, n, x, y;

int main()
{
  cin >> k >> n;
  ll ans = 0, maxn = 0, p;
  for(int i = 1; i <= n; i++)
  {
    cin >> x;
    if(i != 1)
    {
      ans += x - y;
      maxn = max(maxn, x - y);
    }
    else p = x;
    y = x;
  }
  ll t  k - x + p;
  ans += t maxn = max(maxn, t;
  cout << ans - maxn << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: expected initializer before 'k'
   24 |   ll t  k - x + p;
      |         ^
a.cc:25:10: error: 't' was not declared in this scope
   25 |   ans += t maxn = max(maxn, t;
      |          ^
Language: C++

#include <iostream>
using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: expected ',' or ';' before 'for'
   10 |         for(int i=1;i<n;++i){
      |         ^~~
a.cc:10:21: error: 'i' was not declared in this scope
   10 |         for(int i=1;i<n;++i){
      |                     ^
Language: C++

#include <iostream>
using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: expected ',' or ';' before 'for'
   10 |         for(int i=1;i<n;++i){
      |         ^~~
a.cc:10:21: error: 'i' was not declared in this scope
   10 |         for(int i=1;i<n;++i){
      |                     ^
a.cc:17:2: error: expected '}' at end of input
   17 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^