criyle/codenet-compile-errors huggingface dataset:
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(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<n;i++{)
    if(binarySearch(k))sum++;
  }
  print("%d\n",sum);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:18: error: expected ')' before '{' token
   22 |   for(i=0;i<n;i++{)
      |      ~           ^
      |                  )
a.cc:22:19: error: expected primary-expression before ')' token
   22 |   for(i=0;i<n;i++{)
      |                   ^
a.cc:27:18: error: expected ')' before '{' token
   27 |   for(i=0;i<n;i++{)
      |      ~           ^
      |                  )
a.cc:27:19: error: expected primary-expression before ')' token
   27 |   for(i=0;i<n;i++{)
      |                   ^
a.cc:30:3: error: 'print' was not declared in this scope; did you mean 'printf'?
   30 |   print("%d\n",sum);
      |   ^~~~~
      |   printf
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(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<n;i++){
    if(binarySearch(k))sum++;
  }
  print("%d\n",sum);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:3: error: 'print' was not declared in this scope; did you mean 'printf'?
   30 |   print("%d\n",sum);
      |   ^~~~~
      |   printf
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(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    if(binarySearch(k))sum++;
  }
  print("%d\n",sum);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:3: error: 'print' was not declared in this scope; did you mean 'printf'?
   31 |   print("%d\n",sum);
      |   ^~~~~
      |   printf
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(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,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",&k);
    if(binarySearch(k))sum++;
  }
  print("%d\n",sum);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:3: error: 'print' was not declared in this scope; did you mean 'printf'?
   31 |   print("%d\n",sum);
      |   ^~~~~
      |   printf
Language: C++

import Control.Applicative
import Control.Monad
import Data.List
strToInt s = (read :: String -> Int) s
main = do
    n <- getLine
    s <- map read . words <$> getLine
    q <- getLine
    t <- map read . words <$> getLine
    let s' = nub s
    let a = sum [1 | x <- t, binarysearch s' x]
    print a

binarysearch :: [Int] -> Int -> Bool
binarysearch [] _ = False
binarysearch [x] n = x == n
binarysearch xs n
        | n == p = True
        | n <  p = binarysearch (take (m-1) xs) n
        | otherwise = binarysearch (drop m xs) n
        where   m = length xs `div` 2
                p = xs !! (m-1)

Compiler output:
a.cc:10:10: warning: missing terminating ' character
   10 |     let s' = nub s
      |          ^
a.cc:10:10: error: missing terminating ' character
   10 |     let s' = nub s
      |          ^~~~~~~~~
a.cc:11:44: warning: missing terminating ' character
   11 |     let a = sum [1 | x <- t, binarysearch s' x]
      |                                            ^
a.cc:11:44: error: missing terminating ' character
   11 |     let a = sum [1 | x <- t, binarysearch s' x]
      |                                            ^~~~
a.cc:21:31: error: stray '`' in program
   21 |         where   m = length xs `div` 2
      |                               ^
a.cc:21:35: error: stray '`' in program
   21 |         where   m = length xs `div` 2
      |                                   ^
a.cc:1:1: error: 'import' does not name a type
    1 | import Control.Applicative
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int m;
    cin>>m;
    int ans=0;
    rep(i,m){
        int t;
        cin>>t;
        int imax=n-1;
        int imin=0;
        int mid;
        while(imax=>imin){
            mid=(imax+imin)/2;
            if(v[mid]>t)imax=mid+1;
            else if(v[mid]<t)imin=mid-1;
            else {
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:20: error: expected primary-expression before '>' token
   37 |         while(imax=>imin){
      |                    ^
Language: C++

#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int m;
    cin>>m;
    int ans=0;
    rep(i,m){
        int t;
        cin>>t;
        int imax=n-1;
        int imin=0;
        int mid;
        while(imax>imin){
        mid=(imax+imin)/2;
        if(v[mid]>t)imax=mid-1;
        else if(v[mid]<t)imin=mid+1;
        else {
            ans++;
            break;
        }
    }
    cout<<ans<<endl;
}

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

#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int m;
    cin>>m;
    int ans=0;
    rep(i,m){
        int t;
        cin>>t;
        int imax=n-1;
        int imin=0;
        int mid;
        while(imax-imin>1){
            mid=(imax+imin)/2;
            if(v[mid]>t)imax=mid;
            else if(v[mid]<t)imin=mid;
        }
        if(v[imin]==t)amns++;
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:23: error: 'amns' was not declared in this scope; did you mean 'ans'?
   42 |         if(v[imin]==t)amns++;
      |                       ^~~~
      |                       ans
Language: C++

#include <iostream>
#include <vector>

#define ll long long

using namespace std;

bool search(vector<ll> v, ll n) {
	ll top = 0, btm = v.size() - 1, mid;

	while(top < btm) {
		mid = (top + btm) / 2;

		if(v[mid] == n) {
			return true;
		} else if(v[mid] < n) {
			top = mid + 1;
		} else {
			btm = mid;
		}
	}

	return false;
}

ll count(vector<ll> s, vector<ll> t) {
	ll cnt = 0;

	for(ll i = 0;i < t.size();i++) {
		if(search(s, t.at(i)))
			cnt++;
	}

	return cnt;
}

int main() {
	ll n;
	vector<ll> vs, vt;

	cin >> n;h

	vs.resize(n);

	for(ll i = 0;i < vs.size();i++) {
		cin >> vs[i];
	}

	cin >> n;

	vt.resize(n);

	for(ll i = 0;i < vt.size();i++) {
		cin >> vt[i];
	}

	cout << count(vs, vt) << endl;

	return 0;
}

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

#include<iostream>
using namespace std;

// 二分探索
int binary_search(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]) left = mid + 1;
    else if (A[mid] < key) right = mid;
  }
  return 0;
}

int main() {
  int N, Q, sum = 0;
  int S[100000], Q[50000];
  
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) Q[i];
  
  for ( int i = 0; i < Q; i++) {
    key = Q[i];
    if ( binary_search(S, N, key) ) {
      sum++
    } 
  }

  return 0;
}


Compiler output:
a.cc:5:33: error: 'N' has not been declared
    5 | int binary_search(int A[], int, N, int key) {
      |                                 ^
a.cc: In function 'int binary_search(int*, int, int, int)':
a.cc:7:15: error: 'N' was not declared in this scope
    7 |   int right = N;
      |               ^
a.cc:9:5: error: 'mid' was not declared in this scope
    9 |     mid = (left + right) / 2;
      |     ^~~
a.cc: In function 'int main()':
a.cc:19:18: error: conflicting declaration 'int Q [50000]'
   19 |   int S[100000], Q[50000];
      |                  ^
a.cc:18:10: note: previous declaration as 'int Q'
   18 |   int N, Q, sum = 0;
      |          ^
a.cc:24:33: error: invalid types 'int[int]' for array subscript
   24 |   for ( int i = 0; i < Q; i++) Q[i];
      |                                 ^
a.cc:27:5: error: 'key' was not declared in this scope; did you mean 'key_t'?
   27 |     key = Q[i];
      |     ^~~
      |     key_t
a.cc:27:12: error: invalid types 'int[int]' for array subscript
   27 |     key = Q[i];
      |            ^
a.cc:29:12: error: expected ';' before '}' token
   29 |       sum++
      |            ^
      |            ;
   30 |     }
      |     ~
Language: C++

#include<iostream>
using namespace std;
 
// 二分探索
int binary_search(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]) left = mid + 1;
    else if (A[mid] < key) right = mid;
  }
  return 0;
}
 
int main() {
  int N, Q, sum = 0;
  int S[100000], T[50000];
   
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) T[i];
   
  for ( int i = 0; i < Q; i++) {
    key = T[i];
    if ( binary_search(S, N, key) ) {
      sum++
    } 
  }
 
  return 0;


Compiler output:
a.cc:5:33: error: 'N' has not been declared
    5 | int binary_search(int A[], int, N, int key) {
      |                                 ^
a.cc: In function 'int binary_search(int*, int, int, int)':
a.cc:7:15: error: 'N' was not declared in this scope
    7 |   int right = N;
      |               ^
a.cc:9:5: error: 'mid' was not declared in this scope
    9 |     mid = (left + right) / 2;
      |     ^~~
a.cc: In function 'int main()':
a.cc:27:5: error: 'key' was not declared in this scope; did you mean 'key_t'?
   27 |     key = T[i];
      |     ^~~
      |     key_t
a.cc:29:12: error: expected ';' before '}' token
   29 |       sum++
      |            ^
      |            ;
   30 |     }
      |     ~       
a.cc:33:12: error: expected '}' at end of input
   33 |   return 0;
      |            ^
a.cc:17:12: note: to match this '{'
   17 | int main() {
      |            ^
Language: C++

#include<iostream>
using namespace std;
  
// 二分探索
int binary_search(int A[], int M, int key) {
  int left = 0;
  int right = M;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) return mid;
    else if (key < A[mid]) left = mid + 1;
    else if (A[mid] < key) right = mid;
  }
  return 0;
}
  
int main() {
  int N, Q, sum = 0;
  int S[100000], T[50000];
    
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) T[i];
    
  for ( int i = 0; i < Q; i++) {
    key = T[i];
    if ( binary_search(S, N, key) ) {
      sum++
    } 
  }
  
  return 0;


Compiler output:
a.cc: In function 'int binary_search(int*, int, int)':
a.cc:9:5: error: 'mid' was not declared in this scope
    9 |     mid = (left + right) / 2;
      |     ^~~
a.cc: In function 'int main()':
a.cc:27:5: error: 'key' was not declared in this scope; did you mean 'key_t'?
   27 |     key = T[i];
      |     ^~~
      |     key_t
a.cc:29:12: error: expected ';' before '}' token
   29 |       sum++
      |            ^
      |            ;
   30 |     }
      |     ~       
a.cc:33:12: error: expected '}' at end of input
   33 |   return 0;
      |            ^
a.cc:17:12: note: to match this '{'
   17 | int main() {
      |            ^
Language: C++

#include<iostream>
using namespace std;
   
// 二分探索
int binary_search(int A[], int M, int key) {
  int left = 0;
  int right = M;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) return mid;
    else if (key < A[mid]) left = mid + 1;
    else if (A[mid] < key) right = mid;
  }
  return 0;
}
   
int main() {
  int N, Q, key, sum = 0;
  int S[100000], T[50000];
     
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) T[i];
     
  for ( int i = 0; i < Q; i++) {
    key = T[i];
    if ( binary_search(S, N, key) ) {
      sum++;
    } 
  }
   
  return 0;


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

#include<iostream>
using namespace std;

int S[100000], N
     
// 二分探索
int binary_search(int key) {
  int left = 0;
  int right = M;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key) return 1;
    else if (key < A[mid]) left = mid + 1;
    else if (A[mid] < key) right = mid;
  }
  return 0;
}
     
int main() {
  int Q, key, sum = 0;
       
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) {
    key;
    if ( binary_search(key) ) {
      sum++;
    } 
  }
     
  return 0;
}


Compiler output:
a.cc:7:1: error: expected initializer before 'int'
    7 | int binary_search(int key) {
      | ^~~
a.cc: In function 'int main()':
a.cc:23:10: error: 'N' was not declared in this scope
   23 |   cin >> N;
      |          ^
a.cc:28:10: error: 'binary_search' was not declared in this scope
   28 |     if ( binary_search(key) ) {
      |          ^~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
 
int S[100000], N
      
// 二分探索
int binary_search(int key) {
  int left = 0;
  int right = M;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key) return 1;
    else if (key < S[mid]) left = mid + 1;
    else if (S[mid] < key) right = mid;
  }
  return 0;
}
      
int main() {
  int Q, key, sum = 0;
        
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) {
    key;
    if ( binary_search(key) ) {
      sum++;
    } 
  }
      
  return 0;
}


Compiler output:
a.cc:7:1: error: expected initializer before 'int'
    7 | int binary_search(int key) {
      | ^~~
a.cc: In function 'int main()':
a.cc:23:10: error: 'N' was not declared in this scope
   23 |   cin >> N;
      |          ^
a.cc:28:10: error: 'binary_search' was not declared in this scope
   28 |     if ( binary_search(key) ) {
      |          ^~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
  
int S[100000], N
       
// 二分探索
int binary_search(int key) {
  int left = 0;
  int right = M;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key) return 1;
    else if (key < S[mid]) left = mid + 1;
    else if (S[mid] < key) right = mid;
  }
  return 0;
}
       
int main() {
  int Q, k, sum = 0;
         
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) {
    k;
    if ( binary_search(k) ) {
      sum++;
    } 
  }
       
  return 0;
}


Compiler output:
a.cc:7:1: error: expected initializer before 'int'
    7 | int binary_search(int key) {
      | ^~~
a.cc: In function 'int main()':
a.cc:23:10: error: 'N' was not declared in this scope
   23 |   cin >> N;
      |          ^
a.cc:28:10: error: 'binary_search' was not declared in this scope
   28 |     if ( binary_search(k) ) {
      |          ^~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
  
int S[100000], N
       
// 二分探索
int binary_search( int key ) {
  int left = 0;
  int right = M;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key) return 1;
    else if (key < S[mid]) left = mid + 1;
    else if (S[mid] < key) right = mid;
  }
  return 0;
}
       
int main() {
  int Q, k, sum = 0;
         
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) {
    cin >> k;
    if ( binary_search(key) ) {
      sum++;
    } 
  }
       
  return 0;
}


Compiler output:
a.cc:7:1: error: expected initializer before 'int'
    7 | int binary_search( int key ) {
      | ^~~
a.cc: In function 'int main()':
a.cc:23:10: error: 'N' was not declared in this scope
   23 |   cin >> N;
      |          ^
a.cc:28:24: error: 'key' was not declared in this scope
   28 |     if ( binary_search(key) ) {
      |                        ^~~
a.cc:28:10: error: 'binary_search' was not declared in this scope
   28 |     if ( binary_search(key) ) {
      |          ^~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
   
int S[100000], N;
        
// 二分探索
int binarysearch( int key ) {
  int left = 0;
  int right = M;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key) return 1;
    else if (key < S[mid]) left = mid + 1;
    else if (S[mid] < key) right = mid;
  }
  return 0;
}
        
int main() {
  int Q, k, sum = 0;
          
  cin >> N;
  for ( int i = 0; i < N; i++) S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++) {
    cin >> k;
    if ( binarysearch(k) ) {
      sum++;
    } 
  }
        
  return 0;
}


Compiler output:
a.cc: In function 'int binarysearch(int)':
a.cc:9:15: error: 'M' was not declared in this scope
    9 |   int right = M;
      |               ^
Language: C++

#include<iostream>
#include<stdio.h>
#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 + n, k) == k ) sum++;
  }

  cout << sum << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: expected primary-expression before '%' token
   11 |     scanf("%d", %A[i]);
      |                 ^
Language: C++

#include <stdio.h>
//question: how to deal with the duplicate elemets
int binary_search(int target, int b[], int left, int right){
    // nofinding
    if(left>=right) return ((target==b[left])?left:-1);
    int middle = (left+right)/2;    
    if(target == b[middle]) return middle;
    else if(target < b[middle]) return binary_search(target, b, left, middle);
    else return binary_search(target, b, middle+1, right);
}

//binary search
int main()
{
    int n, q;
    scanf("%d", &n);
    int a[n+1];
    for(int i = 0; i<n; i++){
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    int b[q+1];
    for(int i = 0; i<q; i++){
        scanf("%d", &b[i]);
    }

    int count = 0;
    for(int i = 0; i<q; i++){
        //printf("%d\n",binary_search(b[i], a, 0, q-1));
        if(binary_search(b[i], a, 0, n-1)>=0){
            count++;
        }
        
    }
    printf("%d\n", count);
    retur


Compiler output:
a.cc: In function 'int main()':
a.cc:36:5: error: 'retur' was not declared in this scope
   36 |     retur
      |     ^~~~~
a.cc:36:10: error: expected '}' at end of input
   36 |     retur
      |          ^
a.cc:14:1: note: to match this '{'
   14 | {
      | ^
Language: C++

#include <iostream>

using namespace std;

int main() {

    int n, q, 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];

    int ans = 0;

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

    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(S, S + n);
      |     ^~~~
      |     short
Language: C++

#include <iostream>

using namespace std;
int A[1000000];

int bianry_searcher(int A[],int key)
{
    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,q,k,sum=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>key;
        if(binary_searcher(A,n,key)) sum++;
    }
    cout<<sum;
    return sum;

}



Compiler output:
a.cc: In function 'int bianry_searcher(int*, int)':
a.cc:10:9: error: 'mid' was not declared in this scope
   10 |         mid=(left+right)/2;
      |         ^~~
a.cc:10:18: error: invalid operands of types 'std::ios_base&(std::ios_base&)' and 'std::ios_base&(std::ios_base&)' to binary 'operator+'
   10 |         mid=(left+right)/2;
      |              ~~~~^~~~~~
      |              |    |
      |              |    std::ios_base&(std::ios_base&)
      |              std::ios_base&(std::ios_base&)
a.cc:12:17: error: expected '(' before 'key'
   12 |         else if key<A[mid] right=mid;
      |                 ^~~
      |                 (
a.cc:13:9: error: 'else' without a previous 'if'
   13 |         else left=mid+1;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:21:10: error: 'n' was not declared in this scope
   21 |     cin>>n;
      |          ^
a.cc:26:14: error: 'key' was not declared in this scope
   26 |         cin>>key;
      |              ^~~
a.cc:27:12: error: 'binary_searcher' was not declared in this scope; did you mean 'bianry_searcher'?
   27 |         if(binary_searcher(A,n,key)) sum++;
      |            ^~~~~~~~~~~~~~~
      |            bianry_searcher
Language: C++

#include <iostream>

using namespace std;
int A[1000000];

int bianry_searcher(int A[],int key)
{
    int mid;
    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,q,k,sum=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>key;
        if(binary_searcher(A,n,key)) sum++;
    }
    cout<<sum;
    return sum;

}



Compiler output:
a.cc: In function 'int bianry_searcher(int*, int)':
a.cc:10:15: error: 'n' was not declared in this scope
   10 |     int right=n;
      |               ^
a.cc:15:17: error: expected '(' before 'key'
   15 |         else if key<A[mid] right=mid;
      |                 ^~~
      |                 (
a.cc:16:9: error: 'else' without a previous 'if'
   16 |         else left=mid+1;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:24:10: error: 'n' was not declared in this scope
   24 |     cin>>n;
      |          ^
a.cc:29:14: error: 'key' was not declared in this scope
   29 |         cin>>key;
      |              ^~~
a.cc:30:12: error: 'binary_searcher' was not declared in this scope; did you mean 'bianry_searcher'?
   30 |         if(binary_searcher(A,n,key)) sum++;
      |            ^~~~~~~~~~~~~~~
      |            bianry_searcher
Language: C++

#include <iostream>

using namespace std;
int A[100000 + 10];,n;

int binary_searcher(int key)
{
    int mid=0;
    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=0;
    int q=0;
    int sum=0;
    int key=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>key;
        if(binary_searcher(key)) sum++;
    }
    cout<<sum;
    return sum;

}



Compiler output:
a.cc:4:20: error: expected unqualified-id before ',' token
    4 | int A[100000 + 10];,n;
      |                    ^
a.cc:4:22: error: expected constructor, destructor, or type conversion before ';' token
    4 | int A[100000 + 10];,n;
      |                      ^
a.cc: In function 'int binary_searcher(int)':
a.cc:10:15: error: 'n' was not declared in this scope
   10 |     int right=n;
      |               ^
a.cc: In function 'int main()':
a.cc:27:10: error: 'n' was not declared in this scope
   27 |     cin>>n;
      |          ^
Language: C++

#include <iostream>

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

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

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

}



Compiler output:
a.cc: In function 'int main()':
a.cc:31:28: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   31 |         if(binary_searcher(A,n,key))
      |                            ^
      |                            |
      |                            int*
a.cc:31:27: error: too many arguments to function 'int binary_searcher(int, int)'
   31 |         if(binary_searcher(A,n,key))
      |            ~~~~~~~~~~~~~~~^~~~~~~~~
a.cc:6:5: note: declared here
    6 | int binary_searcher(int n,int 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 ( key == A[mid] ) return 1;  /* key を発見 */
    if ( key > A[mid] ) left = mid + 1;  /* 後半を探索 */
    else if ( key < A[mid] ) right = mid;  /* 前半を探索 */
  }
  return 0;
}

int main() {
  int i, q, k. sum = 0;

  scanf("%d", &n);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:14: error: expected initializer before '.' token
   20 |   int i, q, k. sum = 0;
      |              ^
a.cc:24:18: error: 'k' was not declared in this scope
   24 |     scanf("%d", &k);
      |                  ^
a.cc:25:30: error: 'sum' was not declared in this scope
   25 |     if ( binarySearch( k ) ) sum++;
      |                              ^~~
a.cc:27:18: error: 'sum' was not declared in this scope
   27 |   printf("%d\n", sum);
      |                  ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>


using namespace std;


int main()
{
	int n,q;
	int S[100000],T[100000];
	int c=0;//count
	
	cin>>n>>q;
	
	for(int i=0;i<n;i++) cin>>S[i];
	
	for(int i=0;i<q;i++){
		cin>>T[i];
		for(int j=0;j<n;ij++){
			if(S[j]==T[i]) c++;
		}
	}
	cout<<c<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:33: error: 'ij' was not declared in this scope; did you mean 'j'?
   23 |                 for(int j=0;j<n;ij++){
      |                                 ^~
      |                                 j
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1000000],n;
int main ()
{
  cin>>n;
  for(int i = 0 ;i<n;i++)
     cin>>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: In function 'int main()':
a.cc:19:13: error: expected '}' at end of input
   19 |    return 0;
      |             ^
a.cc:7:1: note: to match this '{'
    7 | {
      | ^
Language: C++

#include<iostream>
#include<cstdio>

using namespace std;
int A[10001],m;
int search(int key)
{
	int left=0;
	int right=n;
	int mid;

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

int main(int argc, char const *argv[])
{
	int n,i,sum=0,key;
	scanf("%d",&m);
	for (i = 0; i < m; ++i)
	{
		scanf("%d",&A[i]);
	}

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


Compiler output:
a.cc: In function 'int search(int)':
a.cc:9:19: error: 'n' was not declared in this scope
    9 |         int right=n;
      |                   ^
Language: C++

/Users/muskie0802/CLionProjects/procon/cmake-build-debug/procon
15
0 0 1 1 2 2 3 3 3 5 6 6 8 9 9
10
8 4 6 5 0 2 1 7 9 3
8

Process finished with exit code 0



Compiler output:
a.cc:1:1: error: expected unqualified-id before '/' token
    1 | /Users/muskie0802/CLionProjects/procon/cmake-build-debug/procon
      | ^
Language: C++

#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  int vc[n];
  for(int i = 0 ; i < n ; i++ ) scanf("%d",&vc[i]);
  int ans = 0,q,a;
  scanf("%d",&q);
  sort(vc.begin(),vc.end());
  while(q--){
    cin >> a;
    if(binary_search(vc.begin(),vc.end(),a)) ans++;
  }
  printf("%d\n",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: request for member 'begin' in 'vc', which is of non-class type 'int [n]'
   14 |   sort(vc.begin(),vc.end());
      |           ^~~~~
a.cc:14:22: error: request for member 'end' in 'vc', which is of non-class type 'int [n]'
   14 |   sort(vc.begin(),vc.end());
      |                      ^~~
a.cc:17:25: error: request for member 'begin' in 'vc', which is of non-class type 'int [n]'
   17 |     if(binary_search(vc.begin(),vc.end(),a)) ans++;
      |                         ^~~~~
a.cc:17:36: error: request for member 'end' in 'vc', which is of non-class type 'int [n]'
   17 |     if(binary_search(vc.begin(),vc.end(),a)) ans++;
      |                                    ^~~
Language: C++

// 2分探索
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>

using namespace std;

const int MAX_N = 1000000;
//const int MAX_Q = 500;

bool Binary_Search(int A[], int n, int key);

int main(void)
{

    int n, q, key, count = 0;
    int ary_N[MAX_N + 1];

    scanf("%d", &n);

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

    scanf("%d", &q);

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

        if( Binary_Search(&ary_N[0], n, key) == true )
        {
            count++;
        }
    }

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

    return 0;
}

// 2分探索
bool Binary_Search(int A[], int n, int key)
{
    bool ret = false;

    int left, right, mid;

    left = 0;
    right = n;
    mid = ( left + right ) / 2;

    while( left < right )
    {
        if( A[pos] < key )
        {
        	// 後半を探索
            left = mid + 1;
        }
        else if( A[pos] > key )
        {
            // 前半を探索
            right = mid;
        }
        else
        {
            ret = true;
            // 値が見つかったので処理終了
            break;
        }

        pos = ( top + last ) / 2;
    }

    return ret;
}



Compiler output:
a.cc: In function 'bool Binary_Search(int*, int, int)':
a.cc:59:15: error: 'pos' was not declared in this scope
   59 |         if( A[pos] < key )
      |               ^~~
a.cc:76:9: error: 'pos' was not declared in this scope
   76 |         pos = ( top + last ) / 2;
      |         ^~~
a.cc:76:17: error: 'top' was not declared in this scope
   76 |         pos = ( top + last ) / 2;
      |                 ^~~
a.cc:76:23: error: 'last' was not declared in this scope
   76 |         pos = ( top + last ) / 2;
      |                       ^~~~
Language: C++

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

int BinSearch(int nA[], int nKey, int n)
{
	int nLeft = 0, nRight = n;
	int nMid = (nLeft + nRight) / 2;
	while (nLeft < nRight)
	{

		if (nA[nMid]<nKey)
		{
			nLeft = nMid;
		}
		else if (nA[nMid]>nKey)
		{
			nRight = nMid;
		}
		else
		{
			return nMid != n;
		}
		nMid = (nLeft + nRight) / 2;
	}
}


int main()
{
	int nA[100000] = { 0 };
	int n = 0, q = 0, nKey = 0, nSum = 0;
	int ni = 0;
	cin >> n;
	while (cin >> nA[ni], ni < (n - 1))
	{
		ni++;
	}
	cin >> q;
	for (ni = 0; ni < q; ni++)
	{
		cin >> nKey;
		if (BinSearch(nA, nKey, n))
		{
			nSum++;
		}
	}
	cout << nSum << endl;
	return 0;
}


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

#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int binarySearch(int key, std::vector<int> S;){
  int L = 0;
  int R = S.size();
  int mid;
  while (L < R) {
    mid = (L+R)/2;
    if (A[mid]==key) {
      return 1;
    }
    if (key > A[mid]) {
      L = mid + 1;
    }else if (key < A[mid]) {
      R = mid;
    }
  }
  return 0;
}


int main(int argc, char const *argv[]) {
  int n, val, tmp;
  int len=0;
  std::cin >> n;
  std::vector<int> S; S.reserve(100000);


  for (size_t i = 0; i < n; i++) {
    std::cin >> val;
    if (i==0 || val != tmp) {
      len++;
      S[len]=val;
      tmp=val;
    }
  }

  int num=0;

  int q; std::cin >> q;
  int key;
  for (size_t i = 0; i < q; i++) {
    std::cin >> key;
    if (binarySearch(key, S)) num++;
  }

  }
  std::cout << num << '\n';

  return 0;
}



Compiler output:
a.cc:12:45: error: expected ')' before ';' token
   12 | int binarySearch(int key, std::vector<int> S;){
      |                 ~                           ^
      |                                             )
a.cc:12:46: error: expected unqualified-id before ')' token
   12 | int binarySearch(int key, std::vector<int> S;){
      |                                              ^
a.cc:57:8: error: 'cout' in namespace 'std' does not name a type
   57 |   std::cout << num << '\n';
      |        ^~~~
In file included from a.cc:2:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:59:3: error: expected unqualified-id before 'return'
   59 |   return 0;
      |   ^~~~~~
a.cc:60:1: error: expected declaration before '}' token
   60 | }
      | ^
Language: C++

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

bool BinarySearch(int x, int S[], int N){
  int B = 0;
  int T = N-1;

  while(B<=T){
    int mid = (B+T)/2;

    if(S[mid]==x){
      return mid;
    }
    else if(S[mid]<x){
      B = mid+1;
    }
    else{
      T = mid-1;
    }
  }

  return false;
}

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

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

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

  sort(S, S+n);
  for(int i=0;i<n;i++){
/*  // :cout << S[i] << ' ';
}
cout << endl;*/
  int cnt;
  for(int i=0; i<n; i++){
   if(S[i]!=S[i+1]){
    if(BinarySearch(S[i], T, q)==true)
      cnt++;
   }
  }
      cout << cnt << endl;
  return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;

bool BinarySearch(int x, int S[], int N){
  int B = 0;
  int T = N-1;

  while(B<=T){
    int mid = (B+T)/2;

    if(S[mid]==x){
      return mid;
    }
    else if(S[mid]<x){
      B = mid+1;
    }
    else{
      T = mid-1;
    }
  }

  return false;
}

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

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

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

  sort(S, S+n);
  for(int i=0;i<n;i++){
/*  // :cout << S[i] << ' ';
}
cout << endl;*/
  int cnt;
  for(int i=0; i<n; i++){
   if(S[i]!=S[i+1]){
    if(BinarySearch(S[i], T, q)==true)
      cnt++;
   }
  }
      cout << cnt << endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:61:41: error: a function-definition is not allowed here before '{' token
   61 | bool BinarySearch(int x, int S[], int N){
      |                                         ^
a.cc:82:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   82 | int main(){
      |         ^~
a.cc:82:9: note: remove parentheses to default-initialize a variable
   82 | int main(){
      |         ^~
      |         --
a.cc:82:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:82:11: error: a function-definition is not allowed here before '{' token
   82 | int main(){
      |           ^
a.cc:112:2: error: expected '}' at end of input
  112 | }
      |  ^
a.cc:26:11: note: to match this '{'
   26 | int main(){
      |           ^
Language: C++

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

int Binary(int a[],int sizea,int b[],int sizeb){
  int num=0;
  int check=0;
  for(int i=0;i<sizea;i++){
    int j=check;
    while(j<sizeb){
      if(a[i]==b[j]){
        num++;
        check++;
    }
    j++;
  }
  return num;
}

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

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

  sort(T,T+q);

  cout<<Binary(S,n,T,q)<<endl;
}



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

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

 * 二分探索
 * O(logn)
 *
 * 整列済みである必要がある
 */
template<class T>
bool binary_search(std::vector<T> &vec, T t) {
  int low = 0;
  int high = (int)vec.size();

  while(low <= high) {
    int x = (low + high) / 2;
    if (vec[x] == t) return true;
    else if (t < vec[x]) high = x - 1;
    else low = x + 1;
  }
  return false;
}

int main(){
  int n;
  scanf("%d", &n);

  vector<int> v(n);

  REP (i, n) {
    scanf("%d", &v[i]);
  }

  int q;
  scanf("%d", &q);

  vector<int> t(q);
  REP (i, q) {
    scanf("%d", &t[i]);
  }
  int sum = 0;

  for (int a: t) {
    bool flag = binary_search(v, a);
    if (flag) sum++;
  }

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



Compiler output:
a.cc:15:2: error: expected constructor, destructor, or type conversion before '*' token
   15 |  * O(logn)
      |  ^
a.cc: In function 'int main()':
a.cc:53:30: error: no matching function for call to 'binary_search(std::vector<int>&, int&)'
   53 |     bool flag = binary_search(v, a);
      |                 ~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:2194:5: note: candidate: 'template<class _FIter, class _Tp> bool std::binary_search(_FIter, _FIter, const _Tp&)'
 2194 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2194:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:2228:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> bool std::binary_search(_FIter, _FIter, const _Tp&, _Compare)'
 2228 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2228:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include <iostream>
using namespace std;

int BSearch(int x,int A[],int N){
  int left=0;
  int right=N;

  while(left<=right){
    int mid=(left+right)/2;

    if(A[mid]==x){
      return mid;
    }else if(x<A[mid]){
      right=mid;
    }else{
      legt=mid+1;
    }
  }
  return -1;
}

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

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

  int ans=0;

  for(int i=0;i<q;i++){
    if(BSearch(T[i],S,n)!=-1){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int BSearch(int, int*, int)':
a.cc:16:7: error: 'legt' was not declared in this scope; did you mean 'left'?
   16 |       legt=mid+1;
      |       ^~~~
      |       left
Language: C++

#include<iostream>
using namespace std;

int BinarySearch(int x,int S[],int N);

int main(){
  int a[100000];
  int b[50000];
  int count=0;
  int a_n=0,b_n=0;
  cin >> a_n;
  for(int i=0;i<a_n;i++){
    cin>>a[i];
  }
  cin >> b_n;
  for(int i=0;i<b_n;i++){
    cin>>b[i];
  }
  for(int i=0;i<b_n;i++){
    if(LinearSearch(b[i],a,a_n)!=-1){
      count++;
    }
  }
  cout << count << endl;
}

int BinarySearch(int x,int S[],int N){
  int B=0;
  int T=N-1;
  while(B<=T){
    int mid=(B+T)/2;
    if(S[mid]==x) 
      return mid
    else if(S[mid]<x) 
      B=mid+1;
    else
      T=mid-1;
  }
  return -1;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: 'LinearSearch' was not declared in this scope; did you mean 'BinarySearch'?
   20 |     if(LinearSearch(b[i],a,a_n)!=-1){
      |        ^~~~~~~~~~~~
      |        BinarySearch
a.cc: In function 'int BinarySearch(int, int*, int)':
a.cc:33:17: error: expected ';' before 'else'
   33 |       return mid
      |                 ^
      |                 ;
   34 |     else if(S[mid]<x)
      |     ~~~~
Language: C++

#include <iosteram>

using namespace std;

void BSearch(int A[] ,unsigned int sp ,unsigned int ep ,int n){ //あり、なしのみboolで返す
  int mid = (ep-sp) / 2;
  if(mid == n)
    return 1;
  if(sp > ep)
    return 0;
  else if(n < mid)
    return BSearch(A ,sp ,mid-1 ,n);
  else
    return BSearch(A ,mid+1 ,ep ,n);
}

int main(void){
  int n,q;
  int counter = 0;
  int S[1000000000];
  int T[1000000000];
  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;i++){
    if(BSerach(T,0,q,S[i]))
      counter++;
  }
  cout << counter << endl;
}



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

#include <iostream>

using namespace std;

void BSearch(int A[] ,unsigned int sp ,unsigned int ep ,int n){ //あり、なしのみboolで返す
  int mid = (ep-sp) / 2;
  if(mid == n)
    return 1;
  if(sp > ep)
    return 0;
  else if(n < mid)
    return BSearch(A ,sp ,mid-1 ,n);
  else
    return BSearch(A ,mid+1 ,ep ,n);
}

int main(void){
  int n,q;
  int counter = 0;
  int S[1000000000];
  int T[1000000000];
  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;i++){
    if(BSerach(T,0,q,S[i]))
      counter++;
  }
  cout << counter << endl;
}



Compiler output:
a.cc: In function 'void BSearch(int*, unsigned int, unsigned int, int)':
a.cc:8:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
    8 |     return 1;
      |            ^
a.cc:10:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   10 |     return 0;
      |            ^
a.cc: In function 'int main()':
a.cc:31:8: error: 'BSerach' was not declared in this scope; did you mean 'BSearch'?
   31 |     if(BSerach(T,0,q,S[i]))
      |        ^~~~~~~
      |        BSearch
Language: C++

#include <iostream>

using namespace std;

void BSearch(int A[] ,unsigned int sp ,unsigned int ep ,int n){ //あり、なしのみboolで返す
  int mid = (ep-sp) / 2;
  if(mid == n)
    return 1;
  if(sp > ep)
    return 0;
  else if(n < mid)
    return BSearch(A ,sp ,mid-1 ,n);
  else
    return BSearch(A ,mid+1 ,ep ,n);
}

int main(void){
  int n,q;
  int counter = 0;
  int S[10000000];
  int T[10000000];
  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;i++){
    if(BSerach(T,0,q,S[i]))
      counter++;
  }
  cout << counter << endl;
}



Compiler output:
a.cc: In function 'void BSearch(int*, unsigned int, unsigned int, int)':
a.cc:8:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
    8 |     return 1;
      |            ^
a.cc:10:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   10 |     return 0;
      |            ^
a.cc: In function 'int main()':
a.cc:31:8: error: 'BSerach' was not declared in this scope; did you mean 'BSearch'?
   31 |     if(BSerach(T,0,q,S[i]))
      |        ^~~~~~~
      |        BSearch