Language: Java

#include <stdio.h>

int binarySearch(int *,int key);
int n;
int q;
int T[10000];
int k=0;

int main(){
  int i,j;
  int c=0;
  int S[10000];
  int Q[10000];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&Q[i]);
  }
  for(i=0; i<n; i++){
    T[i] = -1;
  }
  
  for(i=0; i<q; i++){
    c += binarySearch(S,Q[i]);
  }
  printf("%d\n",c);
  return 0;
}

int binarySearch(int *A,int key){
  int i,j,m;
 
  int flug = 0;
  if(key == A[(0+n)/2]) {
    //    printf("%d is being checked.equal\n",key);
    if(flug == 0){
      T[k] = key;
      k++;
      flug = 1;
      //    printf("%d checked\n",key);
      return 1;
    }
  }
  else if(key < A[(0+n)/2]){
    m = (0+n)/2;
    A[m] = key;
    //  printf("%d is being checked.larger\n",key);
    for(i=0; i<m; i++){
      if(A[i]==key){
	for(j=0;j < n;j++){
	  if(key == T[j]){
	    //	    printf("same %d, ",T[j]);
	    return 0;
	  }
	}
	T[k] = key;
	k++;
	//	printf("%d checked\n",key);
	return 1;
      }
    }
  }
  else{
    //  printf("%d is being checked.smaller\n",key);
    m = (0+n)/2;
     A[n] = key;
    for(i=m+1; i<n; i++){
      if(A[i]==key){
	for(j=0;j < n;j++){
	  if(key == T[j]) {
	    //      printf("same %d, ",T[j]);
	    return 0;
	  }
	}
	T[k] = key;
	k++;
	//	printf("%d checked\n",key);
	return 1;
      }
    }

  }
  return 0;
}





Compiler output:
Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <stdio.h>
         ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
int n;
^
  (use --enable-preview to enable unnamed classes)
Main.java:6: error: class, interface, enum, or record expected
int T[10000];
^
Main.java:12: error: ']' expected
  int S[10000];
        ^
Main.java:13: error: ']' expected
  int Q[10000];
        ^
Main.java:14: error: illegal start of expression
  scanf("%d",&n);
             ^
Main.java:16: error: illegal start of expression
    scanf("%d",&S[i]);
               ^
Main.java:18: error: illegal start of expression
  scanf("%d",&q);
             ^
Main.java:20: error: illegal start of expression
    scanf("%d",&Q[i]);
               ^
Main.java:33: error: <identifier> expected
int binarySearch(int *A,int key){
                    ^
Main.java:33: error: class, interface, enum, or record expected
int binarySearch(int *A,int key){
                        ^
Main.java:37: error: class, interface, enum, or record expected
  if(key == A[(0+n)/2]) {
  ^
Main.java:41: error: class, interface, enum, or record expected
      k++;
      ^
Main.java:42: error: class, interface, enum, or record expected
      flug = 1;
      ^
Main.java:44: error: class, interface, enum, or record expected
      return 1;
      ^
Main.java:45: error: class, interface, enum, or record expected
    }
    ^
Main.java:49: error: class, interface, enum, or record expected
    A[m] = key;
    ^
Main.java:51: error: class, interface, enum, or record expected
    for(i=0; i<m; i++){
    ^
Main.java:51: error: class, interface, enum, or record expected
    for(i=0; i<m; i++){
             ^
Main.java:51: error: class, interface, enum, or record expected
    for(i=0; i<m; i++){
                  ^
Main.java:53: error: class, interface, enum, or record expected
	for(j=0;j < n;j++){
	        ^
Main.java:53: error: class, interface, enum, or record expected
	for(j=0;j < n;j++){
	              ^
Main.java:57: error: class, interface, enum, or record expected
	  }
	  ^
Main.java:60: error: class, interface, enum, or record expected
	k++;
	^
Main.java:62: error: class, interface, enum, or record expected
	return 1;
	^
Main.java:63: error: class, interface, enum, or record expected
      }
      ^
Main.java:69: error: class, interface, enum, or record expected
     A[n] = key;
     ^
Main.java:70: error: class, interface, enum, or record expected
    for(i=m+1; i<n; i++){
    ^
Main.java:70: error: class, interface, enum, or record expected
    for(i=m+1; i<n; i++){
               ^
Main.java:70: error: class, interface, enum, or record expected
    for(i=m+1; i<n; i++){
                    ^
Main.java:72: error: class, interface, enum, or record expected
	for(j=0;j < n;j++){
	        ^
Main.java:72: error: class, interface, enum, or record expected
	for(j=0;j < n;j++){
	              ^
Main.java:76: error: class, interface, enum, or record expected
	  }
	  ^
Main.java:79: error: class, interface, enum, or record expected
	k++;
	^
Main.java:81: error: class, interface, enum, or record expected
	return 1;
	^
Main.java:82: error: class, interface, enum, or record expected
      }
      ^
Main.java:87: error: class, interface, enum, or record expected
}
^
38 errors