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

#include "stdafx.h"
#include <iostream>
using namespace std;
void A()
{
	int S[10000];
	int T[500];
	int N;
	int Q;
	int C = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
	}

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

	for (int i = 0; i < Q; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (T[i] == S[j])
			{
				C++;
				break;
			}
		}
	}

	cout << C << endl;
}

void B()
{
	int S[100001];
	int T[5001];
	int N;
	int Q;
	int C = 0;

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

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

	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			if (S[i] > S[j])
			{
				swap(S[i],S[j]);
			}
		}
	}

	for (int i = 0; i < Q; i++)
	{
		int left = 0;
		int right = N - 1;
		int center = (left + right) / 2;
		while (left <= right)
		{
			if (T[i] == S[center])
			{
				C++;
				break;
			}

			if (T[i] > S[center])
			{
				left = center + 1;
				center = (left + right) / 2;
			}
			else
			{
				right = center - 1;
				center = (left + right) / 2;
			}
		}
	}

	cout << C << endl;
}

int main()
{
	//A();
	B();
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include "stdafx.h"
#include <iostream>
using namespace std;
void A()
{
	int S[10000];
	int T[500];
	int N;
	int Q;
	int C = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
	}

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

	for (int i = 0; i < Q; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (T[i] == S[j])
			{
				C++;
				break;
			}
		}
	}

	cout << C << endl;
}

void B()
{
	int S[100001];
	int T[5001];
	int N;
	int Q;
	int C = 0;

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

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

	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			if (S[i] > S[j])
			{
				swap(S[i],S[j]);
			}
		}
	}

	for (int i = 0; i < Q; i++)
	{
		int left = 0;
		int right = N - 1;
		int center = (left + right) / 2;
		while (left <= right)
		{
			if (T[i] == S[center])
			{
				C++;
				break;
			}

			if (T[i] > S[center])
			{
				left = center + 1;
				center = (left + right) / 2;
			}
			else
			{
				right = center;
				center = (left + right) / 2;
			}
		}
	}

	cout << C << endl;
}

int main()
{
	//A();
	B();
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	// your code goes here
	
	std::string buf, S_str, T_str;
	std::vector<int> S,T;
	std::cin >> buf;
	int n = atoi(buf.c_str());
	for (int i=0; i<n; i++){
		std::cin >> buf;
		S.push_back(atoi(buf.c_str()));
	}
	std::cin >> buf;
	int m = atoi(buf.c_str());
	for (int i=0; i<m; i++){
		std::cin >> buf;
		T.push_back(atoi(buf.c_str()));
	}
	
	int count = 0;
	if preNum = -1;
	for (std::vector<int>::iterator it = S.begin(); it != S.end(); it++){
		//std::cout << *it << std::endl;
		if (preNum == *it) continue;
		preNum = *it;
		std::vector<int>::iterator e = find(T.begin(), T.end(), *it);
		if (e!=T.end()){
			count ++;
			continue;
		}
	}
	
	std::cout << count << std::endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:12: error: expected '(' before 'preNum'
   27 |         if preNum = -1;
      |            ^~~~~~
      |            (
a.cc:30:21: error: 'preNum' was not declared in this scope; did you mean 'enum'?
   30 |                 if (preNum == *it) continue;
      |                     ^~~~~~
      |                     enum
a.cc:31:17: error: 'preNum' was not declared in this scope; did you mean 'enum'?
   31 |                 preNum = *it;
      |                 ^~~~~~
      |                 enum
Language: C++

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> S(n);

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

    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; ++i)
    {
        cin >> T[i];
    }
    sort(T.begin(), T.end());

    int current = 0;
    int count = 0;
    for (int i = 0; i < q; ++i) 
    {
        for (int j = current; i < n; ++j)
        {
            if (T[i] < S[j]) 
            {
                current = j;
                break;
            }
            if (T[i] == S[j]) ++count;
        }
    }
    cout << count << endl;

    return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> S(n);
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> S(n);
      |            ^~~
a.cc:13:16: error: 'S' was not declared in this scope
   13 |         cin >> S[i];
      |                ^
a.cc:18:12: error: expected primary-expression before 'int'
   18 |     vector<int> T(q);
      |            ^~~
a.cc:21:16: error: 'T' was not declared in this scope
   21 |         cin >> T[i];
      |                ^
a.cc:23:10: error: 'T' was not declared in this scope
   23 |     sort(T.begin(), T.end());
      |          ^
a.cc:23:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   23 |     sort(T.begin(), T.end());
      |     ^~~~
      |     short
a.cc:31:24: error: 'S' was not declared in this scope
   31 |             if (T[i] < S[j])
      |                        ^
a.cc:36:25: error: 'S' was not declared in this scope
   36 |             if (T[i] == S[j]) ++count;
      |                         ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> S(n);

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

    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; ++i)
    {
        cin >> T[i];
    }
    sort(T.begin(), T.end());

    int current = 0;
    int count = 0;
    for (int i = 0; i < q; ++i)
    {
        for (int j = current; i < n; ++j)
        {
            if (T[i] < S[j])
            {
                current = j;
                break;
            }
            if (T[i] == S[j]) ++count;
        }
    }
    cout << count << endl;

    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |     sort(T.begin(), T.end());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> S(n);

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

    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; ++i)
    {
        cin >> T[i];
    }
    sort(T.begin(), T.end());

    int current = 0;
    int count = 0;
    for (int i = 0; i < q; ++i)
    {
        for (int j = current; i < n; ++j)
        {
            if (T[i] < S[j])
            {
                current = j;
                break;
            }
            if (T[i] == S[j]) ++count;
        }
    }
    cout << count << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |     sort(T.begin(), T.end());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <Python/Python.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> S(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> S[i];
    }
    unique(S.begin(), S.end());

    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; ++i)
    {
        cin >> T[i];
    }
    sort(T.begin(), T.end());

    int current = 0;
    int count = 0;
    for (int i = 0; i < q; ++i)
    {
        for (int j = current; j < n; ++j)
        {
            if (S[j] < T[i])
            {
                current = j;
                break;
            }
            if (S[j] == T[i]) ++count;
        }
    }
    cout << count << endl;

    return 0;
}

Compiler output:
a.cc:4:10: fatal error: Python/Python.h: No such file or directory
    4 | #include <Python/Python.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

      
def binary_search(A,n):
    # sequence A, item n
    l=len(A)
    if l==0:
        return False
    elif A[l/2] > n:
        return binary_search(A[:l/2],n)
    elif A[l/2] == n:
        return True
    elif A[l/2]<n:
        return binary_search(A[(l/2)+1:],n)

n = int(raw_input())
S = list(set(map(int,raw_input().split())))
q = int(raw_input())
T = map(int,raw_input().split())

C = 0
for k in range(len(T)):
    if binary_search(S,T[k]):
        C += 1
print C

Compiler output:
a.cc:3:7: error: invalid preprocessing directive #sequence
    3 |     # sequence A, item n
      |       ^~~~~~~~
a.cc:2:1: error: 'def' does not name a type
    2 | def binary_search(A,n):
      | ^~~
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

void read_separated_string(vector<int> &v, string str) {
  istringstream istr(str);
  string tmp;
  while (getline(istr, tmp, ' ')) {
    v.push_back(stoi(tmp));
  }
}

int binary_search(const vector<int> &v, int first, int last, int key) {
  int middle = (int) ( (first + last) / 2 );
  if (key == v[middle]) {
    return 1;
  } else if (key < v[middle]) {
    return binary_search(v, first, middle, key);
  } else {
    return binary_search(v, middle, last, key);
  }
}

int main() {
  int N, Q;
  vector<int> n;
  vector<int> q;
  string str;

  cin >> N; cin.ignore();
  getline(cin, str);
  read_separated_string(n, str);
  cin >> Q; cin.ignore();
  getline(cin, str);
  read_separated_string(q, str);

  int count = 0;
  for (auto i : q) {
    count+= binary_search(i, n);
  }
  cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:27: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'int'
   42 |     count+= binary_search(i, n);
      |                           ^
a.cc:16:38: note: in passing argument 1 of 'int binary_search(const std::vector<int>&, int, int, int)'
   16 | int binary_search(const vector<int> &v, int first, int last, int key) {
      |                   ~~~~~~~~~~~~~~~~~~~^
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

void read_separated_string(vector<int> &v, string str) {
  istringstream istr(str);
  string tmp;
  while (getline(istr, tmp, ' ')) {
    v.push_back(stoi(tmp));
  }
}

int binary_search(const vector<int> &v, int first, int last, int key) {
  int middle = (int) ( (first + last) / 2 );
  if (key == v[middle]) {
    return 1;
  } else if (key < v[middle]) {
    return binary_search(v, first, middle, key);
  } else {
    return binary_search(v, middle, last, key);
  }
}

int main() {
  int N, Q;
  vector<int> n;
  vector<int> q;
  string str;

  cin >> N; cin.ignore();
  getline(cin, str);
  read_separated_string(n, str);
  cin >> Q; cin.ignore();
  getline(cin, str);
  read_separated_string(q, str);

  int count = 0;
  for (int i = 0; i < q.size(); ++i) {
    count+= binary_search(q[i], n);
  }
  cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:26: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   42 |     count+= binary_search(q[i], n);
      |             ~~~~~~~~~~~~~^~~~~~~~~
a.cc:16:38: note: in passing argument 1 of 'int binary_search(const std::vector<int>&, int, int, int)'
   16 | int binary_search(const vector<int> &v, int first, int last, int key) {
      |                   ~~~~~~~~~~~~~~~~~~~^
Language: C++

#include <iostream>
#include <vector>
using namespace std;


vector<int> s;
int cnt;
int n, p, a;

void bs(int t){
  int right = n;
  int left = 0;
  // cout << "hoge" << endl;
  while(right > left){
    // cout << "hoge" << endl;
    int mid = (right+left)/2;
    if(s[mid] == t){
      cnt++;
      break;
    }
    else if(s[mid] > t){
      right = mid;
    }else if(s[mid] < t){
      left = mid+1;
    }

  }

}

int main(){

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    s.push_back(a);
  }
  // cout << "hoge" << endl;
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(), s.end()), s.end()); 

  cin >> p;
  for(int i = 0; i < p; i++){
    cin >> a;
    bs(a);
  }
  //cout << "hoge" << endl;
  cout << cnt << endl;

 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   39 |   sort(s.begin(),s.end());
      |   ^~~~
      |   short
a.cc:40:11: error: 'unique' was not declared in this scope
   40 |   s.erase(unique(s.begin(), s.end()), s.end());
      |           ^~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int binarySearch(int key, int N, int A[]){
	int left = 0;
	int right = N;
	int mid;
	while(left < right){
		mid = (left + right)/2;
		if( key < A[mid] ) right = mid;
		else if( A[mid] < key) left = mid +1;
		else if( A[mid] = key) return 1;
	}
	return 0;
}

 
 int main(){
 	int N;
 	int S[200000];
 	int q;
 	int T[20000];
 	int count = 0;

 	cin >> N;
 	for(int i = 0; i < N; i++){
 		cin >> S[i];
 	}
 	cin >> q;
 	for(int j = 0; j < q; j++){
 		cin >> T[j];
 	}

 	for(int j = 0; j < q; j++){
 		if( binarySearch(T[j], &N, S) ) count++;
 	}

 	cout << count << endl;

 	return 0;
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:39:40: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   39 |                 if( binarySearch(T[j], &N, S) ) count++;
      |                                        ^~
      |                                        |
      |                                        int*
a.cc:8:31: note:   initializing argument 2 of 'int binarySearch(int, int, int*)'
    8 | int binarySearch(int key, int N, int A[]){
      |                           ~~~~^
Language: C++

object Main{
  def main(args:Array[String]) : Unit = {
      val sc = new java.util.Scanner(System.in)
      val n = sc.nextInt
      val list = List.fill(n)(sc.nextInt)
      val q = sc.nextInt
      val queries = List.fill(q)(sc.nextInt)
      val contained = queries.filter(binarySearch(list, _))
      println(contained.size)
  }
  def binarySearch(list: List[Int], n: Int) : Boolean = {
    val l = list.size
    if (l==0) false
    else if (list(l/2) > n ) binarySearch(list.slice(0, l/2), n)
    else if (list(l/2) == n) true
    else binarySearch(list.slice((l/2) + 1, list.size), n)
  }
}

Compiler output:
a.cc:1:1: error: 'object' does not name a type
    1 | object Main{
      | ^~~~~~
Language: C++

#include <vector>
#include <iostream>

typedef unsigned uint;

bool is_exist_bin_search(uint v, std::vector<uint> s){
  uint min = 0, max = s.size()-1;
  while(min < max){
    uint mid = (min + max) / 2;
    uint v_mid = t[mid];
    if(v_mid == v) return true;
    
    if(v_mid >= v) max = mid;
    else min = mid;
  }
  return false;
}

unsigned count(std::vector<uint> s, std::vector<uint> t){
  uint n = 0;
  for(uint i = 0; i < t.size(); i++){
    if(is_exist_bin_search(t[i],s)) n++;
  }
  return n;
}

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::vector<uint> s,t;

  {
    uint n,buf;
    std::cin >> n;
    for(; n; n--){
      std::cin >> buf;
      s.push_back(buf);
    }
  }

  {
    uint q,buf;
    std::cin >> q;
    for(; q; q--){
      std::cin >> buf;
      t.push_back(buf);
    }
  }

  std::cout << count(s,t) << '\n';
}

Compiler output:
a.cc: In function 'bool is_exist_bin_search(uint, std::vector<unsigned int>)':
a.cc:10:18: error: 't' was not declared in this scope
   10 |     uint v_mid = t[mid];
      |                  ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, c;
int main() {
	auto I = [](){int i;cin>>i;return i;};
	set<int> S;
	cin >> n;
	while(n--) S.insert(I());
	cin >> n;
	while(n--)
		if (S.count(I())) ++c;
	cout << c << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'set' was not declared in this scope
    8 |         set<int> S;
      |         ^~~
a.cc:4:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    3 | #include <algorithm>
  +++ |+#include <set>
    4 | using namespace std;
a.cc:8:13: error: expected primary-expression before 'int'
    8 |         set<int> S;
      |             ^~~
a.cc:10:20: error: 'S' was not declared in this scope
   10 |         while(n--) S.insert(I());
      |                    ^
a.cc:13:21: error: 'S' was not declared in this scope
   13 |                 if (S.count(I())) ++c;
      |                     ^
Language: C++

n = gets.to_i
S = gets.split.map(&:to_i)
q = gets.to_i
T = gets.split.map(&:to_i)

count = 0

for i in T do
	ll = - 1
	ul = n - 1
	while ll + 1 < ul do
		mid = (ll + ul) / 2
		if i > S[mid] then
			ll = mid
		elsif i < S[mid] then
			ul = mid
		else
			count += 1
			break
		end
	end
end 

puts count

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = gets.to_i
      | ^
Language: C++

#include <iostream>
#include <unordered_set>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n = 0;
    cin >> n;
    unordered_set<int> S;
    for (int i = 0; i!= n; ++i){
        int s = 0;
        cin >> s;
        S.insert(s);
    }
    int q = 0;
    cin >> q;
    int counts = 0;
    for (int i = 0; i != q; ++i){
        int t = 0;
        cin >> t;
        counts += S.count(t);
    }
    count << counts << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'count' was not declared in this scope; did you mean 'counts'?
   24 |     count << counts << endl;
      |     ^~~~~
      |     counts
Language: C++

#include <iostream>
#include <vector>
using namespace std;

bool binary_search(vector<int>& S,int n, int key) {
  int st = 0;
  int en = n;
  int bi;
  while true {
    bi = (st - en) / 2;
    if(S[bi] == key)
      return true;

    if(S[bi] > key) {
      st = bi + 1;
    }
    else if(S[bi] < key) {
      en = bi - 1;
    }

    if(bi == 0)
      return false;
  }
}

int main() {
  int n,q;
  vector<int> S,T;

  cin >> n;
  for(int i=0;i<n;i++) {
    int s;
    cin >> s;
    S.push_back(s);
  }
  cin >> q;
  for(int i=0;i<q;i++) {
    int t;
    cin >> t;
    T.push_back(t);
  }

  int C = 0;
  for(int t_itr=0;t_itr<q;t_itr++) {
    if(binary_search(S,n,T[t_itr]))
      C++;
  }

  cout << C << endl;
}

Compiler output:
a.cc: In function 'bool binary_search(std::vector<int>&, int, int)':
a.cc:9:9: error: expected '(' before 'true'
    9 |   while true {
      |         ^~~~
      |         (
a.cc:9:13: error: expected ')' before '{' token
    9 |   while true {
      |         ~~~~^~
      |             )
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int S[100000];

int main(void) {

    int n;
    cin >> n;

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

    int q, total = 0;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        int left = 0, right = n - 1, mid = 0;
        while (left <= right) {     // '<' ?????¨?????¨??§?????????
            mid = (left + right) / 2;
            if (t > S[mid]) {
                left = mid + 1;
            }
            else if (t < S[mid]) {
                right = mid - 1;
            }
            else (t == S[mid]) {
                ++total;
                break;
            }
        }
    }

    printf("%d\n", total);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:31: error: expected ';' before '{' token
   32 |             else (t == S[mid]) {
      |                               ^~
      |                               ;
Language: C++

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



int main(){
    int n,q,a;
    vector<int> S;
    vector<int> T;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> a;
        S.push_back(a);
    }
    cin >> q;
    for (int i = 0; i < q ; ++i) {
        cin >> a;
        T.push_back(a);
    }

    int count = 0;
    for (int i = 0; i < q ; ++i) {
        if(binary_search(S.begin(),S.end(),T[i])){
         count ++;
        }
    }
    cout << count << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'vector' was not declared in this scope
   10 |     vector<int> S;
      |     ^~~~~~
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 | using namespace std;
a.cc:10:12: error: expected primary-expression before 'int'
   10 |     vector<int> S;
      |            ^~~
a.cc:11:12: error: expected primary-expression before 'int'
   11 |     vector<int> T;
      |            ^~~
a.cc:15:9: error: 'S' was not declared in this scope
   15 |         S.push_back(a);
      |         ^
a.cc:20:9: error: 'T' was not declared in this scope
   20 |         T.push_back(a);
      |         ^
a.cc:25:26: error: 'S' was not declared in this scope
   25 |         if(binary_search(S.begin(),S.end(),T[i])){
      |                          ^
a.cc:25:44: error: 'T' was not declared in this scope
   25 |         if(binary_search(S.begin(),S.end(),T[i])){
      |                                            ^
Language: C++

#include <iostream>
using namespace std;

int n;
int S[100000];

int BinSearch( int key );

int main()
{

	int q, C = 0;
	int *T;

	scanf_s( "%d", &n );
	for( int i = 0; i < n; i++ ) scanf_s( "%d", &S[i] );

	scanf_s( "%d", &q );
	T = new int[q];
	for( int i = 0; i < q; i++ ) scanf_s( "%d", &T[i] );

	for( int i = 0; i < q; i++ ) C += BinSearch( T[i] );
	
	printf( "%d\n", C );

	delete[] T;

	return 0;

}

int BinSearch( int key )
{

	int left = 0, mid, right = n - 1;

	while( left <= right ) {

		mid = ( left + right ) / 2;

		if( S[mid] == key ) return 1;

		if( S[mid] < key )		left  = mid + 1;
		else if( S[mid] > key ) right = mid - 1;

	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   15 |         scanf_s( "%d", &n );
      |         ^~~~~~~
      |         scanf
Language: C++

#include <iostream>
#include <cstdio>
using namespace std;

int n;
int S[100000];

int BinSearch( int key );

int main()
{

	int q, C = 0;
	int *T;

	scanf_s( "%d", &n );
	for( int i = 0; i < n; i++ ) scanf_s( "%d", &S[i] );

	scanf_s( "%d", &q );
	T = new int[q];
	for( int i = 0; i < q; i++ ) scanf_s( "%d", &T[i] );

	for( int i = 0; i < q; i++ ) C += BinSearch( T[i] );
	
	printf( "%d\n", C );

	delete[] T;

	return 0;

}

int BinSearch( int key )
{

	int left = 0, mid, right = n - 1;

	while( left <= right ) {

		mid = ( left + right ) / 2;

		if( S[mid] == key ) return 1;

		if( S[mid] < key )		left  = mid + 1;
		else if( S[mid] > key ) right = mid - 1;

	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   16 |         scanf_s( "%d", &n );
      |         ^~~~~~~
      |         scanf
Language: C++

#include <cstdio>

int n;
int S[100000];

int BinSearch( int key );

int main()
{

	int q, C = 0;
	int *T;

	scanf_s( "%d", &n );
	for( int i = 0; i < n; i++ ) scanf_s( "%d", &S[i] );

	scanf_s( "%d", &q );
	T = new int[q];
	for( int i = 0; i < q; i++ ) scanf_s( "%d", &T[i] );

	for( int i = 0; i < q; i++ ) C += BinSearch( T[i] );
	
	printf( "%d\n", C );

	delete[] T;

	return 0;

}

int BinSearch( int key )
{

	int left = 0, mid, right = n - 1;

	while( left <= right ) {

		mid = ( left + right ) / 2;

		if( S[mid] == key ) return 1;

		if( S[mid] < key )		left  = mid + 1;
		else if( S[mid] > key ) right = mid - 1;

	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   14 |         scanf_s( "%d", &n );
      |         ^~~~~~~
      |         scanf
Language: C++

#include <iostream>
#include <cstdio>
using namespace std;

int n;
int S[100000];

int BinSearch( int key );

int main()
{

	int i, q, C = 0;
	int *T;

	scanf_s( "%d", &n );
	for( i = 0; i < n; i++ ) scanf_s( "%d", &S[i] );

	scanf_s( "%d", &q );
	T = new int[q];
	for( i = 0; i < q; i++ ) scanf_s( "%d", &T[i] );

	for( i = 0; i < q; i++ ) C += BinSearch( T[i] );
	
	printf( "%d\n", C );

	delete[] T;

	return 0;

}

int BinSearch( int key )
{

	int left = 0, mid, right = n - 1;

	while( left <= right ) {

		mid = ( left + right ) / 2;

		if( S[mid] == key ) return 1;

		if( S[mid] < key )		left  = mid + 1;
		else if( S[mid] > key ) right = mid - 1;

	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   16 |         scanf_s( "%d", &n );
      |         ^~~~~~~
      |         scanf
Language: C++

#include<stdio.h>
int n, s[100000];
int binary_search(int t)
{
	int left = 0;
	int right = n - 1;
	int mid;
	while (left <= right) {
		mid = (left + right) / 2;
		if (t == s[mid]) {
			return 1;
		}
		else if (t < s[mid]) {
			right = mid - 1;
		}
		else {
			left = mid + 1;
		}
	}
	return 0;
}

int main()
{
	int q, t[50000],i,c=0;
	scanf_s("%d", &n);
	for (i = 0; i < n; i++) {
		scanf_s("%d", &s[i]);
	}
	scanf_s("%d", &q);
	for (i = 0; i < q; i++) {
		scanf_s("%d", &t[i]);
		
	}
	for (i = 0; i < q; i++) {
		if (binary_search(t[i]) == 1) {
			c++;
		}
	}
	printf("%d\n", c);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   26 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

long A[1000000001];
long n,q;
long k,counter;

int main(){

    counter = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        scanf("%ld",&A[i]);
    }
    
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        scanf("%ld",&k);
        if (*lower_bound(A,A+n,k) == k) {
            counter++;
        }
    }
    cout << counter << endl;
    return 0;
}

Compiler output:
/tmp/ccWNOjiT.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0x9e): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0xf1): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccWNOjiT.o
a.cc:(.text+0x11e): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
int center=0;

using namespace std;

int binarySearch(vector<int> S, int from, int to ,int t ){

	center= floor((from + to)/2);

//	printf("(from, center, to) = (%d, %d, %d)\n", from, center, to);

	if( from >= to ){
		return t == S[center];
	}else if( t == S[center] ){
		return 1;
	}else if( S[center] < t ){
		return binarySearch(S, center+1, to, t);
	}else if( t < S[center] ){
		return binarySearch(S, from, center-1, t);
	}



}


	


int main(){

	int *S, *T;
	int t, temp;

	scanf("%d", &t);
	S=new int[t];
	for( int i=0; i<t; i++ ){
		scanf("%d", &temp);
		S[i]=temp;
	}
	scanf("%d", &t);
	T=new int[t];
	for( int i=0; i<t; i++ ){
		scanf("%d", &temp);
		T[i]=temp;
	}

	int ans=0;

	
	cout<<"??????????????\???"<<endl;
	for( unsigned int i=0; i<T.size(); i++ ){

		ans +=binarySearch(S, 0, S.size() -1,  T[i] );
	}
	cout<<ans<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:36: error: request for member 'size' in 'T', which is of non-class type 'int*'
   55 |         for( unsigned int i=0; i<T.size(); i++ ){
      |                                    ^~~~
a.cc:57:44: error: request for member 'size' in 'S', which is of non-class type 'int*'
   57 |                 ans +=binarySearch(S, 0, S.size() -1,  T[i] );
      |                                            ^~~~
a.cc: In function 'int binarySearch(std::vector<int>, int, int, int)':
a.cc:27:1: warning: control reaches end of non-void function [-Wreturn-type]
   27 | }
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
int center=0;

using namespace std;

int binarySearch(int* S, int S_size, int t ){

	int from=0, to=S_size-1, center=(from+to)/2;

	while( from <= to ) {

		if( S[center] == t ){
			return 1;
		}else if( t < S[center] ){
			to = center-1;
		}else if( s[center] < t ){
			from = center+1;
		}
	}

	return 0;



//	printf("(from, center, to) = (%d, %d, %d)\n", from, center, to);

	

	

}


	


int main(){

	int *S, *T;
	int S_size, T_size, temp;

	scanf("%d", &S_size);
	S=new int[S_size];
	for( int i=0; i<S_size; i++ ){
		scanf("%d", &temp);
		S[i]=temp;
	}
	scanf("%d", &T_size);
	T=new int[T_size];
	for( int i=0; i<T_size; i++ ){
		scanf("%d", &temp);
		T[i]=temp;
	}

	int ans=0;

	
	for( int i=0; i<T_size; i++ ){

		ans +=binarySearch(S, S_size, T[i]);
	}
	cout<<ans<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int binarySearch(int*, int, int)':
a.cc:19:27: error: 's' was not declared in this scope
   19 |                 }else if( s[center] < t ){
      |                           ^
Language: C++

#include <stdio.h>

#define N 100000
#define Q 50000
int S[N],T[Q],n,right,left;
int main(){
  int i,q,Sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    right=n;
    left=0;
    while(left<right){
      m=(left+right)/2;
      if(T[i]==S[m])
	Sum++;  
      else if(T[i]>S[m])
	right=m;
      else if(T[i]<S[m])
	left=m+1;
    }  
  }
  printf("%d\n",Sum);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:7: error: 'm' was not declared in this scope
   20 |       m=(left+right)/2;
      |       ^
Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;
int x[100000],a,n,q;
int main(){
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		while(true){
			char c = getchar_unlocked();
			if('0' <= c && c <= '9'){
				a[i] = a[i] * 10 + (c - '0');
			}
			else{break;}
		}
	}
	scanf("%d",&q);x[n]=1<<30;int cnt=0;
	for(int i=0;i<q;i++){
		scanf("%d",&a);
		int pos=lower_bound(x,x+n,a)-x;
		if(x[pos]==a)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:34: error: invalid types 'int[int]' for array subscript
   11 |                                 a[i] = a[i] * 10 + (c - '0');
      |                                  ^
a.cc:11:41: error: invalid types 'int[int]' for array subscript
   11 |                                 a[i] = a[i] * 10 + (c - '0');
      |                                         ^
Language: C++

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B
#include <iostream>
#include <stdio>
#include <algorithm>
using namespace std;

int A[1000000], n;

int main(){
  cin >> n;
  for(int i=0;i<n;i++) scanf("%d", &A[i]);

  int q, k, sum = 0;
  cin >> q;
  for(int i=0;i<n;i++){
    scanf("%d", k);
    if( *lower_bound(A, A+n, k) == k) sum++;
  }
  cout << sum << endl;
  return 0
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B
#include <iostream>
#include <stdio>
#include <algorithm>
using namespace std;

int A[1000000], n;

int main(){
  cin >> n;
  for(int i=0;i<n;i++) scanf("%d", &A[i]);

  int q, k, sum = 0;
  cin >> q;
  for(int i=0;i<n;i++){
    scanf("%d", k);
    if( *lower_bound(A, A+n, k) == k) sum++;
  }
  cout << sum << endl;
  return 0;
}

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

#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
	int n, q, S[10000], T[500], count = 0, i, j;
	scanf_s("%d", &n);
	for (i = 0; i < n; i++) {
		scanf_s("%d", &S[i]);
	}
	scanf_s("%d", &q);
	for (i = 0; i < q; i++) {
		scanf_s("%d", &T[i]);
	}
	for (i = 0; i < q; i++) {
		int a = 0, b = n - 1, ab;
		for (j = 0; j <= (n / 2) + (n % 2); j++) {
			ab = ((b - a) / 2) + ((b - a) % 2) + a;
			if (S[ab] == T[i]) {
				printf("%d %d %d\n", i, a, b);
				count++; break;
			}
			else {
				printf("%d %d %d\n", i, a, b);
				if (S[ab] < T[i]) { a = ab + 1; }
				else {
					b = ab - 1;
				}
			}
		}
	}
	printf("%d\n", count);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
    8 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
Language: C++

def search(S,t):
    return _search(S,t,0,len(S)-1)

def _search(S,t,l,r):
    if l > r:
        return False
    m = (l+r)/2
    if S[m] == t:
        return True
    elif S[m] > t:
        return _search(S,t,l,m-1)
    else:
        return _search(S,t,m+1,r)


n = int(raw_input())
S = map(int,raw_input().split(' '))
q = int(raw_input())
T = map(int,raw_input().split(' '))


ret = 0
for t in T:
    if search(S,t):
        ret += 1
print ret

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def search(S,t):
      | ^~~
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int cnt5;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    PUSH(n,v);
    
    int m;
    cin >> m;
    REP(i,m) {
        int j;
        cin >> j;
        if (binary_search(ALL(v), j) cnt5++;
    }

    cout << cnt5 << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:37: error: expected ';' before 'cnt5'
   29 |         if (binary_search(ALL(v), j) cnt5++;
      |                                     ^~~~~
      |                                     ;
a.cc:29:26: warning: ignoring return value of 'bool std::binary_search(_FIter, _FIter, const _Tp&) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = int]', declared with attribute 'nodiscard' [-Wunused-result]
   29 |         if (binary_search(ALL(v), j) cnt5++;
      |             ~~~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:2194:5: note: declared here
 2194 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
a.cc:30:5: error: expected primary-expression before '}' token
   30 |     }
      |     ^
a.cc:29:45: error: expected ')' before '}' token
   29 |         if (binary_search(ALL(v), j) cnt5++;
      |            ~                                ^
      |                                             )
   30 |     }
      |     ~                                        
a.cc:30:5: error: expected primary-expression before '}' token
   30 |     }
      |     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int s(int);
int a[100000],anum;
int t,tnum,l=0,r,m,count=0;
int main(){
  cin>>anum;
  for(int i=0;i<anum;i++)cin>>a[i];
  cin>>tnum;
  for(int i=0;i<tnum;i++){
    cin>>t;
    if(s(t)==1)count++;
  }
  cout<<count<<endl;
  return 0;
}
 
int s(int key){
  r=anum;
  while(l<r){
    m=(l+r)/2;
    if(key==a[m])return 1;
    else if(key>a[m])l=(++m);
    else r=m;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: reference to 'count' is ambiguous
   13 |     if(s(t)==1)count++;
      |                ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:6:20: note:                 'int count'
    6 | int t,tnum,l=0,r,m,count=0;
      |                    ^~~~~
a.cc:15:9: error: reference to 'count' is ambiguous
   15 |   cout<<count<<endl;
      |         ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:6:20: note:                 'int count'
    6 | int t,tnum,l=0,r,m,count=0;
      |                    ^~~~~
Language: C++

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,q;
  int count = 0;
  cin >> n;
  int *S = new int[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = q;
    while (left < right) {
      mid = (right - left) / 2;
      if (S[mid] == i) {
        count++;
        break;
      } else if (S[mid] < i) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:7: error: 'mid' was not declared in this scope
   21 |       mid = (right - left) / 2;
      |       ^~~
Language: C++

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

int main()
{
	int Count = 0;
	int n;
	cin >> n;
	list<int> S;
	for(int i = 0; i < n; i++){
		int s;
		cin >> s;
		S.push_back(s);
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		vector<int>::iterator it = find(S.begin(), S.end(), t);
		if(it != S.end()){
			Count++;
		}
	}
	cout << Count << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'vector' was not declared in this scope
   22 |                 vector<int>::iterator it = find(S.begin(), S.end(), t);
      |                 ^~~~~~
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 | using namespace std;
a.cc:22:24: error: expected primary-expression before 'int'
   22 |                 vector<int>::iterator it = find(S.begin(), S.end(), t);
      |                        ^~~
a.cc:23:20: error: 'it' was not declared in this scope; did you mean 't'?
   23 |                 if(it != S.end()){
      |                    ^~
      |                    t
Language: C++

 #include <iostream>
 #include <vector>
 using namespace std;

 bool BinarySearch(int t, vector<int> S)
 {
 	int start = 0;
 	int end = S.size() - 1;
 	do{
 		int middle = (end - start) / 2 + start;
 		if(t == S[middle]){
 			return true;
 		}else if(t < S[middle]){ #include <iostream>
 #include <vector>
 using namespace std;

 bool BinarySearch(int t, vector<int>& S)
 {
 	int start = 0;
 	int end = S.size() - 1;
 	do{
 		int middle = (end - start) / 2 + start;
 		if(t == S[middle]){
 			return true;
 		}else if(t < S[middle]){
 			end = middle - 1;
 		}else if(t > S[middle]){
 			start = middle + 1;
 		}
 //		cout << t << " " << start << " " << middle " " << end << endl;
 	}while(end - start >= 0);
 	return false;
 }

 int main()
 {
 	int Count = 0;
 	int n;
 	cin >> n;
 	vector<int> S;
 	for(int i = 0; i < n; i++){
 		int s;
 		cin >> s;
 		S.push_back(s);
 	}
 	int q;
 	cin >> q;
 	for(int i = 0; i < q; i++){
 		int t;
 		cin >> t;
 		if(BinarySearch(t, S)){
 			Count++;
// 			cout << "t:" << t << endl;
 		}
 	}
 	cout << Count << endl;
 	return 0;
 }

 			end = middle - 1;
 		}else if(t > S[middle]){
 			start = middle + 1;
 		}
 //		cout << t << " " << start << " " << middle " " << end << endl;
 	}while(end - start >= 0);
 	return false;
 }

 int main()
 {
 	int Count = 0;
 	int n;
 	cin >> n;
 	vector<int> S;
 	for(int i = 0; i < n; i++){
 		int s;
 		cin >> s;
 		S.push_back(s);
 	}
 	int q;
 	cin >> q;
 	for(int i = 0; i < q; i++){
 		int t;
 		cin >> t;
 		if(BinarySearch(t, S)){
 			Count++;
 //			cout << "t:" << t << endl;
 		}
 	}
 	cout << Count << endl;
 	return 0;
 }

Compiler output:
a.cc:13:42: error: stray '#' in program
   13 |                 }else if(t < S[middle]){ #include <iostream>
      |                                          ^
a.cc: In function 'bool BinarySearch(int, std::vector<int>)':
a.cc:13:43: error: 'include' was not declared in this scope
   13 |                 }else if(t < S[middle]){ #include <iostream>
      |                                           ^~~~~~~
a.cc:13:60: error: expected primary-expression before '>' token
   13 |                 }else if(t < S[middle]){ #include <iostream>
      |                                                            ^
a.cc:15:2: error: expected primary-expression before 'using'
   15 |  using namespace std;
      |  ^~~~~
a.cc:18:2: error: a function-definition is not allowed here before '{' token
   18 |  {
      |  ^
a.cc:35:10: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   35 |  int main()
      |          ^~
a.cc:35:10: note: remove parentheses to default-initialize a variable
   35 |  int main()
      |          ^~
      |          --
a.cc:35:10: note: or replace parentheses with braces to value-initialize a variable
a.cc:36:2: error: a function-definition is not allowed here before '{' token
   36 |  {
      |  ^
Language: C++

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

using namespace std;

bool BinarySerach(const vector<int> &S,int key)
{
	int start = 0;
	int end = S.size() - 1;
	int middle;
	
	while(1){
		middle = ceil((end - start)/2.) + start;
		if(S[middle] == key){
			return true;
		}else if(start == end){
			return false;
		}else if(S[middle] < key){
			start = middle + 1;
		}else if(S[middle] > key){
			end = middle - 1;
		}
	}
} 

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,q;
	vector<long> S;
	
	cin >> n;
	S.resize(n);
	
	for(int i=0; i<n; i++){
		cin >> S[i];
	}
	cin >> q;
	int count = 0;
	for(int i=0; i<q;i++){
		int key;
		cin >> key;
		if(BinarySerach(S,key)){
			count++;
//			cout << "key:" << key << endl;
		}
	}
	cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:33: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long int>'
   46 |                 if(BinarySerach(S,key)){
      |                                 ^
a.cc:7:38: note: in passing argument 1 of 'bool BinarySerach(const std::vector<int>&, int)'
    7 | bool BinarySerach(const vector<int> &S,int key)
      |                   ~~~~~~~~~~~~~~~~~~~^
Language: C++

#include<iostream>
using namespace std;
int n, s[10009], q, t[509], c = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;
	for (int i = 0; i<q; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < q; i++) {
		int left = 0;
		int right = n;
		int key = t[i];

		while (left < right) {
			mid = (left + right) / 2;
			if (s[mid] == key) {
				c++;
				break;
			}
			else if (key < s[mid]) right = mid;
			else left = mid + 1;
		}
	}


	cout << c << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:25: error: 'mid' was not declared in this scope
   21 |                         mid = (left + right) / 2;
      |                         ^~~
Language: C++

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

int main()
{
	int n, q, S[10000], T, res = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	sort(S, S + n);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T;
		if (binary_search(S, S + n, T))
			res++;
	}
	cout << res << endl;
	return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >> n;
      |         ^~~
a.cc:11:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |         sort(S, S + n);
      |         ^~~~
      |         short
a.cc:15:21: error: 'binary_search' was not declared in this scope
   15 |                 if (binary_search(S, S + n, T))
      |                     ^~~~~~~~~~~~~
a.cc:18:9: error: 'cout' was not declared in this scope
   18 |         cout << res << endl;
      |         ^~~~
a.cc:18:24: error: 'endl' was not declared in this scope
   18 |         cout << res << endl;
      |                        ^~~~