Language: C++

#include <iostream>
#include <algorithm>

int main() {

	int N;
	int* D;
	bool *D_tf;
	int M;
	int* T;
	bool *T_tf;
	int count = 0;

	cin >> N;
	D = new int[N];
	D_tf = new bool[N];

	for (int i = 0; i < N;i++) {
		cin >> D[i];
	}

	sort(D,D+N);
	
	cin >> M;
	T = new int[M];
	T_tf = new bool[M];

	for (int i = 0; i < M; i++) {
		cin >> T[i];
	}

	sort(T,T+M);

	for (int i = 0; i < M; i++) {
		int insert = (N+1)/2;
		int old_insert = N-1;
		while (1) {
			if (insert < 0)insert++;
			if (T[i] > D[insert]&&insert<N) {
				insert = insert + (old_insert - insert) / 2+1;
				old_insert = insert;
			}
			else if (T[i] < D[insert]&&insert>0) {
				insert = insert / 2;
				old_insert = insert;
			}
			else if(T[i]==D[insert]) {
				if (D_tf[insert] == true&&D_tf[insert+1]!=T[i]&& D_tf[insert - 1] != T[i]) {
					insert++;
					cout << "NO" << endl;
					return 0;
				}
				D_tf[insert] = true;
				break;
			}
			else if(insert<1||insert>N-1){
				if(T[i]==D[0]){
					break;
				}
				else {
					cout << "NO" << endl;
					return 0;
				}
			}
		}
	}

	cout << "YES" << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   14 |         cin >> N;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   22 |         sort(D,D+N);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:50:41: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   50 |                                         cout << "NO" << endl;
      |                                         ^~~~
      |                                         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:50:57: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   50 |                                         cout << "NO" << endl;
      |                                                         ^~~~
      |                                                         std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:61:41: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   61 |                                         cout << "NO" << endl;
      |                                         ^~~~
      |                                         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:61:57: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   61 |                                         cout << "NO" << endl;
      |                                                         ^~~~
      |                                                         std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:68:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   68 |         cout << "YES" << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:68:26: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   68 |         cout << "YES" << endl;
      |                          ^~~~
      |                          std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~