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

#include<stdio.h>

int main(){
  int x,n; 
  int flaga = 0;
  int flagb = 0;
  scanf("%d%d",&x,&n);
  int p[n];
  if(n == 0){
    printf(x);
  }
  for(int i = 0;i < n;i++){
    scanf("%d",&p[i]);
  }

  for(int i = 0;i<n;i++){
    for(int j = 0;j<n;j++){
        if (x-i == p[j]){
            flaga = 1;
        }
        if(x+i == p[j]){
            flagb = 1;
        }
    }
    if(flaga == 0){
        printf(x-i);
    }else if(flagb == 0){
        printf(x+i);
    }else if(flaga == 0 and flagb == 0){
        printf(x-i);
    }
  }
}
        
      


Compiler output:
main.c: In function 'main':
main.c:10:12: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   10 |     printf(x);
      |            ^
      |            |
      |            int
In file included from main.c:1:
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:26:17: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   26 |         printf(x-i);
      |                ~^~
      |                 |
      |                 int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:28:17: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   28 |         printf(x+i);
      |                ~^~
      |                 |
      |                 int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:29:24: error: expected ')' before 'and'
   29 |     }else if(flaga == 0 and flagb == 0){
      |             ~          ^~~~
      |                        )
main.c:30:17: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   30 |         printf(x-i);
      |                ~^~
      |                 |
      |                 int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int *a_heap;
int X ,N;
bool t = false;

int dfs(int sum){
    for(int a = 0; a < N; a++){
        if(sum != a_heap[a]){
            t = true;
            return sum;  
        }
    }
    return 0;
}

int main(){
    cin >> X >> N;
    int ans = X;
    a_heap = new int[N];
    for(int i = 0;i < N; i++){
        cin >> a_heap[i];
        if( X == a_heap[i]) ans = 0; 
    }
    if(ans != 0){
        cout << ans;
        return;
    }else{
        while(!t){
            int i = 1;
            ans = dfs(X - i);
            ans = dfs(X + i);
            ++i;
        }
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   27 |         return;
      |         ^~~~~~
Language: C

#include<stdio.h>

int main(){
  int X, N, a[101],b=0,c=0,d=0;
  
  scanf("%d %d",&X, &N);
  for(int i=0;i<N;i++){
  scanf("%d",&a[N]);
  }
  for(int i=0;i<101;i++){
      for(int j=0;j<N;j++){
          if(X-i!=a[j]){c++;}
          }
          if(c>0){
              printf("%d",X-i);
              return 0;
            }
            if(X+i!=a[j]){d++;}
            if(d>0){
                printf("%d", X+i);
                return 0;
            }
        }
  }



Compiler output:
main.c: In function 'main':
main.c:18:23: error: 'j' undeclared (first use in this function)
   18 |             if(X+i!=a[j]){d++;}
      |                       ^
main.c:18:23: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int x,n,t,c=0,c1=0,temp;
  cin>>x>>n;
  temp=x;
  vector<int>v;
  vector<int>v1;
  for(int i=0;i<n;i++)
  {
    cin>>t;
    v.push_back(t); 
  }
  if(n==0)
    cout<<x;
  else{
      while(1){
        x=x+c;
        temp=temp-c1;
        if(temp==find(v.begin(),v.end(),temp)){
        c1--;
        }
        else
        {
          cout<<temp;
          break;
        }
        if(x==find(v.begin(),v.end(),x)){
         c++;
        }
        else{
        cout<<x;
          break;
        }
        
      
      }
  }
      
    
  
   
   
return 0;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:22: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   21 |         if(temp==find(v.begin(),v.end(),temp)){
      |                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:21:22: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   21 |         if(temp==find(v.begin(),v.end(),temp)){
      |                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:19: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   29 |         if(x==find(v.begin(),v.end(),x)){
      |               ~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:29:19: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   29 |         if(x==find(v.begin(),v.end(),x)){
      |               ~~~~^~~~~~~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>

int main(){
  int x,n; 
  int flaga = 0;
  int flagb = 0;
  scanf("%d%d",&x,&n);
  int p[n];
  if(n == 0){
    printf(x);
  }
  for(i = 0;i < n;i++){
    scanf("%d",&p[i]);
  }

  for(int i = 0;i<n;i++){
    for(int j = 0;j<n;j++){
        if (x-i == p[j]){
            flaga = 1;
        }
        if(x+i == p[j]){
            flagb = 1;
        }
    }
    if(flaga == 0){
        printf(x-i);
    }else if(flagb == 0){
        print(x+i);
    }else if(flaga == 0 and flagb == 0){
        print(x-i);
    }
  }
}
        
      


Compiler output:
main.c: In function 'main':
main.c:10:12: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   10 |     printf(x);
      |            ^
      |            |
      |            int
In file included from main.c:1:
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:12:7: error: 'i' undeclared (first use in this function)
   12 |   for(i = 0;i < n;i++){
      |       ^
main.c:12:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:26:17: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   26 |         printf(x-i);
      |                ~^~
      |                 |
      |                 int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:28:9: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   28 |         print(x+i);
      |         ^~~~~
      |         printf
main.c:29:24: error: expected ')' before 'and'
   29 |     }else if(flaga == 0 and flagb == 0){
      |             ~          ^~~~
      |                        )
Language: C++

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

int main(){
  int X,N;
  cin >> X >> N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  vector<int> B(N);
  for(int i=0;i<N;i++){
    B.push_back(abs(X-A.at(i)));
  }
  
  int min=min_element(B.begin(), B.end());
  
  cout << (X-min)-1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:22: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
   18 |   int min=min_element(B.begin(), B.end());
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
      |                      |
      |                      __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

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

int main() {
  int X,N;
  cin >> X >> N;
  if(N==0){
    cout << X <<endl;
  }
  else{
  vector<int> p(N);
  rep(i,N){
    cin >> p.at(i);
  }
  vector<int> a(N);
  rep(i,N){
    a.at(i)=p.at(i)-X;
  }
  vector<int> b(N);
  vector<int> c(N);
  int k;
  rep(i,N){
    if(0<=a.at(i) && a.at(i)<N){
      k=a.at(i);
      b.at(k)++;
    }  
    else if(a.at(i)<0 && a.at(i)>-N){
      k=a.at(i);
      c.at(-k)++;
    }
  }
  c.at(0)=b.at(0);
  int S==101,T==101;
  rep(i,N){
    if(b.at(i)==0){
      S=i;
      break;
    }
  }
  rep(i,N){
    if(c.at(i)==0){
      T=i;
      break;
    }
  }
  if(S>=T){
    cout << X-T <<endl;
  }
  else{
    cout << X+S <<endl;
  }
  }   
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:8: error: expected initializer before '==' token
   34 |   int S==101,T==101;
      |        ^~
a.cc:37:7: error: 'S' was not declared in this scope
   37 |       S=i;
      |       ^
a.cc:43:7: error: 'T' was not declared in this scope
   43 |       T=i;
      |       ^
a.cc:47:6: error: 'S' was not declared in this scope
   47 |   if(S>=T){
      |      ^
a.cc:47:9: error: 'T' was not declared in this scope
   47 |   if(S>=T){
      |         ^
Language: C++


#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
    ll x,n;cin>>x>>n;
    if(n!=0){vl a(n);rep(i,n)cin>>a[i];
    ll ans=x+1
    sort(a.begin(),a.end());
    ll j=0;
 


rep(i,a[n]){
   
    if(abs(x-i)<ans&&i!=a[j]){ans=abs(x-i);cout<<ans<<endl;}
    if(i==a[j])j++;

}


cout<<ans<<endl;}

if(n==0)cout<<x<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: expected ',' or ';' before 'sort'
   24 |     sort(a.begin(),a.end());
      |     ^~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
int comp(const void*a,const void*b)
{
    return *(int*)a-*(int*)b;
}

bool cheak(int n,int a[]){
  int i;
  for (i=0;i<(sizeof(a)/sizeof(int));i++){
    if(a[i] == n){
      return true;
    }
  }
  return false;
}

int main(){
  int A,n,i,j;
  int a[101];
  scanf("%d %d",&A,&n);
  if(n==0){
    printf("%d",A);
    return 0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),comp);
  int d = 0;
  for(i=0;i<n;i++){
    if((a[i]-A-d)==0){
       if(check((a[i]-d),a) == false){
         printf("%d",a[i]-d);
         return 0;
       }else if(check((a[i]+d),a) == false)){
         printf("%d",a[i]+d);
         return 0;
       }
    }else{
      d++;
    }
  }
}

Compiler output:
main.c:8:1: error: unknown type name 'bool'
    8 | bool cheak(int n,int a[]){
      | ^~~~
main.c:3:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include<stdlib.h>
  +++ |+#include <stdbool.h>
    3 | int comp(const void*a,const void*b)
main.c: In function 'cheak':
main.c:10:21: warning: 'sizeof' on array function parameter 'a' will return size of 'int *' [-Wsizeof-array-argument]
   10 |   for (i=0;i<(sizeof(a)/sizeof(int));i++){
      |                     ^
main.c:8:22: note: declared here
    8 | bool cheak(int n,int a[]){
      |                  ~~~~^~~
main.c:12:14: error: 'true' undeclared (first use in this function)
   12 |       return true;
      |              ^~~~
main.c:12:14: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:12:14: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:10: error: 'false' undeclared (first use in this function)
   15 |   return false;
      |          ^~~~~
main.c:15:10: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c: In function 'main':
main.c:33:11: error: implicit declaration of function 'check'; did you mean 'cheak'? [-Wimplicit-function-declaration]
   33 |        if(check((a[i]-d),a) == false){
      |           ^~~~~
      |           cheak
main.c:33:32: error: 'false' undeclared (first use in this function)
   33 |        if(check((a[i]-d),a) == false){
      |                                ^~~~~
main.c:33:32: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:36:44: error: expected statement before ')' token
   36 |        }else if(check((a[i]+d),a) == false)){
      |                                            ^
Language: C

#include<stdio.h>
 
int main(){
  int p[100];
  int X,N,i;
  while(scanf("%d %d",&X,&N)==0);
  
  for(i=0;i<N;i++){
  while(scanf("%d",&p[i])==0);
  }
  
  int a,b;
  
  for(i=1;i<N;i++){
    a=X+i;
    b=X-i;
    
    for(j=0;j<N;j++){
    if(b!=p[j]){
      printf("%d",b);
      return 0;
    }
      else if(a!=p[j]){
        printf("%d",a);
      return 0;
      }
    }
    
  }
 
}

Compiler output:
main.c: In function 'main':
main.c:18:9: error: 'j' undeclared (first use in this function)
   18 |     for(j=0;j<N;j++){
      |         ^
main.c:18:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int x,n,t,c=0,c1=0,temp;
  cin>>x>>n;
  temp=x;
  vector<int>v;
  vector<int>v1;
  for(int i=0;i<n;i++)
  {
    cin>>t;
    v.push_back(t); 
  }
  if(n==0)
    cout<<x;
  else{
      while(1){
        x=x+c;
        temp=temp-c1;
        if(find(v.begin(),v.end(),temp)){
        c1--;
        }
        else
        {
          cout<<temp;
          break;
        }
        if(find(v.begin(),v.end(),x)){
         c++;
        }
        else{
        cout<<x;
          break;
        }
        
      
      }
  }
      
    
  
   
   
return 0;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:16: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   21 |         if(find(v.begin(),v.end(),temp)){
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:21:16: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   21 |         if(find(v.begin(),v.end(),temp)){
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:16: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   29 |         if(find(v.begin(),v.end(),x)){
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:29:16: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   29 |         if(find(v.begin(),v.end(),x)){
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>

int main(){
  int p[100];
  int X,N,i;
  while(scanf("%d %d",&X,&N)==0);
  
  for(i=0;i<N;i++){
  while(scanf("%d",p[i])==0);
  }
  
  int a,b
  for(i=1;i<N;i++){
    a=X+i;
    b=X-i;
    
    for(j=0;j<N;j++){
    if(b!=p[j]){
      printf("%d",b);
      return 0;
    }
      else if(a!=p[j]){
        printf("%d",a);
      return 0;
      }
    }
    
  }

}

Compiler output:
main.c: In function 'main':
main.c:13:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'for'
   13 |   for(i=1;i<N;i++){
      |   ^~~
main.c:13:18: error: expected ';' before ')' token
   13 |   for(i=1;i<N;i++){
      |                  ^
      |                  ;
main.c:13:18: error: expected statement before ')' token
main.c:15:5: error: 'b' undeclared (first use in this function)
   15 |     b=X-i;
      |     ^
main.c:15:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:17:9: error: 'j' undeclared (first use in this function)
   17 |     for(j=0;j<N;j++){
      |         ^
Language: C

#include<stdio.h>
#include<stdlib.h>
int comp(const void*a,const void*b)
{
    return *(int*)a-*(int*)b;
}

void cheak(int n,int a[]){
  int i;
  for (i=0;i< sizeof(a);i++){
    if(a[i] == n){
      return true;
    }
  }
  return false;
}

int main(){
  int A,n,i,j;
  int a[101];
  scanf("%d %d",&A,&n);
  if(n==0){
    printf("%d",A);
    return 0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),comp);
  int d = 0;
  for(i=0;i<n;i++){
    if((a[i]-A-d)==0){
       if(check((a[i]-d),a) == false){
         printf("%d",a[i]-d);
         return 0;
       }else if(check((a[i]+d),a) == false)){
         printf("%d",a[i]+d);
         return 0;
       }
    }else{
      d++;
    }
  }
}

Compiler output:
main.c: In function 'cheak':
main.c:10:21: warning: 'sizeof' on array function parameter 'a' will return size of 'int *' [-Wsizeof-array-argument]
   10 |   for (i=0;i< sizeof(a);i++){
      |                     ^
main.c:8:22: note: declared here
    8 | void cheak(int n,int a[]){
      |                  ~~~~^~~
main.c:12:14: error: 'true' undeclared (first use in this function)
   12 |       return true;
      |              ^~~~
main.c:3:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include<stdlib.h>
  +++ |+#include <stdbool.h>
    3 | int comp(const void*a,const void*b)
main.c:12:14: note: each undeclared identifier is reported only once for each function it appears in
   12 |       return true;
      |              ^~~~
main.c:12:14: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
main.c:8:6: note: declared here
    8 | void cheak(int n,int a[]){
      |      ^~~~~
main.c:15:10: error: 'false' undeclared (first use in this function)
   15 |   return false;
      |          ^~~~~
main.c:15:10: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:15:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
main.c:8:6: note: declared here
    8 | void cheak(int n,int a[]){
      |      ^~~~~
main.c: In function 'main':
main.c:33:11: error: implicit declaration of function 'check'; did you mean 'cheak'? [-Wimplicit-function-declaration]
   33 |        if(check((a[i]-d),a) == false){
      |           ^~~~~
      |           cheak
main.c:33:32: error: 'false' undeclared (first use in this function)
   33 |        if(check((a[i]-d),a) == false){
      |                                ^~~~~
main.c:33:32: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:36:44: error: expected statement before ')' token
   36 |        }else if(check((a[i]+d),a) == false)){
      |                                            ^
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int n,x,l,i,r,f=0,lf,rf;
  cin>>x>>n;
  int ar[n];
  for(i=0; i<n; i++)
  {
    cin>>ar[i];
  }
l=x;
r=x;
  if(n==100 && x==100)
    cout<<x;
  else
  if(n!=0)
  {
  while(f==0)
 { 
     l--;
     lf=0;
     for(i=0; i<n; i++)
     {
         if(ar[i]!=l)
         lf++;
     }
     
     if(lf==n)
     f=1;
     
 }
    while(f==0)
 { 
     r++;
     rf=0;
     for(i=0; i<n; i++)
     {
         if(ar[i]!=l)
         lf++;
     }
     
     if(rf==n)
     f=1;
     
 }
  
 if(abs(r-x)<=abs(x-abs(l));
    cout<<r;
    else
    cout<<l;
}
else
cout<<x;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:12: error: expected ')' before ';' token
   49 |     cout<<r;
      |            ^
      |            )
a.cc:48:4: note: to match this '('
   48 |  if(abs(r-x)<=abs(x-abs(l));
      |    ^
Language: C++

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

int main(){
    int x, n;
    cin >> x >> n;

    // nが0なら必ずx自身が答え
    if( n == 0){
        cout << x << endl;
    }
    else{
        // 1から100までが入ったベクトルを作る
        vector<int> vec(100);
        rep(i,100){
            vec.at(i) = ( i + 1 );
        }  

        // vecのうちpにある要素を削除する
        int p;
        for (int i = 0; i < n; i++){
            cin >> p;
            for (double j = 0; j < vec.size(); j++){
                if (vec.at(j) == p){
                    vec.erase(j);
                }
            }
        }
        int diff = 0;
        while(true){
            //vecの各要素にイテレート
            for (double i = 0; i < vec.size(); i++){
                //もしxとの差がdiffのものがあればそれを出力
                //小さい順に数えて、差がdiffのものが出た時点でbreakする
                if(abs(vec.at(i) - x) == diff){
                    cout << vec.at(i) << endl;
                    goto end;
                }
            //差がdiffのものがなかったらdiffを+1する
            diff += 1;
            }
        }
    }
    end:
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:30: error: no matching function for call to 'std::vector<int>::erase(double&)'
   26 |                     vec.erase(j);
      |                     ~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'double' to 'std::vector<int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin >> x >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int k;
  k=lower_bound(a,a+n,x)-a;
  for(int i=0;i<n;i++){
    if(a[i]==k){
      NUM=i;
      break;
    }
  }
  int m;
  for(int i=1;i<9;i++){
    int o;
    o=k-i;
    if(a[NUM]!=o){
      m=o;
      break;
    }
  }
  m=k-2*(k-x);
  cout << m << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:7: error: 'NUM' was not declared in this scope
   15 |       NUM=i;
      |       ^~~
a.cc:23:10: error: 'NUM' was not declared in this scope
   23 |     if(a[NUM]!=o){
      |          ^~~
Language: C

lst = []
l = []
str = input()
l = str.split(' ')
n = int(l[0])
no = int(l[1])
if no==0:
  print(n)
 

else:  
  str1 = input()
  lst = str1.split(' ')
  for i in range(0,no):
    lst[i] = int(lst[i])
  for i in range(1,100):
    if n-i not in lst :
      print(n-i)
      break
    if n+i not in lst:
      print(n+i)
      break
  


Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | lst = []
      | ^~~
main.c:1:1: error: type defaults to 'int' in declaration of 'lst' [-Wimplicit-int]
main.c:1:7: error: expected expression before '[' token
    1 | lst = []
      |       ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int x,n,t,c=0,c1=0,temp;
  cin>>x>>n;
  temp=x;
  vector<int>v;
  vector<int>v1;
  for(int i=0;i<n;i++)
  {
    cin>>t;
    v.push_back(t); 
  }
  if(n==0)
    cout<<x;
  else{
      while(1){
        x=x+c;
        temp=temp-c1;
        if(v.find(temp)){
        c1--;
        }
        else
        {
          cout<<temp;
          break;
        }
        if(v.find(x)){
         c++;
        }
        else{
        cout<<x;
          break;
        }
        
      
      }
  }
      
    
  
   
   
return 0;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: 'class std::vector<int>' has no member named 'find'
   21 |         if(v.find(temp)){
      |              ^~~~
a.cc:29:14: error: 'class std::vector<int>' has no member named 'find'
   29 |         if(v.find(x)){
      |              ^~~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int x,n,t,c=0,c1=0,temp;
  cin>>x>>n;
  temp=x;
  vector<int>v;
  vector<int>v1;
  for(int i=0;i<n;i++)
  {
    cin>>t;
    v.push_back(t); 
  }
  if(n==0)
    cout<<x;
  else{
      while(1){
        x=x+c;
        temp=temp-c1;
        if(vi.find(temp)){
        c1--;
        }
        else
        {
          cout<<temp;
          break;
        }
        if(v.find(x)){
         c++;
        }
        else{
        cout<<x;
          break;
        }
        
      
      }
  }
      
    
  
   
   
return 0;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: 'vi' was not declared in this scope; did you mean 'v1'?
   21 |         if(vi.find(temp)){
      |            ^~
      |            v1
a.cc:29:14: error: 'class std::vector<int>' has no member named 'find'
   29 |         if(v.find(x)){
      |              ^~~~
Language: C++

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

int main() {
        int x, n, ans = -1;
        cin >> x >> n;
        vector<int> arr(n);
        for(int i = 0 ; i<n ; i++) {
                cin >> arr[i];
        }
        ans = x;
        if(n > 0)
                int mx = *max_element(arr.begin(), arr.end());
                int mn = *min_element(arr.begin(), arr.end());
                vector<int> p;
                for(int i = mn ; i<=mx ; i++) {
                        if(find(arr.begin(), arr.end(), i) == arr.end()) {
                                p.push_back(i);
                        }
                }
                int d = abs(x - p[0]);
                ans = p[0];
                for(int i = 1 ; i<p.size() ; i++){
                        if(d > abs(x-p[i])){
                                d = abs(x-p[i]);
                                ans = p[i];
                        }
                }
        }
        cout << ans << "\n";
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:37: error: 'mx' was not declared in this scope; did you mean 'mn'?
   17 |                 for(int i = mn ; i<=mx ; i++) {
      |                                     ^~
      |                                     mn
a.cc: At global scope:
a.cc:31:9: error: 'cout' does not name a type
   31 |         cout << ans << "\n";
      |         ^~~~
a.cc:32:9: error: expected unqualified-id before 'return'
   32 |         return 0;
      |         ^~~~~~
a.cc:33:1: error: expected declaration before '}' token
   33 | }
      | ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:34:18: error: lvalue required as left operand of assignment
   34 |     if(A==s.at(i)&&i=x-1){
      |        ~~~~~~~~~~^~~
Language: C++

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

int main() {
  int x, n;
  cin >> x >> n;
  if(n == 0){
    cout << x << endl;
    return 0;
  }
  int arr[300];
  int diff[n];
  int min = 200;
  int minVal = 0;
  for(int i = 0; i < n; i++){
    int t;
    cin >> t;
    arr[t+100] = 1;
  }
  for(int i = 199; i >= -100; i--){
    if(arr[i+100] == 1){
      continue;
    }
    if(abs(x-i) <= min){
      minVal = i;
      min = abs(x-i);
    }
  }
  cout << smallestVal << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:11: error: 'smallestVal' was not declared in this scope
   29 |   cout << smallestVal << endl;
      |           ^~~~~~~~~~~
Language: C

#include<stdio.h>

int main(){
  int X, N, a[101],b=0;
  *a=&a;
  scanf("%d %d",&X, &N);
  for(int i=0;i<N;i++){
  scanf("%d",*a[101]);
  }
  for(int i=0;i<101;i++){
      for(int j=0;j<N;j++){
          if(X-i!=a[j]){
              printf("%d",X-i);
              return 0;
            }
            if(X+i!=a[j]){
                printf("%d", X+i);
                return 0;
            }
        }


  }

}

Compiler output:
main.c: In function 'main':
main.c:5:5: error: assignment to 'int' from 'int (*)[101]' makes integer from pointer without a cast [-Wint-conversion]
    5 |   *a=&a;
      |     ^
main.c:8:14: error: invalid type argument of unary '*' (have 'int')
    8 |   scanf("%d",*a[101]);
      |              ^~~~~~~
Language: C

#include<stdio.h>

int main(){
  int X, N, a[101],b=0;
  scanf("%d %d",&X, &N);
  for(int i=0;i<N;i++){
  scanf("%d",*a[101]);
  }
  for(int i=0;i<101;i++){
      for(int j=0;j<N;j++){
          if(X-i!=a[j]){
              printf("%d",X-i);
              return 0;
            }
            if(X+i!=a[j]){
                printf("%d", X+i);
                return 0;
            }
        }


  }

}

Compiler output:
main.c: In function 'main':
main.c:7:14: error: invalid type argument of unary '*' (have 'int')
    7 |   scanf("%d",*a[101]);
      |              ^~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:4:25: error: expected unqualified-id before ';' token
    4 |   int X, N, A, B, x, y, ;
      |                         ^
Language: C

#include <stdio.h>

int main(){
	int x, n;
    int num;
    int a[100];
    int i, j;
  
  	for (i = 0; i < 100; i++){
    	a[i] = 0;
    }
  	
  	(void)scanf("%d", &x)
  	(void)scanf("%d", &n);

    if (n == 0){
        printf("%d", x);
        return 0;
    }
  	for (i = 0; i < n; i++){
    	(void)scanf("%d", &num);
      	a[(num - 1)] = 1;
    }
  
  	for(i = 0; i < 99; i++){
    	if(a[(x - 1 - i)] == 0){
            printf("%d", x - i);
        	break;
        }
        if(a[(x - 1 + i)] == 0){
            printf("%d", x + i);
        	break;
        }
    }
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:14:10: error: expected expression before 'void'
   14 |         (void)scanf("%d", &n);
      |          ^~~~
main.c:13:15: error: called object is not a function or function pointer
   13 |         (void)scanf("%d", &x)
      |               ^~~~~
main.c:14:15: error: expected ';' before 'scanf'
   14 |         (void)scanf("%d", &n);
      |               ^~~~~
      |               ;
Language: C++

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

int main(){
  int X,N;
  cin >> X >> N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  vector<int> B(N);
  for(int i=0;i<N;i++){
    B.push_back(abs(X-A.at(i)));
  }
  int index=max_element(v.begin(),v.end()) - v.begin();
  
  cout << A.at(index) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:25: error: 'v' was not declared in this scope
   17 |   int index=max_element(v.begin(),v.end()) - v.begin();
      |                         ^
Language: C++

import numpy as np
X, N = list(map(int, input().split()))
try:
	p = np.array(list(map(int, input().split())))
except EOFError:
    print(X)
    exit()
I = np.arange(1, 101)
idx = np.argsort(np.abs(I - X)) + 1
for i in idx:
    if i not in p:
        print(i)
        break

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
cin.tie(0);
int x,n;
vector<int> tempResult;
cin >>x >>n;
int p[110];
if(n==0){cout <<x;return 0;}
for(int i=1;i<=n;i++){
  cin >>p[i-1];
}
for(int i=0;i<=n+1;i++){
  int k=0;
  if(i==0)k=x;
  else if(i%2==0)k=x+(i/2);
  else k=x-((i+1)/2);
  int c=0;
  for(int m=0;m<n&&c==0;m++){
   if(p[m]==k)c=1; 
  }
  //cout <<"k:" <<k <<"c:" <<c <<endl;
  //printf("k:%d c:%d\n",k,c);
  if(c==0){cout <<k;return 0;}
}

  

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

#include<stdio.h>

int main(){
  int X, N, a[101],b=0;
  scanf("%d %d",&X, &N);
  for(int i=0;i<N;i++){
  scanf("%d",a[]);
  }
  for(int i=0;i<101;i++){
      for(int j=0;j<N;j++){
          if(X-i!=a[j]){
              printf("%d",X-i);
              return 0;
            }
            if(X+i!=a[j]){
                printf("%d", X+i);
                return 0;
            }
        }


  }

}

Compiler output:
main.c: In function 'main':
main.c:7:16: error: expected expression before ']' token
    7 |   scanf("%d",a[]);
      |                ^
Language: C++

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

int main() {
  ll x,n;
  cin >> x >> n;
  ll q;
  vector<ll> p;
  ll y=101;
  ll ans=101;
  
  if(n==0) {
    y=x;
  } else {
    for (ll i=0;i<n;i++) {
      cin >> q;
      p.push_back(q);
    for (ll i=-1;i<102;i++) {
      auto itr = std::find(p.begin(), p.end(), i);
      if( itr != p.end() ) {
        break;
      } else {
        if( llabs(x-i)<ans ) {
          ans = llabs(x-i);
          y=i;
        }
      }
    }
  }
  cout << y;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:2: error: expected '}' at end of input
   34 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C

#include<stdio.h>

int main(){
  int X, N, a[101],b=0;
  scan("%d %d",X, N);
  for(int i=0;i<N;i++){
  scanf("%d",a);
  }
  for(int i=0;i<101;i++){
      for(int j=0;j<N;j++){
          if(X-i!=a[j]){
              printf("%d",X-i);
              return 0;
            }
            if(X+i!=a[j]){
                printf("%d", X+i);
                return 0;
            }
        }


  }

}

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

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using vi = vector<int>;


int main() {int x,n,m;
  cin >>x>>n;
             vi p(n);
            vi z(n);
  rep(i,n){cin>>p[i];
       z[i]=abs(x-p[i]);
          }
     sort(z.begin(), z.end()); 
      m=z.at(0);
     if(m!=0){      
    rep(i,n){rep(j,n){if(x-i!=p[j]){cout<<x-i<<endl;break;}}
            rep(j,n){if(x+i!=p[j]){cout<<x+i<<endl;break;}}
    }     
     }

Compiler output:
a.cc: In function 'int main()':
a.cc:20:7: error: expected '}' at end of input
   20 |      }
      |       ^
a.cc:7:12: note: to match this '{'
    7 | int main() {int x,n,m;
      |            ^
Language: C++

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

int main() {
  int X, N, r, s;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  if (N==0) {
    cout << X << endl;
  }
  else {
    for (int j = 0; j < 101; j++) {
    }
    for (int i = 0; i < N; i++) {
      if (j!=X-p.at(i)) {
        r=j;
        break;
      }
    }
    for (int j = 0; j < 101; j++) {
      for (int i = 0; i < N; i++) {
      }
      if ((-1)*j!=X-p.at(i)) {
        s=j;
        break
      }
    }
    if (r > s) {
      cout << X+s << endl;
    }
    else {
      cout << X-r << endl;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:11: error: 'j' was not declared in this scope
   18 |       if (j!=X-p.at(i)) {
      |           ^
a.cc:26:26: error: 'i' was not declared in this scope
   26 |       if ((-1)*j!=X-p.at(i)) {
      |                          ^
a.cc:28:14: error: expected ';' before '}' token
   28 |         break
      |              ^
      |              ;
   29 |       }
      |       ~
Language: C++

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

int main() {
  ll x,n;
  cin >> x >> n;
  ll q;
  vector<ll> p;
  ll y=101;
  ll ans=101;
  
  if(n==0) {
    y=x;
  } else {
    for (ll i=0;i<n;i++) {
      cin >> q;
      p.pushback(q);
    for (ll i=-1;i<102;i++) {
      auto itr = std::find(p.begin(), p.end(), i);
      if( itr != p.end() ) {
        break;
      } else {
        if( llabs(x-i)<ans ) {
          ans = llabs(x-i);
          y=i;
        }
      }
    }
  }
  cout << y;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'class std::vector<long long int>' has no member named 'pushback'; did you mean 'push_back'?
   18 |       p.pushback(q);
      |         ^~~~~~~~
      |         push_back
a.cc:34:2: error: expected '}' at end of input
   34 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: Java

import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner (System.in);
        
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        //もしゼロだったら答えを返して終わり
        if (n == 0) {
            System.out.println(x);   
            return;
        }
        //nがゼロ以外だったら
        Arrays.sort(array);
        int abs = 100;
        int num = 0;
        for (int i = 0; i <= 100; i++) {
            int count = 0;
            for (int j = 0; j < n; j++) {
                if (i == array[j]) {
                    count++;
                }
            }
            if (count == 0) {
            //数字間の大きさを比較して絶対値を求める
            //もし絶対値が増加したらリターン
            if (i =< x) {
                int dif = x - i;
                if (dif < abs) {
                    abs = dif;
                    num = i;
                } else {
                    break;
                }
            } else if (i > x) {
                int dif = i - x;
                if (dif < abs) {
                    abs = dif;
                    num = i;
                } else {
                    break;
                }
            }
            }
        }
        System.out.println(num);
    }
}
        
        

Compiler output:
Main.java:35: error: > or ',' expected
            if (i =< x) {
                      ^
1 error
Language: C++

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

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

#include <stdio.h>

int main(void)
{
	int a[110] = { 0 };
	int x, n;
	int ans1 = 0, kyo = 0;
	int f[110] = { 0 };
	scanf("%d%d", &x, &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		f[a[i]] = 1;
	}

	for (int i = 1; i <= 100; i++) {
		if (i < x) {
			if (f[i] == 0) {
				ans1 = i;
				kyo = x - i;
			}
		}
		else if (x < i) {
			if (ans1 == 0) {
				ans1 = i;
				kyo = i - x;
			}
			else
				if (f[i] == 0 && kyo > i - x)
					ans1 = i;
		}

		if (n == 0)
			printf("%d\n", x);
		else if (ans1)
			printf("%d\n", ans1);

		return 0;

	}

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


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
    ll x,N,p[110]={0},cnt[110]={0},min=100000;
    cin>>x>>N;
    for(int i=1;i<=N;i++) cin>>p[i];
    for(int i=1;i<=N;i++){
        cnt[p[i]]++;
    }
for(int j=1;j<=100;j++){
    if(cnt[j]==0){
        if( abs(j-x)<min) min=abs(j-x);
    }
}

  if(cnt[x-min]==0)  p(x-min);
  else if(cnt[x+m]==0) p(x+min);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:17: error: 'm' was not declared in this scope
   48 |   else if(cnt[x+m]==0) p(x+min);
      |                 ^
Language: C++

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

int main() {
    int X, N;
    cin >> X >> N;
    if (N == 0) {
        cout << X;
    }
    else {
        vector<int>p(N);
        for (int i = 0; i < N; i++) {
            cin >> p.at(i);
        }
        sort(p.begin(), p.end());
        if (p.at(N-1) < X) {
            cout << X;
        }
        else if (X < p.at(0)) {
            cout << X;
        }
        else {
            int s = 0, l = N-1;
        for (int i = 1; i < N-1; i++) {
            if (p.at(i) <= X) {
                s = i;
            }
            if (p.at(i) >= X) {
                l = i;
                break;
            }
        }
        if (p.at(s) != X) {
            cout << X;
        }
        else {
            int small = p.at(0) - 1, large = p.at(N-1) + 1;
            if (s == 0) {
                cout << X - 1;
            }
            else if (l == N-1) {
                if (p.at(l) - p.at(l-1) > 1) {
                    cout << X - 1;
                }
                else {
                    cout << X + 1;
                }
            }
            else {
                for (int i = s; i > 0; i--) {
                    if (p.at(i) - p.at(i-1) > 1) {
                        small = p.at(i) - 1;
                        break;
                    }
                }
                for (int i = l; l < N-1; i++) {
                    if (p.at(i+1) - p.at(i) > 1) {
                        large = p.at(i) + 1;
                        break;
                    }
                }
                if (large - X < X - small) {
                    cout << large;
                }
                else {
                    cout << small;
                }
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:2: error: expected '}' at end of input
   71 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^