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

import java.util*;

class Main{
  public static void main(String[] args){
    static void swap(int[] a,int idx1, int idx2) {
		int t = a[idx1]; a[idx1] = a[idx2]; a[idx2] = t;
	}

	static void quicksort(int[] a, int left, int right) {
		int pl = left;
		int pr = right;
		int x = a[(pl + pr)/2];
		
		do {
			while(a[pl] < x) pl++;
			while(a[pr] > x) pr--;
			if(pl <= pr)
				swap(a,pl++,pr--);
		}while (pl <= pr);
		
		if(left < pr) quicksort(a,left,pr);
		if(pl < right) quicksort(a,pl,right);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt(); //整数
		int N = sc.nextInt(); //長さNの整数列
		int[] p = new int[N];
		for (int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
		}
		
		int[] q = new int[N];
		int ans = 0;
		
		if (N != 0) {
			for (int i = 0; i<N ; i++) {
				q[i] = X - p[i];
			}
			quicksort(q,0,N); //配列をクイックソート
			// -2 -1 1 3 5 7
			
			int d = 0;
			int i = 0;
			do{
				for(int j = 0; j < N; j++) {
					if(i != q[j]) {
						ans = i;
						d = 1;
					}
				}
				i = -i/i * (Math.abs(i)+1);
			}while(d == 0);
		}
		else
			ans = X;
		
		System.out.println(ans);
  }
}
  

Compiler output:
Main.java:1: error: ';' expected
import java.util*;
                ^
Main.java:5: error: illegal start of expression
    static void swap(int[] a,int idx1, int idx2) {
    ^
2 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int FindSum (int n) {
  int sum =0;
  while (n>0) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}


int main() 
{
  int x,n;
  vector<int>p(n);
  int a,z;
  for (int i=0; i<n; i++) {
    cin >> p[i];
    sort(p.begin(), p.end());
    a=p[0];
    z=p[n];
  }
  int c[z];
  for (int i=0; i<z; i++) {
    if (p[i] =! c[i]) ans=c[i];
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |     if (p[i] =! c[i]) ans=c[i];
      |                       ^~~
      |                       abs
a.cc:29:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

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

int main()
{
	int x,n,c=0;
	cin >> x >> n;
	int a[n];
	for(int i=0;i>n;++i)
		cin >> a[i];
	int i=1;
	while(1)
	{

		if(binary_search(a,a+n,x)==0)
		{
			++flag;break;
		}
	else
		if(binary_search(a,a+n,x-i)==0)
		{
			++flag;break;
		}
		else
			{x=x+i;++i;}
	}
	cout << x;
	exit(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: 'flag' was not declared in this scope
   17 |                         ++flag;break;
      |                           ^~~~
a.cc:22:27: error: 'flag' was not declared in this scope
   22 |                         ++flag;break;
      |                           ^~~~
Language: C

#include <stdio.h>

int main(){
	int x, n;
    int m;
    int i, j;
  	
  	if(scanf("%d", &x) == 1){};
  	if(scanf("%d", &n) == 1){};

    if (n == 0){
        printf("%d", x);
        return 0;
    }

    int num[n];
  	for (i = 0; i < n; i++){
    	if(scanf("%d", &num[i]) == 1){};
    }

    for (i = -1; i < 102; i++){
        for (j = 0; j < n; j++){
            if(num[j] == i){
                j = 0;
                break;
            }
        }
        if (j == n){
            if (x-j < m){
                if ((x-j) * (-1) < m){
                    m = x - j;
                    if ((x-j) < 0){
                        m = m * -1;
                    }
                }
            }
        }
    }

    for (j = 0; j < n; j++){
        if(num[j] == x-m){
            printf("%d", x+m);
            return 0;
        }
    }

    printf("%d", x-m;)

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:47:21: error: expected ')' before ';' token
   47 |     printf("%d", x-m;)
      |           ~         ^
      |                     )
main.c:47:23: error: expected ';' before 'return'
   47 |     printf("%d", x-m;)
      |                       ^
      |                       ;
   48 | 
   49 |     return 0;
      |     ~~~~~~
Language: C++

#include <iostream>
using namespace std;

int main() {
  int X, N, min;
  cin >> X >> N;

  if (N = 0) {
    cout << X << endl;
  }
  else if {
  vector<int> vec(N);

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

  min = vec(0)
  for (int i = 0; i < N - 1; i++) {
    if (abs(vec(i) - X) < min && min != 0) {
      min = vec(i)
    }
  }

  cout << min << endl;
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: expected '(' before '{' token
   11 |   else if {
      |           ^
      |           (
Language: Java

import java.util.*;
import java.io.*;
public class Solution {
       public static void main(String args[]) {
           Scanner sc = new Scanner(System.in);
           int  x =  sc.nextInt();
           int  y =  sc.nextInt();
           if(y == 0)  {
               System.out.println(x);
           }
           else {
               HashSet<Integer> hs = new HashSet<Integer>();
               for(int i = 0; i < y; i++) {
                          hs.add(sc.nextInt());
               }
               for(int i = 1; i <= 100; i++) {
                          if(hs.contains(x-i) == false) {
                                     System.out.println(x-i);
                                     break;
                          }
                          else if(hs.contains(x+i) == false) {
                                     System.out.println(x-i); 
                                     break;
                          }
               }
           }
       }
}

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

#include <bits/stdc++.h>
using namespace std;
// using std::cin;
// using std::cout;
// using std::endl;
// using std::string;

int main() {
int X, N;
int m=0, ANS=0;

cin >> X >> N;

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

    vector <int> subt(N);
    for(int k=0; k<N; k++){
        subt.at(k) = vec.at(k) - X;
    }


    // 小さい順に並び変え
    sort(subt.begin(), subt.end());
    /*
    for(int k=0; k<N; k++){
        cout << subt.at(k) << endl;
    }
    */
    if(subt.at(0) > 0){
        ANS = 0;
    }
    else if(sub.at(N-1) < 0){
        ANS = 0;
    }
    else if(subt.at(0) <= 0){
        ANS = subt.at(0) - 1;
    }  


    m = subt.at(0);// k番目と比較する初期値
    for(int k=1; k<N; k++){
        if(subt.at(k) > 0 ){
            if(m >= 0){
                if(subt.at(k)-m != 1 && abs(subt.at(k-1)+1) < abs(ANS) ){
                    ANS = subt.at(k-1) + 1;
                }
            }
            else{
                ANS = 0;
            }
        }
        if(subt.at(k) <= 0 ){
            if(subt.at(k)-m != 1 && abs(subt.at(k)-1) < abs(ANS) ){
                ANS = subt.at(k) - 1;
            }
        }

        m = subt.at(k);
    }

    if(ANS == subt.at(0) - 1){
        if(abs(subt.at(N-1)+1) < abs(subt.at(0)-1)){
            ANS = X + subt.at(N-1) + 1;
        }
    }
    // cout << ANS << endl;
    cout << X+ANS << endl;
}
else{
    cout << X << endl;
}

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:13: error: 'sub' was not declared in this scope; did you mean 'subt'?
   36 |     else if(sub.at(N-1) < 0){
      |             ^~~
      |             subt
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
	int num = 0;
	int cnt = 0;
	vector<int> forbiddenLs;

	cin >> num >> cnt;
	for(int i = 0; i < cnt; i++) {
		int p = 0;
		cin >> p;
		forbiddenLs.push_back(num - p);
	}

	if (cnt == 0) {
		cout << num << endl;
	} else {
		for(int i = 0; i < 50; i++) {
			vector<int>::iterator itr;
			itr = find(forbiddenLs.begin(), forbiddenLs.end(), i);
			if (itr == forbiddenLs.end()) {
				cout << num - i << endl;
				break;
			}
			itr = find(forbiddenLs.begin(), forbiddenLs.end(), -i);
			if (itr == forbiddenLs.end()) {
				cout << num + i << endl;
				break;
			}
		}
	}

	return 0;
}






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

#include <iostream>

using namespace std;

int main()
{
    int x,n,a,b;
    cin>>x>>n;
    int p[n]={0};
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    if(n==0){
        cout<<x;
    }
    for(int i=0;i<n;i++){
        a=0;
        if(x==p[i]){
            a=1;
        }
        if(a==0){
            cout<<x;
            return 0;
        }
    }
    else{
        for(int i=1;i<x-1;i++){
            a=0;
            b=0;
            for(int j=0;j<n;j++){
                if(x-i==p[j]){
                    a=1;
                }
                if(x+i==p[j]){
                    b=1;
                }
            }
            if(a==0){
                cout<<x-i;
                return 0;
            }
            else{
                if(b==0){
                    cout<<x+i;
                    return 0;
                }
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'else' without a previous 'if'
   26 |     else{
      |     ^~~~
Language: C++

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

int main(){
  int  X,N;
  cin >> X >>N;
  vector<int> T(2*N);
  rep(i,2*N){
  T.at(i) = 0;
  }
  vector<int> PN(N);
  int V = 0;;
  rep(i,N){
  cin >> PN.at(i);
  }
  
  for(int i = 0; i < N; i++){
    rep(j,N){
  if(!(X - i == PN.at(j))){
   t = t + 1;
  }
     if(t < 0){
      T.at(i) = X - i;
     }
  }
  }
  
  int t = 0;
  for(int i = 0 ; i < N ; i++){
   rep(j,N){
  if(X + i != PN.at(j)){
   t = t + 1;
  }
     if(t < 0){
      T.at(i) = X + i;
     }
  }
  }
  rep(i,2*N){
  cout << T.at(i) << endl;
  }
    rep(i,2*N){
    rep(j,N){
    if(T.at(i) != PN.at(j)){
  if(T.at(i) - X < V -X && T.at(i) - X > 0 && V - X > 0){
    V = T.at(i);
  }
    else if(X - T.at(i) < V - X && X - T.at(i) > 0 && V - X > 0){
    V = T.at(i);
    }
    else if(X - T.at(i) < X - V && X - T.at(i) > 0 && X - V > 0){
    V = T.at(i);
    }
    else if(T.at(i) - X < X - V && T.at(i) - X > 0 && X - V > 0){
    V = T.at(i);
    }
    }
  }
  }
  
  cout << V << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:4: error: 't' was not declared in this scope
   23 |    t = t + 1;
      |    ^
a.cc:25:9: error: 't' was not declared in this scope
   25 |      if(t < 0){
      |         ^
Language: C++

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

int main()
{
	int x,n,c=0;
	cin >> x >> n;
	int a[n];
	for(int i=0;i>n;++i)
		cin >> a[i];

	while(1)
	{
		if(binary_search(a,a+n,x)==0)
		{
			++flag;break;
		}
	else
		if(binary_search(a,a+n,--x)==0)
		{
			++flag;break;
		}
		else
			x+=2;
	}
	cout << x;
	exit(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:27: error: 'flag' was not declared in this scope
   16 |                         ++flag;break;
      |                           ^~~~
a.cc:21:27: error: 'flag' was not declared in this scope
   21 |                         ++flag;break;
      |                           ^~~~
Language: C++

include<iostream>
using namespace std;

int main(){
  println("I dont know")

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:3: error: 'println' was not declared in this scope
    5 |   println("I dont know")
      |   ^~~~~~~
a.cc:5:25: error: expected '}' at end of input
    5 |   println("I dont know")
      |                         ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

int a[2*100001];
int so[1000002];
int num[1000002];

int ans=0;
bool check(int n,vector<int>& res,int idx,int sum){
    if(idx==res.size()){
        if(num[sum]==0){
            return false;
        }
        if(sum == n && num[sum]==1){
            return false;
        }
        return true;
    }
    bool flg = check(n,res,idx+1,sum);
    if(!flg) flg = check(n,res,idx+1,sum*res[idx]);
    return flg;
}

bool calc[]

void soinsu(int n){
    vector<int> res;
    int nn = n;
    for(int a=2;a*a<=n;a++){
        if(n%a!=0)continue;
        while(n%a==0){  
            res.push_back(a);
            n/=a;
        }
    }
    if(n!=1)res.push_back(n);
    //sort(res.begin(),res.end());
    if(check(nn,res,0,1)==false){
        ans++;
    }
}

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

    for(int i=1;i<=n;i++){
        cin >> a[i]; 
        num[a[i]]++;
    }

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

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc:27:1: error: expected initializer before 'void'
   27 | void soinsu(int n){
      | ^~~~
a.cc: In function 'int main()':
a.cc:53:9: error: 'soinsu' was not declared in this scope
   53 |         soinsu(a[i]);
      |         ^~~~~~
Language: C++

#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int x,n;
	cin>>x>>n;
	vector<int> p(n);
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	//答え
	int ans=inf;
	//直前の最小値
	int pre=inf;
	bool flag=true;
	int start
	for(int i=0;i<100;i++)
	{
		flag=true;
		for(int j=0;j<n;j++)
		{
			if(i==p[j]) flag=false;
		}
		if(flag)
		{
			if(pre==abs(x-i)&&ans==i)
			{
				ans=min(ans,i);
			}
			else if(pre>abs(x-i))
			{
				ans=i;
			}
			pre=min(pre,abs(x-i));
		}
	}
	if(n==0) cout<<x<<endl;
	else cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: expected initializer before 'for'
   29 |         for(int i=0;i<100;i++)
      |         ^~~
a.cc:29:21: error: 'i' was not declared in this scope
   29 |         for(int i=0;i<100;i++)
      |                     ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
	int num = 0;
	int cnt = 0;
	vector<int> forbiddenLs;

	cin >> num >> cnt;
	for(int i = 0; i < cnt; i++) {
		int p = 0;
		cin >> p;
		forbiddenLs.push_back(num - p);
	}

	if (cnt == 0) {
		cout << num << endl;
	} else {
		for(int i = 0; i < 50; i++) {
			vector<int>::iterator itr;
			itr = find(forbiddenLs.begin(), forbiddenLs.end(), i);
			if (itr == forbiddenLs.end()) {
				cout << num - i << endl;
				break;
			}
			itr = find(forbiddenLs.begin(), forbiddenLs.end(), -i);
			if (itr == forbiddenLs.end()) {
				cout << num + i << endl;
				break;
			}
		}
	}

	return 0;
}

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

#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    
    int X,N;
    int answer=0;
    int dis=9999;
    bool match=false;
    cin>>X>>N;
    if(N==0){
      cout<<X<<endl;
      return 0;
    }
    vector<int> p(N);
    for(int i=0;i<N;i++)
    {
       cin>>p[i];
    }
    sort(p.begin(),p.end());
    //p.pop_back();
    //reverse(p.begin(),p.end());
    /*for(int i=0;i<N;i++)
    {
      cout<<p[i]<<endl;
    }*/
    for(int i=0;i<N-1;i++)
    {
      for(int t=p[i]+1;t<p[i+1];t++)
      {
        //cout<<"abs"<<abs(t-X)<<endl;
        if(abs(X-t)<dis){
          answer=t;
          dis=abs(X-t);
          match=true;
          //cout<<t<<endl;
        }
      }
    }
    if(match){
    	cout<<answer<<endl;
    }
    else
    {
        cout<<X<<endl;
    }
    return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:53:14: error: expected '}' at end of input
   53 |     return 0;
      |              ^
a.cc:10:12: note: to match this '{'
   10 | 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 if (N != 0) {
    vector<int> vec(102);
    vector<int> vecD(102);
    vector<int> vecAns(102, 1000);
    
    for (int i = 0; i < 102; i++)
      vec.at(i) = i;
    
    for (int i = 0; i < N; i++) {
      int p;
      cin >> p;
      vec.at(p - 1) = 1000; //入力配列の除外
    }
    
    for (int i = 0; i < 102; i++)
      vecD.at(i) = abs(vec.at(i) - X); //Xとの差の配列
    
  int counter = 0;
  for (int j = 0; j < 101; j++) {
    for (int i = 0; i < 102; i++) {
      if (vecD.at(i) == j) {
      vecAns.at(i) = vec.at(i);
      counter += 1;
      }
    }
      if (counter == 0)
        continue;
      else if (counter != 0)
        break;
  }
    int min = vecAns.at(0);
    for (int i = 0; i < 102, i++) {
      if (vecAns.at(i) <= min)
        min = vecAns.at(i);
    }
    cout << min << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:33: error: expected ';' before ')' token
   42 |     for (int i = 0; i < 102, i++) {
      |                                 ^
      |                                 ;
Language: C++

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

int main() {
  int X, N;
  cin >> X >> N;
  
  if (N == 0)
    cout << X << endl;
  
  else if (N != 0) {
    vector<int> vec(102);
    vector<int> vecD(102);
    vector<int> vecAns(102, 1000);
    
    for (int i = 0; i < 102; i++)
      vec.at(i) = i;
    
    for (int i = 0; i < N; i++) {
      int p;
      cin >> p;
      vec.at(p - 1) = 1000; //入力配列の除外
    }
    
    for (int i = 0; i < 102; i++)
      vecD.at(i) = abs(vec.at(i) - X); //Xとの差の配列
    
  int counter = 0;
  for (int j = 0; j < 101; j++) {
    for (int i = 0; i < 102; i++) {
      if (vecD.at(i) == j) {
      vecAns.at(i) = vec.at(i);
      counter += 1;
      }
    }
      if (counter == 0)
        continue;
      else if (counter != 0)
        break;
  }
    int min = vecAns.at(0);
    for (i = 0; i < 102, i++) {
      if (vecAns.at(i) <= min)
        min = vecAns.at(i);
    }
    cout << min << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:10: error: 'i' was not declared in this scope
   42 |     for (i = 0; i < 102, i++) {
      |          ^
a.cc:42:29: error: expected ';' before ')' token
   42 |     for (i = 0; i < 102, i++) {
      |                             ^
      |                             ;
Language: C++

#include<bits/stdc++.h> 
using namespace std; 
int main(){
  int x, n, min=1000, min2=1000; 
  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(i=1;i<=150;i++){
    if(abs(x-i)<=min){
      for(int j=1;j<=n;j++){
        if(p[j]==i) break;
        if(j==n){
          min=abs(x-i);
          if(i<min2) min2=i;
          }
        }
      }
    }
  cout<<min2; 
  }

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n, x;
	cin>>x>>n;
	ll a[n];
	set<int> s;
	s.inserrt(0);
	for(int i=0;i<=100;i++){
		s.insert(i+1);
	}
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s.erase(s.find(a[i]));
	}
//	sort(a, a+n);
	ll mi = INT_MAX;
	ll op=0;
	for(ll ai : s){
		if(abs(ai-x)<mi){
			op = ai;
			mi = abs(ai-x);
		}
		else if(abs(ai-x)==mi){
			op = min(op, ai);
		}
	}
	cout<<op;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:11: error: 'class std::set<int>' has no member named 'inserrt'; did you mean 'insert'?
   53 |         s.inserrt(0);
      |           ^~~~~~~
      |           insert
Language: C++


#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

void c(std::istream& in)
{
    int X, N;
    in >> X >> N;

    std::set<int> pSet;
    for (int i = 0; i < N; ++i)
    {
        int p;
        in >> p;
        pSet.insert(p);
    }

    auto itrL = pSet.lower_bound(X);
    if (itrL == pSet.end())
    {
        std::cout << X;
        return;
    }

    if (itrL == pSet.begin())
    {
        std::cout << *itrL - 1;
        return;
    }

    int diff = 0;
    while (true)
    {
        if (pSet.find(X - diff) == pSet.end())
        {
            std::cout << X - diff;
            return;
        }
        if (pSet.find(X + diff) == pSet.end())
        {
            std::cout << X + diff;
            return;
        }

        ++diff;
    }
}

int main(int, char* [])
{
    c(std::cin);
    return 0;
}


Compiler output:
a.cc: In function 'void c(std::istream&)':
a.cc:13:10: error: 'set' is not a member of 'std'
   13 |     std::set<int> pSet;
      |          ^~~
a.cc:7:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    6 | #include <algorithm>
  +++ |+#include <set>
    7 | 
a.cc:13:14: error: expected primary-expression before 'int'
   13 |     std::set<int> pSet;
      |              ^~~
a.cc:18:9: error: 'pSet' was not declared in this scope
   18 |         pSet.insert(p);
      |         ^~~~
a.cc:21:17: error: 'pSet' was not declared in this scope
   21 |     auto itrL = pSet.lower_bound(X);
      |                 ^~~~
Language: C++

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

int main(){
  int X,N;
  cin >> X >> N;
  
  if(N==0){
    cout << X <<endl;
  }
  
  vector<int>num(N);
  vector<int>copy(N);
  for(int i=0;i<N;i++){
    cin >> num.at(i);
    copy.at(i)=num.at(i);
    num.at(i)=abs(X-num.at(i));
  }
  sort(num.begin(),num.end());
  
  for(int i=0;i<N;i++){
    if(num.at(i)==(i+1)/2){
      continue;
    }
    else{
      int flag=0;
      for(int j=0;j<N;j++){
        if(X-((i+1)/2)==copy.at(j)){
          flag=1;
        }
      }
      if(flag==1){
        cout << X+((i+1)/2) << endl;
        return 0;
      }
      else if(flag==0){
        cout << X-((i+1)/2) << endl;
        return 0;        
      }
    }
  }
  int flag=0;
  for(int j=0;j<N;j++){
    if(X-((N+1)/2)==copy.at(j)){
      flag=1;
    }
  }
  if(flag==1){
    cout << X+((i+1)/2) << endl;
    return 0;
  }
  else if(flag==0){
    cout << X-((i+1)/2) << endl;
    return 0;        
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:17: error: 'i' was not declared in this scope
   49 |     cout << X+((i+1)/2) << endl;
      |                 ^
a.cc:53:17: error: 'i' was not declared in this scope
   53 |     cout << X-((i+1)/2) << endl;
      |                 ^
Language: C++

#include<iostream>
#include<algorithm>

#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;

int main() {
  int x,n;
  cin >> x >> n;
  if (!n)
  {
    cout << x << endl;
    return 0;
  }
  vector<int> boll(n);
  for (int i = 0; i < n; ++i)
    cin >> boll[i];
  sort(boll.begin(), boll.end());
  int start = 0, end = n - 1;
  if (x < boll[start] || x>boll[end])
  {
    cout << x << endl;
    return 0;
  }
  if (x == boll[start])
  {q
    cout << (boll[start]-1)<< endl;
    return 0;
  }
  int i;
  for (i = 0; i < n; ++i)
    if (boll[i] == x)
      break;
  if (i == n)
  {
    cout << x << endl;
    return 0;
  }
  int j = i, k = i;
  while (j >= 0 && k <= end)
  {
    if (j-1>=0 &&  abs(boll[j] - boll[j -1]) > 1)
    {
      cout << (boll[j] - 1);
      return 0;
    }
    if (k+1<=end &&  abs(boll[k] - boll[k + 1]) > 1)
    {
      cout << (boll[k] + 1);
      return 0;
    }
    --j;
    ++k;
  }
  if (abs(x - (boll[0] - 1)) > abs(x - (boll[end] + 1)))
  {
    cout << (boll[end] + 1);
    return 0;
  }
  cout << (boll[0] - 1) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'vector' was not declared in this scope
   17 |   vector<int> boll(n);
      |   ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include <unordered_set>
  +++ |+#include <vector>
    6 | using namespace std;
a.cc:17:10: error: expected primary-expression before 'int'
   17 |   vector<int> boll(n);
      |          ^~~
a.cc:19:12: error: 'boll' was not declared in this scope; did you mean 'bool'?
   19 |     cin >> boll[i];
      |            ^~~~
      |            bool
a.cc:20:8: error: 'boll' was not declared in this scope; did you mean 'bool'?
   20 |   sort(boll.begin(), boll.end());
      |        ^~~~
      |        bool
a.cc:28:4: error: 'q' was not declared in this scope
   28 |   {q
      |    ^
Language: C++

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


}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:14: error: expected ';' before 'break'
   28 |           x=0
      |              ^
      |              ;
   29 |           break;
      |           ~~~~~
a.cc:37:14: error: expected ';' before 'break'
   37 |           x=0
      |              ^
      |              ;
   38 |           break;
      |           ~~~~~
Language: C++

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  bool re = true;
  
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == X) {
      
      int j = 0;
      while (re) {
        if (vec.at(i - j) != X - j) {
          cout << X - j;
          re = false;
          break;
        } else if (vec.at(i + j) != X + j) {
          cout << X + j;
          re = false;
          break;
        }
        j++;
      }
      
    }
    }
  }
}


Compiler output:
a.cc:34:1: error: expected declaration before '}' token
   34 | }
      | ^
Language: C

#include<stdio.h>
#include<stdlib.h>

int main(){
int X,N;
int z=0;
int flag[101];
  scanf("%d %d",&X,&N);
  int *p=(int*)malloc(sizeof(int)*N);
  for(int i=0;i<101;i++)flag[i]=1;
  for(int i=0;i<N;i++){
  	scanf("%d",&p[i]);
  }
  for(i=0;i<N;i++)flag[p[i]]=0;
  for(z=0;z<100;z++){
   if(X-z>0 && flag[X-z]==1){
         printf("%d\n",X-z);
         break;
   }
   else if(X+z<101 && flag[X+z]==1){
       printf("%d\n",X+z);
       break;
   }
  }
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:14:7: error: 'i' undeclared (first use in this function)
   14 |   for(i=0;i<N;i++)flag[p[i]]=0;
      |       ^
main.c:14:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main(){
  int X,N;
  cin >> X >> N;
  
  if(N==0){
    cout << X <<endl;
  }
  
  vector<int>num(N);
  vector<int>copy(N);
  for(int i=0;i<N;i++){
    cin >> num.at(i);
    copy.at(i)=num.at(i);
    num.at(i)=abs(X-num.at(i));
  }
  sort(num.begin(),num.end());
  
  for(int i=0;i<N;i++){
    if(num.at(i)==(i+1)/2){
      continue;
    }
    else{
      int flag=0;
      for(int j=0;j<N;j++){
        if(X-((i+1)/2)==copy.at(j)){
          flag=1;
        }
      }
      if(flag==1){
        cout << X+((i+1)/2) << endl;
        return 0;
      }
      else if(flag==0){
        cout << X-((i+1)/2) << endl;
        return 0;        
      }
    }
  }
  int flag=0;
  for(int j=0;j<N;j++){
    if(X-((N+1)/2)==copy.at(j)){
      flag=1;
    }
    if(flag==1){
      cout << X+((i+1)/2) << endl;
      return 0;
    }
    else if(flag==0){
      cout << X-((i+1)/2) << endl;
      return 0;        
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:19: error: 'i' was not declared in this scope
   48 |       cout << X+((i+1)/2) << endl;
      |                   ^
a.cc:52:19: error: 'i' was not declared in this scope
   52 |       cout << X-((i+1)/2) << endl;
      |                   ^
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[i];
  }
  vector<int> all(100);
  for(int i=0;i<100;i++){
    all.at(i) = i+1;
  }
  sort(p.begin(), p.end());
  for(int i = 0; i<n;i++){
    for(int j = 0; j < 100; j++){
      if(all.at(j) == p.at(i)){
        all.at(j) = 10000;
      }
    }
  }
  int judge = 500;
//  int ans = 0;
  if(n==0){
    cout << x << endl;
  } else { 
  for(int i = 0; i<100; i++){
    int h = abs(x-all.at(i));
    judge = min(judge, h);
  }
/*    if(judge >= x+1){
      cout << -1 << endl;
  */  }
    //else{
  for(int i = 0; i < 100; i++){
    int H = abs(x-all.at(i));
    if(judge == H){
      cout << all.at(i) << endl;
      break;
    }
  }
   // }
  }
}

Compiler output:
a.cc:44:1: error: expected declaration before '}' token
   44 | }
      | ^
Language: C++

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


}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:7: error: expected ',' or ';' before 'while'
   18 |       while(x){
      |       ^~~~~
Language: C++

X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

p = set(map(int,input().split()))
not_p = list(set(range(0,100)) - p)
print(not_p)

minV = 101
ans = 0
for i in not_p:
    if abs(X - i) < minV:
        minV = abs(X - i) 
        ans = i
print(ans)

Compiler output:
a.cc:1:1: error: 'X' does not name a type
    1 | X, N = map(int, input().split())
      | ^
Language: C

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

int check(int n,int a[]){
  int i;
  for (i=0;i<strlen(a);i++){
    if(a[i] == n){
      return 1;
    }
  }
  return 0;
}

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

Compiler output:
main.c: In function 'check':
main.c:11:21: error: passing argument 1 of 'strlen' from incompatible pointer type [-Wincompatible-pointer-types]
   11 |   for (i=0;i<strlen(a);i++){
      |                     ^
      |                     |
      |                     int *
In file included from main.c:3:
/usr/include/string.h:407:35: note: expected 'const char *' but argument is of type 'int *'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
main.c: In function 'main':
main.c:37:40: error: expected statement before ')' token
   37 |        }else if(check((a[i]+d),a) == 0)){
      |                                        ^
Language: C++

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int main(void)
{
    ll x,n; cin>>x>>n;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    if(n==0){
        cout<<x<<endl;
        return 0;
    }else if(n==100){
        if(x<=50) cout<<0<<endl;
        else cout<<101<<endl;
        return 0;
    }else if(n==1){
        if(x==1) cout<<0<<endl;
        else if(x==)
        return 0;
    }else if(n==2){
        if(x==2) cout<<0<<endl;
        return 0;
    }

    sort(p.begin(),p.end());
    ll dist=1e9,tmp,ans=1e9;
    bool skip=false;
    for(int i=1;i<=100;i++){
        skip=false;
        rep(j,n){
            if(i==p[j]){
                skip=true;
                continue;
            }
        }
        if(skip) continue;
        tmp=abs(x-i);
        if(tmp<dist){
            dist = tmp;
            ans = i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:20: error: expected primary-expression before ')' token
   21 |         else if(x==)
      |                    ^
Language: C++

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

int main(){
  int x, n;
  cin >> x >> n;
  if(n == 0){
    cout << x << endl;
    return 0;
  }
  vector<int> a(n);
  int i;
  bool judge = false;
  for(i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] == x){ judge = true;}
  }
  if(!judge){
    cout << x << endl;
    return 0;
  }
  sort(a, a + SIZE_OF_ARRAY(a));
  int c_min, c_max;
  for(i = 0; a[i] < x; i++){
    if(c_min == nullptr){ c_min = a[i] - 1;}
    else if(a[i] - a[i-1] > 1){ c_min = a[i] -1;}
  }
  if(x - a[i-1] > 1){ c_min = x-1;}
  for(i = n-1; a[i] > x; i -= 1){
    if(c_max == nullptr){ c_max = a[i] + 1;}
    else if(a[i+1] - a[i] > 1){ c_max = a[i] + 1;}
  }
  if(a[i+1] - x > 1){ c_max = x+1;}
  int b = x - c_min, c = c_max - x;
  if(b == c){ cout << c_min << endl;}
  else if(b < c){ cout << c_min << endl;}
  else{ cout << c_max << endl;}
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: 'SIZE_OF_ARRAY' was not declared in this scope
   22 |   sort(a, a + SIZE_OF_ARRAY(a));
      |               ^~~~~~~~~~~~~
a.cc:25:14: error: invalid operands of types 'int' and 'std::nullptr_t' to binary 'operator=='
   25 |     if(c_min == nullptr){ c_min = a[i] - 1;}
      |        ~~~~~~^~~~~~~~~~
a.cc:30:14: error: invalid operands of types 'int' and 'std::nullptr_t' to binary 'operator=='
   30 |     if(c_max == nullptr){ c_max = a[i] + 1;}
      |        ~~~~~~^~~~~~~~~~
Language: C++

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

int main() {
    int x,n;
    cin>>x>>n;
    if(n==0)
    {
        cout<<x;
        return 0;
    }
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int lower=x,upper=x;
    sort(arr,arr+n);
     while(binary_search(arr,arr+n,lower))
    {
        lower--;
    }
    while(binary_search(arr,arr+n,upper))
    {
        upper++;
    }
    if(lower == upper)
    {
        if(lower>arr[n-1])
        {
            cout<<arr[n-1][]
        }
        else if(lower<arr[0])
        {
            cout<<arr[0];
        }
        else
        {
            cout<<lower;
        }
        return 0;
    }
    if((upper-x)<(x-lower))
    {
        if(upper>arr[n-1])
        {
            cout<<lower;
        }
        else
        {
            cout<<upper;
        }
    }
    else if((upper-x)>(x-lower))
    {
        if(lower<arr[0])
        {
            cout<<upper;
        }
        else
        {
            cout<<lower;
        }
    }
    else if((upper-x)==(x-lower))
    {
        if(lower<arr[0])
        {
            cout<<upper;
        }
        else
        {
            cout<<lower;
        }
    }
    
    // your code goes here
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:28: error: expected primary-expression before ']' token
   31 |             cout<<arr[n-1][]
      |                            ^
Language: C

#include<stdio.h>

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

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


Compiler output:
main.c: In function 'main':
main.c:29:24: error: expected ')' before 'and'
   29 |     }else if(flaga == 0 and flagb == 0){
      |             ~          ^~~~
      |                        )
Language: C

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

int cheak(int n,int a[]){
  int i;
  for (i=0;i< a.length;i++){
    if(a[i] == n){
      return 1;
    }
  }
  return 0;
}

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

Compiler output:
main.c: In function 'cheak':
main.c:10:16: error: request for member 'length' in something not a structure or union
   10 |   for (i=0;i< a.length;i++){
      |                ^
main.c: In function 'main':
main.c:33:11: error: implicit declaration of function 'check'; did you mean 'cheak'? [-Wimplicit-function-declaration]
   33 |        if(check((a[i]-d),a) == 0){
      |           ^~~~~
      |           cheak
main.c:36:40: error: expected statement before ')' token
   36 |        }else if(check((a[i]+d),a) == 0)){
      |                                        ^
Language: C

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


int main()
{
 int x,n;
 cin >> x;
 cin >> n;
 vector<int> vec(n);
for (int i = 0; i < n; i++) {
  cin >> vec.at(i);
 
}
int ans=100;
 for(int i=100;-100<=i;i--){
   for(int j=0;j<n;j++){
      if(vec.at(j)!=i){
      if(abs(x-i)<=abs(x-ans)){
     ans=i;
   }
   }  
   }
 }

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

  




  
    
    
    
  
  
  


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++

#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int main() {
  int x,n;
  cin >> x >> n;
  if (!n)
  {
    cout << x << endl;
    return 0;
  }
  if(n==0){
		cout<<x;
		return 0;
	}
  vector<int> v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  sort(v.begin(), v.end());
  int start = 0, end = n - 1;
  if (x < v[start] || x>v[end])
  {
    cout << x << endl;
    return 0;
  }
  if (x == v[start])
  {q
    cout << (v[start]-1)<< endl;
    return 0;
  }
  int i;
  for (i = 0; i < n; ++i)
    if (v[i] == x)
      break;
  if (i == n)
  {
    cout << x << endl;
    return 0;
  }
  int j = i, k = i;
  map<int,int> m;
	int minm=100000;
	int maxm=0;
  while (j >= 0 && k <= end)
  {
    if (j-1>=0 &&  abs(v[j] - v[j -1]) > 1)
    {
      cout << (v[j] - 1);
      return 0;
    }
    if (k+1<=end &&  abs(v[k] - v[k + 1]) > 1)
    {
      cout << (v[k] + 1);
      return 0;
    }
    --j;
    ++k;
  }
  if (abs(x - (v[0] - 1)) > abs(x - (v[end] + 1)))
  {
    cout << (v[end] + 1);
    return 0;
  }
  cout << (v[0] - 1) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'vector' was not declared in this scope
   18 |   vector<int> v(n);
      |   ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include<map>
  +++ |+#include <vector>
    5 | using namespace std;
a.cc:18:10: error: expected primary-expression before 'int'
   18 |   vector<int> v(n);
      |          ^~~
a.cc:20:12: error: 'v' was not declared in this scope
   20 |     cin >> v[i];
      |            ^
a.cc:21:8: error: 'v' was not declared in this scope
   21 |   sort(v.begin(), v.end());
      |        ^
a.cc:29:4: error: 'q' was not declared in this scope
   29 |   {q
      |    ^