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

#include<bits/stdc++.h>
using namespace std;
int main(){
        int x,a,n; cin>>x>>n; unordered_map<int,int>  vis; memset(vis,0,sizeof(vis)); for(int i=0;i<n;i++) {cin>>a; vis[a]=1;}
        if(!vis[x]) {cout<<x<<endl; return 0;}
        int low=x-1,high=x+1;
        while(1){
                if(!vis[low]) { cout<<low<<endl; return 0;}
                if(!vis[high]) { cout<<high<<endl; return 0; }
                low--,high++;
        }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:4:67: error: cannot convert 'std::unordered_map<int, int>' to 'void*'
    4 |         int x,a,n; cin>>x>>n; unordered_map<int,int>  vis; memset(vis,0,sizeof(vis)); for(int i=0;i<n;i++) {cin>>a; vis[a]=1;}
      |                                                                   ^~~
      |                                                                   |
      |                                                                   std::unordered_map<int, int>
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
set<int>s;
int main(){
	int x,num;
	cin>>x>>num;
	int use;
	for(int i=0;i<=num;i++){
		cin>>a;
		s.insert(a); 
	}
	for(int i=0;i<=100;i++){
      	if(!s.count(x+i)){
			cout<<(x+i)<<endl;
			return 0;
		}
		else if(!s.count(x-i))cout<<(x-i)<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: 'a' was not declared in this scope
    9 |                 cin>>a;
      |                      ^
Language: C++

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

int main(){
    int n,x,t;
    set<int> s;
    cin >> x >> n;
    for(int i = 0; i < n; ++i){
        cin >> t;
        s.insert(t);
    }

    vector<pair<int,int>> diff;
    for(int i = 1; i <= 100; ++i){
        if(s.count(i)) continue;
        diff.emplace_back(abs(x-i),i);
    }
    sort(diff.begin(),diff.end());
    int mn = 2e9;
    for(int i = 0; i < diff.size(); ++i){
        if(diff[i]!=diff[0]) break;
        mn = min(diff[i],mn);
    }
    cout << mn;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type&, int&)'
   22 |         mn = min(diff[i],mn);
      |              ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:22:17: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<int, int>' and 'int')
   22 |         mn = min(diff[i],mn);
      |              ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:22:17: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   22 |         mn = min(diff[i],mn);
      |              ~~~^~~~~~~~~~~~
Language: C++

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

int main(){
    int n,x,t;
    set<int> s;
    for(int i = 0; i < n; ++i){
        cin >> t;
        s.insert(t);
    }

    vector<pair<int,int>> diff;
    for(int i = 0; i < v.size(); ++i){
        if(s.count(i)) continue;
        diff.emplace_back(abs(x-i),i));
    }
    sort(diff.begin(),diff.end());
    cout << diff[0].second;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:24: error: 'v' was not declared in this scope
   13 |     for(int i = 0; i < v.size(); ++i){
      |                        ^
a.cc:15:38: error: expected ';' before ')' token
   15 |         diff.emplace_back(abs(x-i),i));
      |                                      ^
      |                                      ;
Language: C++

int main() {
  int x,n;
  cin>>x>>n;
  int p[n];
  for (int i=0;i<n;i++){
    cin>>p[i];
  }
  int ans1,ans2,abs1,abs2;
  for (int i=x;i<=200;i++){
    int flag=0;
    for (int j=0;j<n;j++){
      if (i==p[j]) flag=1;
    }
    if (flag==0){
      ans1=i;
      abs1=abs(x-i);
      goto loop1;
    }
  }
  loop1:
  for (int i=x;i>=-100;i--){
    int flag=0;
    for (int j=0;j<n;j++){
      if (i==p[j]) flag=1;
    }
    if (flag==0){
      ans2=i;
      abs2=abs(x-i);
      goto loop2;
    }
  }
  loop2:
  if (abs1<abs2) cout<<ans1<<endl;
  else cout<<ans2<<endl;
  return 0;
}

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:16:12: error: 'abs' was not declared in this scope; did you mean 'abs2'?
   16 |       abs1=abs(x-i);
      |            ^~~
      |            abs2
a.cc:28:12: error: 'abs' was not declared in this scope; did you mean 'abs2'?
   28 |       abs2=abs(x-i);
      |            ^~~
      |            abs2
a.cc:33:18: error: 'cout' was not declared in this scope
   33 |   if (abs1<abs2) cout<<ans1<<endl;
      |                  ^~~~
a.cc:33:30: error: 'endl' was not declared in this scope
   33 |   if (abs1<abs2) cout<<ans1<<endl;
      |                              ^~~~
a.cc:34:8: error: 'cout' was not declared in this scope
   34 |   else cout<<ans2<<endl;
      |        ^~~~
a.cc:34:20: error: 'endl' was not declared in this scope
   34 |   else cout<<ans2<<endl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    set<int> st;
    REP(i, n) {
        cin >> p[i];
        st.insert(p[i]);
    }

    int ans = 1000;
    for(int i = 0; i < 102; i++) {
        if(st.count(i)) continue;
        if(abs(ans - x) > abs(i - x)) {
            ans = i;
        }
    }

    cout << i << endl;
    

    return 0;
}

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

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    REP(i, n) cin >> p[i];
    
    for(int i = 0; i < x+1; i++) {
        int a;
        a = x+i;
        bool ok = 1;
        for(int j = 0; j < n; j++) {
            if(a == p[j]) ok = 0;
        }
        if(ok){
            cout << a << endl;
            return 0;
        }
        
        a = x-i;
        bool ok = 1;
        for(int j = 0; j < n; j++) {
            if(a == p[j]) ok = 0;
        }
        if(ok){
            cout << a << endl;
            return 0;
        }
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:14: error: redeclaration of 'bool ok'
   36 |         bool ok = 1;
      |              ^~
a.cc:26:14: note: 'bool ok' previously declared here
   26 |         bool ok = 1;
      |              ^~
Language: C++

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int x, n;
	int ans = INF;
	cin >> x >> n;
	Vi p(i);
	rep(i, n) { cin >> p[i]; }
	sort(all(p));
	auto itr = p.begin();
	for (int i = -1; i <= 101; i++) {
		if (*itr < i) {
			itr++;
			if (itr == p.end()) {
				p[0] = INF;
				itr  = p.begin;
			}
		}
		if (*itr == i) {
			continue;
		} else {
			if (abs(ans - x) > abs(i - x)) {
				ans = i;
			}
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:14: error: 'i' was not declared in this scope
   47 |         Vi p(i);
      |              ^
a.cc:56:42: error: no match for 'operator=' (operand types are '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and '<unresolved overloaded function type>')
   56 |                                 itr  = p.begin;
      |                                          ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >& __gnu_cxx::__normal_iterator<int*, std::vector<int> >::operator=(const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&)'
 1038 |     class __normal_iterator
      |           ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >& __gnu_cxx::__normal_iterator<int*, std::vector<int> >::operator=(__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&)'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&'
Language: C++


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

int main() {
    int X,N;
    cin >> X >> N;
   
    bool easy=true;
    vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p.at(i);
        if(p.at(i)==X) easy=false;
    }
    int a,b;
    if(easy) cout << X << endl;
    else{
        for(int i=1; i<110; i++){
            a=0,b=0;
            for(int j=0; j<N; j++){
                if(p.at(j)==X-i){
                    a=1;
                }
                else if(p.at(i)==X+i){
                    b=1;
                }
            }
            if (a==0) {
                cout << X-i << endl;
                
                break;
                }
             else if(b==0){
                cout << X+i <<endl;
                
                break;
                 }   
                
                
               
        }
        
    }


  


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

x,n=map(int,input().split())
p=set(map(int,input().split()))
l=set(range(-100,201))-p
ans=0
tmp=1000
for i in l:
    if tmp>abs(x-i):
        ans=i
        tmp=abs(x-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 <vector>
#include <algorithm>
using namespace std;

int main() {
	int thynumb,c = 0;
	cin >> thynumb;
	int noofseq = 0;
	cin>> noofseq;
	        vector <int> vect;
	for(int i=0;i<noofseq;i++){
	    //store all these numbers in a array
						cin>> c;
            vect.push_back(c);
	}

	int deco = thynumb;
	int inco = thynumb;
	while ( find(vect.begin(),vect.end(),inco) != vect.end() ) 
		inco++;
	while ( find(vect.begin(),vect.end(),deco) != vect.end() ) 
		deco--;

	if(inco <= deco){
		cout<< inco;
	}
	else
		cout<< deco;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >> thynumb;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:25:17: error: 'cout' was not declared in this scope
   25 |                 cout<< inco;
      |                 ^~~~
a.cc:25:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:28:17: error: 'cout' was not declared in this scope
   28 |                 cout<< deco;
      |                 ^~~~
a.cc:28:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer
using namespace std;

int main() {
  int X, N;
  cin >> X >> N;
  
  vector<int> p(N);
  for(int i=0; i<N; i++)
    cin >> P.at(i);
  
  sort(P.begin(),P.end());
  
  int ans=0;
  bool cont;
  
  for(int i=0; i<101; i++){
    cont = false;
    for(int j=0; j<N; j++){
      if(i == P.at(j)){
        cont=true;
        break;
      }
    }
    if(cont==true)
      continue;
    
    if(abs(X-ans) - abs(X-i))
      ans = i;
  }
  
  cout << ans << endl;
      
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'P' was not declared in this scope
   11 |     cin >> P.at(i);
      |            ^
a.cc:13:8: error: 'P' was not declared in this scope
   13 |   sort(P.begin(),P.end());
      |        ^
Language: C

#include<stdio.h>

int main(){
	int x,n;
	scanf("%d %d",&x,&n);
	int i,p[n + 1] = {0},tmp,min,max;
	for(i = 0; i < n; i++){
		scanf("%d",&tmp);
		p[tmp] = 1;
	}
	min = x;
	max = x;
	for(i = 0; i < n / 2 + 1; i++){
		if(p[min] == 0 || p[max] == 0){
			if(p[min] == 0){
				printf("%d",min);
				break;
			} else {
				printf("%d",max);
				break;
			}
		}
		min--;
		max++;
		if(min < 0){
			printf("%d",min);
			break;
		}
	}
	if(n == 0){
		printf("%d",x);
	}

	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:6:26: error: variable-sized object may not be initialized except with an empty initializer
    6 |         int i,p[n + 1] = {0},tmp,min,max;
      |                          ^
Language: C++

#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <limits>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	int x, n;
	cin >> x >> n;
	unordered_set<int> niz(n);
	vector<int> possible;

	if (n == 0)
	{
		cout << x;
		return 0;
	}

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		niz.insert(x);
	}

	int b = 0;
	for (int i = *min_element(niz.begin(), niz.end()); i < *max_element(niz.begin(), niz.end()); i++)
	{
		if (niz.find(i) == niz.end())
		{
			possible.push_back(i);
			b++;
		}
	}

	int min_diff = INT_MAX;
	int result = -1;
	for (int i = 0; i < b; i++)
	{
		int d = abs(possible[i] - x);
		if (d < min_diff)
		{
			min_diff = d;
			result = possible[i];
		}
	}
	cout << result;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:24: error: 'INT_MAX' was not declared in this scope
   41 |         int min_diff = INT_MAX;
      |                        ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <algorithm>
  +++ |+#include <climits>
    9 | using namespace std;
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


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

    int x,n;
    cin >> x >> n;
    unordered_map<int,int> mp;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        mp[x] = 1;
    }

    if (mp[x] != 1) {
        cout << x;
        return;
    }   
    for (int i = 1; i < x + 1; i++) {
        int a1 = x + (-1)*i;
        int a2 = x + (1)*i;
        if (mp[a1] != 1) {
            cout << a1;
            return 0;
        } 
        if (mp[a2] != 1) {
            cout << a2;
            return 0;
        }
    }


    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


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

import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    int X = scan.nextInt();
    int N = scan.nextInt();
    int Y = X;
    
    int i = 1
    while (i <= N) {
      int p_i = scan.nextInt();
      
      if (p_i == X || p_i == Y) {
        X = X + 1;
        Y = Y - 1;
        i = 1;
      }
    }
    System.out.println(X);
  }
}
    


Compiler output:
Main.java:12: error: ';' expected
    int i = 1
             ^
1 error
Language: C++

#include<iostream>

#include<algorithm>
#include<cstring>
using namespace std;

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

    cout << ok << endl;
//    system("pause");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:38: error: return-statement with no value, in function returning 'int' [-fpermissive]
   26 |     else if (ok == -1) {cout << ok2; return;}
      |                                      ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
bool comp(int a,int b){
return a>b;
}
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	fast;
	ll res=INT_MAX,n,a,m,mi=INT_MAX;
	unordered_map<int,int>mp;
	cin>>n>>m;
	rep(i,0,m){
		cin>>a;
   mp[a]++;
		    	
		}
		
		rep(i,0,n+1)
		{
			if(mp[n-i]==0 &&)
			{
				cout<<n-i<<endl;
				return 0;
			}
			if(mp[n+i]==0 && n+i<=100)
			{
				cout<<n+i<<endl;
				return 0;
			}
							
			
		}
		
		
//	cout<<res;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:38:41: error: expected primary-expression before ')' token
   38 |                         if(mp[n-i]==0 &&)
      |                                         ^
Language: C++

int X, N;
	scanf_s("%d %d", &X, &N);
	int* p = new int[N];

	
	if (N != 0)// 0이면 입력을 안 받아
	{
		for (int i = 0; i < N; i++) {
			scanf_s("%d", &p[i]);
		}
	}

	bool okay = false;
	int test[2];
	int answer;
	int count = 0; 
	while (!okay) {
		//빼기 먼저
		test[0] = X + count; // X 자체도 답이 될 수 있어 -> count = 0; -> 더하기
		test[1] = X - count; // 빼기
		if (N == 0) {
			answer = X;
			okay = true;
		}
		else // test_m과 test_p가 sequence에 있는지 확인
		{
			bool exist[2] = { false, false };
			for (int i = 0; i < N; i++) {
				if (exist[0] == false && test[0] == p[i]) { // 있으면 넘어가야지 
					exist[0] = true;
				}
				if (exist[1] == false && test[1] == p[i]) {
					exist[1] = true;
				}
			}
			if (!exist[0]) // 없어
			{
				answer = test[0];
				okay = true;
			}
			if (!exist[1])
			{
				answer = test[1];
				okay = true;
			}
		}
		count++;
	}
	printf("%d", answer);
	delete p;

Compiler output:
a.cc:2:16: error: expected constructor, destructor, or type conversion before '(' token
    2 |         scanf_s("%d %d", &X, &N);
      |                ^
a.cc:6:9: error: expected unqualified-id before 'if'
    6 |         if (N != 0)// 0이면 입력을 안 받아
      |         ^~
a.cc:17:9: error: expected unqualified-id before 'while'
   17 |         while (!okay) {
      |         ^~~~~
a.cc:49:15: error: expected constructor, destructor, or type conversion before '(' token
   49 |         printf("%d", answer);
      |               ^
a.cc:50:9: error: expected unqualified-id before 'delete'
   50 |         delete p;
      |         ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    int X,N;
    cin >> X >> N;
    int p[N];
    for(int i = 0, i < N , i++)cin >> p[i];
    int n = *min_element(p,p + N),a,b,f,g;
    for (int i = 0;true; i++)
    {
        a = X-n+1-i;
        b = X+n-1+i;
        f = count(p,p+N,a);
        g = count(p,p+N,b);
        if(f==0){
            cout << a << endl;
            break;
        }else if(g==0){
            cout << b << endl;
            break;
        }
    }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:21: error: expected ';' before '<' token
    7 |     for(int i = 0, i < N , i++)cin >> p[i];
      |                     ^~
      |                     ;
a.cc:7:22: error: expected primary-expression before '<' token
    7 |     for(int i = 0, i < N , i++)cin >> p[i];
      |                      ^
a.cc:7:31: error: expected ';' before ')' token
    7 |     for(int i = 0, i < N , i++)cin >> p[i];
      |                               ^
      |                               ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,n;
  cin >> x >> n;
  
  vector<int>	map(102);
  for(int i=0;i<n;i++){
    int key;
    cin >> key;
    map.at(key)=key;
  }
  
  for(int sa=0;sa<100;sa++){
    if(map.at(x-sa)==0){
      cout << x-sa;
      return 0;
    }
    if(map.at(x+sa)==0){
      cout << x+sa;
      return 0;
    }
  }
    
}
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x,n;
  cin >> x >> n;
  
  vector<int>	map(102);
  for(int i=0;i<n;i++){
    int key;
    cin >> key;
    map.at(key)=key;
  }
  
  for(int sa=0;sa<100;sa++){
    if(map.at(x-sa)==0){
      cout << x-sa;
      return 0;
    }
    if(map.at(x+sa)==0){
      cout << x+sa;
      return 0;
    }
  }
    
}

Compiler output:
a.cc:30:5: error: redefinition of 'int main()'
   30 | int main() {
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main() {
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,n;
  cin >> x >> n;
  
  vector<int>	map(102);
  for(int i=0;i<n;i++){
    int key;
    cin >> key;
    map.at(key)=key;
  }
  
  for(int sa=0;sa<100;sa++){
    if(map.at(x-sa)==0){
      cout << x-sa;
      return 0;
    }
    if(map.at(x+sa)==0){
      cout << x+sa;
      return 0;
    }
  }
    
}
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x,n;
  cin >> x >> n;
  
  vector<int>	map(102);
  for(int i=0;i<n;i++){
    int key;
    cin >> key;
    map.at(key)=key;
  }
  
  for(int sa=0;sa<100;sa++){
    if(map.at(x-sa)==0){
      cout << x-sa;
      return 0;
    }
    if(map.at(x+sa)==0){
      cout << x+sa;
      return 0;
    }
  }
    
}


Compiler output:
a.cc:30:5: error: redefinition of 'int main()'
   30 | int main() {
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main() {
      |     ^~~~
Language: Java

import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int x = scan.nextInt();
    int xx = x;
    boolean[] p = new boolean[100];
    Arrays.fill(p,false);
    for(int i = 0;i < scan.nextInt();i++){
      p[scan.nextInt()] = true;
    }
    boolean flag = false;
    int ans = x;
    while(!flag){
      if(!p[x]){flag=true;ans=x++;}
      if(!p[xx]){flag=true;ans=xx--;}
    }
  }
}

Compiler output:
Main.java:8: error: cannot find symbol
    Arrays.fill(p,false);
    ^
  symbol:   variable Arrays
  location: class Main
1 error
Language: C

#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(i=0;i<n;i++)
int main(){
    int x,n,i,e,dif,ans=200;
    scanf("%d%d",&x,&n);
    int a[n],p[102]={0};
    rep(i,n){
        scanf("%d",&a[n]);
        p[a[n]]=1;
    }
    for(i=0;i<102;i++){
        if(p[i]==1) continue;
        dif=abs(x-i);
        if(ans>dif){
            e=i;
            ans=dif;
    }
    printf("%d",e);
    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++

ios_base::sync_with_stdio(false);cin.tie(0);
  int X;
  int N;
  int a = 0;
  int b = 0;
  set<int> s;
  cin>>X;
  cin>>N;
  for(int i = 0;i < N;i++){
    cin>>a;
    s.insert(a);
    //cout<<"A"<<a<<'\n';
  }
  for(int i = 0;i < 100;i++){
    //cout<<X - i<<' ';
    //cout<<X + i<<'\n';
    if(s.find(X - i) == s.end()){
      cout<<X - i<<'\n';
      //cout<<"B"<<'\n';
      //cout<<"B"<<X - i<<'\n';
      break;
    }
    if(s.find(X + i) == s.end()){
      cout<<X - i<<'\n';
      //cout<<"A"<<'\n';
      //cout<<"C"<<X + i<<'\n';
      break;
    }
  }

Compiler output:
a.cc:1:1: error: 'ios_base' does not name a type
    1 | ios_base::sync_with_stdio(false);cin.tie(0);
      | ^~~~~~~~
a.cc:1:34: error: 'cin' does not name a type
    1 | ios_base::sync_with_stdio(false);cin.tie(0);
      |                                  ^~~
a.cc:6:3: error: 'set' does not name a type
    6 |   set<int> s;
      |   ^~~
a.cc:7:3: error: 'cin' does not name a type
    7 |   cin>>X;
      |   ^~~
a.cc:8:3: error: 'cin' does not name a type
    8 |   cin>>N;
      |   ^~~
a.cc:9:3: error: expected unqualified-id before 'for'
    9 |   for(int i = 0;i < N;i++){
      |   ^~~
a.cc:9:17: error: 'i' does not name a type
    9 |   for(int i = 0;i < N;i++){
      |                 ^
a.cc:9:23: error: 'i' does not name a type
    9 |   for(int i = 0;i < N;i++){
      |                       ^
a.cc:14:3: error: expected unqualified-id before 'for'
   14 |   for(int i = 0;i < 100;i++){
      |   ^~~
a.cc:14:17: error: 'i' does not name a type
   14 |   for(int i = 0;i < 100;i++){
      |                 ^
a.cc:14:25: error: 'i' does not name a type
   14 |   for(int i = 0;i < 100;i++){
      |                         ^
Language: C

#include<stdio.h>

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

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

#include <bits/stdc++.h>

using namespace std;

int main(){
  int x,n;
  cin >> x >> n;
  
  bool arrayOfLight[101] = {false};
  
  int temp;
  for (int i = 0; i < n; i++){
	cin >> temp;
    arrayOfLight[temp] = true;
  }
  
  int ans = 0;
  
  for (int i = 0; i <= 101; i++){
    if (arrayOfLight[i] == false){
      if(abs(X-i) < abs(X-ans){
        ans = i;
      }
    }
  }
         
  cout << ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: 'X' was not declared in this scope
   21 |       if(abs(X-i) < abs(X-ans){
      |              ^
a.cc:21:31: error: expected ')' before '{' token
   21 |       if(abs(X-i) < abs(X-ans){
      |         ~                     ^
      |                               )
a.cc:24:5: error: expected primary-expression before '}' token
   24 |     }
      |     ^
Language: C

    #include <stdio.h>
     
    int main(){
     
        int a;
        int b;
     
        
        int n[101];
        int data[101];
     
        scanf("%d", &a);
        scanf("%d", &b);
     
        for (int i = 0; i <= 100; i++){
            data[i] = 0;
        }
     
        for (int i = 0; i < b; i++){
            scanf("%d", &n[i]);
            deta[n[i]] = 1;
        }
     
        for (int i = 0; i <= 100; i++){
            if(a-i>=0){//0よりでかい
            if(data[a-i]==0){
                printf("%d", a - i);
                break;
            }
            }
            if(a+i==101){
                printf("%d", 101);
                break;
            }
            if (a + i <= 100){ 
                if (deta[a + i] == 0){
                    printf("%d", a + i);
                    break;
                }
            }
        }
     
        printf("\n");
    }

Compiler output:
main.c: In function 'main':
main.c:21:13: error: 'deta' undeclared (first use in this function); did you mean 'data'?
   21 |             deta[n[i]] = 1;
      |             ^~~~
      |             data
main.c:21:13: note: each undeclared identifier is reported only once for each function it appears in
Language: Java


import java.io.*;
import java.util.Scanner;


class main{

    static boolean check(int q, int N, int arr[]) {
        for (int a = 0; a<N; a++) {
            if (arr[a] == q)
            {
                return true;
            }
        }
        
        return false;
    }

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        int N = scan.nextInt();
        int a[] = new int[N];
        for (int j = 0; j < N; j++) {
            a[j] = scan.nextInt();
        }
        scan.close();

        Boolean res = new Boolean(false);

        if (check(X, N, a)==true)
        {
            res=true;
        }
        if (!res)
        {
            System.out.print(""+X);
        }

        else
        {
            int p=X-1 , q=X+1;
            while(res)
            {
                if(!check(p,N,a))
                {
                    res=true;
                    System.out.print(""+p);
                    break;   
                }
                if(!check(q,N,a))
                {
                    res=true;
                    System.out.print(""+q);
                    break;   
                }
                
                p--;
                q++;
                
            }
        }
        
    }
}


Compiler output:
Main.java:29: warning: [removal] Boolean(boolean) in Boolean has been deprecated and marked for removal
        Boolean res = new Boolean(false);
                      ^
1 warning
Language: Java


import java.io.*;
import java.util.Scanner;

import sun.text.normalizer.NormalizerBase.QuickCheckResult;

class main{

    static boolean check(int q, int N, int arr[]) {
        for (int a = 0; a<N; a++) {
            if (arr[a] == q)
            {
                return true;
            }
        }
        
        return false;
    }

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        int N = scan.nextInt();
        int a[] = new int[N];
        for (int j = 0; j < N; j++) {
            a[j] = scan.nextInt();
        }
        scan.close();

        Boolean res = new Boolean(false);

        if (check(X, N, a)==true)
        {
            res=true;
        }
        if (!res)
        {
            System.out.print(""+X);
        }

        else
        {
            int p=X-1 , q=X+1;
            while(res)
            {
                if(!check(p,N,a))
                {
                    res=true;
                    System.out.print(""+p);
                    break;   
                }
                if(!check(q,N,a))
                {
                    res=true;
                    System.out.print(""+q);
                    break;   
                }
                
                p--;
                q++;
                
            }
        }
        
    }
}


Compiler output:
Main.java:5: error: package sun.text.normalizer.NormalizerBase does not exist
import sun.text.normalizer.NormalizerBase.QuickCheckResult;
                                         ^
Main.java:30: warning: [removal] Boolean(boolean) in Boolean has been deprecated and marked for removal
        Boolean res = new Boolean(false);
                      ^
1 error
1 warning
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int x.n; cin >> x >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int now = INF;
  int ans = -1;
  rep(i,102){
    bool ok = false;
    rep(j,n){
      if(p[j] == i) ok = true;
    }
    if(!ok){
      if(now > abs(i-x)){
        now = abs(i-x);
        ans = i;
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:8: error: expected initializer before '.' token
   35 |   int x.n; cin >> x >> n;
      |        ^
a.cc:35:19: error: 'x' was not declared in this scope
   35 |   int x.n; cin >> x >> n;
      |                   ^
a.cc:35:24: error: 'n' was not declared in this scope; did you mean 'yn'?
   35 |   int x.n; cin >> x >> n;
      |                        ^
      |                        yn
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int x.n; cin >> x >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int now = INF;
  int ans = -1;
  rep(i,102){
    bool ok = false;
    rep(j,n){
      if(p[i] == i) ok = true;
    }
    if(!ok){
      if(now > abs(i-x)){
        now = abs(i-x);
        ans = i;
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:8: error: expected initializer before '.' token
   35 |   int x.n; cin >> x >> n;
      |        ^
a.cc:35:19: error: 'x' was not declared in this scope
   35 |   int x.n; cin >> x >> n;
      |                   ^
a.cc:35:24: error: 'n' was not declared in this scope; did you mean 'yn'?
   35 |   int x.n; cin >> x >> n;
      |                        ^
      |                        yn
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
  int X, N;
  cin >> X >> N;
  
  if(N == 0){
    cout << X << endl;
    return 0;
  }
  
  int ans;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  
  vector<int>num(101, 0);
  for(int i=0;i<N;i++){
    num[p[i]]++;
  }
  
  it d = 999;
  for(int i=0;i<N;i++){
    if(num[i] == 0 && abs(X - i) < d){
      d = abs(X - i);
      ans = i;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:3: error: 'it' was not declared in this scope; did you mean 'int'?
   25 |   it d = 999;
      |   ^~
      |   int
a.cc:27:36: error: 'd' was not declared in this scope
   27 |     if(num[i] == 0 && abs(X - i) < d){
      |                                    ^
Language: Java

import java.util.*;
import java.util.Scanner;
import java.util.HashSet;

public class main{
    public static Scanner scn = new Scanner(System.in);
    public static void main(String[] args){
        int X=scn.nextInt();
        Integer N=scn.nextInt();

        
        
        int[] arr=new int[N];
        for(int i=0;i<N;i++)
        {
            arr[i]=scn.nextInt();
        }

        System.out.println(find_nearest(X, N, arr));
      
    }

    public static int find_nearest(int x,Integer n,int[] arr)
    {   if(n==0 || n==null)
        return x;

         HashSet<Integer> set=new HashSet<>();
      
        for(int i=0;i<arr.length;i++)
        {

            set.add(arr[i]);
        }
      
        int val1=x;
        int val2=x;
       
        while(!set.contains(val1)){
            val1--;
        }
        while(!set.contains(val2)){
            val2++;
        }

        if(Math.abs(x-val1)>Math.abs(x-val2))
        return val2;
        else
        return val1;
    

    }
}

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

import java.util.*;
import java.util.Scanner;
import java.util.HashSet;

public class test{
    public static Scanner scn = new Scanner(System.in);
    public static void main(String[] args){
        int X=scn.nextInt();
        Integer N=scn.nextInt();

        
        
        int[] arr=new int[N];
        for(int i=0;i<N;i++)
        {
            arr[i]=scn.nextInt();
        }

        System.out.println(find_nearest(X, N, arr));
      
    }

    public static int find_nearest(int x,Integer n,int[] arr)
    {   if(n==0 || n==null)
        return x;

         HashSet<Integer> set=new HashSet<>();
      
        for(int i=0;i<arr.length;i++)
        {

            set.add(arr[i]);
        }
      
        int val1=x;
        int val2=x;
       
        while(!set.contains(val1)){
            val1--;
        }
        while(!set.contains(val2)){
            val2++;
        }

        if(Math.abs(x-val1)>Math.abs(x-val2))
        return val2;
        else
        return val1;
    

    }
}

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

[9:11 pm, 05/07/2020] Siddharth Sharma 2 No: import java.util.*;

public class Main{

public static void main(String[] args) {

// write your code here.
Scanner scn=new Scanner (System.in);
int x=scn.nextInt();
int n=scn.nextInt();
int []arr=new int[n];
boolean temp=false;
for(int i=0;i<n;i++){
    arr[i]=scn.nextInt();
    if(arr[i]==x){
        temp=true;
    }
}
Arrays.sort(arr);
if(arr.length==0){
    System.out.println(x);
    return;
}
if( temp==false){
    System.out.println(x);
    return;
}
int idx=0;
for(int i=0;i<arr.length;i++){
    if(arr[i]==x){
        idx=i;
    }
    
}

int p1=idx+1;
int p2=idx-1;
int val=1;
while(p1!=arr.length && p2!=-1){
    if(arr[p2]!=x-val){
      
        System.out.println(x-val);
        return;
    }
    if(arr[p1]!=x+val){
         
        System.out.println(x+val);
        return;
    }
    val++;
    p2--;
    p1++;
}
if(p1!=arr.length){

   System.out.println(x-val);
   return;
}
if(p2!=-1){
    
    if(arr[p2]==x-val){
         
        System.out.println(x+val);
        return;
    }
      
     System.out.println(x-val);
     return;
}
System.out.println(arr[0]-1);



 }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
[9:11 pm, 05/07/2020] Siddharth Sharma 2 No: import java.util.*;
^
1 error
Language: C++

#include<iostream>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(){
int n,x,ans=0;
cin>>x>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int h= INT_MAX;
for(int i=0;i<n;i++){
int p = abs(arr[i]-x);
if(p<h){
h=p;
ans=arr[i];
}
}
cout<<ans;
return 0;
}

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

#include<iostream>
#include<cstdlib>
#include<math>
using namespace std;
int main(){
int n,x,ans=0;
cin>>x>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int h= INT_MAX;
for(int i=0;i<n;i++){
int p = abs(arr[i]-x);
if(p<h){
h=p;
ans=arr[i];
}
}
cout<<ans;
return 0;
}

Compiler output:
a.cc:3:9: fatal error: math: No such file or directory
    3 | #include<math>
      |         ^~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstdlib.h>
#include<math.h>
using namespace std;
int main(){
int n,x,ans=0;
cin>>x>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int h= INT_MAX;
for(int i=0;i<n;i++){
int p = abs(arr[i]-x);
if(p<h){
h=p;
ans=arr[i];
}
}
cout<<ans;
return 0;
}

Compiler output:
a.cc:2:9: fatal error: cstdlib.h: No such file or directory
    2 | #include<cstdlib.h>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream.h>
#include<cstdlib.h>
#include<math.h>
using namespace std;
int main(){
int n,x,ans=0;
cin>>x>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int h= INT_MAX;
for(int i=0;i<n;i++){
int p = abs(arr[i]-x);
if(p<h){
h=p;
ans=arr[i];
}
}
cout<<ans;
return 0;
}

Compiler output:
a.cc:1:9: fatal error: iostream.h: No such file or directory
    1 | #include<iostream.h>
      |         ^~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.*;
public class Main{
    public static void main(String[] args){
         int x,n;
         Scanner scn = new Scanner(System.in);
         x = scn.nextInt();
         n = scn.nextInt();
         int[] a = new int[n];
         Hashmap<Integer,Boolean> map = new Hashmap<>();
  
         for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
            map.put(a[i],true);
          }
           
          int diff = 0;
     
          while(1){
             if(!map.containsKey(check-diff)){
                 System.out.println(check-diff);
                  break;
              }
              else if(!map.containsKey(check+diff)){
                 System.out.println(check-diff);
                  break;
              }
              else {
                  diff++;
               }
           }
  }
}

Compiler output:
Main.java:9: error: cannot find symbol
         Hashmap<Integer,Boolean> map = new Hashmap<>();
         ^
  symbol:   class Hashmap
  location: class Main
Main.java:9: error: cannot find symbol
         Hashmap<Integer,Boolean> map = new Hashmap<>();
                                            ^
  symbol:   class Hashmap
  location: class Main
Main.java:18: error: incompatible types: int cannot be converted to boolean
          while(1){
                ^
Main.java:19: error: cannot find symbol
             if(!map.containsKey(check-diff)){
                                 ^
  symbol:   variable check
  location: class Main
Main.java:20: error: cannot find symbol
                 System.out.println(check-diff);
                                    ^
  symbol:   variable check
  location: class Main
Main.java:23: error: cannot find symbol
              else if(!map.containsKey(check+diff)){
                                       ^
  symbol:   variable check
  location: class Main
Main.java:24: error: cannot find symbol
                 System.out.println(check-diff);
                                    ^
  symbol:   variable check
  location: class Main
7 errors
Language: Java

import java.util.*;
public class Main(String args[]){
    public static void main(){
         int x,n;
         Scanner scn = new Scanner(System.in);
         x = scn.nextInt();
         n = scn.nextInt();
         int[] a = new int[n];
         Hashmap<Integer,Boolean> map = new Hashmap<>();
  
         for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
            map.put(a[i],true);
          }
           
          int diff = 0;
     
          while(1){
             if(!map.containsKey(check-diff)){
                 System.out.println(check-diff);
                  break;
              }
              else if(!map.containsKey(check+diff)){
                 System.out.println(check-diff);
                  break;
              }
              else {
                  diff++;
               }
           }
  }
}

Compiler output:
Main.java:2: error: '{' expected
public class Main(String args[]){
                 ^
1 error
Language: Java

import java.util.*;
public class Main(String[] args){
    public static void main(){
         int x,n;
         Scanner scn = new Scanner(System.in);
         x = scn.nextInt();
         n = scn.nextInt();
         int[] a = new int[n];
         Hashmap<Integer,Boolean> map = new Hashmap<>();
  
         for(int i=0;i<n;i++){
            a[i]=scn.nextInt();
            map.put(a[i],true);
          }
           
          int diff = 0;
     
          while(1){
             if(!map.containsKey(check-diff)){
                 System.out.println(check-diff);
                  break;
              }
              else if(!map.containsKey(check-diff)){
                 System.out.println(check-diff);
                  break;
              }
              else {
                  diff++;
               }
           }
  }
}

Compiler output:
Main.java:2: error: '{' expected
public class Main(String[] args){
                 ^
1 error