Language: C++

#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;



signed main() {
int X,N,frag=0,frag2=0,deg=0,min=0;
cin >> X >> N ;
vector<int> p(N);
REP(i,N){
    cin >> p[i];
}

while(frag==0){
    min = 0;
    frag = 0;
    frag2 = 0;
    REP(i,N){
if((X-deg)==p[i]){
        frag2=1;
        }
    }
if(frag2==0){
frag =1;
min =1;
break;
}
else frag2 = 0;

REP(i,N){
if((X+deg)==p[i]){
        frag2=1;
        }
    }
if(frag2==0){
frag =1;
break;
}
else frag2 = 1;

deg +=1;
}
if(min == 1){
answer(X-deg);
}
else answer(X+deg);
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:1: error: 'cin' was not declared in this scope
   41 | cin >> X >> N ;
      | ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    6 | #include<valarray>//なんとなく追加
  +++ |+#include <iostream>
    7 | //メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
a.cc:34:21: error: 'cout' was not declared in this scope
   34 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:77:1: note: in expansion of macro 'answer'
   77 | answer(X-deg);
      | ^~~~~~
a.cc:34:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   34 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:77:1: note: in expansion of macro 'answer'
   77 | answer(X-deg);
      | ^~~~~~
a.cc:34:32: error: 'endl' was not declared in this scope
   34 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:77:1: note: in expansion of macro 'answer'
   77 | answer(X-deg);
      | ^~~~~~
a.cc:7:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    6 | #include<valarray>//なんとなく追加
  +++ |+#include <ostream>
    7 | //メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
a.cc:34:21: error: 'cout' was not declared in this scope
   34 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:79:6: note: in expansion of macro 'answer'
   79 | else answer(X+deg);
      |      ^~~~~~
a.cc:34:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   34 | #define answer(ans) cout<<ans<<endl;
      |                     ^~~~
a.cc:79:6: note: in expansion of macro 'answer'
   79 | else answer(X+deg);
      |      ^~~~~~
a.cc:34:32: error: 'endl' was not declared in this scope
   34 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:79:6: note: in expansion of macro 'answer'
   79 | else answer(X+deg);
      |      ^~~~~~
a.cc:34:32: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
   34 | #define answer(ans) cout<<ans<<endl;
      |                                ^~~~
a.cc:79:6: note: in expansion of macro 'answer'
   79 | else answer(X+deg);
      |      ^~~~~~