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

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

int main()
{
	int n = 0, q = 0, k = 0;
	long t = 0;

	cin >> n;
	vector<long> S(n);
	vector<long>::iterator st;

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

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> t;
		st = find(S.begin(), S.end(), t);
		if (st != S.end())
			k++;
	}

	cout << k << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, long int&)'
   21 |                 st = find(S.begin(), S.end(), t);
      |                      ~~~~^~~~~~~~~~~~~~~~~~~~~~~
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:21:26: note:   '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   21 |                 st = find(S.begin(), S.end(), t);
      |                      ~~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<stdio.h>

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  return i!=n;
}

int main(){
  int i,n,A[1000+1],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(search(A,n,key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:36: error: expected ')' before '}' token
   14 |   for(i=0;i<n;i++){scanf("%d",&A[i]};
      |                         ~          ^
      |                                    )
Language: C++

#include<stdio.h>

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  return i!=n;
}

int main(){
  int i,n,A[1000+1],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(search(A,n,key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:37: error: expected ';' before '}' token
   14 |   for(i=0;i<n;i++){scanf("%d",&A[i])};
      |                                     ^
      |                                     ;
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    int n, q;
    int i, j;
    int *S, *T;
    S = malloc(sizeof(int) *10000);
    T = malloc(sizeof(int) *500);
    int cnt = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++){
        scanf("%d", &T[i]);
    }

    for (i = 0; i < q; i++){
        for (j = 0; j < n; j++){
            if (T[i] == S[j]){
                cnt++;
            }
        }
    }
    printf("%d", cnt);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   10 |     S = malloc(sizeof(int) *10000);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~
      |               |
      |               void*
a.cc:11:15: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   11 |     T = malloc(sizeof(int) *500);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~
      |               |
      |               void*
Language: C++

#include<iostream>
using namespace std

int S[100000];
int T[500];

int main() {
  int N, Q, sum;
  cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++ ) cin >> T[i];

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

  cout << sum
  return 0;
}


Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
    3 | 
    4 | int S[100000];
      | ~~~                 
a.cc: In function 'int main()':
a.cc:23:14: error: expected ';' before 'return'
   23 |   cout << sum
      |              ^
      |              ;
   24 |   return 0;
      |   ~~~~~~
Language: C++

#include<iostream>
using namespace std;
 
int S[10000];
int T[500];
 
int main() {
  int N, Q, sum;
  cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> S[i];
  cin >> Q;
  for ( int i = 0; i < Q; i++ ) cin >> T[i];
 
  sum = 0;
  for ( int i = 0; i < Q; i++ ) {
    for ( int j = 0; j < N; j++ ) {
      if ( S[j] == T[i] ) {
        sum++;
      }
    }
  }
 
  cout << sum
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: expected ';' before 'return'
   23 |   cout << sum
      |              ^
      |              ;
   24 |   return 0;
      |   ~~~~~~
Language: C++

#include <iostream>

using namespace std;

int main() {

    int n, q, S[10000], T[500];

    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++) {
        if (count(S, S + n, T[i])) ans++;
    }

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: 'count' was not declared in this scope
   18 |         if (count(S, S + n, T[i])) ans++;
      |             ^~~~~
Language: C++

import java.util.Arrays;
import java.util.Scanner;

public class LinearsearchAizu {
    public static void main(String[] args) {
        int n ;
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        //System.out.println(n);
        int[] arr = new int[n];
        for(int i = 0; i<n; i++){
            arr[i] = in.nextInt();
        }


        Arrays.sort(arr);
        int m = 0;
        m = in.nextInt();
        //System.out.println(m);
        int[] brr = new int[m];
        for(int i = 0; i<m; i++){
            brr[i] = in.nextInt();
        }
        int res = 0;
        //System.out.println("n"+n+" "+arr[0]);
        //System.out.println(res);
        for(int i = 0; i<m; i++){
            if(search(arr,brr[i],0,n-1)==1) res++;
            //System.out.println(search(arr,brr[i],0,n-1));
        }
        System.out.println(res);
    }

    private static int search(int[] arr, int i,int left, int right) {
        //System.out.println("i:"+i);
        if(right<left) return -1;
        int mid = (left+right)/2;
        //System.out.println(arr[mid]+" "+mid);
        if(arr[mid] == i) return 1;
        if(arr[mid]>i){
            return search(arr,i,left,mid-1);
        }else {
            return search(arr,i,mid+1,right);
        }

    }
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Arrays;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class LinearsearchAizu {
      | ^~~~~~
Language: C++

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

int n,q;
long long S;
long long T[510];
int main(){
	cin >> n;
	set<long long> s;
	for(int i=1;i<=n;i++){
		cin >> S;
		s.insert(S);
	}
	cin >> q;
	for(int i=1;i<=q;i++){
		cin >> T[i];
	}
	int count = 0;
	for(int i=1;i<=q;i++){
		iterator it = s.find(T[i]);
		if(it!=s.end()) count++;
	}
	cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:42: error: class template argument deduction failed:
   21 |                 iterator it = s.find(T[i]);
      |                                          ^
a.cc:21:42: error: no matching function for call to 'iterator(std::set<long long int>::iterator)'
In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66,
                 from /usr/include/c++/14/string:47,
                 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:1:
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator()-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator(std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>)-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   template argument deduction/substitution failed:
a.cc:21:42: note:   'std::_Rb_tree_const_iterator<long long int>' is not derived from 'std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
   21 |                 iterator it = s.find(T[i]);
      |                                          ^
Language: C++

#include<stdio.h>

int search(int A[],int n,int key)
{
   int i=0;
   A[n]=key;
   while(A[i]!=key) i++;
   return (i!=n)
}

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


Compiler output:
a.cc: In function 'int search(int*, int, int)':
a.cc:8:17: error: expected ';' before '}' token
    8 |    return (i!=n)
      |                 ^
      |                 ;
    9 | }
      | ~                
a.cc: In function 'int main()':
a.cc:14:4: error: 'cin' was not declared in this scope
   14 |    cin>>n
      |    ^~~
a.cc:15:19: error: expected ';' before ')' token
   15 |    for(i=0;i<n;i++) cin>>A[i];
      |                   ^
      |                   ;
a.cc:20:8: error: 'seach' was not declared in this scope; did you mean 'search'?
   20 |     if(seach(A,n,key)) sum++;
      |        ^~~~~
      |        search
a.cc:22:3: error: 'cout' was not declared in this scope
   22 |   cout<<sum;
      |   ^~~~
Language: C++

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

int linearSearch(int A[], int n, int key){
   A[n] = key;
   int i=0; 
   while(A[i] != key) i++;
   return i != n;
}

int main()
{
   int n, q, key;
   int S[10000+1];
   cin >> n;
   for(int i=0; i<n; i++) cin >> S[i];
   
   cin >> q;
   for(int i=0; i<q; i++){
      cin >> key;
      if(search(A, n, key)) sum++;
   }
   cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'A' was not declared in this scope
   22 |       if(search(A, n, key)) sum++;
      |                 ^
a.cc:22:29: error: 'sum' was not declared in this scope
   22 |       if(search(A, n, key)) sum++;
      |                             ^~~
a.cc:24:12: error: 'sum' was not declared in this scope
   24 |    cout << sum << endl;
      |            ^~~
Language: C++

#include <stdio.h>

int main(void)
{
	int n, q, i, j, count = 0;
	int *S, *T;
	
	scanf("%d", &n);
	S = (int *)malloc(n * sizeof(int));
	for(i=0; i<n; i++)
	{
		scanf("%d", S[i]);
	}
	scanf("%d", &q);
	T = (int *)malloc(q * sizeof(int));
	for(i=0; i<q; i++)
	{
		scanf("%d", T[i]);
	}
	
	for(i=0; i<q; i++)
	{
		for(j=0; j<n; j++)
		{
			if(S[j] == T[i])count++;
		}
	}
	
	printf("%d", count);
}
	
	
	






Compiler output:
a.cc: In function 'int main()':
a.cc:9:20: error: 'malloc' was not declared in this scope
    9 |         S = (int *)malloc(n * sizeof(int));
      |                    ^~~~~~
a.cc:2:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    1 | #include <stdio.h>
  +++ |+#include <cstdlib>
    2 |
Language: C++

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


//番兵により比較回数の削減
int isin_Lsearch(std::vector<int> S, int n, int key){
  int i=0;
  S[n] = key;
  while (A[i]!=key) {
    i++;
  }
  return i != n;
}

int main(int argc, char const *argv[]) {
  int n, key, cnt=0;
  std::cin >> n;

  std::vector<int> S; S.reserve(10001);

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

  int q;  std::cin >> q;

  for (size_t i = 0; i < q; i++) {
    std::cin >> key;
    if( isin_Lsearch(S, n, key) ) cnt++;
  }

  std::cout << cnt << '\n';

  return 0;
}



Compiler output:
a.cc: In function 'int isin_Lsearch(std::vector<int>, int, int)':
a.cc:11:10: error: 'A' was not declared in this scope
   11 |   while (A[i]!=key) {
      |          ^
Language: C++

#include<iostream>
using namespace std;

const int NOT_FOUND=-1;

LinearSearch(int key, int A[], int n){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  if(i==n){
    return NOT_FOUND;
  }
  return 0;
}

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

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

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

  for(int i=0; i<q; i++){
    if(LinearSearch(T[i], S, n)!=NOT_FOUND){
      C++;
    }
  }
  cout << c << endl;
  return 0;
}



Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'LinearSearch' with no type [-fpermissive]
    6 | LinearSearch(int key, int A[], int n){
      | ^~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:11: error: 'c' was not declared in this scope
   40 |   cout << c << endl;
      |           ^
Language: C++

n1=int(input())
l1=list(input().split())

n2=int(input())
l2=list(input().split())


cnt=0
for x in l1:
    if x in l2:
        cnt+=1

print(cnt)


Compiler output:
a.cc:1:1: error: 'n1' does not name a type
    1 | n1=int(input())
      | ^~
Language: C++

def linear_search(arr, key):
    idx = 0
    while arr[idx] != key:
        idx += 1

    if idx == len(arr) - 1:
        return False

    return True


n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

s.append(None)
cnt = 0
for i in range(q):
    s[n] = t[i]
    if linear_search(s, t[i]):
        cnt += 1

print(cnt)



Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def linear_search(arr, key):
      | ^~~
Language: C++

#include<iostream>
int main()
{
	int n;
	int q;
	int s[10000]={0};
	int t[500]={0};
	int cnt=0;
	int i,j;
	
	std::cin>>n;
	for(i=0;i<n;i++){
		std::cin>>s[i];
	}
	
	std::cin>>q;
	for(i=0;i<q;i++){
		std::cin>>t[i];
	}

	for(i=0;i<q;i++){
		for(j=0;j<s;j++){
			if(s[j]==t[i]){
				cnt++;
				break;
			}
		}
	}
	std::cout<<cnt<<'\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   22 |                 for(j=0;j<s;j++){
      |                         ~^~
Language: C++

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

int main(void){
	int n, q, num=0;
	long S[10001], T[501];
	
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> S[i];
	}
	
	std::cin >> q;
	for(int i=0; i<q; i++){
		std::cin >> T[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=0; j<q; j++){
			if(S[i] == T[j]) num+=1;
		}
	}
	
	cout(num);
	
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: no match for call to '(std::ostream {aka std::basic_ostream<char>}) (int&)'
   25 |         cout(num);
      |         ~~~~^~~~~
Language: C++

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

int main(void){
	int n, q, num=0, a;
	long S[10001], T[501];
	
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> S[i];
	}
	
	std::cin >> q;
	for(int i=0; i<q; i++){
		std::cin >> T[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=0; j<q; j++){
			a = 0;
			for(int k=0; k<i; k++){
				if(S[i] == S[k]){ a = 1; }
				
			if(S[i] == T[j] || a>1){
				num+=1;
				break;
			}
		}
	}
	
	cout << num << "\n";
	
	return 0;
}



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

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

int main(void){
	int n, q, num=0, a;
	long S[10001], T[501];
	
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> S[i];
	}
	
	std::cin >> q;
	for(int i=0; i<q; i++){
		std::cin >> T[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=0; j<q; j++){
			a = 0;
			for(int k=0; k<i; k++){
				if(S[i] == S[k]){ 
                                    a = 1; 
                                }
				
			if(S[i] == T[j] || a>1){
				num+=1;
				break;
			}
		}
	}
	
	cout << num << "\n";
	
	return 0;
}



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

#include<iostream>
using namespace std;

int main(void){
	int n, q, num=0, a;
	long S[10001], T[501];
	
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> S[i];
	}
	
	std::cin >> q;
	for(int i=0; i<q; i++){
		std::cin >> T[i];
	}
	
	for(int i=0; i<n; i++){
		for(int j=0; j<q; j++){
			a = 0;
			for(int k=0; k<i; k++){
				if(S[i] == S[k]){
					a = 1;
				}
				
			if(S[i] == T[j] || a>1){
				num+=1;
				break;
			}
		}
	}
	
	cout << num << "\n";
	
	return 0;
}



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

#include <iostream>
#include <queue>
#include <list>

using namespace std;

int main(){
	int n, q;
	int cnt = 0;
	cin >> n;
	list<int> A;
	list<int>::iterator it;
	int B[q];
	for(int i; i < n; i++){
		cin >> x;
		A.push_front(x);
	}
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> B[i];
		for(it = A.begin(); it != A.end();it++){
			if(B[i] == *it){
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


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

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

// Aにkeyがあるなら1，ないなら0を返す
int search(int A[],int n,int key){
  A[n] = key;
  /*
  for(int i=0;i<n;i++){
    if(A[i]==key){
      return 1;
    }
  }
  return 0;
  */
  while(A[i]!=key){
    i++;
  }
  return i!=n;
}

int main(){
  int n,q;
  scanf("%d",&n);
  int S[n+1];
  for(int i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int t;
  int sum=0;
  for(int i=0;i<q;i++){
    scanf("%d",&t);
    if(search(S,n,t)){
      sum++;
    }
  }
  printf("%d\n",sum);

}



Compiler output:
a.cc: In function 'int search(int*, int, int)':
a.cc:16:11: error: 'i' was not declared in this scope
   16 |   while(A[i]!=key){
      |           ^
a.cc:19:10: error: 'i' was not declared in this scope
   19 |   return i!=n;
      |          ^
Language: C++

#include<stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i, n, A[10000+1], 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 ( search(A, n, key) ) sum++;
  }
  print("%d\n", sum);

  return 0;
}


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

#include<iostream>

using namespace std;

int linearSearch(vector<int>& A, int n, int key)
{
  int i = 0;
  A[n] = key;
  while (A[i] != key) {
    i++;
  }
  return i != n;
}

int main() {
  vector<int> A;
  A.reserve(10000 + 1);

  int N;
  cin >> N;
  A.resize(N  + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int M;
  int key;
  int sum = 0;
  for (int i = 0; i < M; i++) {
    cin >> key;
    if(linearSearch(A, N, key)) {
      sum++;
    }
  }
  cout<< sum << endl;

  return 0;
}


Compiler output:
a.cc:5:18: error: 'vector' was not declared in this scope
    5 | int linearSearch(vector<int>& A, int n, int key)
      |                  ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | 
a.cc:5:25: error: expected primary-expression before 'int'
    5 | int linearSearch(vector<int>& A, int n, int key)
      |                         ^~~
a.cc:5:34: error: expected primary-expression before 'int'
    5 | int linearSearch(vector<int>& A, int n, int key)
      |                                  ^~~
a.cc:5:41: error: expected primary-expression before 'int'
    5 | int linearSearch(vector<int>& A, int n, int key)
      |                                         ^~~
a.cc:5:48: error: expression list treated as compound expression in initializer [-fpermissive]
    5 | int linearSearch(vector<int>& A, int n, int key)
      |                                                ^
a.cc: In function 'int main()':
a.cc:16:3: error: 'vector' was not declared in this scope
   16 |   vector<int> A;
      |   ^~~~~~
a.cc:16:3: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:16:10: error: expected primary-expression before 'int'
   16 |   vector<int> A;
      |          ^~~
a.cc:17:3: error: 'A' was not declared in this scope
   17 |   A.reserve(10000 + 1);
      |   ^
a.cc:31:20: error: 'linearSearch' cannot be used as a function
   31 |     if(linearSearch(A, N, key)) {
      |        ~~~~~~~~~~~~^~~~~~~~~~~
Language: C++

#include "stdafx.h"
#include<iostream>
#include<fstream>

using namespace std;



int main()
{
	//n,Sの要素,q,Tの要素を入力
	int n;
	cin >> n;
	int *S = new int[n+1];
	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 count = 0;

	//線形探索
	for (int i = 0;i < q;i++) {
		int j = 0;
		S[n+1] = T[i];
		while (S[j] != T[i]) j++;
		if (j == n+1) {
			continue;
		}
		else
		{
			count++;
		}
	}
	//countの出力
	cout << count << endl;

    return 0;
}


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

#include <stdio.h>

int main() {
    int n, q;
    scanf("%d", &n);
    
    int S[n];
    for (int i=0; i<n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    
    int tmp, count=0;
    for (int i=0; i<q; i++) {
        scanf("%d", &tmp);
        for (int j=0; j<n; j++) {
            if(S[j] == tmp && flag) { 
                count++;
                break;
            }
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:31: error: 'flag' was not declared in this scope
   15 |             if(S[j] == tmp && flag) {
      |                               ^~~~
Language: C++

int main(){
    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[n];
    for(int i=0; i<n; i++){
        cin >> T[i];
    }
    
    int ans = 0;
    
    for(int i=0; i<q; i++){
        for(int j=0; j<n; j++){
            if(T[i] == S[j]){
                ans++;
                break;
            }
        }
    }
    
    delete[] S;
    delete[] T;
    
}


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

using namespace std;

int main(){
    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[n];
    for(int i=0; i<n; i++){
        cin >> T[i];
    }
    
    int ans = 0;
    
    for(int i=0; i<q; i++){
        for(int j=0; j<n; j++){
            if(T[i] == S[j]){
                ans++;
                break;
            }
        }
    }
    
    delete[] S;
    delete[] T;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
Language: C++

#include<stdio.h>

int main(){
  int i, n, q, key, ans;
  int Y[10001];

  scanf("%d", &n);
  for(i=0 ; i<n ; i++){
    scanf("%d", &Y[i]);
  }
  scanf("%d", &q);
  for(i=0 ; i<q ; i++){
    scanf("%d", &key);
    ans+=LS(Y, n, key);
  }
  printf("%d\n",ans);
  return 0;
}
int LS(int X[], int n, int key){
  int i=0, len;
  X[n]=key;
  while(i<n){
    if(X[i]==key)return 1;
    else i++;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'LS' was not declared in this scope
   14 |     ans+=LS(Y, n, key);
      |          ^~
Language: C++

#include<iostream>

using namespace std;
bool search(int A[],int n,int key){
	for(int i=0;i<n;++i)
		if(A[i]==key)break;
	return i<n;
}
int main(){
	int n,m;
	cin>>n;
	int* S=new int[n];
	for(int i=0;i<n;++i)cin>>S[i];
	cin>>m;
	int *T=new int[m];
	for(int i=0;i<m;++i)cin>>T[i];
	int sum=0;
for(int j=0;j<m;++j)
	if(search(S,n,T[j]))sum++;
    cout<<sum<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'bool search(int*, int, int)':
a.cc:7:16: error: 'i' was not declared in this scope
    7 |         return i<n;
      |                ^
Language: C++

#include<iostream>

using namespace std;

#define N 1000
#define Q 500

int main(){

  int n[N];
  int q[Q];

  int num,num2,i,j,count=0;

  cin >>num;

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

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

  for(i=0;i<num;i++){
    for(j=0;j<num2j++){
      if(n[i]==q[j]){
	count++;
	break;
      }
    }
  }

  cout <<count<<endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:15: error: 'num2j' was not declared in this scope; did you mean 'num2'?
   27 |     for(j=0;j<num2j++){
      |               ^~~~~
      |               num2
a.cc:27:22: error: expected ';' before ')' token
   27 |     for(j=0;j<num2j++){
      |                      ^
      |                      ;
Language: C++

#include <iostream.h>

int S[10000];

int main(){

  int n, q;
  int min, max, mid;
  int tmp;
  int count;

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

  cin >> q;
  for(int i=0; i<q; i++){
    cin >> tmp;
    min = 0;
    max = n - 1;
    while(min <= max){
      mid = (min + max) / 2;
      if(S[mid] == tmp){
	count++;
	break;
      }else if(S[mid] > tmp){
	max = mid - 1;
      }else{
	min = mid + 1;
      }
    }
  }

  cout << count << "\n";

return 0;

}

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

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main_binary_search {

  static final int N = 100000;
  static final int Q = 50000;
  static int n, q;
  static int s[], t[];

  public static int binary_search(int x) {
    int l = 0;
    int r = n;
    int m;
    while (r-l > 0) {
      m = (l+r)/2;
      if (s[m] == x)
      return m;
      else if (s[m] < x) 
        l = m + 1;
      else
        r = m;
    }
    return -1;
  }

  public static void main(String[] args) {
    int i;
    Scanner sc = new Scanner(System.in); 
    n = Integer.parseInt(sc.next());
    s = new int[n];
    for (i=0; i<n; i++)
      s[i] = Integer.parseInt(sc.next());

    q = Integer.parseInt(sc.next());
    t = new int[q];
    for (i=0; i<q; i++)
      t[i] = Integer.parseInt(sc.next());

    int res = 0;
    for (i=0; i<q; i++)
      if (binary_search(t[i]) != -1)
        res++;

    System.out.println(res);
  }
}

Compiler output:
Main.java:7: error: class Main_binary_search is public, should be declared in a file named Main_binary_search.java
public class Main_binary_search {
       ^
1 error
Language: Java

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

  static final int N = 100000;
  static final int Q = 50000;
  static int n, q;
  static int s[], t[];

  public static int binary_search(int x) {
    int l = -1;
    int r = n-1;
    int m;
    while (r-l > 1) {
      m = (l+r)/2;
      if (x <= s[m]) 
        r = m;
      else
        l = m;
    }
    
    return ((s[r]==x) ? r : -1)
  }

  public static void main(String[] args) {
    int i;
    Scanner sc = new Scanner(System.in); 
    n = Integer.parseInt(sc.next());
    s = new int[n];
    for (i=0; i<n; i++)
      s[i] = Integer.parseInt(sc.next());

    q = Integer.parseInt(sc.next());
    t = new int[q];
    for (i=0; i<q; i++)
      t[i] = Integer.parseInt(sc.next());

    int res = 0;
    for (i=0; i<q; i++)
      if (binary_search(t[i]) != -1)
        res++;

    System.out.println(res);
  }
}

Compiler output:
Main.java:26: error: ';' expected
    return ((s[r]==x) ? r : -1)
                               ^
1 error
Language: Java

# coding: utf-8
# Here your code !
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
C = 0

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

for item in T:
    if binary_search(S,item):
        C += 1
print C

Compiler output:
Main.java:1: error: illegal character: '#'
# coding: utf-8
^
Main.java:1: error: class, interface, enum, or record expected
# coding: utf-8
        ^
Main.java:2: error: illegal character: '#'
# Here your code !
^
3 errors
Language: Java

import java.io.*;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int ans=0;
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st1=new StringToenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integr.parseInt(st1.nextToken());
int m=Integer.parseInt(br.readLine());
StringTokenizer st2=new StringToenizer(br.readLine());
for(int i=0;i<m;i++){
int b=Integr.parseInt(st2.nextToken());
if(BinarySearch(a,b)>=0) ans++
}
out.println(ans);
out.flush();
}
}

private static int BinarySearch(int[] a,int b){
int lb=0;
int ub=a.length;
while(ub>lb){
int mid=(lb+ub)/2;
if(a[mid]==b) return mid;
else if(a[mid]>b) ub=mid;
else lb=mid+1;
}
return -1;
}
}

Compiler output:
Main.java:20: error: ';' expected
if(BinarySearch(a,b)>=0) ans++
                              ^
1 error
Language: Java

import java.io.*;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int ans=0;
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st1=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integr.parseInt(st1.nextToken());
int m=Integer.parseInt(br.readLine());
StringTokenizer st2=new StringTokenizer(br.readLine());
for(int i=0;i<m;i++){
int b=Integr.parseInt(st2.nextToken());
if(BinarySearch(a,b)>=0) ans++;
}
out.println(ans);
out.flush();
}
}

private static int BinarySearch(int[] a,int b){
int lb=0;
int ub=a.length;
while(ub>lb){
int mid=(lb+ub)/2;
if(a[mid]==b) return mid;
else if(a[mid]>b) ub=mid;
else lb=mid+1;
}
return -1;
}
}

Compiler output:
Main.java:14: error: cannot find symbol
StringTokenizer st1=new StringTokenizer(br.readLine());
^
  symbol:   class StringTokenizer
  location: class Main
Main.java:14: error: cannot find symbol
StringTokenizer st1=new StringTokenizer(br.readLine());
                        ^
  symbol:   class StringTokenizer
  location: class Main
Main.java:15: error: cannot find symbol
for(int i=0;i<n;i++) a[i]=Integr.parseInt(st1.nextToken());
                          ^
  symbol:   variable Integr
  location: class Main
Main.java:17: error: cannot find symbol
StringTokenizer st2=new StringTokenizer(br.readLine());
^
  symbol:   class StringTokenizer
  location: class Main
Main.java:17: error: cannot find symbol
StringTokenizer st2=new StringTokenizer(br.readLine());
                        ^
  symbol:   class StringTokenizer
  location: class Main
Main.java:19: error: cannot find symbol
int b=Integr.parseInt(st2.nextToken());
      ^
  symbol:   variable Integr
  location: class Main
6 errors
Language: Java

import java.util.*;
class  Main{
	Scanner sc= new Scanner(System.in);
	void aaaa(){
		int gundam=0;
		int n=sc.nextInt();
		int[] N=new int[n];
		for(int i=0;i<n;i++)N[i]=sc.nextInt();
		int q=sc.nextInt();
		for(int i=0;i<q;i++){
			int Q=sc.nextInt();
			int l=L(n-1);
			int r=R(n-1);
			for(int j=0;n*2;j++){
				if(N[0]>Q||N[n-1]<Q){
					break;
				}else if(N[l]>Q){
					l=L(r);
					r=R(r);
				}else if(N[r]<Q){
					l=L(n-1+l);
					r=R(n-1+l);
				}else if(N[l]==Q||N[l]==Q){
					gundam++;
					break;
				}else break;
			}
		}
		System.out.println(gundam);
	}
	int R(int n){
		int l=n/2;
		int r=n-l;
		return r;
	}
	int L(int n){
		int l=n/2;
		return l;
	}
	public static void main(String[]args){
		new Main().aaaa();
		
	}
}

Compiler output:
Main.java:14: error: incompatible types: int cannot be converted to boolean
			for(int j=0;n*2;j++){
			             ^
1 error
Language: Java

import java.util.*;
class  LS{
	Scanner sc= new Scanner(System.in);
	void aaaa(){
		int gundam=0;
		int n=sc.nextInt();
		int[] N=new int[n];
		for(int i=0;i<n;i++)N[i]=sc.nextInt();
		int q=sc.nextInt();
		for(int i=0;i<q;i++){
			int Q=sc.nextInt();
			int L=0;
			int R=n-1;
			while(N[L]<Q&&Q<N[R]){
				int cent=(R-L)/2+L;
				if(N[cent]==Q||N[cent+1]==Q){
					gundam++;
					break;
				}else if(N[cent]>Q)r=cent;
				else if(N[cent+1]<Q)l=cent+1;
				else break;
			}
		}
		System.out.println(gundam);
	}
	public static void main(String[]args){
		new LS().aaaa();
	}
}

Compiler output:
Main.java:19: error: cannot find symbol
				}else if(N[cent]>Q)r=cent;
				                   ^
  symbol:   variable r
  location: class LS
Main.java:20: error: cannot find symbol
				else if(N[cent+1]<Q)l=cent+1;
				                    ^
  symbol:   variable l
  location: class LS
2 errors
Language: Java

import java.util.*;

class Main {
	//?????¢??¢?´¢?????¬???
	public static boolean search(int[] A, int n, int key) {
		A[n] = key;
		int i = 0;
		while(A[i] != key)i++;
		return i != n;
	}
	
	public static boolean binarySearch(int[] A, int n, int key) {
		int left = 0;
		int right = n - 1;
		int mid = 0;
		while(left < right) {
			 mid = (left + right) / 2;
			if ( key == A[mid] ) return true;
			if ( key > A[mid] ) left = mid + 1
			if ( key < A[mid] ) right = mid;
		}
	return false;
	}

	public static void main(String args[]) {

		Scanner scan = new Scanner(System.in);
		int[] arrayS = new int[10000]; //??°???S
		int[] arrayT = new int[5000];   //??°???T
		int count = 0;						 //?????°????¨???????????????°

		//????´??????°???????????????ArrayS?????°???S???????????????
		int sNum = scan.nextInt();
		for (int i = 0; i < sNum; i++)
			arrayS[i] = scan.nextInt();

		//????´??????°???????????????ArrayT?????°???T???????????????
		int tNum = scan.nextInt();
		for (int j = 0; j < tNum; j++)
			arrayT[j] = scan.nextInt();

		//??°???T???????´??????°???A????????????????????????????????????
		for (int j = 0; j < tNum; j++)
			if(binarySearch(arrayS, sNum, arrayT[j])) count++;

		System.out.println(count);
	}
}

Compiler output:
Main.java:19: error: ';' expected
			if ( key > A[mid] ) left = mid + 1
			                                  ^
1 error
Language: Java

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Arrays;

public class Alds1_4_b {
	public static void main(String[] args) {
		FS r = new FS();
		int n = r.nextInt();
		int[] S = new int[n];
		for(int i=0; i<n; i++) {
			S[i] = r.nextInt();
		}
		int q = r.nextInt();
		int c = 0;
		for(int i=0; i<q; i++) {
			int t = r.nextInt();
			if(Arrays.binarySearch(S, t) >= 0) c++;
		}
		System.out.println(c);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Compiler output:
Main.java:6: error: class Alds1_4_b is public, should be declared in a file named Alds1_4_b.java
public class Alds1_4_b {
       ^
1 error
Language: Java

import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] S = new int[n+1];
		String[] ins = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			S[i] = Integer.parseInt(ins[i]);
		}
		int q = Integer.parseInt(br.readLine());
		int[] T = new int[q];
		ins = br.readLine().split(" ");
		for(int i = 0; i < q; i++){
			T[i] = Integer.parseInt(ins[i]);
		}

		int C = 0;
		for(int i = 0; i < T.length; i++){
			boolean flag = binarySearch(T[i], S, n);
			if(flag == true)
				C++;
		}
		System.out.printf("%d\n", C);
	}

	private boolean 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 true;
			else if(key < A[mid])
				right = mid;
			else
				left = mid + 1;
		}
		return false;
	}
}

Compiler output:
Main.java:23: error: non-static method binarySearch(int,int[],int) cannot be referenced from a static context
			boolean flag = binarySearch(T[i], S, n);
			               ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class AOJBinerySearch {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		String n = r.readLine();
		String Sinput = r.readLine();
		String[] S = Sinput.split(" ", 0);
		String q = r.readLine();
		String Tinput = r.readLine();
		String[] T =  Tinput.split(" ", 0);
		int cnt = 0;
		for (int i=0; i<n; i++) {
			for (int j=0; j<q; j++) {
				if (S[i] == T[j]) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

}

Compiler output:
Main.java:5: error: class AOJBinerySearch is public, should be declared in a file named AOJBinerySearch.java
public class AOJBinerySearch {
       ^
Main.java:16: error: bad operand types for binary operator '<'
		for (int i=0; i<n; i++) {
		               ^
  first type:  int
  second type: String
Main.java:17: error: bad operand types for binary operator '<'
			for (int j=0; j<q; j++) {
			               ^
  first type:  int
  second type: String
3 errors
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class AOJBinerySearch {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		int n = Integer.parseInt(r.readLine());
		String Sinput = r.readLine();
		String[] S = Sinput.split(" ", 0);
		int q = Integer.parseInt(r.readLine());
		String Tinput = r.readLine();
		String[] T =  Tinput.split(" ", 0);
		int cnt = 0;
		for (int i=0; i<n; i++) {
			for (int j=0; j<q; j++) {
				if (Integer.parseInt(S[i]) == Integer.parseInt(T[j])) {
//					System.out.println("S[i]" + S[i] + "T[i]" + T[j] );
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

}

Compiler output:
Main.java:5: error: class AOJBinerySearch is public, should be declared in a file named AOJBinerySearch.java
public class AOJBinerySearch {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class AOJBinerySearch {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
		int n = Integer.parseInt(r.readLine());
		String Sinput = r.readLine();
		String[] S = Sinput.split(" ", 0);
		int q = Integer.parseInt(r.readLine());
		String Tinput = r.readLine();
		String[] T =  Tinput.split(" ", 0);
		int cnt = 0;
		int SBefore = Integer.parseInt(S[0]);
		int SNext;
		for (int i=0; i<n; i++) {
			for (int j=0; j<q; j++) {
				if (SBefore != Integer.parseInt(S[i+1]) && Integer.parseInt(S[i]) == Integer.parseInt(T[j])) {
					cnt++;
					SBefore = Integer.parseInt(S[i]);

				}
			}
		}
		System.out.println(cnt);
	}

}

Compiler output:
Main.java:5: error: class AOJBinerySearch is public, should be declared in a file named AOJBinerySearch.java
public class AOJBinerySearch {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main{
 
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] S = new int[100000];
        int[] T = new int[50000];
        String[] in_S = br.readLine().split(" ");
        for(int i = 0; i < n; i++){
            S[i] = Integer.parseInt(in_S[i]);
        }
        int q = Integer.parseInt(br.readLine());
        String[] in_T = br.readLine().split(" ");
        int sum = 0;
        for(int i = 0; i < q; i++){
            T[i] = Integer.parseInt(in_T[i]);
            if( binarySearch(S, n, T[i])) sum++;
        }
        System.out.println(sum);
    }
 
    public static boolean binarySearch(int[] A, int n, int key){
        int left = 0;
        int right = n;
        int mid;
        while(left < right){
            mid = (left + right) / 2;
            if(A[mid] == key) return true;
            else if(A[mid] < key) left = mid + 1;
            else right = mid;
        }
        return false;
    }

Compiler output:
Main.java:37: error: reached end of file while parsing
    }
     ^
1 error
Language: Java

import java.util.Scanner;

public class Main{
    private static boolean binarySearch(int[] array, int key){
        int left = 0;
        int right = array.length - 1;
        int mid = 0;
        while(left < right){
            mid = (left + right) / 2
            if(array[mid] == key) return true;
            if(array[mid] < key){
                left = mid + 1;
            }else if(array[mid] > key){
                right = mid;
            }
        }
    }
    
    private static int[] inputArray(){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] array = new int[num];
        for(int i = 0; i < num; i++){
            array[i] = sc.nextInt();
        }
        return array;
    }    
    
    public static void main(String[] args){
        int s = inputArray();
        int t = inputArray();
        int count = 0;
        
        for(int i = 0; i < t.length; i++){
            if(binarySearch(s, t[i])){
                count++;
            }
        }
        System.out.println(count);
    }
}


Compiler output:
Main.java:9: error: ';' expected
            mid = (left + right) / 2
                                    ^
1 error
Language: Java

import java.util.Scanner;

public class Main{
    private static boolean binarySearch(int[] array, int key){
        int left = 0;
        int right = array.length - 1;
        int mid = 0;
        while(left < right){
            mid = (left + right) / 2;
            if(array[mid] == key) return true;
            if(array[mid] < key){
                left = mid + 1;
            }else if(array[mid] > key){
                right = mid;
            }
        }
    }
    
    private static int[] inputArray(){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] array = new int[num];
        for(int i = 0; i < num; i++){
            array[i] = sc.nextInt();
        }
        return array;
    }    
    
    public static void main(String[] args){
        int s = inputArray();
        int t = inputArray();
        int count = 0;
        
        for(int i = 0; i < t.length; i++){
            if(binarySearch(s, t[i])){
                count++;
            }
        }
        System.out.println(count);
    }
}


Compiler output:
Main.java:30: error: incompatible types: int[] cannot be converted to int
        int s = inputArray();
                          ^
Main.java:31: error: incompatible types: int[] cannot be converted to int
        int t = inputArray();
                          ^
Main.java:34: error: int cannot be dereferenced
        for(int i = 0; i < t.length; i++){
                            ^
Main.java:35: error: array required, but int found
            if(binarySearch(s, t[i])){
                                ^
4 errors
Language: Java

import java.util.Scanner;

public class Main{
    private static boolean binarySearch(int[] array, int key){
        int left = 0;
        int right = array.length - 1;
        int mid = 0;
        while(left < right){
            mid = (left + right) / 2;
            if(array[mid] == key) return true;
            if(array[mid] < key){
                left = mid + 1;
            }else if(array[mid] > key){
                right = mid;
            }
        }
    }
    
    private static int[] inputArray(){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] array = new int[num];
        for(int i = 0; i < num; i++){
            array[i] = sc.nextInt();
        }
        return array;
    }    
    
    public static void main(String[] args){
        int[] s = inputArray();
        int[] t = inputArray();
        int count = 0;
        
        for(int i = 0; i < t.length; i++){
            if(binarySearch(s, t[i])){
                count++;
            }
        }
        System.out.println(count);
    }
}


Compiler output:
Main.java:17: error: missing return statement
    }
    ^
1 error