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

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int main() {
	int N; cin >> N;
	vector<int>ns(N);
	for (int i = 0; i < N; ++i) {
		cin >> ns[i];
	}
	int Q; cin >> Q;
	int sum = 0;
	while (Q--) {
		int a; cin >> a;
		auto it = lower_bound(ns.begin(), ns.end(), a);
		auto jt = upper_bound(ns.begin(), ns.end(), a);
		sum += min(1,jt - it);
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:27: error: no matching function for call to 'min(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   22 |                 sum += min(1,jt - it);
      |                        ~~~^~~~~~~~~~~
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:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   22 |                 sum += min(1,jt - it);
      |                        ~~~^~~~~~~~~~~
/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:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |                 sum += min(1,jt - it);
      |                        ~~~^~~~~~~~~~~
Language: C++

#include <stdio.h>
int S[100005], T[50000];
int binarysearch(int A[], int n, int key)
{
	int left = 0
	int right = n;
	while(left<right)
	{
		int mid = (left+right)/2;
		if(A[mid]==key) return mid;
		else if(A[mid] > key) left = mid+1;
		else if(A[mid] < key) right = mid;
	}
	return -1;
}
int main(int argc, char const *argv[])
{
	int n,q;
	int cnt = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for (int i = 0; i < q; ++i)
	{
		scanf("%d",&S[i]);
		int ans = binarysearch(A,n,S[i]);
		if(ans!=-1) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Compiler output:
a.cc: In function 'int binarysearch(int*, int, int)':
a.cc:6:9: error: expected ',' or ';' before 'int'
    6 |         int right = n;
      |         ^~~
a.cc:7:20: error: 'right' was not declared in this scope
    7 |         while(left<right)
      |                    ^~~~~
a.cc: In function 'int main(int, const char**)':
a.cc:23:29: error: 'A' was not declared in this scope
   23 |                 scanf("%d",&A[i]);
      |                             ^
a.cc:29:40: error: 'A' was not declared in this scope
   29 |                 int ans = binarysearch(A,n,S[i]);
      |                                        ^
Language: C++

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

int s[111111];
int q,n,t;
int c=0;

int main(){

  scanf(" %d",&n);

  for(int i=0;i<n;i++){
    scanf(" %d",&s[i]);
  }

  scanf(" %d",&q);

  for(int j=0;j<q;j++){
    scanf(" %d",&t);

    //bynary search                                                             
    int l,r,m;
    l=0;
    r=n;

    while(l<r){
      m=(r+l)/2;
      if(s[m]==t){
        c++;
        cout << t << endl;
        break;
      }
      if(s[m]>=t){
        r=m;
      }else{
        l=m+1;
      }
    }

  }

  cout << c << endl;

  return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:46:12: error: expected '}' at end of input
   46 |   return 0;
      |            ^
a.cc:10:11: note: to match this '{'
   10 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;

int ar(int *c,int n){
    int num,f=0,a[100000];
a=c;
    for (int i=0;i<n;i++) {
        cin>>a[i];
        for(int j=0;j<i;j++)
        if(a[i]==a[j])i--,n--,f++;
		      int tmp=a[i],j;
		      for(j=i-1;j>=0&&tmp<a[j]&&!f;j--)a[j+1]=a[j];
		      a[j+1]=tmp,num=n,f=0;
	   }
    return num;
}

int main(){
    int p,q,a[100000],b[10000],n=0;
    cin>>p,p=ar(a,p);
    cin>>q,q=ar(b,q);
    for(int i=0;i<q;i++)
        for(int j=0;j<p;j++)
            if(b[i]==a[j])n++;
    cout<<n<<endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int ar(int*, int)':
a.cc:6:2: error: incompatible types in assignment of 'int*' to 'int [100000]'
    6 | a=c;
      | ~^~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q;
	vector<int> S(100000);
	vector<int> T(50000);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T[i];
	}
	int ans = 0;
	
	for (int i = 0; i < q; i++) {
		auto itr = find(S.begin(), S.end(), T[i]);
		if (itr != S.end()) ans++;
	}
	
	cout << ans << endl;
	return 0;
}v

Compiler output:
a.cc: In function 'int main()':
a.cc:25:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   25 |                 auto itr = find(S.begin(), S.end(), T[i]);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:25:32: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   25 |                 auto itr = find(S.begin(), S.end(), T[i]);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: At global scope:
a.cc:31:2: error: 'v' does not name a type
   31 | }v
      |  ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q;
	vector<int> S(100000);
	vector<int> T(50000);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T[i];
	}
	int ans = 0;
	
	for (int i = 0; i < q; i++) {
		auto itr = find(S.begin(), S.end(), T[i]);
		if (itr != S.end()) ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   25 |                 auto itr = find(S.begin(), S.end(), T[i]);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:25:32: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   25 |                 auto itr = find(S.begin(), S.end(), T[i]);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

int n;
inline int search(int a[], int key) {
	int l = 0;
	int r = n;
	while (r != l) {
		int mid = (l + r) / 2;
		if (a[mid] = key)
			return 1;
		else if (a[mid] < key)
			l = mid + 1;
		else if (a[mid] > key)
			r = mid;
	}
	return 0;
}
int main() {
	const int num = 10001;
	int ar[num], q, key, sum=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (search(ar, key)) sum++;
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'cin' was not declared in this scope
   19 |         cin >> n;
      |         ^~~
a.cc:28:9: error: 'cout' was not declared in this scope
   28 |         cout << sum << endl;
      |         ^~~~
a.cc:28:24: error: 'endl' was not declared in this scope
   28 |         cout << sum << endl;
      |                        ^~~~
Language: C++

#include <iostream>
using namespace std;

int main() 
{
	int n;
	int ans = 0, q, a;
	cin >> n;
	vector<int> vc(n);

	for (int i = 0; i < n; i++)
		cin >> vc[i];

	cin >> q;
	
	sort(vc.begin(), vc.end());
	
	while (q--)
	{
		cin >> a;
		if (binary_search(vc.begin(), vc.end(), a)) 
			ans++;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'vector' was not declared in this scope
    9 |         vector<int> vc(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 | using namespace std;
a.cc:9:16: error: expected primary-expression before 'int'
    9 |         vector<int> vc(n);
      |                ^~~
a.cc:12:24: error: 'vc' was not declared in this scope
   12 |                 cin >> vc[i];
      |                        ^~
a.cc:16:14: error: 'vc' was not declared in this scope
   16 |         sort(vc.begin(), vc.end());
      |              ^~
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |         sort(vc.begin(), vc.end());
      |         ^~~~
      |         short
a.cc:21:21: error: 'binary_search' was not declared in this scope
   21 |                 if (binary_search(vc.begin(), vc.end(), a))
      |                     ^~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
 
int main() 
{
    int n;
    int ans = 0, q, a;
    cin >> n;
    vector<int> vc(n);
 
    for (int i = 0; i < n; i++)
        cin >> vc[i];
 
    cin >> q;
     
    sort(vc.begin(), vc.end());
     
    while (q--)
    {
        cin >> a;
        if (binary_search(vc.begin(), vc.end(), a)) 
            ans++;
    }
    cout << ans << endl;
}

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

#include <cstdio>

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

int main() {
  int i, n, A[1000000], q, key, sum = 0;

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

  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%d", &key);
    if (BinarySearch(A, n, key)) {
      ++sum;
    }
  }

  printf("%d\n", sum);
}

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

#include <stdio.h>

int binarysearch(int q[], int key, int n)
{
	int left = 0;
	int right = n;
	
	while (left < right)
	{
		int mid = (left + right) / 2;
		if (q[mid] == key)	return 1;
		else if (q[mid] > key) right = mid;
		else left = mid + 1;
	}
	return 0;
}

int main()
{
	int n,a;
	scanf_s("%d", &n);
	int s[100000];

	for (int i = 0; i < n; i++) {
		scanf_s("%d", &a);
		s[i] = a;
	}
	
	int n_t, key;
	int sum = 0;
	scanf_s("%d", &n_t);
	for (int i = 0; i < n_t; i++) {
		scanf_s("%d", &key);
		if(binarysearch(s,key,n)) sum++;
	}

	printf("%d\n", sum);
}

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

#include <stdio.h>

int binarysearch(int q[], int key, int n)
{
	int left = 0;
	int right = n;
	
	while (left < right)
	{
		int mid = (left + right) / 2;
		if (q[mid] == key)	return 1;
		else if (q[mid] > key) right = mid;
		else left = mid + 1;
	}
	return 0;
}

int main()
{
	int n,a;
	scanf("%d", &n);
	int s[100000];

	for (int i = 0; i < n; i++) {
		scanf_s("%d", &a);
		s[i] = a;
	}
	
	int n_t, key;
	int sum = 0;
	scanf("%d", &n_t);
	for (int i = 0; i < n_t; i++) {
		scanf("%d", &key);
		if(binarysearch(s,key,n)) sum++;
	}

	printf("%d\n", sum);
}

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

#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main()
{
    int n,q,left,right,mid,key,counter = 0;
    cin >> n;
    int S[n];
    REP(i,n)cin >> S[i];    
    cin >> q;

    REP(i,q) {
        cin >> key;
        left = 0;
        right = n;
        while( left < right ) {
            mid = (left + right) / 2;
            if (S[mid] == key) {
                counter++;
                D(key);
                break;
            } else if (key < S[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
    }
    cout << counter << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'D' was not declared in this scope
   21 |                 D(key);
      |                 ^
Language: C++

#include<iostream>
??
using namespace std ;
??
int ans = 0 ;
??
bool answer( int n ,long num[] ,int p )
{
????????if( n == num[ p ] )
????????{
????????????????ans++ ;
????????????????return true ;
????????}
????????return false ;
}
??
int main()
{
????????int s ,t ,n ;
??
????????cin >> s ;
????????long num[ s ] ;
??
????????for( int i = 0 ; i < s ; i++ )
????????????????cin >> num[ i ] ;
??
????????cin >> t ;
????????for( int i = 0 ; i < t ; i++ )
????????{
????????????????int p = 0 ,pp = s ;
????????????????bool br = false ;
????????????????cin >> n ;
????????????????while( true )
????????????????{
????????????????????????int a = p + ( ( pp - p ) / 2 ) ;
????????????????????????if( answer( n ,num ,a ) )
????????????????????????????????break ;
????????????????????????else if( n > num[ a ] )
????????????????????????{
????????????????????????????????if( answer( n ,num ,a + 1 ) )
????????????????????????????????????????break ;
????????????????????????????????p = p + a + 2 ;
????????????????????????????????if( p >= s )
????????????????????????????????????????break ;
????????????????????????}
????????????????????????else if( answer( n, num ,a - 1 ) )
????????????????????????????????break ;
????????????????????????else
????????????????????????{
????????????????????????????????pp = a - 2 ;
????????????????????????????????if( pp <= p )
????????????????????????????????????????break ;
????????????????????????}
??????????????????????????
????????????????}
????????}
??
????????cout << ans << endl ;
??
????????return 0 ;
}

Compiler output:
a.cc:2:1: error: expected unqualified-id before '?' token
    2 | ??
      | ^
a.cc:4:1: error: expected unqualified-id before '?' token
    4 | ??
      | ^
a.cc:6:1: error: expected unqualified-id before '?' token
    6 | ??
      | ^
a.cc:16:1: error: expected unqualified-id before '?' token
   16 | ??
      | ^
Language: C++

#include<iostream>

using namespace std ;

int ans = 0 ;

bool answer( int n ,long num[] ,int p )
{
	if( n == num[ p ] )
	{
		ans++ ;
		return true ;
	}
	return false ;
}

int main()
{
	int s ,t ,n ;

	cin >> s ;
	long num[ s ] ;

	for( int i = 0 ; i < s ; i++ )
		cin >> num[ i ] ;

	cin >> t ;
	for( int i = 0 ; i < t ; i++ )
	{
		int p = 0 ,pp = s ;
		bool br = false ;
		cin >> n ;
		while( true )
		{
			int a = p + ( ( pp - p ) / 2 ) ;
			if( answer( n ,num ,a )
				break ;
			else if( n > num[ a ] )
			{
				if( answer( n ,num ,a + 1 ) )
					break ;
				p += 2 ;
				if( p >= s )
					break ;
			}
			else if( answer( n ,num ,a - 1 )
				break ;
			else
			{
				pp = a - 2 ;
				if( pp <= p )
					break ;
			}
		}
	}

	cout << ans << endl ;

	return 0 ;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:48: error: expected ';' before 'break'
   36 |                         if( answer( n ,num ,a )
      |                                                ^
      |                                                ;
   37 |                                 break ;
      |                                 ~~~~~           
a.cc:38:25: error: expected primary-expression before 'else'
   38 |                         else if( n > num[ a ] )
      |                         ^~~~
a.cc:37:40: error: expected ')' before 'else'
   37 |                                 break ;
      |                                        ^
      |                                        )
   38 |                         else if( n > num[ a ] )
      |                         ~~~~            
a.cc:36:27: note: to match this '('
   36 |                         if( answer( n ,num ,a )
      |                           ^
Language: C++

#include<iostream>
#define FORI(N) for(int i=0;i<N;i++)
#define FORL(N) for(int l=0;l<N;l++)
using namespace std;

int main()
{
	int n;
	int q;
	int ans=0;
	bool *b;
	b = new bool[1000000000];
	scanf_s("%d",&n);
	FORI(n)
	{
		int a;
		scanf_s("%d", &a);
		b[a] = true;
	}
	scanf_s("%d", &q);
	FORI(q)
	{
		int c;
		scanf_s("%d", &c);
		if (b[c] == true)
		{
			ans++;
		}

	}
	cout << ans << endl;
	delete[]b;
	return 0;
}

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

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

bool check(int n,int s[],int t){
  int left=0,right=n;
  while(right-left>=1){
    int mid=(left+right)/2;
    if(s[mid]==t)return true;
    if(s[mid]<t)left=mid+1;
    else right=mid;
  }
  return false;
}

int main(){
  int ans=0;
  int n,s[100005],q,t;
  
  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(check(n,s,t))ans++;
  }
  cout<<ans<<endl;
  
}

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


#include<stdio.h>

int binary(int [],int,int);

int main()
{
  int S[100000],key,n,q,i,count=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",&key);
      if(binarySearch(S,n,key)!=0)count++;
    }
  printf("%d\n",count);

  return 0;
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: 'binarySearch' was not declared in this scope
   16 |       if(binarySearch(S,n,key)!=0)count++;
      |          ^~~~~~~~~~~~
Language: C++


#include<stdio.h>

int binary(int [],int,int);

int main()
{
  int S[100000],key,n,q,i,count=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",&key);
      if(binarySearch(S,n,key)!=0)count++;
    }
  printf("%d\n",count);

  return 0;
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: 'binarySearch' was not declared in this scope
   16 |       if(binarySearch(S,n,key)!=0)count++;
      |          ^~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;

int binary(int key,int a[],int n){

	int left=0;
	int right=n;
	
	while(left<right){
		int mid=(left+right)/2;
		
		if(a[mid]==key){
			return mid;
		}
		else if(key<a[mid]){
			right=mid;
		}
		else{
			left=mid+1;
		}
	}
	
	return -1;
}

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

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

	int x;
	cin>>x;
	
	int t[500];
	for(int i=0;i<x;i++){
		cin>>t[i];
	}

	int count=0;
		
	for(int i=~;i<x;i++){
		if(binary(t[i],s,n)!=(-1)){
			count++;
		}
	}

	cout<<count<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:20: error: expected primary-expression before ';' token
   45 |         for(int i=~;i<x;i++){
      |                    ^
Language: C++

#include<iostream>
using namespace std;

int main(){
  int n;
  cin>>n;
  
  int S[100000];
  for(int i=0;i<n;i++){
    cin>>S[i];
  }
  
  int T[50000];
  for(int i=0;i<q;i++){
    cin>>T[i];
  }
  
  int C=0;
  
  for(int i=0;i<Q;i++){
    if(binarysearch(T[i],S,n)!=NOT_FOUND){
      C++;
    }
  }
  
  cout<<C<<endl;
  return 0;
}          

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'q' was not declared in this scope
   14 |   for(int i=0;i<q;i++){
      |                 ^
a.cc:20:17: error: 'Q' was not declared in this scope
   20 |   for(int i=0;i<Q;i++){
      |                 ^
a.cc:21:8: error: 'binarysearch' was not declared in this scope
   21 |     if(binarysearch(T[i],S,n)!=NOT_FOUND){
      |        ^~~~~~~~~~~~
a.cc:21:32: error: 'NOT_FOUND' was not declared in this scope
   21 |     if(binarysearch(T[i],S,n)!=NOT_FOUND){
      |                                ^~~~~~~~~
Language: C++

#include<iostream>
using namespace std;

const int NOT_FOUND=-1;

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

	return NOT_FOUND;

}

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

	int q;
	cin>>q;
	
	int T[50000;
	for(int i=0;i<q;i++){
		cin>>T[i];
	}
	
	int C=0;
	
	for(int i=0;i<q;i++){
		if(binarySearch(T[i],S,n)!=NOT_FOUND){
			C++;
		}
	}

	cout<<C<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int binarySearch(int, int*, int)':
a.cc:27:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   27 | int main(){
      |         ^~
a.cc:27:9: note: remove parentheses to default-initialize a variable
   27 | int main(){
      |         ^~
      |         --
a.cc:27:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:27:11: error: a function-definition is not allowed here before '{' token
   27 | int main(){
      |           ^
a.cc:55:2: error: expected '}' at end of input
   55 | }
      |  ^
a.cc:6:40: note: to match this '{'
    6 | int binarySearch(int key,int A[],int n){
      |                                        ^
a.cc:55:2: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      |  ^
Language: C++

#include<iostream>
using namespace std;

const int NOT_FOUND=-1;

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

	return NOT_FOUND;

}

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

	int q;
	cin>>q;
	
	int T[50000;
	for(int i=0;i<q;i++){
		cin>>T[i];
	}
	
	int C=0;
	
	for(int i=0;i<q;i++){
		if(binarySearch(T[i],S,n)!=NOT_FOUND){
			C++;
		}
	}

	cout<<C<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int binarySearch(int, int*, int)':
a.cc:27:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   27 | int main(){
      |         ^~
a.cc:27:9: note: remove parentheses to default-initialize a variable
   27 | int main(){
      |         ^~
      |         --
a.cc:27:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:27:11: error: a function-definition is not allowed here before '{' token
   27 | int main(){
      |           ^
a.cc:55:2: error: expected '}' at end of input
   55 | }
      |  ^
a.cc:6:40: note: to match this '{'
    6 | int binarySearch(int key,int A[],int n){
      |                                        ^
a.cc:55:2: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      |  ^
Language: C++

#include<iostream>
using namespace std;

const int NOT_FOUND=-1;

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

	return NOT_FOUND;

}

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

	int q;
	cin>>q;
	
	int T[50000];
	for(int i=0;i<q;i++){
		cin>>T[i];
	}
	
	int C=0;
	
	for(int i=0;i<q;i++){
		if(binarySearch(T[i],S,n)!=NOT_FOUND){
			C++;
		}
	}

	cout<<C<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int binarySearch(int, int*, int)':
a.cc:27:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   27 | int main(){
      |         ^~
a.cc:27:9: note: remove parentheses to default-initialize a variable
   27 | int main(){
      |         ^~
      |         --
a.cc:27:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:27:11: error: a function-definition is not allowed here before '{' token
   27 | int main(){
      |           ^
a.cc:55:2: error: expected '}' at end of input
   55 | }
      |  ^
a.cc:6:40: note: to match this '{'
    6 | int binarySearch(int key,int A[],int n){
      |                                        ^
a.cc:55:2: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      |  ^
Language: C++

#include<iostream>
using namespace std;

const int NOT_FOUND=-1;

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

}
         
int main(){
  int n;
  cin>>n;
  
  int S[100000];
  for(int i=0;i<n;i++){
    cin>>S[i];
  }
  
  int T[50000];
  for(int i=0;i<q;i++){
    cin>>T[i];
  }
  
  int C=0;
  
  for(int i=0;i<Q;i++){
    if(binarysearch(T[i],S,n)!=NOT_FOUND){
      C++;
    }
  }
  
  cout<<C<<endl;
  return 0;
}          

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

#include <iostream>
#define MAX 1000000

int binarySearch(int);
int A[MAX];
int n;

int main(){
  int i,q;
  int key,result = 0;
  //scanf("%d",&n);
  cin >> n;
  for(i = 0; i < n; i++){
    //scanf("%d",&A[i]);
    cin >> A[i];
  }
  //scanf("%d",&q);
  cin >> q;
  for( i = 0; i < q; i++){
    //scanf("%d",&key);
    cin >> key;
    if(binarySearch(key)){ /**/
      result++;
    }
  }
  //printf("%d\n",result);
  cout << result;
  return 0;
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   12 |   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:27:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |   cout << result;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include<stdio.h>

int A[1000000], n;

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

int main() {
	int i, q, k, sum = 0;
	
	scanf("%d", n);
    for(int i = 0; i < n; i++) { 
        scanf("%d", A[i]);
    }
    
    scanf("%d", q);
    for(int i = 0; i < q; i++) {
	    scanf("%d", key);
		if( binarySearch(key) = 1 ) sum++; 
	}
	printf("%d", sum);    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:25: error: 'key' was not declared in this scope
   28 |             scanf("%d", key);
      |                         ^~~
Language: C++

#include<stdio.h>

int A[1000000], n;

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

int main() {
	int i, q, key, sum = 0;
	
	scanf("%d", n);
    for(int i = 0; i < n; i++) { 
        scanf("%d", A[i]);
    }
    
    scanf("%d", q);
    for(int i = 0; i < q; i++) {
	    scanf("%d", key);
		if( binarySearch(key) = 1 ) sum++; 
	}
	printf("%d", sum);    
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:29:33: error: lvalue required as left operand of assignment
   29 |                 if( binarySearch(key) = 1 ) sum++;
      |                     ~~~~~~~~~~~~^~~~~
Language: C++

#include<stdio.h>


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

int main(){
	int S[100000],T[50000];
	int n,q;
	int count = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d ", &S[n]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		scanf("%d ", &T[n]);
	}
	for (int i = 0; i < q; i++){
		if (binarySearch(S, T[i], n))
			count++;
	}
	printf("%d\n", count);
	return 0;
}

Compiler output:
a.cc: In function 'int binarySearch(int*, int, int)':
a.cc:5:9: error: 'left' was not declared in this scope
    5 |         left = 0;
      |         ^~~~
a.cc:6:9: error: 'right' was not declared in this scope
    6 |         right = n;
      |         ^~~~~
a.cc:8:17: error: 'mid' was not declared in this scope
    8 |                 mid = (left + right) / 2;
      |                 ^~~
a.cc:12:26: error: 'key' was not declared in this scope
   12 |                 else if (key < R[mid]){
      |                          ^~~
a.cc:12:32: error: 'R' was not declared in this scope
   12 |                 else if (key < R[mid]){
      |                                ^
Language: C++

#include<stdio.h>


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

int main(){
	int S[100000],T[50000];
	int n,q;
	int count = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d ", &S[n]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		scanf("%d ", &T[n]);
	}
	for (int i = 0; i < q; i++){
		if (binarySearch(S, T[i], n))
			count++;
	}
	printf("%d\n", count);
	return 0;
}

Compiler output:
a.cc: In function 'int binarySearch(int*, int, int)':
a.cc:13:32: error: 'R' was not declared in this scope
   13 |                 else if (key < R[mid]){
      |                                ^
Language: C++

#include<stdio.h>
#include<iostream>
#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 < q; i++){
		scanf("%d", &k);
		if (*lower_bound(A, A + k) == k)sum++;
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:33: error: no matching function for call to 'lower_bound(int [1000000], int*)'
   17 |                 if (*lower_bound(A, A + k) == k)sum++;
      |                      ~~~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

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

int A[1000000+1], 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 < q; i++ ) {
        scanf( "%d", &k );
        if ( *lower_bound( A, A+n, k ) == k ) {
            sum++;
        }
    }
    
    cout << sum << endl;
    
    return 0;
}

Compiler output:
a.cc:8:1: error: expected initializer before 'int'
    8 | int main() {
      | ^~~
Language: C++

#include<cstdio>

int A[100000],n;

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

int main() {
  int n;
  scanf("%d",&n);
  
  
  for(int i=0;i<n;i++){
    scanf("%d",A+i);
  }
  
  int q;
  scanf("%d",&q);
  
  int key,sum=0;
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    if(binarysearch(A,n,key)){
      sum++;
    }
  }
  
  printf("%d\n",sum);
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:21: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   36 |     if(binarysearch(A,n,key)){
      |                     ^
      |                     |
      |                     int*
a.cc:36:20: error: too many arguments to function 'int binarysearch(int)'
   36 |     if(binarysearch(A,n,key)){
      |        ~~~~~~~~~~~~^~~~~~~~~
a.cc:5:5: note: declared here
    5 | int binarysearch(int key){
      |     ^~~~~~~~~~~~
Language: C++

#include<iostream>

using namespace std;
int A[1000000],n;

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


int main(){
    int i,q,k,sum = 0;
    cin>> n;
    for (i = 0;i<n;i++){
        cin>>A[i];
    }
    cin>>q;
    for(i=0;i<q;i++){
        cin>>key;
        if(binarysearch(key)) sum++;
    }
    cout<<sum<<endl;
    return 0;
}

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

#include<iostream>

using namespace std;
int A[1000000],n;

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


int main(){
    int i,q,k,sum = 0;
    cin>> n;
    for (i = 0;i<n;i++){
        cin>>A[i];
    }
    cin>>q;
    for(i=0;i<q;i++){
        cin>>k;
        if(binarysearch(key)) sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:25: error: 'key' was not declared in this scope
   35 |         if(binarysearch(key)) sum++;
      |                         ^~~
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

int main(void)
{
	int n;
	cin >> n;
	
	int *s = new int[n];
	for (int i = 0; i < n; i++) cin >> s[i];
	
	int q;
	cin >> q;
	
	int *t = new int[q];
	for (int i = 0; i < q; i++) cin >> t[i];
	
	int c = 0;
	for (int i = 0; i < q; i++) {
		int st = 0, ed = n;
		while (st <= ed) {
			m = (ed - st) / 2;
			if (t[i] == s[m]) {
				c++;
				break;
			} else if (t[i] > s[m]) {
				st = m + 1;
				break;
			} else if (t[i] < s[m]) {
				ed = m - 1;
			}			
		}
	}
	
	cout << c << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: 'm' was not declared in this scope
   26 |                         m = (ed - st) / 2;
      |                         ^
Language: C++

#include<iostream>
using namespace std;

int main(){
  int n, q, count = 0, max, min;
  int S[100000], T[50000];

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

  //T?????????????????????
  for(int i = 0; i < q; i++){
    //S????????????n/2??????????????§??????????°??????????
    max = n;
    min = 0;
    for(;max > min;){
      if(T[i] == S[(max+min)/2]){
        count++;
        break;
      }
      else if(T[i] > S[(max+min)/2]){
        max = max;
        min = (max+min)/2 + 1N;
      }
      else if(T[i] < S[(max+min)/2]){
        max = (max+min)/2;
        min = min;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:29: error: unable to find numeric literal operator 'operator""N'
   29 |         min = (max+min)/2 + 1N;
      |                             ^~
Language: C++

/*
 * Problem Description: Linear Search
 * Category:
 * Author: Khan
 * Date: 13th October, 2017
 */

#include <cstdio>
#include <algorithm>

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int i, n, A[1000000], q, key, sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; ++i)
    {
        scanf("%d", &key);
        if(binary_search(A, A + n, key))
            sum++;
    }
    printf("%d\n", sum);
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:24:12: error: 'binary_search' was not declared in this scope; did you mean 'std::binary_search'?
   24 |         if(binary_search(A, A + n, key))
      |            ^~~~~~~~~~~~~
      |            std::binary_search
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_algo.h:2228:5: note: 'std::binary_search' declared here
 2228 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
Language: C++

#include <cstdio.h>
using namespace std;
int S[1000000],n;
int serch(int key){
  int left=0,right,mid;
  right=n;
  while(left<right){
    mid=(left+right)/2;
    if(key==S[mid])return 1;
    if(key>S[mid])left=mid;
    else if(key<S[mid])right=mid;
  }
  return 0;
}
int main(){
  int q,key;
  int i,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",&key);
    if(serch(key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

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

#include <cstdio>
#include <iostrame>
#include <algorithm>
using namespace std;
int main(){
  int n,S[100000],q,key,sum;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    if(*lower_bound(S,S+n,key)==key)sum++;
  }
  printf("%d",sum);
  return 0;
}

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

#include<iostream>
using namespace std;

int binarySearch(int n,int q,int S[],int flag) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (S[mid] == flag) return 1;
		else if (S[mid] > flag) right = mid;
		else if (S[mid] < flag) left = mid + 1;

	}
	return 0;

}
int main() {

	int S[100000],T,n,q,i,c=0;

	cin >> n;
	for (i = 0; i < n; i++) cin >> S[i];
	cin >> q;

	for (i = 0; i < q; i++) {
		cin >> T;

		if (binarySearch(n, q, S, T)) c++;
	}

	cout << c<<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:32:25: error: expected '}' at end of input
   32 |         cout << c<<endl;
      |                         ^
a.cc:18:12: note: to match this '{'
   18 | int main() {
      |            ^
Language: C++

#include <stdlib.h>
#include <stdio.h>
 
int main(){
int a,m,n,q,i,j,S[10000],T[500];
m=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]);
    }
a=n/2;
for(i=0;i<q;i++){
   if(S[a]==T[i]){
      m++;
      break;
  }else if(S[a]<T[i]){
    for(j=a;j<n;j++){
        if(T[i]==S[j]){
          m++;
          break;
        }
      }
    }
  }else if(S[a]>T[i]){
    for(j=0;j<a;j++){
        if(T[i]==S[j]){
          m++;
          break;
    }
   }
  }
printf("%d\n",m);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:4: error: 'else' without a previous 'if'
   29 |   }else if(S[a]>T[i]){
      |    ^~~~
Language: C++

#include <stdlib.h>
#include <stdio.h>
 
int main(){
int a,m,n,q,i,j,S[10000],T[500];
m=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]);
    }
a=n/2;
for(i=0;i<q;i++){
   if(S[a]==T[i]){
      m++;
      break;
  }else if(S[a]<T[i]){
    for(j=a;j<n;j++){
        if(T[i]==S[j]){
          m++;
          break;
        }
      }
    }
  }else{
    for(j=0;j<a;j++){
        if(T[i]==S[j]){
          m++;
          break;
    }
   }
  }
printf("%d\n",m);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:4: error: 'else' without a previous 'if'
   29 |   }else{
      |    ^~~~
Language: C++

#include <stdlib.h>
#include <stdio.h>
 
int main(){
int a,m,n,q,i,j,S[10000],T[500];
m=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]);
    }
a=n/2;
for(i=0;i<q;i++){
   if(S[a]==T[i]){
      m++;
      break;
  }else if(S[a]<T[i]){
    for(j=a;j<n;j++){
        if(T[i]==S[j]){
          m++;
          break;
      }
    }
  }else if(S[a]>T[i]){
    for(j=0;j<a;j++){
        if(T[i]==S[j]){
          m++;
          break;
    }
   }
  }
printf("%d\n",m);
return 0;
}

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

#include <stdlib.h>
#include <stdio.h>
 
int main(){
int a,m,n,q,i,j,S[10000],T[500],r,l;
m=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]);
    }

l=0;
r=n;
a=(r+l)/2

for(i=0;i<q;i++){
  while(l<r){
   if(S[a]==T[i]){
      m++;
      break;
  }else if(S[a]<T[i]){
      l=a+1;
  }else if(S[a]>T[i]){
      r=a;
   }
  }
 }
printf("%d\n",m);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: expected ';' before 'for'
   19 | a=(r+l)/2
      |          ^
      |          ;
   20 | 
   21 | for(i=0;i<q;i++){
      | ~~~       
a.cc:21:16: error: expected ';' before ')' token
   21 | for(i=0;i<q;i++){
      |                ^
      |                ;
Language: C++

#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
    int n,q;
    int s[100010];
    int t[50010];
    P u[100010];
    int ans=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 ti=0;ti<q;ti++){
        int left=0;int right=n-1;
        while(1)
        {
            int mid=(left+right)/2;
            if(t[ti]<s[mid]) right=mid;
            if(t[ti]>s[mid]) left=mid+1;
            if(t[ti]==s[mid]){ans++;break;}
            if(left==right){if(s[left]==t[ti]){ans++;}break;}
        }
        
    }
    
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'P' was not declared in this scope
   10 |     P u[100010];
      |     ^