criyle/codenet-compile-errors huggingface dataset:
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,k;
	cin>>n>>k;
	if((k-2*n)%2==0&&k<=4*n&&&k>=2*n)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	 } 
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:36: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   50 |         if((k-2*n)%2==0&&k<=4*n&&&k>=2*n)
      |                                  ~~^~~~~
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int x=sc.nextInt(),y=sc.nextInt(),a,b;
    if(y%2==0){
      System.out.println("No");
    }else{
      for(int i=0;i<=x;i++){
        a=i;
        b=x-i;
        int f=0;
        if((2*a+4*b)==y){
          System.out.println("Yes");
          f++;
          break;
        }
      }
      if(f==0){
        System.out.println("No");
      }
    }
  }
}


Compiler output:
Main.java:21: error: cannot find symbol
      if(f==0){
         ^
  symbol:   variable f
  location: class Main
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
void A(string t){
  cout<<t<<endl;
  exit(0);
}

int main() {
  int x,y; cin >> x >> y;
  if(y%2==1) A("No");
  y/=2;
  if(x<=y&&y<=2*x) A("Yes");
  a("No");
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'a' was not declared in this scope
   13 |   a("No");
      |   ^
Language: C++

#include <iostream>
using namespace std;

int main()
{
    int X, Y;

    cin >> X >> Y;

    if((Y>=2X)&&(Y<=4X))
    {
        if(Y%2 == 0)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: unable to find numeric literal operator 'operator""X'
   10 |     if((Y>=2X)&&(Y<=4X))
      |            ^~
a.cc:10:21: error: unable to find numeric literal operator 'operator""X'
   10 |     if((Y>=2X)&&(Y<=4X))
      |                     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
   
   
        
     ll x,y;
     cin>>x>>y;
     ll x=y-2*a;
     if(x%2==0&&x>=0)
     {cout<<"YES";}
     else
        cout<<"NO";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: redeclaration of 'long long int x'
   12 |      ll x=y-2*a;
      |         ^
a.cc:10:9: note: 'long long int x' previously declared here
   10 |      ll x,y;
      |         ^
a.cc:12:15: error: 'a' was not declared in this scope
   12 |      ll x=y-2*a;
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int x,y;
  	cin>>x>>y;
  	int a=(2*X)-y/2;
  	if (y==a*2+(x-a)*4)
      cout<<"Yes";
  	else cout<<"No";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:18: error: 'X' was not declared in this scope
    7 |         int a=(2*X)-y/2;
      |                  ^
Language: C++

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

int main() {
  int X, Y;
  cin >> X >> Y;
  // a + b = x
  // 2a + 4b = y;
  for (int a = 0; a <= 1000; ++a) {
    for (int b = 0; b <= 1000; ++b) {
      if (a + b == X && a * 2 + b * 4 == Y) {
        puts("Yes");
        return 0;
      }
    }
  }
  pus("No");
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'pus' was not declared in this scope; did you mean 'puts'?
   17 |   pus("No");
      |   ^~~
      |   puts
Language: C++

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max();
constexpr auto llinf = numeric_limits<ll>().max();

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << "\n";
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << "\n";
}

void solve() {
  double x, y;
  cin >> x >> y;
  if (y % 2 == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
	cout << "\n";
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:42:9: error: invalid operands of types 'double' and 'int' to binary 'operator%'
   42 |   if (y % 2 == 0) {
      |       ~ ^ ~
      |       |   |
      |       |   int
      |       double
Language: C++

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

int main(){
  int X, Y;
  cin >> X >> Y;
  if((4 * X - Y) % 2 == 0){
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
}

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

#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
//head

void run() {
	int x,y;
	cin>>x>>y;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			if(i+j!=x) continue;
			if(i*2+j*4==y){
			 cout<<"Yes"<<'\n';
			 return 0;
		  }
		}
	}
	cout<<"No"<<'\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(20);
	//int T; cin >> T; while (T--)
	run();
	return 0;
}

Compiler output:
a.cc: In function 'void run()':
a.cc:22:33: error: return-statement with a value, in function returning 'void' [-fpermissive]
   22 |                          return 0;
      |                                 ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    if((y-2x)%2==0) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: unable to find numeric literal operator 'operator""x'
    7 |     if((y-2x)%2==0) cout<<"Yes"<<"\n";
      |           ^~
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first<y.first)
        return true;
    else if(x.first==y.first)
        return x.second>y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}

void solve()
{   
    int x,y;
    cin>>x>>y;
    if(x*2==y)
        cout<<"No";
    else if(X*4==y)
        cout<<"No";
    else
        cout<<"Yes";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:72:13: error: 'X' was not declared in this scope
   72 |     else if(X*4==y)
      |             ^
Language: C++

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std; 

const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}

void ok() {
    cout << "YES" << '\n';
}

void no() {
    cout << "NO" << '\n';
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int t1 = nxt(), y = nxt();
    for (int i = 0; i <= x; i++) {
        int t2 = x - t1;
        int cur = i * 2 + t2 * 4;
        if (cur == y) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:26: error: 'x' was not declared in this scope
   46 |     for (int i = 0; i <= x; i++) {
      |                          ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	int x,y;
	std::cin>>x>>y;
	if(y%2)puts("No");
	else if(2*x<=y&&y<=4*x)puts("Yes")+
	else puts("No");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:108:9: error: expected primary-expression before 'else'
  108 |         else puts("No");
      |         ^~~~
Language: C++

int mainx()
{
    int x, n;
    cin >> x >> n;
    rep(i, 1, n) {
        cin >> a[i];
        vis[a[i]] = true;
    }
    int delta = 0;
    while (true) {
        if (!vis[x - delta]) {
            cout << x - delta << endl;
            return 0;
        }
        if (!vis[x + delta]) {
            cout << x + delta << endl;
            return 0;
        }
        delta++;
    }

}


Compiler output:
a.cc: In function 'int mainx()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> x >> n;
      |     ^~~
a.cc:5:9: error: 'i' was not declared in this scope
    5 |     rep(i, 1, n) {
      |         ^
a.cc:5:5: error: 'rep' was not declared in this scope
    5 |     rep(i, 1, n) {
      |     ^~~
a.cc:11:14: error: 'vis' was not declared in this scope
   11 |         if (!vis[x - delta]) {
      |              ^~~
a.cc:12:13: error: 'cout' was not declared in this scope
   12 |             cout << x - delta << endl;
      |             ^~~~
a.cc:12:34: error: 'endl' was not declared in this scope
   12 |             cout << x - delta << endl;
      |                                  ^~~~
a.cc:15:14: error: 'vis' was not declared in this scope
   15 |         if (!vis[x + delta]) {
      |              ^~~
a.cc:16:13: error: 'cout' was not declared in this scope
   16 |             cout << x + delta << endl;
      |             ^~~~
a.cc:16:34: error: 'endl' was not declared in this scope
   16 |             cout << x + delta << endl;
      |                                  ^~~~
Language: C++

#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;
const ll mod=1000000007;

int main(){
int n,x;
cin>>n>>x;
int a;
vector<int>p(n);
rep(i,n){
  cin>>a;
  p[a]=1;
}
P ans(1000,-1);
rep(i,n){
  if(p[i])continue;
  dif=abs(x-i);
  ans=min(ans,P(dif,i));
}
cout<<ans.second<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:3: error: 'dif' was not declared in this scope; did you mean 'div'?
   24 |   dif=abs(x-i);
      |   ^~~
      |   div
Language: C++

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

int main(){
  int x,n;
  cin >> x >> n;
  vector<int> p(n); rep(i,n) cin>>p[i];
  vector<int> pa(n); rep(i,n) cin>>pa[i];
  rep(i,n) pa[i]=abs(p[i]-x);
  sort(pa.begin(),pa.end());
  int diff=0,ans=0;
  int cnt=0;
  rep(i,n){
    if(pa[i]!=0) cnt++;
  }
  if(cnt==n) diff=0;
  else{
    cnt=0;
    for(int i=1; i<n100; i++){
      for(int j=1; j<n; j++){
        if(pa[j]==i) cnt++;
      }
      if(cnt!=2){
        diff=i;
        break;
      }
    }
  }
  rep(i,n){
    ans=x+diff;
    if(p[i]==x-diff) break;
    ans=x-diff;
    if(p[i]==x+diff) break;
  }
  if(n==0) ans=x;
  cout << ans << endl;
}

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

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

    if (n == 0) {
        cout << x << endl;
    } else {
        vector<int> p(n);
        for (int i = 0; i < n; i++) {
            cin >> p[i];
        }

        int closest, minAbs;
        minAbs = 1000;
        for (int i = 0; i <= 101; i++) {
            if (find(p.begin(), p.end(), i) == p.end()) {
                if (abs(x - i) < minAbs) {
                    closest = i;
                    minAbs = abs(x - i);
                }
            }
        }

        cout << closest << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:21: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   22 |             if (find(p.begin(), p.end(), i) == p.end()) {
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~
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:22:21: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   22 |             if (find(p.begin(), p.end(), i) == p.end()) {
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
  int X,N;cin>>X>>N;
  if(N==0) cout<<X<<endl;
  else{
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  set<int> D;
    for(int i=-10;i<=100) D.insert(i);
    for(int i=0;i<N;i++) D.erase(A.at(i));
  int ans;
  int dist=1e9;
  for(auto S:D){
    int T=abs(X-S);
    if(0<T && T<dist){
      ans=S;
      dist=T;
    }
  }
  cout<<S<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: expected ';' before ')' token
   11 |     for(int i=-10;i<=100) D.insert(i);
      |                         ^
      |                         ;
a.cc:22:9: error: 'S' was not declared in this scope
   22 |   cout<<S<<endl;
      |         ^
Language: C++

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

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

  set<int> p;
  rep(i, N) {
    int pi;
    cin >> pi;
    p.insert(pi);
  }

  rep(i, N) {
    if (p.count(X - i)) {
      cout << X - i << endl;
      return 0;
    } else if (p.count(X + i)) {
      cout << X + i << endl;
      return 0;
    }

    return 0;
  }

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

#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main(){
  int X, N, k=0;
  cin >> X >> N;
  vector<int> p(N);
  rep(i,0,N) {
    cin >> p[i];
  }
  while(true) {
    int A=X-i, B=X+i;
    bool a=true, b=true;
    rep(j,0,N) {
      if(A==p[j]){
        a=false;
      }
    }
    if(a){
      cout << A << endl;
    }
    rep(j,0,N) {
      if(B==p[j]){
        b=false;
      }
    }
    if(b){
      cout << B << endl;
    }
    i++;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:13: error: 'i' was not declared in this scope
   29 |     int A=X-i, B=X+i;
      |             ^
a.cc:40:10: error: 'B' was not declared in this scope
   40 |       if(B==p[j]){
      |          ^
a.cc:45:15: error: 'B' was not declared in this scope
   45 |       cout << B << endl;
      |               ^
Language: C++

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

int abs(int a){
  if(a<0) return -a;
  return a;
}
  
int main(){
 int x,n,min=100,ans=0;
  cin >> x >> n;
 
 vector<int> p(n);
  rep(i,n) cin >> p.at(i);
 
 vector<int> con(100);
  rep(i,n) con(p.at(i))=1;
   
  
 rep(i,100){
  if(con.at(i)==0){ 
   if(abs(x-i)<min){
     min=abs(x-i);
     ans=i;
   }
  }
 }
  cout << ans << endl;
  return 0;
  
}
 
   
  
  
  
  

  
    


Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   19 |   rep(i,n) con(p.at(i))=1;
      |            ~~~^~~~~~~~~
Language: C++

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) {
    int num;
    cin >> num;
    p.at(i) = num;
  }
  sort(p.begin(), p.end());
  vector<int> check(101, 0);
  check.at(0) = 9;
  rep(i, n) {
    check.at(p.at(i)) = 1;
  }
  vector<int> x_chikasa(101);
  x_chikasa.at(0) = 1000;
  for (int i = 1; i < 101; i++) {
    x_chikasa.at(i) = i-x;
  }
  int min = 1000;
  int min_num = 1000;
  for (int i = 1; i<101; i++) {
    if (check.at(i) == 0) {
      if (abs(x_chikasa.at(i)) < min) {
        min = abs(x_chikasa.at(i));
        min_num = i;
      }
    }
  }
  cout << min_num << endl;
}
      


Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> x >> n;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> p(n);
      |   ^~~~~~
a.cc:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> p(n);
      |          ^~~
a.cc:5:7: error: 'i' was not declared in this scope
    5 |   rep(i, n) {
      |       ^
a.cc:5:3: error: 'rep' was not declared in this scope
    5 |   rep(i, n) {
      |   ^~~
a.cc:10:8: error: 'p' was not declared in this scope
   10 |   sort(p.begin(), p.end());
      |        ^
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |   sort(p.begin(), p.end());
      |   ^~~~
      |   short
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vector<int> check(101, 0);
      |          ^~~
a.cc:12:3: error: 'check' was not declared in this scope
   12 |   check.at(0) = 9;
      |   ^~~~~
a.cc:16:10: error: expected primary-expression before 'int'
   16 |   vector<int> x_chikasa(101);
      |          ^~~
a.cc:17:3: error: 'x_chikasa' was not declared in this scope
   17 |   x_chikasa.at(0) = 1000;
      |   ^~~~~~~~~
a.cc:25:11: error: 'abs' was not declared in this scope
   25 |       if (abs(x_chikasa.at(i)) < min) {
      |           ^~~
a.cc:31:3: error: 'cout' was not declared in this scope
   31 |   cout << min_num << endl;
      |   ^~~~
a.cc:31:22: error: 'endl' was not declared in this scope
   31 |   cout << min_num << endl;
      |                      ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
  int target, n;
  ans = 101;
  way = 101;
  cin >> target >> n;
  
  if(n == 0) {
    cout << target << endl;
    return 0;
  }
  
  vector<int> ex(n);
  
  for(int i=0;i<n;i++) {
    cin >> ex.at(i);
  }
  
  vector<int> dx(101);
  
  for(int i=0;i<n;i++) {
    dx.at(ex.at(i)) = 1;
  }
  
  for(int i=0;i<101;i++) {
    if(dx.at(target - i) == 0) {
      cout << target - i << endl;
      break;
    }
    if(dx.at(target + i) == 0) {
      cout << target + i << endl;
      break;
    }
  }
  return 0;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
    5 |   ans = 101;
      |   ^~~
      |   abs
a.cc:6:3: error: 'way' was not declared in this scope
    6 |   way = 101;
      |   ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

    vector<int> p(n);
    for(i=0; i<n; i++)
    cin >> p.at(i);

    int ans =0;
    for(int q=0; q<=101; q++){
        inf f= 1;
        for(i=0; i<n; i++){
            if(q == p.at(i)){
                f = 0;
            }
        }

        if(f==0){
            continue;
        }
        if(abs(ans - x) > abs(q-x)){
            ans = q;
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   16 |         inf f= 1;
      |         ^~~
      |         ynf
a.cc:19:17: error: 'f' was not declared in this scope
   19 |                 f = 0;
      |                 ^
a.cc:23:12: error: 'f' was not declared in this scope
   23 |         if(f==0){
      |            ^
Language: C++

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

signed main(){
	int X, N, i;
	scanf("%d%d", &X, &N);
	vector<int> p(N);
	for(i = 0; i < N; i++){
		scanf("%d", &p[i]);
	}
	ans = 0;
	for(int q = 0; q <= 101; q++){
		int f = 1;
		for(i = 0; i < N; i++){
			if(q == p[i]){
				f = 0;
			}
		}
		if(f == 0){
			continue;
		}
		if(abs(ans - X) > abs(q - X)){
			ans = q;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

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

int main() {
    int n, x, check[101] = {0};
    cin >> x >> n;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        check[tmp] = 1;
    }

    int ans, tmp = 1000;
    for(int i = 1, i <= 100;i++) {
        if(!check[i]) {
            if(abs(x - i) < tmp)
                ans = i;
            tmp = abs(x - i);
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: expected ';' before '<=' token
   17 |     for(int i = 1, i <= 100;i++) {
      |                     ^~~
      |                     ;
a.cc:17:22: error: expected primary-expression before '<=' token
   17 |     for(int i = 1, i <= 100;i++) {
      |                      ^~
Language: C++

using namespace std;
#include <iostream>
#include <algorithm>
#include <string>

int main(){
  int X, N;
  cin >> X >> N;
  int p;
  vector<int> Ps;
  int count = 0;
  int reached = 0;
  
  while (cin >> p) Ps.push_back(p);
  
  while (True){
    for (int i = 0; i < N; i++){
      reached++;
      if (Ps[i] == X - count){
        break;
      }
      count = count * (-1);
      if (Ps[i] == X - count){
        break;
      }
      count = count * (-1);
    }

    if (reached == N){
        cout << X - count;
        return 0;
    }
    
    count++
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<int> Ps;
      |   ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | #include <string>
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> Ps;
      |          ^~~
a.cc:14:20: error: 'Ps' was not declared in this scope
   14 |   while (cin >> p) Ps.push_back(p);
      |                    ^~
a.cc:16:10: error: 'True' was not declared in this scope
   16 |   while (True){
      |          ^~~~
a.cc:19:11: error: 'Ps' was not declared in this scope
   19 |       if (Ps[i] == X - count){
      |           ^~
a.cc:23:11: error: 'Ps' was not declared in this scope
   23 |       if (Ps[i] == X - count){
      |           ^~
a.cc:34:12: error: expected ';' before '}' token
   34 |     count++
      |            ^
      |            ;
   35 |   }
      |   ~
Language: C++

using namespace std;
#include <iostream>
#include <algorithm>
#include <string>

int main(){
  int X, N;
  cin >> X >> N;
  int p;
  vector<int> Ps;
  int answer = -1;
  
  for (cin >> p) Ps.push_back(p);
  
  sort(Ps.begin, Ps.end());
  
  for (int i = 0; i < N; i++){
    if (Ps[i] < X) answer = min(X - Ps[i], answer);
    else answer = min(Ps[i] - X, answer);
  }
  
  cout << answer;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<int> Ps;
      |   ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | #include <string>
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> Ps;
      |          ^~~
a.cc:13:16: error: expected ';' before ')' token
   13 |   for (cin >> p) Ps.push_back(p);
      |                ^
      |                ;
a.cc:15:8: error: 'Ps' was not declared in this scope
   15 |   sort(Ps.begin, Ps.end());
      |        ^~
a.cc:17:3: error: expected primary-expression before 'for'
   17 |   for (int i = 0; i < N; i++){
      |   ^~~
a.cc:15:28: error: expected ')' before 'for'
   15 |   sort(Ps.begin, Ps.end());
      |                            ^
      |                            )
   16 | 
   17 |   for (int i = 0; i < N; i++){
      |   ~~~                       
a.cc:13:7: note: to match this '('
   13 |   for (cin >> p) Ps.push_back(p);
      |       ^
Language: C

#include <stdio.h>

int main()
{
	int i, x, n, ans, pp, p[102] = {};
	scanf("%d %d", &x, &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &pp);
		p[pp] = 1;
	}
	for (i = 0; i <= 100; i++) {
		if (p[x-i] == 0) {
			ans=x - i;
			break;
		} else if (p[x+i] == 0) {
			ans=x + i;
			break;
		}
    printf("%d",ans);  
	return 0;
}


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

#include<stdio.h>
int main(void){
  int x,n,pp,p[102]={},i,ans;
  scanf("%d %d",&x,&n);
  for(i=0;i<n;i++)scanf("%d",&pp);p[pp]=1;
  for(i=0;i<101;i++){
    if(x-i>=0&&p[x-i]==0){
      ans=x-i;
      break;
    }
    if(x+i<101&&p[x+i]==0){
      ans=x+i;
      break;
    }
  }
  printf("%d",ans);
  fflish(stdout);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:17:3: error: implicit declaration of function 'fflish'; did you mean 'fflush'? [-Wimplicit-function-declaration]
   17 |   fflish(stdout);
      |   ^~~~~~
      |   fflush
Language: C

#include<stdio.h>
int main(void){
  int x1,x2,n,pp,p[101],i,ans;
  scanf("%d %d",&x1,&n);
  for(i=0;i<n;i++)scanf("%d",&pp);p[pp]=0;
  for(i=1;i<101;i++){
    if(p[i]!=0)p[i]=1;
  }
  for(i=0,x2=x1;i<101;i++){
    if(x1-i>=0&&p[x1-i]=1)ans=x1-i;break;
    if(x2+i<101&&p[x2+i]=1)ans=x1-i;break;
  }
  printf("%d",ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:10:24: error: lvalue required as left operand of assignment
   10 |     if(x1-i>=0&&p[x1-i]=1)ans=x1-i;break;
      |                        ^
main.c:11:25: error: lvalue required as left operand of assignment
   11 |     if(x2+i<101&&p[x2+i]=1)ans=x1-i;break;
      |                         ^
Language: C

#include<stdio.h>
int main(void){
  int x1,x2,n,pp,p[101],i,ans;
  scanf("%d %d",&x,&n);
  for(i=0;i<n;i++)scanf("%d",&pp);p[pp]=0;
  for(i=1;i<101;i++){
    if(p[i]!=0)p[i]=1;
  }
  for(i=0,x2=x1:i<101;i++){
    if(x1-i>=0&&p[x1-i]=1)ans=x1-i;break;
    if(x2+i<101&&p[x2+i]=1)ans=x1-i;break;
  }
  printf("%d",ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:4:18: error: 'x' undeclared (first use in this function)
    4 |   scanf("%d %d",&x,&n);
      |                  ^
main.c:4:18: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:16: error: expected ';' before ':' token
    9 |   for(i=0,x2=x1:i<101;i++){
      |                ^
      |                ;
main.c:9:26: error: expected ';' before ')' token
    9 |   for(i=0,x2=x1:i<101;i++){
      |                          ^
      |                          ;
main.c:10:24: error: lvalue required as left operand of assignment
   10 |     if(x1-i>=0&&p[x1-i]=1)ans=x1-i;break;
      |                        ^
main.c:11:25: error: lvalue required as left operand of assignment
   11 |     if(x2+i<101&&p[x2+i]=1)ans=x1-i;break;
      |                         ^
Language: C++

#include<iostream>
#include<math.h>
int main()
{
  int A, B;
  scanf( "%d%d", &A, &B);
  int ARR1[100] = {0};
  for(int a = 0; a < B; a++)
  {
    scanf( "%d", &(ARR1[a]));
  }
  int n = 100;
  int abc;
  for(int a = 0; a < 100; a++)
  {
    if((n>abs(A-a))&&(std::find(begin(ARR1),std::end(ARR!),A)==std::end(ARR1)))
      n = abs(A-a);
      abc = a;
  }
  printf("%d",a);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:33: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   16 |     if((n>abs(A-a))&&(std::find(begin(ARR1),std::end(ARR!),A)==std::end(ARR1)))
      |                                 ^~~~~
      |                                 std::begin
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:16:54: error: 'ARR' was not declared in this scope; did you mean 'ARR1'?
   16 |     if((n>abs(A-a))&&(std::find(begin(ARR1),std::end(ARR!),A)==std::end(ARR1)))
      |                                                      ^~~
      |                                                      ARR1
a.cc:20:15: error: 'a' was not declared in this scope
   20 |   printf("%d",a);
      |               ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:28:23: error: 'x' was not declared in this scope
   28 |         if(r.at(j) == x + i) {
      |                       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void part(){
  int x,n,p;
  cin>>x>>n;
  unordered_map<int,int> unmp;
  while(n--){
    cin>>p;
    ++unmp[p];
  }
  for(int i=0;i<=x;i++){
    for(auto j:{-1,1}){
      int a=x+p*d;
      if(unmp[a]==0){
        cout<<a;
        return;
      }
    }
  }
}
int main(void){
  int num=1;
  while(num--){
    part();
  }
  return 0;
}

Compiler output:
a.cc: In function 'void part()':
a.cc:13:17: error: 'd' was not declared in this scope
   13 |       int a=x+p*d;
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void part(){
  int x,n,p;
  cin>>x>>n;
  unordered_map<int,int> unmp;
  while(n--){
    cin>>p;
    ++unmp[p];
  }
  for(int i=0;i<=x;i++){
    for(auto j:{-1,1}){
      int a=x+s*d;
      if(unmp[a]==0){
        cout<<a;
        return;
      }
    }
  }
}
int main(void){
  int num=1;
  while(num--){
    part();
  }
  return 0;
}

Compiler output:
a.cc: In function 'void part()':
a.cc:13:15: error: 's' was not declared in this scope
   13 |       int a=x+s*d;
      |               ^
a.cc:13:17: error: 'd' was not declared in this scope
   13 |       int a=x+s*d;
      |                 ^
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();
    ArrayList<Integer> pList = new ArrayList<Integer>();
    for (int i=0; i<n; i++) {
      pList.add(sc.nextInt());
    }
    // Arrays.sort(pList);
    
    int number;
    for (int i=0; ; i++) {
      number = x - i;
      if (pList.contains()) {
        System.out.println(number);
        return;
      }
      number = x + i;
      if (pList.contains()) {
        System.out.println(number);
        return;
      }
    }
  }
}


Compiler output:
Main.java:18: error: method contains in class ArrayList<E> cannot be applied to given types;
      if (pList.contains()) {
               ^
  required: Object
  found:    no arguments
  reason: actual and formal argument lists differ in length
  where E is a type-variable:
    E extends Object declared in class ArrayList
Main.java:23: error: method contains in class ArrayList<E> cannot be applied to given types;
      if (pList.contains()) {
               ^
  required: Object
  found:    no arguments
  reason: actual and formal argument lists differ in length
  where E is a type-variable:
    E extends Object declared in class ArrayList
2 errors
Language: C++

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

int main() {
    int x,n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int count=1;
    int ans;
    while(true) {
        if(n==0) {
            ans = x;
            break;
        }
        if (count(p.begin(), p.end(), x-count) == 0) {
            ans = x-count;
            break;
        } else if(count(p.begin(), p.end(), x+count) == 0) {
            ans = x+count;
            break;
        }
        ++count;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: 'count' cannot be used as a function
   19 |         if (count(p.begin(), p.end(), x-count) == 0) {
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:24: error: 'count' cannot be used as a function
   22 |         } else if(count(p.begin(), p.end(), x+count) == 0) {
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: Java

import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
      	int n = scn.nextInt();
		int[] p = new int[n];
		for(int i=0; i<n; i++){
			p[i] = scn.nextInt();
		}
      	int ans = x;
      	int num = x;
      	for(int i=0; i<n; i++){
          if(ans==p[i]){
            ans++;
            i=-1;
          }
        }
      	for(int i=0; i<n; i++){
          if(num==p[i]&&ans>0){
            num--;
            i=-1;
          }
        }
      	if(Math.abs(ans-a)>=Math.abs(num-a)) {
		System.out.println(num);
		}else {
			System.out.println(ans);
		}
	}
}

Compiler output:
Main.java:26: error: cannot find symbol
      	if(Math.abs(ans-a)>=Math.abs(num-a)) {
      	                ^
  symbol:   variable a
  location: class Main
Main.java:26: error: cannot find symbol
      	if(Math.abs(ans-a)>=Math.abs(num-a)) {
      	                                 ^
  symbol:   variable a
  location: class Main
2 errors
Language: C++

// https://atcoder.jp/contests/abc170/tasks/abc170_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int X, N;
    cin >> X >> N;
    bitset<10000> bt;
    REP(i, N) {
        int t;
        cin >> t;
        bt.set(t);
    }
    if (N == 0) {
        cout << X << endl;
        return 0;
    }
    int ans = 0, diff = 1e9;
    REP(i, 101) {
        if (!bt[i] && abs(X - i) < diff) {
            ans = i;
            diff = abs(X - i);
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:22:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   22 |         return 0;
      |                ^
Language: C++

#include <iostream>
#include <cmath>

using namespace std;

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

    int a = 9999;
    int ans;
    for (int k = -1; k <= 101; k++) {
        if (a > abs(x-k) && *(lower_bound(p, p+n, k)) != k) {
            a = abs(x-k);
            ans = k;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int x,n;
    cin >> x >> n;
    
    if(n==0){
        cout << x-1 << endl;
        return 0;
    }
    
    map<int,int> p;
    int i;
    for(i=0;i<=101;i++) p[i]=i;
    int q;
    for(i=0;i<n;i++){
        cin >> q;
        p.erase(q);           
    }

    int a=0,u=x,o=101-x,b=101;
    for(i=0;i<=101;i++){
        if(p.count(i)){
            if(i<x){
                if(u>x-p.at(i)){
                    u = x-p.at(i);
                    a = p.at(i);
                }
            if(i>x){
                if(o>p.at(i)-x){
                    o = p.at(i)-x;
                    b = p.at(i);
                }
            }
        }else{
            continue;
        }
    }

    if(u<=o){
        cout << a << endl;
    }else{
        cout << b << endl;
    }

}

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

#include <bits/stdc++.h>
using namespace std;
int a[110];
int main(){
  int x, y;
  cin >> x >> y;
  if(y == 0)
  {
    cout << x;
    return 0;
  }
  for(int i = 0;i < y;i++)
  {
    cin >> a[i];
  }
  if(x <= a[0])
  {
    cout << a[0];
    return 0;
  }
  if(x >= a[y - 1]){
    cout << a[y - 1];
    return 0;
  }
  int p = lower_bound(a, a + y, x) - &a;
  if(a[p] - x >= x - a[p - 1]){
    cout << a[p - 1];
    return 0;
  }
  cout << a[p];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:36: error: invalid operands of types 'int*' and 'int (*)[110]' to binary 'operator-'
   25 |   int p = lower_bound(a, a + y, x) - &a;
      |           ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
      |                      |               |
      |                      int*            int (*)[110]
Language: C++

#include <bits/stdc++.h>
using namespace std;
int a[110];
int main(){
  int x, y;
  cin >> x >> y;
  if(y == 0)
  {
    cout << x;
    return 0;
  }
  for(int i = 0;i < y;i++)
  {
    cin >> a[i];
  }
  if(x <= a[0])
  {
    cout << a[0];
    return 0;
  }
  if(x >= a[y - 1]){
    cout << a[y - 1];
    return 0;
  }
  int p = *lower_bound(a, a + y, x) - &a;
  if(a[p] - x >= x - a[p - 1]){
    cout << a[p - 1];
    return 0;
  }
  cout << a[p];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:37: error: invalid operands of types 'int' and 'int (*)[110]' to binary 'operator-'
   25 |   int p = *lower_bound(a, a + y, x) - &a;
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
      |           |                           |
      |           int                         int (*)[110]
Language: C++

#include <bits/stdc++.h>
using namespace std;
int a[110];
int main(){
  int x, y;
  cin >> x >> y;
  if(y == 0)
  {
    cout << x;
    return 0;
  }
  for(int i = 0;i < y;i++)
  {
    cin >> a[i];
  }
  if(p <= a[0])
  {
    cout << a[0];
    return 0;
  }
  if(p >= a[y - 1]){
    cout << a[y - 1];
    return 0;
  }
  int p = *lower_bound(a, a + y, x) - &a;
  if(a[p] - x >= x - a[p - 1]){
    cout << a[p - 1];
    return 0;
  }
  cout << a[p];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:6: error: 'p' was not declared in this scope
   16 |   if(p <= a[0])
      |      ^
a.cc:21:6: error: 'p' was not declared in this scope
   21 |   if(p >= a[y - 1]){
      |      ^
a.cc:25:37: error: invalid operands of types 'int' and 'int (*)[110]' to binary 'operator-'
   25 |   int p = *lower_bound(a, a + y, x) - &a;
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
      |           |                           |
      |           int                         int (*)[110]
Language: C++

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

int main(){
  int x,n;
  cin>>x>>n;
  vector<int>a(101);
  vector<int>b(101);
  
  for(int i=1;i<=n;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  
  int ans;
  
  for(int i=0;i<=100;i++){
    if(!b[x-i]){
      ans=x-i;
      break;
    }
    else if!b[x+i]){
      ans=x+i;
      break;
    }
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: expected '(' before '!' token
   22 |     else if!b[x+i]){
      |            ^
      |            (
Language: C++

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

int main(){
  int x,n;
  cin>>x>>n;
  vector<int>a(101);
  vector<int>b(101);
  
  for(int i=1;i<=n;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  
  int ans;
  
  for(int i=0;i<=100;i++){
    if(!b[x-i]){
      p=x-i;
      break;
    }
    else if!b[x+i]){
      p=x+i;
      break;
    }
  }
  cout<<p<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: 'p' was not declared in this scope
   19 |       p=x-i;
      |       ^
a.cc:22:12: error: expected '(' before '!' token
   22 |     else if!b[x+i]){
      |            ^
      |            (
a.cc:27:9: error: 'p' was not declared in this scope
   27 |   cout<<p<<endl;
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int x, n;
  cin >> x >> n;
  vector<int> p(n), d(n);
  int dmin = 101;
  int ans = x;
  
    for(int i = 1; i <= n; i++){
      cin >> p[i];
    
      if(p[i] >= x){
        d[i] = p[i] - x;
      }else{
        d[i] = x - p[i];
      }
    
      if(dmin > d[i]){
        dmin = d[i];
        ans = p[i];
      }else if(dmin == d[i] && p[i] < x){
        ans = p[i];
      }
    }
  }
    
  cout << ans << endl;
}

Compiler output:
a.cc:29:3: error: 'cout' does not name a type
   29 |   cout << ans << endl;
      |   ^~~~
a.cc:30:1: error: expected declaration before '}' token
   30 | }
      | ^