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

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

int main() {
  int x,num;
  cin >> x >> num;
  vector<int> n(num);
  for(int i=0; i<num;i++){
  	cin >> n.at(i);
  }
  int a,b,l=0,m=0,i;
  for(i=x;i<101;i++){
  	for(int j=0;j<num;j++){
    	if(i!=n.at(j)){
        	l++;
        }
    }
    if(l==num){
    	a=i;
      goto end;
    }
  }
  end:

  for(i=x;i>0;i--){
  	for(int j=0;j<num;j++){
    	if(i!=n.at(j)){
        	m++;
        }
    }
    if(m==num){
    	b=i;
      goto end;
    }
  }
  end:
  int u,r;
  u=a-x;
  r=x-b;
  if(u>r){cout << b << endl;}
  if(r<u){cout << a << endl;}
  if(u==r){cout << b << endl;}
  if(num==0){cout << x << endl;}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:3: error: duplicate label 'end'
   36 |   end:
      |   ^~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
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]);
  }
  sort(a,a+n);
  for(i=0;i<n;i++){
    for(j=1;j<n;j++){
    	if((a[j]-A-i)==0){
          if(a[j]-i > a[j-1]){
            printf("%d",a[j]-i);
            return 0;
          }else if((a[j]+i) < a[j+1]){
            printf("%d",a[j]+i);
            return 0;
          }
        }
    }
  }
}
     
    
  

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

def main():
    X,N = map(int, input().split())
    if N ==0:
        print(X)
        return 0
    p = list(map(int, input().split()))
    for i in range(51):
        if not (X-i) in p:
            print(X-i)
            return 0
        elif not (X+i) in p:
            print(X+i)
            return 0
          
main()

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: C++

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> vecP(N);
  vector<int> vecD(N);
  vector<int> vecAns(N, 101);
  
  for (int i = 0; i < N; i++) {
    int p, q;
    cin >> p;
    vecP.at(i) = p; //入力値の配列
    q = vecP.at(i);
    vecD.at(i) = abs(q-X); //差の絶対値のベクトル
  }
  
  int counter = 0;
  for (int j = 0; j < 101; j++) {
    for (int i = 0; i < N; i++) {
      if (vecD.at(i) == j) {
      vecAns.at(i) = vecP.at(i);
      counter++;
    }
      if (counter == 0)
        continue;
      else if (counter != 0)
        break;
  }
    sort(vecAns.begin(), vecAns.end());
    cout << vecAns(0) << endl;
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:32:19: error: no match for call to '(std::vector<int>) (int)'
   32 |     cout << vecAns(0) << endl;
      |             ~~~~~~^~~
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> vecP(N);
  vector<int> vecD(N);
  vector<int> vecAns(N, 101);
  
  for (int i = 0; i < N; j++) {
    int p, q;
    cin >> p;
    vecP.at(i) = p; //入力値の配列
    q = vecP.at(i);
    vecD.at(i) = abs(q-X); //差の絶対値のベクトル
  }
  
  int counter = 0;
  for (int j = 0; j < 101; i++) {
    for (int i = 0; i < N; i++) {
      if (vecD.at(i) == j) {
      vecAns.at(i) = vecP.at(i);
      counter++;
    }
      if (counter == 0)
        continue;
      else if (counter != 0)
        break;
  }
    sort(vecAns.begin(), vecAns.end());
    cout << vecAns(0) << endl;
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:11:26: error: 'j' was not declared in this scope
   11 |   for (int i = 0; i < N; j++) {
      |                          ^
a.cc:20:28: error: 'i' was not declared in this scope
   20 |   for (int j = 0; j < 101; i++) {
      |                            ^
a.cc:32:19: error: no match for call to '(std::vector<int>) (int)'
   32 |     cout << vecAns(0) << endl;
      |             ~~~~~~^~~
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main() {
  int x,n;
  cin>>x>>n;
  vector<int> vec1={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100};
  vector<int> vec2(n);
  for (int i = 0; i < n; i++) {
    cin >> vec2.at(i);
  }
  for(int i=0;i<100;i++){
    for(int j=0;j<n;j++){
      if(vec1.at(i)==vec2.at(j)){
        vec1.at(i)=1000;
      }
    }
  }
  for(int i=0;i<100;i++){
    if(vec1.at(i)>=x){
      vec1.at(i)=vec1.at(i)-x;
    }
    else{
      vec1.at(i)=x-vec1.at(i);
    }
  }
  
  
  sort(vec1.begin(), vec1.end());
  if(vec1.at(1)!=vec1.at(0)){
   cout<<x+vec1.at(0)<<endl;
  }
  else{
    cout<<x-vec.at(0)<<endl;
  }  


}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: 'vec' was not declared in this scope; did you mean 'vec2'?
   34 |     cout<<x-vec.at(0)<<endl;
      |             ^~~
      |             vec2
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;
  while(f==0)
 { 
     l--;
     r++;
     lf=0;
     rf=0;
     for(i=0; i<n; i++)
     {
         if(ar[i]!=l)
         lf++;
         if(ar[i]!=r)
         rf++;
     }
     
     if(lf==n)
     f=1;
     else
     if(rf==n)
     f=2;
     
 }
  
 if(f==1)
 cout<<l;
 else
 cout<<r;
  else
    if(n==0)
      cout<<k;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:3: error: 'else' without a previous 'if'
   40 |   else
      |   ^~~~
a.cc:42:13: error: 'k' was not declared in this scope
   42 |       cout<<k;
      |             ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int X,N;
  cin >> X >> N;
  if(N==0){
    cout << X << emdl;
    return 0;
  }
  int tmp=0;
  vector<int> P;
  for(int i=0; i<N; i++){
    cin >> tmp;
    P.push_back(tmp);
  }

  vector<int> P_non;
  bool flag = true;
  sort(P.begin(), P.end());
  for(int i=1; i<=100; i++){
    for(int j=0; j<N; j++){
      if(i == P.at(j)) flag = false;
    }
    if(flag) P_non.push_back(i);
    flag=true;
  }

  int diff=1000;
  int num=0;
  for(int i=0; i<P_non.size(); i++){
    if(abs(P_non.at(i)-X) < diff){
      diff = abs(P_non.at(i)-X);
      num = i;
    } 
  } 
  cout << P_non.at(num) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: 'emdl' was not declared in this scope
    9 |     cout << X << emdl;
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  	int x,n;
  	cin>>x>>n;
  	vector<int> v;
  	for(int i=0;i<n;i++){
    	int num;
    	cin>>num;
    	v.push_back(num);}
  	int min=1000,max=*max_element(v.begin(),v.end());
  	for(int j=-1;j<=max+1;j++){
    	if(find(v.begin(),v.end(),j)==v.end()){
        	if(abs(x-j)<min){
            	min=j;}}}
  	cout<<j;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: 'j' was not declared in this scope
   16 |         cout<<j;
      |               ^
Language: C++

#include <iostream>
#include <cstdlib>>
using namespace std;
int main()
{
    int X, N = 0;
    cin >> X >> N;
    int p[100];
    int i;
    for (i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    quick_sort(p[0], p[N - 1]);
    bool flag1;
    bool flag2;
    int a=0, b=0;
    for (i = 1; i < N+2; i++)
    {
        flag1 = 0;
        flag2 = 0;
        for (int j = 0; j < N; j++)
        {
            if (X - i == p[j])
            {
                flag1 = 1;
            }
            if (X + i == p[j])
            {
                flag2 = 1;
            }
        }
        if (flag1 == 0 or flag2 == 0)
            break;
    }
    if (flag1 == 0)
        cout << X - i << "\n";
    else
        cout << X + i << "\n";
    return 0;
}

template< class RandomIter, class Predicate =
    std::less< typename std::iterator_traits< RandomIter >::value_type > >
    static inline bool iter_sorting_swap(RandomIter a, RandomIter b,
        Predicate pred = Predicate())
{
    if (a > b) { return iter_sorting_swap(b, a); }
    // arguments must be a <= b
    return pred(*b, *a) ? std::iter_swap(a, b), true : false;
}

template< class RandomIter >
void quick_sort(RandomIter first, RandomIter last)
{
    if (last - first <= 1) { return; }
    RandomIter i = first, j = last - 1;
    for (RandomIter pivot = first;; ++i, --j)
    {
        while (*i < *pivot) { ++i; }
        while (*pivot < *j) { --j; }
        if (i >= j) { break; }
        std::iter_swap(i, j);
    }
    quick_sort(first, i);
    quick_sort(j + 1, last);
}

Compiler output:
a.cc:2:19: warning: extra tokens at end of #include directive
    2 | #include <cstdlib>>
      |                   ^
a.cc: In function 'int main()':
a.cc:14:5: error: 'quick_sort' was not declared in this scope; did you mean 'quick_exit'?
   14 |     quick_sort(p[0], p[N - 1]);
      |     ^~~~~~~~~~
      |     quick_exit
Language: C++

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

bool found(int x,int a[],int n){
	for(int i=0;i<n;i++){
		if(x==a[i]){
			return true;
			break;
		}
	}
	return false;
}
int32_t main(){
int x;
int n
cin>>x>>n;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
sort(a,a+n);
int d=x;
d++;
int pos=0;
while(pos==0){
	if(!found(d,a,n)) pos=d;
	d++;
}
int e=x;
e--;
int nex=0;
while(nex==0){
	if(!found(e,a,n))nex=e;
	e--;
}
if(x-nex>pos-x ){
	cout<<pos<<endl;
}else if(x-nex<pos-x){
	cout<<nex<<endl;
}
if(x-nex==pos-x){
	cout<<min(nex,pos)<<endl;
}
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:17:1: error: expected initializer before 'cin'
   17 | cin>>x>>n;
      | ^~~
a.cc:18:7: error: 'n' was not declared in this scope
   18 | int a[n];
      |       ^
a.cc:20:14: error: 'a' was not declared in this scope
   20 |         cin>>a[i];
      |              ^
a.cc:22:6: error: 'a' was not declared in this scope
   22 | sort(a,a+n);
      |      ^
Language: C

#include<stdio.h>

int main(void){
  int x , n;
  scanf("%d %d",&x ,&n);

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

  int ans;
  for(int i = 0;i <= 101;i ++){
    if(x-i >= -101){
      if(x-i == -1){
        ans = -1;
        i += 1000
      }
      else if(p[x-i] == 0){
        ans = x-i;
        i += 1000;
      }
      if(i <= 101){
      if(p[x+i] == 0){
        ans = x+i;
        i += 1000;
      }
      }
    }
  }

  printf("%d\n",ans);

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:18: error: expected ';' before '}' token
   18 |         i += 1000
      |                  ^
      |                  ;
   19 |       }
      |       ~
Language: C++

#include <iostream>
#include <vector>

using namespace std;


int main(){
    int X, N;
    cin >> X >> N;
    vector<int> p;

    for(int i=0; i<N; ++i){
        int a;
        cin >> a;
        p.push_back(a);
    }

    int ans;
    if( count(p.begin(), p.end(), X) == 0 ){
        ans = X;
    }else{
        //left
        int l = X-1;
        while( count(p.begin(), p.end(), l) > 0 ){
            --l;
        }

        //right 
        int r = X+1;
        while( count(p.begin(), p.end(), r) > 0 ){
            ++r;
        }

        if( abs(X-l) <= abs(r-X) ){
            ans = l;
        }else{
            ans = r;
        }

    }
    cout << ans << endl;

    // //left
    // int tmp = X;
    // int left_idx = -1;
    // int left_dist;
    // while(tmp >= 0){
    //     if(cant_use[tmp] == true){
    //         tmp--;
    //     }else{
    //         left_idx = tmp;
    //         left_dist = abs(X- left_idx);
    //         break;
    //     }

    // }

    // //right
    // int tmp2 = X;
    // int right_idx = -1;
    // int right_dist;
    // while(tmp2 <= 100){
    //     if(cant_use[tmp2] == true){
    //         tmp2++;
    //     }else{
    //         right_idx = tmp2;
    //         right_dist = abs(tmp2 - X);
    //         break;
    //     }
    // }


    // //ans
    // int ans;
    // if(left_idx == -1){
    //     ans = right_idx;
    // }else if(right_idx == -1){
    //     ans = left_idx;
    // }else{
    //     if(left_dist <= right_dist){
    //         ans = left_idx;
    //     }else{
    //         ans = right_idx;
    //     }
    // }


    // cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'count' was not declared in this scope
   19 |     if( count(p.begin(), p.end(), X) == 0 ){
      |         ^~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int x, n;
	cin >> x >> n;
	int p[n + 1];
	for (int i = 1; i <= n; ++i) cin >> p[i];
	sort(p + 1, p + n + 1);
	for (int i = 1; i <= n; ++i) cout << p[i] << " \n"[i == n];
	int minx = INT_MAX;
	for (int i = 1; i <= 100; ++i) {
		if (!binary_search(p + 1, p + n + 1, i)) {
			minx = min(minx, abs(x - i));
		};
	} 
	int res1 = x - minx;
	int res2 = x + minx;
	if (!binary_search(p + 1, p + n + 1, res1)) cout << res1 << '\n';
	else cout << res2 << '\n';
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:20: error: 'INT_MAX' was not declared in this scope
   14 |         int minx = INT_MAX;
      |                    ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <cmath>
  +++ |+#include <climits>
    4 |
Language: C++

#include<bits/stdc++.h> 
using namespace std; 
int main(){
  int x, n, min=1000; 
  int cnt=0;
  
  cin>>x>>n; 
  if(n==0){
    cout<<x; 
    return 0;
    }
  int p[n+1]; 
  for(int i=1;i<=n;i++){
    cin>>p[i];
    }
  for(int j=1;j<=150;i++){
    if(abs(x-j)<min ){
      for(int k=1;k<=n;k++){
        if(j!=p[k]) cnt++;
        if(cnt==n) min=j;
        }
      }
    if(abs(x-j)==min){
      for(int k=1;k<=n;k++){
        if(j!=p[k]) cnt++;
        if(cnt==n && j<min) min=j;
        }
      
      }
    }
    cout<<min; 
  
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:16:22: error: 'i' was not declared in this scope
   16 |   for(int j=1;j<=150;i++){
      |                      ^
Language: C++

#include <iostream>
using namespace std;
int main(){
  int x;
  cin>>x;
  int n;
  cin>>n;
  int arr[n];
  int a;
  int ans=x;
  int ans2=x;
  for(int i=0;i<n;i++){
     cin>>a;
     arr[i]=a;
  }
  for(int j=0;j<n;j++){
     if(arr[i]==ans){
        ans=ans-1;
     }else if(arr[i]==ans2){
       ans2=ans2+1
     }
  }
  if((x-ans)>=(ans2-x)){
    cout<<ans;
  }else{
    cout<<ans2;
}  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'i' was not declared in this scope
   17 |      if(arr[i]==ans){
      |             ^
a.cc:20:19: error: expected ';' before '}' token
   20 |        ans2=ans2+1
      |                   ^
      |                   ;
   21 |      }
      |      ~             
a.cc:27:2: error: expected '}' at end of input
   27 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
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;
    }
    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, large;
        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:69:2: error: expected '}' at end of input
   69 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main (){
  int x,n,a;
  cin>>x>>n;
  vector<int>vec(n);
vector<int>data(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);}
for (int i=0;i<n;i++){
  if(x>vec.at(i)){
  data.at(i)=x-vec.at(i);}
  else{
    data.at(i)=vec.at(i)-x;
  }}
  sort(data.begin(),data.end());
  for(int i=0;i<n;i++){
    if(i!=data.at(i)){
      cout<<i+x<<endl;}
  }

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

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

public class Main {
    static List<Integer> list = new ArrayList<Integer>();
    static int x = 0;

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

        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!(list.contains(x))) {
            System.out.println(x);
        } else {
            System.out.println(dfs(1));
        }
    }

Compiler output:
Main.java:22: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, n;
    cin >> x >> n;
    int p[n];
    for(int i=0; i<n; i++) cin >> p[i];
    int q[102 - n];
    for(int i=0; i<102-n; i++){
        for(int k=0; k<=101; k++){
            bool exist = false;
            for(int j=0; j<n; j++){
                if(p[j] == k){
                    exist = true;
                    break;
                }
            }
            if!(exist) q[i] = k;
        }
    }
    
    int gap[102-n];
    for(int i=0; i<102-n; i++){
        gap[i] = abs(q[i] - x);
    }
    int min = 1000;
    for(int i=0; i<102-n; i++){
        if(min > gap[i]) min = gap[i];
    }
    int pool = 0;
    int ans = 103;
    for(int i=0; i<102-n; i++){
        if(min == gap[i]){
            pool = q[i];
            if(ans > q[i]) ans = q[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: expected '(' before '!' token
   18 |             if!(exist) q[i] = k;
      |               ^
      |               (
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main (){
  int x,n,a;
  cin>>x>>n;
  vector<int>vec(n);
vector<int>data(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);}
for (int i=0;i<n;i++){
  if(x>vec.at(i)){
  data.at(i)=x-vec.at(i)}
  else{
    data.at(i)=vec.at(i)-x;
  }}
  sort(data.begin(),data.end());
  for(int i=0;i<n;i++){
    if(i!=data.at(i)){
      cout<<i+x<<endl;}
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: expected ';' before '}' token
   12 |   data.at(i)=x-vec.at(i)}
      |                         ^
      |                         ;
a.cc:20:4: error: expected '}' at end of input
   20 |   }
      |    ^
a.cc:3:12: note: to match this '{'
    3 | int main (){
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int x,n,c=10000;
  cin>>x>>n;
  vector<int>a(n),d(100);
  rep(i,n) {
    cin>>a[i];
    d[a[i]]=100000;
  }
  int ans;
  for(int i=-2;i<=100;i++){
    rep(j,n){
      if(i==a[j])
        continue;
      int b=i;
      int c=min(c,abs(b-x));
      if(abs(b-x)==c){
        ans==i;
        ans=min(ans,i);
      }
    }
  }
  cout<<ans<<endl;
}
    }
  }

Compiler output:
a.cc:41:5: error: expected declaration before '}' token
   41 |     }
      |     ^
a.cc:42:3: error: expected declaration before '}' token
   42 |   }
      |   ^
Language: Java


public class Main {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X,N;
		X=sc.nextInt();
		N=sc.nextInt();

		int syoki_hairetu[] = new int[101];
		for(int i=0;i<=100;i++) {
			syoki_hairetu[i]=i;
		}

		int p[]=new int[N];
		for(int i=0;i<N;i++) {
			p[i]=sc.nextInt();
			syoki_hairetu[p[i]]=-101;
		}

		int tmp;
		int min_abs=X;
		int min_number=X;

		for(int i=0;i<=100;i++) {
			tmp=Math.abs(X-syoki_hairetu[i]);
			if(tmp<min_abs) {
				min_abs=tmp;
				min_number=syoki_hairetu[i];
			}
		}
		System.out.println(min_number);
	}
}


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

#include <iostream>
using namespace std;
int main(void){
    int r;
    int x, n;
    int f = 0;
    cin >> x >> n;

    int l, i=0, a[n];

    int u = x + 1;
    int d = x - 1;

    while(cin>>l){
        a[i] = l;
        i++;
    }
    
    std::sort(a, a + n);
    for (int i = 0; i < n; i++) {
        if (n == 0) {
            break;
        }
        if (a[i] == x) f = 1;
        if (a[i] == u) {
            u ++;
        }
        
    }

    std::sort(a, a + n, greater<int>());

    for (int i = 0; i < n; i++) {
        if (n == 0) {
            break;
        }
        if (a[i] == x) f = 1;
        if (a[i] == d) {
            d --;
        }
        
    }

    r = x;

    if (f == 1) {
        r = d;
        if (abs(u-x) < abs (x-d)) r = u;
    }
    
    cout << r;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   19 |     std::sort(a, a + n);
      |          ^~~~
      |          qsort
a.cc:31:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   31 |     std::sort(a, a + n, greater<int>());
      |          ^~~~
      |          qsort
Language: C++

#include<bits/stdc++.h> 
using namespace std; 
int main(){
  int x, n, min=1000; 
  int cnt=0;
  
  cin>>x>>n; 
  if(n==0){
    cout<<x; 
    return 0;
    }
  int p[n+1]; 
  for(int i=1;i<=n;i++){
    cin>>p[i];
    }
  for(int j=1;j<=150;i++){
    if(abs(x-j)<min ){
      for(int k=1;k<=n;k++){
        if(j!=p[k]) cnt++;
        if(cnt==n) min=j;
        }
      }
    }
    cout<<min; 
  
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:16:22: error: 'i' was not declared in this scope
   16 |   for(int j=1;j<=150;i++){
      |                      ^
Language: Java

import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
		Scanner scn  = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
  		if(b==0){
          System.out.println(a);
		
		HashMap<Integer,Integer> map = new HashMap<>();
		for(int i=0;i<b;i++) {
			map.put(scn.nextInt(), 1);
		}
		int p=Integer.MAX_VALUE;
		int q=Integer.MAX_VALUE;
		for(int i=a;i>0;i--) {
			if(!map.containsKey(i)) {
				p=a-i;
				break;
			}
		}
		for(int i=a+1;i<=100;i++) {
			if(!map.containsKey(i)) {
				 q=i-a;
				break;
			}
		}
		if(p<=q) {
			System.out.println(a-p);
		}
		else {
			System.out.println(a+q);
		}
 
	}
 
}

Compiler output:
Main.java:39: error: reached end of file while parsing
}
 ^
1 error
Language: C++

#include <iostream>
using namespace std;
int main(void){
    int r;
    int x, n;
    int f = 0;
    cin >> x >> n;

    int l, i=0, a[n];

    int u = x + 1;
    int d = x - 1;

    while(cin>>l){
        a[i] = l;
        i++;
    }
    
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        if (n == 0) {
            break;
        }
        if (a[i] == x) f = 1;
        if (a[i] == u) {
            u ++;
        }
        
    }

    sort(a, a + n, greater<int>());

    for (int i = 0; i < n; i++) {
        if (n == 0) {
            break;
        }
        if (a[i] == x) f = 1;
        if (a[i] == d) {
            d --;
        }
        
    }

    r = x;

    if (f == 1) {
        r = d;
        if (abs(u-x) < abs (x-d)) r = u;
    }
    
    cout << r;
}

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

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

int main() {
  int x, N, a;
  cin >> x >> N;
  a=101;
  for (int i=0; i<N; i++){
    int y;
    cin >> y;
    if( abs(x-y) < abs(x-a) ) {
      a = y;
    } else if ( abs(x-y)==abs(x-a) && a>y ){
      a = y;
    }
  cout << a << endl;
  return 0;
}


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

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

int main() {
  int x,n;
  cin>>x>>n;
  if(n==0)
    cout<<x<<endl;
  
  else{
    vector<int> p(n);
    vector<int> vec(100,1)
    for(int i=0;i<n;i++){
      cin>>p.at(i);
      vec.at(p.at(i))=0;
    }
    //最もxに近いpの値を保持
    int ans=0;
    //xとpの差の最小値を保持
    int p_min=100;
    for(int i=0;i<100;i++){
      if(vec.at(i)==1){
        if(p_min > abs((i+1)-x))){
          p_min=abs((i+1)-x);
          ans=i+1;
        }
        if(p_min == abs((i+1)-x))
          ans=min(ans,i+1);
      }
    }
    cout<<ans<<endl;
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: expected ',' or ';' before 'for'
   13 |     for(int i=0;i<n;i++){
      |     ^~~
a.cc:13:17: error: 'i' was not declared in this scope
   13 |     for(int i=0;i<n;i++){
      |                 ^
a.cc:23:33: error: expected primary-expression before ')' token
   23 |         if(p_min > abs((i+1)-x))){
      |                                 ^
Language: C++

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

void primeFactorization2(uint64_t number, list<uint64_t> &factors){
  uint64_t val = sqrt(number);
  for (uint64_t i = 2; i <= val; i++){
    while (number % i == 0){
      number /= i;
      factors.push_back(i);
	}
  }
  if(number != 1){
    factors.push_back(number);
  }
}

signed main() {
  int x, n;
  cin >> x >> n;
  int *p = new int[101];
  int val = 0;
  for(int i = 1; i <= n; i++){
    cin >> val;
    p[val] = 1;
  }

  bool isEnd = false;
  bool isStart  = false;
  int answer = 0;
  for(int i = 0; i <= n; i++){
    if(x-i==0){
      isStart = true;
    }
    if(x+i==101){
      isEnd = true;
    }
    if(!isStart){
      if(p[x-i]==0){
        isFound = true;
        cout << x-i << endl;
        return 0;
      }
    }
    if(!isEnd){
      if(p[x+i]==0){
        cout << x+i << endl;
        return 0;
      }
    }
  }
  if(x<=50){
  	cout << "0" << endl;
  }
  else{
    cout << "101" << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:105:9: error: 'isFound' was not declared in this scope; did you mean 'isEnd'?
  105 |         isFound = true;
      |         ^~~~~~~
      |         isEnd
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define INF 1000000000001
#define se second
#define mod 1000000007
int main()
{
	
	ll x,n,ans;
	cin>>x>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		ma[a[i]]++;
	}
	ll j=0;
	while(1)
	{
		if(ma[x-j]==0)
		{
			ans=x-j;
			break;
		}
		else if(ma[x+j]==0)
		{
			ans=x+j;
			break;
		}
		else
		{
			j++;
		}
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: 'ma' was not declared in this scope; did you mean 'a'?
   19 |                 ma[a[i]]++;
      |                 ^~
      |                 a
a.cc:24:20: error: 'ma' was not declared in this scope; did you mean 'a'?
   24 |                 if(ma[x-j]==0)
      |                    ^~
      |                    a
Language: C++

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


int main() {
    int X, N;
    cin >> X >> N;
    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;
    }
    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 {
        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;
            }
        }
        int small, large;
        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:45:9: error: 'else' without a previous 'if'
   45 |         else {
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define MAXN 10000001

int main ()
{
    ll T;
    T=1;
    //cin>>T;
    while(T--)
    {
   
   int x,n;
   cin>>x>>n;
    	set<int> st;
    	if(n==0)cout<<x<<endl;
    	else{
    	fori(i,0,n){int x;cin>>x;st.insert(x);}
            int d=INT_MAX,ans=0;
            for(int i=0;i<102;i++){
            	if(st.count(i)==0){
            		if(abs(x-i)<d){ans=i;d=abs(x-i);}
            	}
            }
    cout<<ans<<endl;
    	}
    
    	
    	}
    }
    return 0;
}


Compiler output:
a.cc:48:5: error: expected unqualified-id before 'return'
   48 |     return 0;
      |     ^~~~~~
a.cc:49:1: error: expected declaration before '}' token
   49 | }
      | ^
Language: C++

// include all standard library.
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(int argc, char const *argv[]) {
  int x, n;
  vector<int> p;
  cin >> x >> n;
  if( n == 0) { cout << x << endl; return 0;}

  for(int i=0; i< n;i++){
      int k;
      cin >> k;
      p.push_back(k);
  }

  // 数列pに含まれない整数でxに最も近いものをプリント
  // 複数ある時は小さいものを答える．
  int d = 0;
  for(true) {
      bool flag = true;
      int curr = d+ x;
      for( int i = 0; i<n; i++){
          if(p[i] == curr){
              flag = false;
              break;
          }
      }
      if(flag) {
          cout << curr << endl;
          return 0;
      }
  }  

  return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:22:11: error: expected ';' before ')' token
   22 |   for(true) {
      |           ^
      |           ;
a.cc:37:3: error: expected primary-expression before 'return'
   37 |   return 0;
      |   ^~~~~~
a.cc:35:4: error: expected ';' before 'return'
   35 |   }
      |    ^
      |    ;
   36 | 
   37 |   return 0;
      |   ~~~~~~
a.cc:37:3: error: expected primary-expression before 'return'
   37 |   return 0;
      |   ^~~~~~
a.cc:35:4: error: expected ')' before 'return'
   35 |   }
      |    ^
      |    )
   36 | 
   37 |   return 0;
      |   ~~~~~~
a.cc:22:6: note: to match this '('
   22 |   for(true) {
      |      ^
Language: C++

#include<bits/stdc++.h>
#define console
using namespace std;
#ifndef console
ifstream fin("data.in");
ofstream fout("data.out");
#else
#define fin cin
#define fout cout
#endif
#define usain_bolt() (ios_base::sync_with_stdio(false), \
fin.tie(NULL), fout.tie(NULL))
typedef long long ll;
int main()
{
    usain_bolt();
    ll x, n, cit, minn = INT_MAX, rez;
    fin >> x >> n;
    if (!n) fout << x;
    else 
    {
		vector<int> vf(105);
		for (int i = 1; i <= n; ++i)
		{
			fin >> cit;
			++vf[cit];
		}
		for (int i = 1; i <= 101; ++i)
		{
			if (!vf[i])
			{
				if (abs(i - x) < minn)
					minn = abs(i - x), rez = i;
				if (abs(-i - x) < minn)
					minn = abs(-i - x), rez = -i;
				else if (abs(-i - x) == min && rez > i)
					minn = abs(-i - x), rez = -i;
			}
		}
		fout << rez;
	}
#ifndef console
    fin.close(), fout.close();
#endif
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:54: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator=='
   36 |                                 else if (abs(-i - x) == min && rez > i)
      |                                          ~~~~~~~~~~~~^~~~~~
Language: C++

#include <iostream>
using namespace std;

int main()
{
    int x, n;
    cin >> x >> n;
    bool flag[102];
    int p;
for(int i=0; i<102; i++){
        flag[i] = false;
    } 

    for(int i=0; i<n; i++){
        cin >> p;
        flag[p] = true;
    } 

    int d = 0;
    while(1){
        if(flag[x-d]==false) {cout <<  x-d << endl; break;}
        if(flag[x+d]==false) {cout <<  x+d << endl; break;}
        d++;
    }


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

#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;


int main(){
    int n, m;
    cin >> n >> m;
    int ns[100];
    for(int i = 0; i < 100; i++){
        ns[i] = 1;
    }

    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        ns[x - 1] = 0;
    }
    int ans = 10000;
    for(int i = 0; i < 100; i++){
        if(abs(n - ans) > abs(n - (i + 1))){
            if(ns[i]) ans = i + 1;
        }
    }

    if(abs(n - ans) >= abs(n - 0){
         ans = 0;
    }

    if(abs(n - ans) >= abs(n - (-1))){
         ans = -1;
    }

    cout << ans << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:34: error: expected ';' before '{' token
   36 |     if(abs(n - ans) >= abs(n - 0){
      |                                  ^
      |                                  ;
a.cc:40:5: error: expected primary-expression before 'if'
   40 |     if(abs(n - ans) >= abs(n - (-1))){
      |     ^~
a.cc:38:6: error: expected ')' before 'if'
   38 |     }
      |      ^
      |      )
   39 | 
   40 |     if(abs(n - ans) >= abs(n - (-1))){
      |     ~~
a.cc:36:7: note: to match this '('
   36 |     if(abs(n - ans) >= abs(n - 0){
      |       ^
Language: C++

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

int main(){
    int x, n;
    cin >>x>>n;
    vector<int>p(101);
    //int min = 100000;
    rep(i,n){
        int p0;
        cin >>p0;
        p[p0] = 1;
    }
    if(n==0){
        cout <<x<<endl;
    }
    else{
    int ans = 10000;
    for(int i=1;i<100;i++){
        int num1 = x-i;
        int num2 = x+i;
        if(num1<1){}
        else if(p[num1]!=1){
            ans = num1;
            break;
        }
        if(num2>100){}
        else if(p[num2]!=1){
            ans = num2;
            break;
        }
        
    }
    
    cout <<ans<<endl;a
    }
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:22: error: 'a' was not declared in this scope
   41 |     cout <<ans<<endl;a
      |                      ^
Language: C++



//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define endl '\n'


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

	int x, n, p;
	cin >> x >> n;
	vector<int> v;
	while (n--)
	{
		cin >> p;
		v.push_back(p);
	}
	int l = x, r = x, ansL = INT_MIN, ansR = INT_MIN;
	bool found = false;
	while (!found)
	{
		if (find(v.begin(), v.end(), l) == v.end())
		{
			found = true;
			ansL = l;
		}
		if (find(v.begin(), v.end(), r) == v.end())
		{
			found = true;
			ansR = r;
		}
		l--;
		r++;
	}
	if (ansL == INT_MIN)
		cout << ansR << endl;
	else
		cout << ansL << endl;

	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:34: error: 'INT_MIN' was not declared in this scope
   24 |         int l = x, r = x, ansL = INT_MIN, ansR = INT_MIN;
      |                                  ^~~~~~~
a.cc:7:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <algorithm>
  +++ |+#include <climits>
    7 | using namespace std;
a.cc:36:25: error: 'ansR' was not declared in this scope; did you mean 'ansL'?
   36 |                         ansR = r;
      |                         ^~~~
      |                         ansL
a.cc:42:25: error: 'ansR' was not declared in this scope; did you mean 'ansL'?
   42 |                 cout << ansR << endl;
      |                         ^~~~
      |                         ansL
Language: Java

package codeforces;
import java.util.*;
import java.io.*;

public class chef1 {
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int x=Integer.valueOf(cmd[0]);
		int n=Integer.valueOf(cmd[1]);
		int[] arr=new int[101];
		cmd=br.readLine().split(" ");
		for(int i=0;i<n;i++)
		{
			arr[Integer.valueOf(cmd[i])]=1;
		}
		int len=0;
		int ans=-1;
		while(true)
		{
			int a=x-len;
			int b=x+len;
			if(arr[a]==0)
			{
				ans=a;
				break;
			}
			if(arr[b]==0)
			{
				ans=b;
				break;
			}
			len++;
		}
		System.out.println(ans);
	}

}


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

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


int main(){

int x,n;
cin >> x >> n;

int a = 101;
int ab = abs(x-a);
int ans = a;

if(n == 0){
ans = x;
goto goal;
}
set<int>p;
int tmp;
rep(i,n){
    cin >> tmp;
    p.insert(tmp);    
}

while(a > -2){
    //あるかチェック
    if(p.count(a)) {
        a--;
        continue;
    }
    else{
        if(ab >= abs(x-a)){
            ab = abs(x-a);
            ans = a;
        }
        a--;
    }
    
}

goal:
cout  << ans << endl;



    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:1: error: jump to label 'goal'
   45 | goal:
      | ^~~~
a.cc:20:6: note:   from here
   20 | goto goal;
      |      ^~~~
a.cc:22:9: note:   crosses initialization of 'std::set<int> p'
   22 | set<int>p;
      |         ^
Language: C++

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int x,n;cin>>x>>n;
  vector<ll> p(n);
  set<int> s;
  rep(i,n){
    cin >>p[i];
    s.insert(p[i]);
  }
  int ans=101;
  int key1=100;
  sort(all(p));
  rep2(i,x,101){
    int a=s.size();
    s.insert(i);
    b=s.size();
    if(a!=b){
      key1=i-x;
      ans=i;
      break;
    }
  }
  int key2;
  for(int i=x-1;x>=0;i--){
    int a=s.size();
    s.insert(i);
    b=s.size();
    if(a!=b){
      key2=x-i;
      if(key2<=key1||ans==101){
        ans=i;
      }
      break;
    }
  }
    cout <<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:5: error: 'b' was not declared in this scope
   34 |     b=s.size();
      |     ^
a.cc:45:5: error: 'b' was not declared in this scope
   45 |     b=s.size();
      |     ^
Language: C++

#include<bits/stdc++.h>
usimg namespace std;
int main(){
  int n,x;
  cin>>x>>n;
  map<int,int> m;
  for(int i=0;i<n;i++){
    int ele;
    cin>>ele;
    m[ele]++;
  }
  int i;
  for(i=x;i>=1;i--){
    if(m[i]==0)break;
  }
  int min=i;
   for(i=x+1;i<=100;i++){
    if(m[i]==0)break;
   }
  int max=i;
  int ans=abs(min-x)<abs(max-x)?min:max;
  printf("%d",ans);
  return 0;
}

Compiler output:
a.cc:2:1: error: 'usimg' does not name a type
    2 | usimg namespace std;
      | ^~~~~
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   cin>>x>>n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:6:3: error: 'map' was not declared in this scope
    6 |   map<int,int> m;
      |   ^~~
a.cc:6:3: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_map.h:102:11: note:   'std::map'
  102 |     class map
      |           ^~~
/usr/include/c++/14/map:89:13: note:   'std::pmr::map'
   89 |       using map
      |             ^~~
a.cc:6:7: error: expected primary-expression before 'int'
    6 |   map<int,int> m;
      |       ^~~
a.cc:10:5: error: 'm' was not declared in this scope
   10 |     m[ele]++;
      |     ^
a.cc:14:8: error: 'm' was not declared in this scope
   14 |     if(m[i]==0)break;
      |        ^
a.cc:18:8: error: 'm' was not declared in this scope
   18 |     if(m[i]==0)break;
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int main()
{
    int n,x;
    cin>>x>>n;
    int a[n];
    int d[102]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
        d[a[i]]=1;
    }
    int ab=INT_MAX;
    for(int i=0;i<=101;i++){
        if(d[i]==0){
            if(abs(i-x)<ab){
                ab=abs(i-x);
                ans=i;
            }
        }
    }
    cout<<ans;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |                 ans=i;
      |                 ^~~
      |                 abs
a.cc:36:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |     cout<<ans;
      |           ^~~
      |           abs
Language: C

#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
  int x,n;
  cin>>x>>n;
  if(n==0)
    cout<<x;
  else
  {
    vector <int> p;
    vector <int> ne;
    int a;
    for(int i=1;i<=n;i++)
    {
      cin>>a;
      if(a>=x)
      {p.pb(a-x);}
      else
      {ne.pb(x-a);}
    }
    int n1,n2;
    sort(p.begin(),p.end());
    sort(ne.begin(),ne.end());
    for(int i=0;i<p.size();i++)
    {
      if(p[i]!=i)
      {n1=i;break;}
      if(i==(p.size()-1) && p[i]==i)
      {n1=i+1;}
    }
    for(int i=0;i<ne.size();i++)
    {
      if(ne[i]!=(i+1))
      {n2=i+1;break;}
      if(i==(ne.size()-1) && ne[i]==(i+1))
      {n2=i+2;}
    }
    if(n1==n2)
      cout<<x-n2;
    else if(n1<n2)
      cout<<x+n1;
    else
      cout<<x-n2;
  }
}

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

//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES

using namespace std;




int main()
{
    int x,n;
    unordered_map<int,int>mp;
    cin>>x>>n;
    int a[n],i;
    for(i=0;i<n;i=i+1){ cin>>a[i]; mp[a[i]]++;}
    int val = 0, minm = INT_MAX;
    for(int i=-101;i<=101;i=i+1)
    {
        if(mp[i]==0)
        {
            if(abs(i-x)<minm){minm=abs(i-x);val=i;}
        }
    }
    cout<<val<<endl;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:36:25: error: 'INT_MAX' was not declared in this scope
   36 |     int val = 0, minm = INT_MAX;
      |                         ^~~~~~~
a.cc:22:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   21 | #include <numeric>
  +++ |+#include <climits>
   22 | #define _USE_MATH_DEFINES