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

/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int a[101001];
bool f[101010];
int main()
{
	int n,m;
	cin>>n>>m;
	int i;
	for(i=0;i<m;i++){
		cin>>a[i];
		f[a[i]]=1;
	}
	int i1=n,i2=n,i=0;
	while(1){
		if(f[i1]==0&&f[i2]==0){
			cout<<i<<endl;
			return 0;
		}
		i1++;i2--;i++;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:23: error: redeclaration of 'int i'
   41 |         int i1=n,i2=n,i=0;
      |                       ^
a.cc:36:13: note: 'int i' previously declared here
   36 |         int i;
      |             ^
Language: Java

import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      
      	int x = sc.nextInt();
      	int n = sc.nextInt();
      
        Integer p[] = new int[n];
      
      	for(int i = 0; i < n; i++){
        	p[i] = sc.nextInt();
        }
      
      	if(n == 0){
          System.out.print(x);
          return;
        }
      
      	List<Integer> list = Arrays.asList(p);
      
      	int r = 0;
     	for(int i =0; i < 100; i++){
          	r = x - i;
          
          	if(!list.contains(r)){
            	System.out.print(r);
              return;
            }
          
          	r = x + i;
          
          	if(!list.contains(r)){
            	System.out.print(r);
              return;
            }
          
        }
      
    }
}


Compiler output:
Main.java:10: error: incompatible types: int[] cannot be converted to Integer[]
        Integer p[] = new int[n];
                      ^
1 error
Language: Java

import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      
      	int x = sc.nextInt();
      	int n = sc.nextInt();
      
        Integer p[] = new int[n];
      
      	for(int i = 0; i < n; i++){
        	p[i] = sc.nextInt();
        }
      
      	if(n == 0){
          System.out.print(x);
          return;
        }
      
      	List<Integer> list = Arrays.asList(p);
      
      	int r = 0;
     	for(int i =0; i < 100; i++){
          	r = x - i;
          
          	if(!p.contains(r)){
            	System.out.print(r);
              return;
            }
          
          	r = x + i;
          
          	if(!p.contains(r)){
            	System.out.print(r);
              return;
            }
          
        }
      
    }
}


Compiler output:
Main.java:10: error: incompatible types: int[] cannot be converted to Integer[]
        Integer p[] = new int[n];
                      ^
Main.java:27: error: cannot find symbol
          	if(!p.contains(r)){
          	     ^
  symbol:   method contains(int)
  location: variable p of type Integer[]
Main.java:34: error: cannot find symbol
          	if(!p.contains(r)){
          	     ^
  symbol:   method contains(int)
  location: variable p of type Integer[]
3 errors
Language: C++

#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
const ll INF=10000000010101001;
int main(){
    ll x,n;cin>>x>>n;
    vector<ll> p(n);
    rep(i,n)cin>>p[i];
    ll tmp=INF;
    ll ans=0;
    for(int i=-1;i<=101;i++){
        if(find(all(p),i)==p.end()){
       if(tmp>abs(x-i))ans=i;
        tmp=min(tmp,abs(x-i));
    }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'vector' was not declared in this scope
   11 |     vector<ll> p(n);
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | #include<string>
a.cc:6:12: error: expected primary-expression before 'long'
    6 | #define ll long long
      |            ^~~~
a.cc:11:12: note: in expansion of macro 'll'
   11 |     vector<ll> p(n);
      |            ^~
a.cc:12:18: error: 'p' was not declared in this scope
   12 |     rep(i,n)cin>>p[i];
      |                  ^
a.cc:16:21: error: 'p' was not declared in this scope
   16 |         if(find(all(p),i)==p.end()){
      |                     ^
a.cc:5:17: note: in definition of macro 'all'
    5 | #define all(x) (x).begin(), (x).end()
      |                 ^
Language: Java

import java.util.*;
import java.lang.Math.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
      int x=sc.nextInt();
      int n=sc.nextInt();
      int bigans=x;
      int smlans=x;
      for(int i=0;i<n;i++){
        int nx=sc.nextInt();
        if(bigans==nx){
          bigans=nx+1;
        }
        if(smlans==nx){
          smlans=nm-1;
        }
      }
      if(Math.abs(smlans)<Math.ans(bigans)){
        System.out.println(smlans);
      }else{
        System.out.println(bigans);
      }
}
}

Compiler output:
Main.java:17: error: cannot find symbol
          smlans=nm-1;
                 ^
  symbol:   variable nm
  location: class Main
Main.java:20: error: cannot find symbol
      if(Math.abs(smlans)<Math.ans(bigans)){
                              ^
  symbol:   method ans(int)
  location: class Math
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,n;
  scanf("%d %d",&x,&n);
  int arr[n];
  int a;
  for(int i=0;i<n;i++)
  {
    scanf("%d",&arr[i]);
  }
  int prefix=0,suffix=0,j,flag=0,got=1;
  while(flag==0)
  {
  	for(int i=0;i<n;i++)
  	{
  	  if(x+prefix==arr[i])
      {
        got=0;
        break;
      }
    if(got==1)
      break;
    else
    {
      prefix++;
      got=1;
    }
    }
  }
  while(flag==0)
  {
  	for(int i=0;i<n;i++)
  	{
  	  if(x-suffix==arr[i])
      {
        got=0;
        break;
      }
    }
    if(got==1)
      break;
    else
    {
      suffix--;
      got=1;
    }
   if(x-suffix==0)
   {
     suffix=10000;
     break;
   }
  }
  if(suffix<=prefix)
    printf("%d",x-suffix);
  else
    printf("%d",x+prefix);

Compiler output:
a.cc: In function 'int main()':
a.cc:58:27: error: expected '}' at end of input
   58 |     printf("%d",x+prefix);
      |                           ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: Java

import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      
      	int x = sc.nextInt();
      	int n = sc.nextInt();
      
        int p[] = new int[n];
      
      	for(int i = 0; i < n; i++){
        	p[i] = sc.nextInt();
        }
      
      	if(n == 0){
          System.out.print(x);
          return;
        }
      
      	List<Integer> list = Arrays.asList(p);
      
      	int r = 0;
     	for(int i =0; i < 100; i++){
          	r = x - i;
          
          	if(p.contains(r)){
            	System.out.print(r);
              return;
            }
          
          	r = x + i;
          
          	if(p.contains(r)){
            	System.out.print(r);
              return;
            }
          
        }
      
    }
}


Compiler output:
Main.java:21: error: incompatible types: inference variable T has incompatible bounds
      	List<Integer> list = Arrays.asList(p);
      	                                  ^
    equality constraints: Integer
    lower bounds: int[]
  where T is a type-variable:
    T extends Object declared in method <T>asList(T...)
Main.java:27: error: cannot find symbol
          	if(p.contains(r)){
          	    ^
  symbol:   method contains(int)
  location: variable p of type int[]
Main.java:34: error: cannot find symbol
          	if(p.contains(r)){
          	    ^
  symbol:   method contains(int)
  location: variable p of type int[]
3 errors
Language: C++

#include <iostream>
using namespace std;

int main() {
    int x, n;
    scanf("%d %d", &x, &n);
    int p[200];
    int nMin = 100000;
    int nMinTmp = 1000000;
    int vis[200];
    memset(vis, 0, sizeof(vis));
    for(int i=0; i<n; i++) {
        scanf("%d", &p[i]);
        vis[p[i]] = 1;
    }
    for(int i=0; i<=100; i++) {
        if(vis[i] == 0 && abs(i - x) <= nMinTmp) {
            if(abs(i - x) == nMinTmp) {
                if(nMin > i) {
                    nMin = i;
                }
            }
            else {
                nMin = i;
                nMinTmp = abs(i - x);
            }
            
        }
    }
    
    printf("%d\n", nMin);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'memset' was not declared in this scope
   11 |     memset(vis, 0, sizeof(vis));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
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 a, b = -1;
	int c, d = 0;
	int min = 101;

	for (int i = 1; i < 101; i++) {
		if (x + i =< 100) {
			a = (x + i);
		}
		if (x - i >= 1) {
			b = (x - i);
		}

		if (a != -1) {
			for (int j = 0; j < n; j++) {
				if (a == p[j]) {
					c++;
				}
			}
			if (c == 0) {
				if (min < a) {
					min = a;
				}
			}
		}
		if (b != -1) {
			for (int j = 0; j < n; j++) {
				if (b == p[j]) {
					d++;
				}
			}
			if (d == 0) {
				if (min < b) {
					min = b;
				}
			}
		}

		cout << min << endl;

		return 0;
   }

Compiler output:
a.cc: In function 'int main()':
a.cc:17:28: error: expected primary-expression before '<' token
   17 |                 if (x + i =< 100) {
      |                            ^
a.cc:52:5: error: expected '}' at end of input
   52 |    }
      |     ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: Java

import java.util.*;

public class Main{
public static void main(String[] args)
{ 
  Scanner sc=new Scanner(System.in);
  int x=sc.nextInt();
  int n=sc.nextInt();
  Set<Integer> set =new Set<>();
  for(int i=0;i<n;i++)
    set.add(sc.nextInt());
  int ans=0;
  for(int i=x;;i++)
  {
    if(!set.contains(i+1))
    { ans=i+1;
     break;}
    else if(!set.contains(i-1))
    {ans=i-1
      break}
  }

  System.out.println(ans);
}
 
}


Compiler output:
Main.java:19: error: ';' expected
    {ans=i-1
            ^
Main.java:20: error: ';' expected
      break}
           ^
2 errors
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
    bool arr[102];
    fill(arr, arr+102, false);
    int x, n;
    cin >> x >> n;
    int tmp;
    for(int i=0; i<n; i++){
        cin >> tmp;
        arr[tmp] = true;
    }
    int i = x;
    int j = x;
    while(arr[i]){
        i--;
    }
    while(arr[j]){
        j++;
    }
    if(i == j){
        cout << i << '\n';
    }
    else{
        if(x - i == j - x){
            cout << i << '\n';
        }
        else if( x - i < j - x){
            cout << i << '\n';
        }
        else{
            cout << j << '\n';
        }
    }
    

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

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

int main(){
    int x,n;
    cim >> x >> n;
    int p[n],cot[n];
    for(int i = 0;i < n ;i++ ){
        cot[p[i]] = 1;
    }
    int number = 0;
    for(int i = 0 ; i < n; i++){
        if(cot[i] == 1){
            number = i;
        }
    }
    int ans = p[0];
    for(int i=0;i<n;i++){
        if(abs(number - ans) > abs(number - p[i])){
            ans = p[i];
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'cim' was not declared in this scope
    6 |     cim >> x >> n;
      |     ^~~
Language: Java

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.IntToDoubleFunction;

import org.junit.experimental.theories.FromDataPoints;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = getInt(sc);
		int n = getInt(sc);
		List<Integer> p = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			p.add(getInt(sc));
		}

		for (int i = 0; i < 100; i++) {
			if (!p.contains(x - i)) {
				System.out.println(x - i);
				break;
			} else if (!p.contains(x + i)) {
				System.out.println(x + i);
				break;
			}
		}

	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Compiler output:
Main.java:8: error: package org.junit.experimental.theories does not exist
import org.junit.experimental.theories.FromDataPoints;
                                      ^
1 error
Language: C++

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

int main(){
	int x, n;
	cin >> x >> n;
	
	if (n == 0) {
		cout << x << endl;
		return 0;
	}
	
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	
	rep(i, n) {
		if (p[i] == x) {
			cout << x << endl;
			return 0;
		}
	}
	
	int a = 1;
	int plus;
	while (true) {
		bool judgep = true;
		rep(i, n) {
			if (p[i] == x + a) {
				judgep = false;
				break;
			}
		}
		if (judgep) {
			plus = x + a;
			break;
		}
		a++;
	}

	int b = 1;
	int minus;
	while (true) {
		bool judgem = true;
		rep(i, n) {
			if (p[i] == x - b) {
				judgem =  false;
				break;
			}
		}
		if (judgen) {
			minus = x - b;
			break;
		}
		b++;
	}
	
	if (plus - x < x - minus) {
		cout << plus << endl;
	} else {
		cout << minus << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:21: error: 'judgen' was not declared in this scope; did you mean 'judgem'?
   52 |                 if (judgen) {
      |                     ^~~~~~
      |                     judgem
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0xfff;
const int maxn = 100005;
ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int a[200] = {0};
int main()
{
    int x, n;
    cin >> x >> n;
    int b;
    for (int i = 1; i <= n;i++)
    {
        cin >> b;
        a[b]++;
    }
    int left=0, right=111;
    int i, j;
    for (i = x; i >= 1;i--)
    {
        if(!a[i]) {
            break;
        }
    }
    for ( j = x; j <= 100;j++)
    {
        if(!a[i]) {
            break;
        }
    }
    if()
    if(j-x < x-i)
        cout <<  j<<endl;
    else if(j-x == x-i)
        cout << i <<endl;
    else {
        cout << i<< endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:8: error: expected primary-expression before ')' token
   39 |     if()
      |        ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: no match for call to '(std::vector<int>) (int&)'
    7 |     cin >> p(i);
      |            ~^~~
a.cc:18:13: error: 'i' was not declared in this scope
   18 |     if(p.at(i)>X) {
      |             ^
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;
  sort(all(p));
  rep2(i,x,101){
    int a=s.size();
    s.insert(i);
    if(a!=s.size()){
      key1=i-x;
      ans=i;
      break;
    }
  }
  int key2;
  for(int i=x-1;x>=0;x--){
    int a=s.size();
    s.insert(i);
    if(a!=s.size()){
      key2=x-i;
      if(key2<=key1||ans==101){
        ans=i;
      }
      break;
    }
  }
    cout <<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:10: error: expected initializer before '==' token
   28 |   int ans==101;
      |          ^~
a.cc:36:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |       ans=i;
      |       ^~~
      |       abs
a.cc:46:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |       if(key2<=key1||ans==101){
      |                      ^~~
      |                      abs
a.cc:52:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   52 |     cout <<ans<<endl;
      |            ^~~
      |            abs
Language: Java

import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      
      	int x = sc.nextInt();
      	int n = sc.nextInt();
      
        int p[] = new int(n);
      
      	for(int i = 0; i < n; i++){
        	p[i] = sc.nextInt();
        }
      
      	if(n == 0){
          System.out.print(x);
          return;
        }
      
      	Arrays.sort(p);
      
      	boolean flg = true;
      	int r = 0;
      	int diff = Integer.MAX_VALUE;
     	for(int i =0; i < n; i++){
          	if(x - p[i] < diff){
            	diff = x - p[i];
                r = p[i];
            }
        }
      	System.out.print(r);
      
    }
}


Compiler output:
Main.java:10: error: '[' expected
        int p[] = new int(n);
                         ^
Main.java:10: error: ']' expected
        int p[] = new int(n);
                            ^
2 errors
Language: C

#include<stdio.h>

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

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

  int ans;
  for(int i = 0;i <= 100;i ++){
    if(x-i >= 0){
      if(p[x-i] == 0){
        ans = x-i;
        i += 1000;
      }
    if(i < 500){
      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:31:1: error: expected declaration or statement at end of input
   31 | }
      | ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"


int main(){

        int x,n; cin >> x>>n;
        vi a(n);
        rep(i,n)cin >> a[i];
        sort(all(a));
        rep1(i,x-1,100){
            bool f = binary_search(all(a),i);
            if(!f){
                cout<<i<<endl;
                return 0;
            }
        }


return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'vi' was not declared in this scope
   18 |         vi a(n);
      |         ^~
a.cc:19:24: error: 'a' was not declared in this scope
   19 |         rep(i,n)cin >> a[i];
      |                        ^
a.cc:20:18: error: 'a' was not declared in this scope
   20 |         sort(all(a));
      |                  ^
a.cc:3:17: note: in definition of macro 'all'
    3 | #define all(v) (v).begin(),(v).end()
      |                 ^
Language: C++

#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int main()
{
	int n,x;
	bool a[110];
	rep(i,110)
	{
		a[i]=1;
	}
	cin>>x>>n;
	int ans=0;
	rep(i,n)
	{
		int b;
		cin>>b;
		a[b]=false;
	}
	int minn=1e9;
	rep3(i,102)
	{
		if(a[i]&&abs(x-i)<minn)
		{
			ans=i;
			minn=abs(x-i);
		}
	}
	cout<<ans;
	return 0;
}

Compiler output:
a.cc:63:19: error: macro "rep3" requires 3 arguments, but only 2 given
   63 |         rep3(i,102)
      |                   ^
a.cc:33:9: note: macro "rep3" defined here
   33 | #define rep3(i,a,n) for(ll i=(a);i<(n);i++)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:63:9: error: 'rep3' was not declared in this scope
   63 |         rep3(i,102)
      |         ^~~~
Language: C++

/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define repk(a) for(int k=0;k<int(a);k++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)
#define l_b lower_bound
#define u_b upper_bound
#define b_s binary_search

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}
int keta(int num) {
	int n = 0;
	if (num == 0) {
		return 1;
	}
	while (num != 0) {
		num /= 10;
		n++;
	}
	return n;
}
int gcd(int n, int m) {
	
	int a = 0;
	return 0;
}

int x, n,p[123],a,b,A,B;
signed main() {
	cin >> x >> n;
	rep(n)cin >> p[i];
	sort(p, p + n);
	int i = x;
	while (1) {
		int z=0;
		repj(n) {
			if (p[j] == i) {
				z++;
			}
		}
		if (z==1)i++;
		else {
			a = sa(i, x);
			A = i;
			break;
		}
	}
	i = x;
	while (1) {
		bool z = 0;
		repj(n) {
			if (p[j] == i) {
				z++;
			}
		}
		if (z==1)i--;
		else {
			b = sa(i, x);
			B = i;
			break;
		}
	}
	if (a < b)cout << A << endl;
	else cout << B << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:109:33: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
  109 |                                 z++;
      |                                 ^
Language: Java

import java.util.*;
import java.lang.Math.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
        int X = sc.nextInt();
        int n = sc.nextInt();
      if(n==0){
        System.out.println(X);
      }else{
        int cannnotuse[]=new int[100];
        for(int i=0;i<n;i++){
          cannnotuse[sc.nextInt-1]=1;
        }
      int abssa=100;
      int realsa=100;
        for(int i=0;i<100;i++){
          if(Math.abs(cannnotuse[i]-X)<abssa){
            abssa=Math.abs(cannnotuse[i]-X);
            realsa=cannnotuse[i]-X;
          }
        }
      System.out.println(X+realsa);
      }
}
}

Compiler output:
Main.java:14: error: cannot find symbol
          cannnotuse[sc.nextInt-1]=1;
                       ^
  symbol:   variable nextInt
  location: variable sc of type Scanner
1 error
Language: C++


#include <iostream>
using namespace std;


int main()
{
	int x, n, tab[101];
	memset(tab, 1, sizeof(tab));
	cin >> x >> n;
	int p;
	while (n--) {
		cin >> p;
		tab[p] = 0;
	}
	for (int a = 0; a < 101; ++a) {
		if (x - a >= 0 && tab[x - a]) {
			cout << x - a;
			break;
		}
		if (x + a < 101 && tab[x + a]) {
			cout << x + a;
			break;
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'memset' was not declared in this scope
    9 |         memset(tab, 1, sizeof(tab));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    int x, n;
    cin >> x >> n;
    if(n==0){
        cout << x;
        return 0;
    }
    set<int> p;
    rep(i,n) {
        int X;
        cin >> X;
        p.insert(X);
    }
    vector<int> P;
    for(int i=1; i<=101;i++){
        if(p.count(i)) continue;
        P.push_back(i);a
    }
    vector<int> ans;
    int sa=300;
    rep(i,n){
        int res = abs(x-P[i]);
        if(res<sa) {
            ans.clear();
            ans.push_back(i);
        }
        if(res == sa){
            ans.push_back(i);
        }
        sa = res;
    }
    
    cout << P[ans[0]] << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:24: error: 'a' was not declared in this scope
   24 |         P.push_back(i);a
      |                        ^
Language: Java

import java.util.*;
import java.lang.Math.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
      if(n==0){
        System.out.println(X);
      }else{
		int X = sc.nextInt();
        int n = sc.nextInt();
        int cannotuse[]=new int[100];
        for(int i=0;i<n;i++){
          cannnotuse[sc.nextInt-1]=1;
        }
      int abssa=100;
      int realsa=100;
        for(int i=0;i<100;i++){
          if(Math.abs(cannnotuse[i]-X)<abssa){
            abssa=Math.abs(cannnotuse[i]-X);
            realsa=cannnotuse[i]-X;
          }
        }
      System.out.println(X+realsa);
      }
}
}

Compiler output:
Main.java:7: error: cannot find symbol
      if(n==0){
         ^
  symbol:   variable n
  location: class Main
Main.java:8: error: cannot find symbol
        System.out.println(X);
                           ^
  symbol:   variable X
  location: class Main
Main.java:14: error: cannot find symbol
          cannnotuse[sc.nextInt-1]=1;
          ^
  symbol:   variable cannnotuse
  location: class Main
Main.java:14: error: cannot find symbol
          cannnotuse[sc.nextInt-1]=1;
                       ^
  symbol:   variable nextInt
  location: variable sc of type Scanner
Main.java:19: error: cannot find symbol
          if(Math.abs(cannnotuse[i]-X)<abssa){
                      ^
  symbol:   variable cannnotuse
  location: class Main
Main.java:20: error: cannot find symbol
            abssa=Math.abs(cannnotuse[i]-X);
                           ^
  symbol:   variable cannnotuse
  location: class Main
Main.java:21: error: cannot find symbol
            realsa=cannnotuse[i]-X;
                   ^
  symbol:   variable cannnotuse
  location: class Main
7 errors
Language: C++

#include <bits/stdc++.h>
#include <unordered_map>

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n, m;
	ll x;
	ll a;
	string s;
	string s_ans;
	ll l_ans = 0;
	double d_ans = 0;
	
	cin >> x >> n;

	V p(n);
	vector<bool> z(101, false);
	rep(i, n) {
		cin >> p[i];
		z[p[i]] = true;
	}
	sort(ALL(p));

	ll pos = x;
	ll a1 = -1, a2 = 101;
	while (pos>=0) {
		if (!z[pos]) {
			a1 = pos;
			break;
		}
		pos--;
	}
	pos = x;
	while (pos <= 100) {
		if (!z[pos]) {
			a2 = pos;
			break;
		}
		pos++;
	}

	if ((x - a1) > (a2 - x)) {
		l_ans = a2;
	}
	else {
		l_ans = a1;
	}


	cout << l_ans << "\n";
}

int mainc(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_c();

	return 0;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

ll a[maxn];

void solve() {
	ll n,x,mi=INF,id=INF; cin >> x >> n;
	set<ll> s;
	rep(i,0,n) {
		cin >> a[i];
		s.insert(a[i]);
	}
	if (n==0) {cout << X; return;}
	per(i,300,-1) {
		if (s.count(i)) continue;
		if (abs(x-i) <= mi) mi = abs(x-i), id = min(id,(ll)i);
	}
	cout << id;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:19:28: error: 'X' was not declared in this scope
   19 |         if (n==0) {cout << X; return;}
      |                            ^
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 998244353
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
} 
int main()
{
    fast;
        ll n,x;
        std::cin >>x>> n;
        ll a[n];
        mp<ll,ll>mp;
        fr(i,0,n)
        {
            std::cin >> a[i];
            mp[a[i]]++;
        }
        if(mp.find(x)==mp.end())
        {
            cout<<x<<"\n";
        }
        else
        {
            ll ans,ans1;
            rf(i,x,0)
            {
                if(mp.find(i)==mp.end())
                {
                    ans=i;
                    break;
                }
            }
            fr(i,x,102)
            {
                if(mp.find(i)==mp.end())
                {
                    ans1=i;
                    break;
                }
            }
            if(x-ans>ans1-x)
            cout<<ans1<<"\n";
            else
            cout<<ans<<"\n";
        }
        
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'mp' was not declared in this scope; did you mean 'MP'?
   43 |         mp<ll,ll>mp;
      |         ^~
      |         MP
a.cc:43:14: error: expected primary-expression before ',' token
   43 |         mp<ll,ll>mp;
      |              ^
a.cc:43:17: error: expected primary-expression before '>' token
   43 |         mp<ll,ll>mp;
      |                 ^
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int x,n;
	cin >> x >> n;
	if(n==0) {
		cout << x << endl;
		return 0;
	}
	vint p(n);
	rep(i,n) cin >> p[i];
	sort(be(p));
	reverse(be(p));

	int ans = 10000;
	for(int i=p[0];i>=0;i--) {
		bool ok=true;
		for(int j=0;j<n;j++) {
			if(i==p[j]) ok = false;
		}
		if(ok) {
			if(abs(x-ans)=>abs(x-i)) ans=i;
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:39: error: expected primary-expression before '>' token
   33 |                         if(abs(x-ans)=>abs(x-i)) ans=i;
      |                                       ^
Language: C++

#include <iostream>
#include <bitset>
#include <cmath>
using namespace std;
#define ll long long
ll x,x1,n,i,y1,y2,y,dif1,dif2;
bitset <200> f;
int main ()
{
   cin>>x>>n;
   for (i=1;i<=n;++i)
   {
       cin>>x1;
       f[x1]=1;
   }
   y=x;
   while (f[y])  y--;
   dif1=abs(x-y);
   y1=y;
   y=x;
   while (f[y]) y++;
   dif2=abs(x-y);
   y2=y;
   if (dif1<=dif2) cout<<y1<<"\n";
   else cout<<y2<<"\n";
}



Compiler output:
a.cc:6:13: error: 'long long int y1' redeclared as different kind of entity
    6 | ll x,x1,n,i,y1,y2,y,dif1,dif2;
      |             ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/bits/requires_hosted.h:31,
                 from /usr/include/c++/14/iostream:38,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:19:6: error: assignment of function 'double y1(double)'
   19 |    y1=y;
      |    ~~^~
Language: C++

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

int main(){
    bool p[101]; memset(p, false, sizeof p);
    int x, n, _p;
    scanf("%d%d", &x, &n);
    for (int i=0; i<n; ++i){
        scanf("%d", &_p);
        p[_p] = true;
    }
    vector<int> arr;
    if (x > 100 || x < 1){
        else printf("%d", x);
        return 0;
    }
    if (x == 1){
        if (p[1]) printf("0");
        else printf("1");
    }
    for (int i=0; i<=100; ++i){
        if (!p[i]) arr.push_back(i);
    }
    int lo = 0, hi = arr.size(), ans = 0, mid;
    while (lo <= hi){
        mid = (lo + hi) / 2;
        if (arr[mid] >= x){
            ans = mid;
            hi = mid - 1;
        }
        else{
            lo = mid + 1;
        }
    }
    //arr[ans] is the first element such that arr[ans] >= x
    if (arr[ans] - x < x - arr[ans - 1]){
        printf("%d", arr[ans]);
    }
    else{
        printf("%d", arr[ans-1]);
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: expected '}' before 'else'
   14 |         else printf("%d", x);
      |         ^~~~
a.cc:13:26: note: to match this '{'
   13 |     if (x > 100 || x < 1){
      |                          ^
a.cc: At global scope:
a.cc:17:5: error: expected unqualified-id before 'if'
   17 |     if (x == 1){
      |     ^~
a.cc:21:5: error: expected unqualified-id before 'for'
   21 |     for (int i=0; i<=100; ++i){
      |     ^~~
a.cc:21:19: error: 'i' does not name a type
   21 |     for (int i=0; i<=100; ++i){
      |                   ^
a.cc:21:27: error: expected unqualified-id before '++' token
   21 |     for (int i=0; i<=100; ++i){
      |                           ^~
a.cc:24:22: error: 'arr' was not declared in this scope
   24 |     int lo = 0, hi = arr.size(), ans = 0, mid;
      |                      ^~~
a.cc:25:5: error: expected unqualified-id before 'while'
   25 |     while (lo <= hi){
      |     ^~~~~
a.cc:36:5: error: expected unqualified-id before 'if'
   36 |     if (arr[ans] - x < x - arr[ans - 1]){
      |     ^~
a.cc:39:5: error: expected unqualified-id before 'else'
   39 |     else{
      |     ^~~~
a.cc:42:5: error: expected unqualified-id before 'return'
   42 |     return 0;
      |     ^~~~~~
a.cc:43:1: error: expected declaration before '}' token
   43 | }
      | ^
Language: C

#include <stdio.h>

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

    int p[n];
    int i = 0;
    while(true)
    {
        int f = 0;
        for(int j = 0; j < n; j++)
            if(p[j] == x - i)
                f = 1;
        if(f == 0)
        {
            printf("%d\n" x - i);
            return 0;
        }
        f = 0;
        for(int j = 0; j < n; j++)
            if(p[j] == x + i)
                f = 1;
        if(f == 0)
        {
            printf("%d\n" x + i);
            return 0;
        }
        i++;
    }
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:10:11: error: 'true' undeclared (first use in this function)
   10 |     while(true)
      |           ^~~~
main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdbool.h>
    2 | 
main.c:10:11: note: each undeclared identifier is reported only once for each function it appears in
   10 |     while(true)
      |           ^~~~
main.c:18:26: error: expected ')' before 'x'
   18 |             printf("%d\n" x - i);
      |                   ~      ^~
      |                          )
main.c:27:26: error: expected ')' before 'x'
   27 |             printf("%d\n" x + i);
      |                   ~      ^~
      |                          )
Language: C++

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

ll a[maxn];

void solve() {
	ll n,x,mi=INF,id=INF; cin >> x >> n;
	set<ll> s;
	rep(i,0,n) {
		cin >> a[i];
		s.insert(a[i]);
	}
	if (n==0) {cout << 0; return;}
	rep(i,0,300) {
		if (s.count(i)) continue;
		if (abs(x-i) <= mi) mi = abs(x-i), id = min(id,i);
	}
	cout << id;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:22:60: error: no matching function for call to 'min(ll&, int&)'
   22 |                 if (abs(x-i) <= mi) mi = abs(x-i), id = min(id,i);
      |                                                         ~~~^~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:22:60: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |                 if (abs(x-i) <= mi) mi = abs(x-i), id = min(id,i);
      |                                                         ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:22:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |                 if (abs(x-i) <= mi) mi = abs(x-i), id = min(id,i);
      |                                                         ~~~^~~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vii;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<b;i++)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//	#endif
	
	FASTIO

	int T=1;
//	cin >> T;

	while(T--) {
		int x,n,input;
		cin >> x >> n;

		int d[102]={};

		REP(i,0,n) {
			cin >> input;
			dat[input]++;
		}

		REP(i,1,min(x+1,101-x)) {
			if(dat[x-i]==0) {
				x-=i;
				break;
			}
			if(dat[x+i]==0) {
				x+=i;
				break;
			}
		}

		cout << x;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:25: error: 'dat' was not declared in this scope
   37 |                         dat[input]++;
      |                         ^~~
a.cc:41:28: error: 'dat' was not declared in this scope
   41 |                         if(dat[x-i]==0) {
      |                            ^~~
a.cc:45:28: error: 'dat' was not declared in this scope
   45 |                         if(dat[x+i]==0) {
      |                            ^~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;

 ll mod=1e9 +7;


const ll M=200006;
ll f[M],inv[M];
ll expo(ll base,ll exponent){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

vector<bool>  prime(1000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=1000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=1000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

int main()
{

	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
 //    #endif

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();

    ll tests=1,t=1;
   // cin>>tests;
    while(tests--)
    {
    	int i,j,x,n,ans,val=102;
    	cin>>x>>n;
    	int a[101]=0;
    	for(i=0;i<n;i++)
    	{
    		cin>>j;
    		a[j]++;
    	}
    	for(i=x;i<=100;i++)
    	{
    		if(a[i]>0) continue;
    		if(val>i-x)
    		{
    			val=i-x;
    			ans=i;
    		}
    		break;
    	}
    	for(i=x;i>=0;i--)
    	{
    		if(a[i]>0) continue;
    		if(val>x-i)
    		{
    			val=x-i;
    			ans=i;
    		}
    		break;
    	}
    	if(val>101-x) {val=101-x;ans=101;}
    	if(val>x+1) {ans=-1;}
    	cout<<ans;



    }

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:20: error: array must be initialized with a brace-enclosed initializer
   70 |         int a[101]=0;
      |                    ^