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

#include <stdio.h>

int int_sort(const void* a, const void* b) {
  return *( int * )a - *( int * )b;
}

int main(void) {
	int T[100000];
	int S[50000];
	int i,j,k,n,q,t;

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

	scanf("%d\n", &q);
	for(i=0;i<q;i++) {
		scanf("%d", &S[i]);
	}
	
	qsort((void*)T, n, sizeof(T[0]), int_sort);
	qsort((void*)S, q, sizeof(S[0]), int_sort);
	
	i=j=k=0;
	while(i<n&&j<q) {
		if(T[i] == S[j]) {
			R[k] = T[i];
			i++;j++;k++;
		} else if(T[i] > S[j]) {
			j++;
		} else if(T[i] < S[j]) {
			i++;
		}
	}
	printf("%d\n", k);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:22:9: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration]
   22 |         qsort((void*)T, n, sizeof(T[0]), int_sort);
      |         ^~~~~
main.c:28:25: error: 'R' undeclared (first use in this function)
   28 |                         R[k] = T[i];
      |                         ^
main.c:28:25: note: each undeclared identifier is reported only once for each function it appears in
Language: C

include <stdio.h>
#define MAX 100000
int main(){
  int a,b,A[MAX],B[MAX],count=0,i,j;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&B[i]);
  }
  
  for(i=0;i<b;i++){
    for(j=0;j<a;j++){
      if(A[j]==B[i]){count++;break;}
      if(A[j]>B[i]){break;}
    }
  }
  printf("%d\n",count);
  return 0;
}

Compiler output:
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include <stdio.h>
      |         ^
Language: C

#include<stdio.h>
   
int main(){
    int S[100001],T[50001],U[10001];
    int i,j,lengh1,lengh2,count=0,count2=0;
      int key;
    scanf("%d",&lengh1);
    for(i=1;i<=lengh1;i++){
        scanf("%d",&S[i]);}
       
    scanf("%d",&lengh2);
    for(i=1;i<=lengh2;i++){
        scanf("%d",&T[i]);
    }
       
	
	for(i=1;i<lengh1;i++){
		for(j=lengh1;j>i;j--){
			if(S[j]<S[j-1]){
			key=S[j];
				S[j]=S[j-1];
				S[j-1]=key;
			}}}
	
    for(i=1;i<=lengh1;i++){
        for(j=1;j<=lengh2;j++){
            if(S[i]==T[j]){ 
                count++;
                U[count]=T[j];}
              }}
     
     count2=count;
     
    for(i=1;i<=count2;i++){
        for(j=count2;j!=i;j--{
            if(U[j]==U[i]){
                count--;
                break;}
        }}
 
    printf("%d\n",count);
        
       
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:35:30: error: expected ')' before '{' token
   35 |         for(j=count2;j!=i;j--{
      |            ~                 ^
      |                              )
main.c:39:10: error: expected expression before '}' token
   39 |         }}
      |          ^
Language: C

#include<stdio.h>
   
int main(){
    int S[100001],T[50001],U[10001];
    int i,j,lengh1,lengh2,count=0,count2=0,count3=0;
      int key;
    scanf("%d",&lengh1);
   
	for(i=1;i<=lengh1;i++){
        scanf("%d",&S[i]);}
       
    scanf("%d",&lengh2);
    for(i=1;i<=lengh2;i++){
        scanf("%d",&T[i]);
    }
       
	
	
    for(i=1;i<=lengh1;i++){
    	if(i>1 && S[i]<S[i-1]){
    		key=S[i];
				S[i]=S[i-1];
			S[i-1]=key;
count3=1;}
if(count3==1){    	
for(j=1;j<=lengh2;j++){
            if(key==T[j]){ 
                count++;
                U[count]=T[j];}
              }
}}
else if(count3==0){
for(j=1;j<=lengh2;j++){
            if(S[i]==T[j]){ 
                count++;
                U[count]=T[j];}
         }
count3=0;
}
     
     count2=count;
     
    for(i=1;i<=count2;i++){
        for(j=count2;j!=i;j--){
            if(U[j]==U[i]){
                count--;
                break;}
        }}
 
    printf("%d\n",count);
        
       
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:32:1: error: 'else' without a previous 'if'
   32 | else if(count3==0){
      | ^~~~
Language: C

#include<stdio.h>
   
int main(){
    int S[100001],T[50001],U[10001];
    int i,j,lengh1,lengh2,count=0,count2=0,count3;
      int key;
    scanf("%d",&lengh1);
   
	for(i=1;i<=lengh1;i++){
        scanf("%d",&S[i]);}
       
    scanf("%d",&lengh2);
    for(i=1;i<=lengh2;i++){
        scanf("%d",&T[i]);
    }
       
	
	/*for(i=1;i<lengh1;i++){
		for(j=lengh1;j>i;j--){
			if(S[j]<S[j-1]){
			key=S[j];
				S[j]=S[j-1];
				S[j-1]=key;
			}}}
	*/
    for(i=1;i<=lengh1+1;i++){
    	if(i>2 && S[i-1]<S[i-2]){
    		key=S[i-1];
				S[i-1]=S[i-2];
				S[i-2]=key;
    	}
    	if(i!=lengh+1){
    	for(j=1;j<=lengh2;j++){
            if(S[i]==T[j]){ 
                count++;
                U[count]=T[j];}
              }
    	}
    	}
     
     count2=count;
     
    for(i=1;i<=count2;i++){
        for(j=count2;j!=i;j--){
            if(U[j]==U[i]){
                count--;
                break;}
        }}
 
    printf("%d\n",count);
        
       
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:32:15: error: 'lengh' undeclared (first use in this function); did you mean 'lengh2'?
   32 |         if(i!=lengh+1){
      |               ^~~~~
      |               lengh2
main.c:32:15: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
   
int main(){
    int S[100001],T[50001],U[100001];
    int i,j,lengh1,lengh2,count=0,count2=0;
      
    scanf("%d",&lengh1);
    for(i=1;i<=lengh1;i++){
        scanf("%d",&S[i]);
    	if(i>1 S[i]==S[i-1]) i--;
    
    }
       
    scanf("%d",&lengh2);
    for(i=1;i<=lengh2;i++){
        scanf("%d",&T[i]);
    }
       
    for(i=1;i<=lengh1;i++){
        for(j=1;j<=lengh2;j++){
            if(S[i]==T[j]){ 
                count++;
                U[count]=T[j];}
              }}
     
     count2=count;
     
    for(i=1;i<=count2;i++){
        for(j=i+1;j<=count2;j++){
            if(U[j]==U[i]){
                count--;
                break;}
        }}
 
    printf("%d\n",count);
        
       
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:10:15: error: expected ')' before 'S'
   10 |         if(i>1 S[i]==S[i-1]) i--;
      |           ~   ^~
      |               )
Language: C

#include<stdio.h>

int main(){
  int i,j,n,q,S[10001],T[501],count=0,l,r,m;
  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 (j=0;j<q;j++){
    l = 0;
    r = n;
    while(left<right){
      m = (l+r)/2;
      if(l==r){
	break;
      }
      if (S[m]==T[j]){
	count++;
	break;
      }
      if (S[m]>T[j]){
	r = m;
      } else if(S[m]<T[j]){
	l = m+1;
      }
    }
  }

  printf("%d\n",count);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:17:11: error: 'left' undeclared (first use in this function)
   17 |     while(left<right){
      |           ^~~~
main.c:17:11: note: each undeclared identifier is reported only once for each function it appears in
main.c:17:16: error: 'right' undeclared (first use in this function)
   17 |     while(left<right){
      |                ^~~~~
Language: C

#include<stdio.h>

#define MAX1 100000
#define MAX2 50000

int main()
{
  int m,n,i,j;
  int s[MAX1],t[MAX2];
  int count=0;

  //ここからscan
  scanf("%d",&m);
  for(i=0;i<m;i++)
    {
      scanf("%d",&s[i]);
    }
  scanf("%d",&n);
  for(I=0;i<n;i++)
    {
      scanf("%d",&t[i]);
    }
  //ここまで

  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
	{
	  if(s[i]==t[j])
	    {
	      count+=1;
	      break;
	    }
	}
    }
  printf("%d",count);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:19:7: error: 'I' undeclared (first use in this function)
   19 |   for(I=0;i<n;i++)
      |       ^
main.c:19:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

include<stdio.h>
#define N 100000
#define M 50000
main()
{
  int s[N],t[M],i,q,n,l=0,j;
  
  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(j=0;j<n;j++){
      if(s[j]==t[i]){
	l++;
	break;
      }
  }
  }
 
  printf("%d\n",l);
  return 0;
}

Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
Language: C

  for(i = 0; i < q; i++){
    key = T[i];
    left = 0;
    right = n;
    
    while(left < right){
      mid = (left + right) / 2;
      
      if(key == S[mid]) count++;

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

Compiler output:
main.c:1:3: error: expected identifier or '(' before 'for'
    1 |   for(i = 0; i < q; i++){
      |   ^~~
main.c:1:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 |   for(i = 0; i < q; i++){
      |                ^
main.c:1:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    1 |   for(i = 0; i < q; i++){
      |                      ^~
Language: C

#include <stdio.h>
#define N 100000
#define T 50000

main()
{

  int i,j;
  int A[N],B[T];
  int n,t,left,right,mid,key=0;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&t);
  
  for(j = 0; j < t; j++){
    scanf("%d",&B[j]);
    left = 0;
    right = n;
    
    while(left < right){
      mid = (left + right)/2;
      
      if(B[j] == A[mid]){
	return mid;
      }
      
      if(B[j] > A[mid]){
	left = mid + 1;
      }
      
      else if(B[j] < A[mid]){
	right = mid;
      }
    }
    
    
    
    
  }
  

Compiler output:
main.c:5:1: error: return type defaults to 'int' [-Wimplicit-int]
    5 | main()
      | ^~~~
main.c: In function 'main':
main.c:44:3: error: expected declaration or statement at end of input
   44 |   }
      |   ^
Language: C

#include<stdio.h>

main(){
  int n,q,S[100000],T[50000],i,j,count=0;
  int left,mid,right;

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

  scanf("%d",&q);

  left = 0;
  right = q+1;

  for(j=0 ; j<q ; j++){
    sacnf("%d",&T[j]);

    while(left < right){
      mid = (left + right) / 2;
      if(T[j] == S[left]){
	count++;
	break;
      }
      else if(T[j] < S[mid]){
	right = mid;
      }
      else if(T[j] > S[mid]){
	left = mid + 1;
      }
    }
  }

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

  return 0;
}

Compiler output:
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | main(){
      | ^~~~
main.c: In function 'main':
main.c:16:5: error: implicit declaration of function 'sacnf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   16 |     sacnf("%d",&T[j]);
      |     ^~~~~
      |     scanf
Language: C

#include<stdio.h>
#include<string.h>
   
int main(){
  int S[10000];
  int T[500];
  int n,i,q,j,count=0,left,right,mid;

  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++){
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(T[i] == A[mid]){
	count++;
	break;
      }
      if(T[i] > A[mid]){
	left = mid + 1;
      }else if(T[i] < A[mid]){
	right = mid;
      }
      break;
    } 
  }
  
  printf("%d\n",count);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:24:18: error: 'A' undeclared (first use in this function)
   24 |       if(T[i] == A[mid]){
      |                  ^
main.c:24:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

include<stdio.h>
#define N 100000
#define M 50000


int main(void){
  int i, j, n, q, S[N], T[M], a, count=0, t;
  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<n; i++){
    j=0;
    a = S[i];
    T[q] = a;

    while(T[j] != a) j++;
    if(j < q){
      T[j] = -1;
      count++;
    }

  }
  printf("%d\n", count);
  return 0;
}

Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
Language: C

#include<stdio.h>
#define N 100000
#define M 50000


int main(void){
  int i, j, n, q, S[N], T[M], count=0, t;
  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<n; i++){
    j=0;
    T[q] = a;

    while(T[j] != S[i]) j++;
    if(j < q){
      T[j] = -1;
      count++;
    }

  }
  printf("%d\n", count);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:15:12: error: 'a' undeclared (first use in this function)
   15 |     T[q] = a;
      |            ^
main.c:15:12: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define N 10000
#define Q 500
main(){

  int s,t,c=0,i,j,m,r,l;
  int a[N],b[Q];
  scanf("%d",&s);
  for(i = 0; i < s; i++){
    scanf("%d",&a[i]);
  }
    scanf("%d",&t); 
   for(i = 0; i < t; i++){
      scanf("%d",&b[i]);
      r = a;
      l = 0;
      while(l <= right){
	m = (r + l) / 2;
	if(b[i] == a[m])
	  {
	    c++;
	    break;
	  }
	else if(b[i] > s[m]) l = m + 1;
	else r = m - 1;
      }
   }
printf("%d\n",c);
 return 0;
}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:15:9: error: assignment to 'int' from 'int *' makes integer from pointer without a cast [-Wint-conversion]
   15 |       r = a;
      |         ^
main.c:17:18: error: 'right' undeclared (first use in this function)
   17 |       while(l <= right){
      |                  ^~~~~
main.c:17:18: note: each undeclared identifier is reported only once for each function it appears in
main.c:24:25: error: subscripted value is neither array nor pointer nor vector
   24 |         else if(b[i] > s[m]) l = m + 1;
      |                         ^
Language: C

#include<stdio.h>
#define Max1 100000
#define Max2 50000
main(){
  int i;
  int n, q;
  int S[Max], T[mAx];
  int left, right, mid, count = 0, key;

  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]);
  }

return 0;

}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:9: error: 'Max' undeclared (first use in this function); did you mean 'Max1'?
    7 |   int S[Max], T[mAx];
      |         ^~~
      |         Max1
main.c:7:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:17: error: 'mAx' undeclared (first use in this function)
    7 |   int S[Max], T[mAx];
      |                 ^~~
Language: C

#include<stdio.h>
#define Max1 100000
#define Max2 50000
main(){
  int i;
  int n, q;
  int S[Max], T[mAx];
  int left, right, mid, count = 0, key;

  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]);
  }
printf("%d\n", count);
return 0;

}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:9: error: 'Max' undeclared (first use in this function); did you mean 'Max1'?
    7 |   int S[Max], T[mAx];
      |         ^~~
      |         Max1
main.c:7:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:17: error: 'mAx' undeclared (first use in this function)
    7 |   int S[Max], T[mAx];
      |                 ^~~
Language: C

#include<stdio.h>
#define Max1 100000
#define Max2 50000
main(){
  int i;
  int n, q;
  int S[Max], T[mAx];
  int left, right, mid, count = 0, key;

  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++){

    left = 0;

    right = n;

    key =  T[i];

    while(left<right){

      if((left + right)%2 == 0) mid = (left + right)/2;

      else  mid = ( left + right -1)/2;

      if(key == S[mid]){count++;
        break;
      }
}
}
printf("%d\n", count);
return 0;

}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:9: error: 'Max' undeclared (first use in this function); did you mean 'Max1'?
    7 |   int S[Max], T[mAx];
      |         ^~~
      |         Max1
main.c:7:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:17: error: 'mAx' undeclared (first use in this function)
    7 |   int S[Max], T[mAx];
      |                 ^~~
Language: C

#include<stdio.h>
#define Max 100000
#define mAx 50000
main(){
  int i;
  int n, q;
  int S[Max1], T[Max2];
  int left, right, mid, count = 0, key;

  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+1; i++){

    left = 0;

    right = n;

    key =  T[i];

    while(left<right){

      if((left + right)%2 == 0) mid = (left + right)/2;

      else  mid = ( left + right -1)/2;

      if(key == S[mid]){count++;
        break;
      }

      else if(key < S[mid])right = mid;

      else if(key > S[mid])left = mid+1;
    }
  }
  printf("%d\n", count);

  return 0;

}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:9: error: 'Max1' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |         ^~~~
      |         Max
main.c:7:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:18: error: 'Max2' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |                  ^~~~
      |                  Max
Language: C

#include<stdio.h>
#define Max 100000
#define mAx 50000
main(){
  int i;
  int n, q;
  int S[Max1], T[Max2];
  int left, right, mid, count = 0, key;

  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++){

    left = 0;

    right = n;

    key =  T[i];

    while(left<right){

      if((left + right)%2 == 0) mid = (left + right)/2;

      else  mid = ( left + right -1)/2;

      if(key == S[mid]){count++;
        break;
      }

      else if(key < S[mid])right = mid;

      else if(key > S[mid])left = mid+2;
    }
  }
  printf("%d\n", count);

  return 0;

}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:9: error: 'Max1' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |         ^~~~
      |         Max
main.c:7:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:18: error: 'Max2' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |                  ^~~~
      |                  Max
Language: C

#include<stdio.h>
#define Max 100000
#define mAx 50000
main(){
  int i;
  int n, q;
  int S[Max1], T[Max2];
  int left, right, mid, count = 0, key;

  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++){

    left = 0;

    right = n;

    key =  T[i];

    while(left<right){

      if((left + right)%2 == 0) mid = (left + right)/2;

      else  mid = ( left + right -1)/2;

      if(key == S[mid]){count++;
        break;
      }

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

      else if(key > S[mid])left = mid+1;
    }
  }
  printf("%d\n", count);

  return 0;

}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:9: error: 'Max1' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |         ^~~~
      |         Max
main.c:7:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:18: error: 'Max2' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |                  ^~~~
      |                  Max
Language: C

#include<stdio.h>
#define Max 100000
#define mAx 50000
main(){
  int i;
  int n, q;
  int S[Max1], T[Max2];
  int left, right, mid, count = 0, key;

  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++){

    left = 0;

    right = n;

    key =  T[i];

    while(left<right){

      if((left + right)%2 == 0) mid = (left + right)/2;

      else  mid = ( left + right -1)/2;

      if(key == S[mid]){count++;
        break;
      }

      else if(key < S[mid])right = mid;

      else if(key > S[mid])left = mid+1;
    }
  }
  printf("%d\n", count);

  return 0;

}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:7:9: error: 'Max1' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |         ^~~~
      |         Max
main.c:7:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:18: error: 'Max2' undeclared (first use in this function); did you mean 'Max'?
    7 |   int S[Max1], T[Max2];
      |                  ^~~~
      |                  Max
Language: C

#include<stdio.h>
#define SMAX 100000
#define TMAX 50000

main(){
  int i,j,n,q,count = 0;
  int S[SMAX],T[TMAX];
  int left,right,mid;
  
  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++){
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right)/2;
      if(S[j] == T[mid]){
	count++;
	break;
      }
      else if(S[j] > T[mid]) {
	left = mid + 1;
      }
      else{
	right = mid;
      }
    }
  
  printf("%d\n",count);
  
  return 0;
}

Compiler output:
main.c:5:1: error: return type defaults to 'int' [-Wimplicit-int]
    5 | main(){
      | ^~~~
main.c: In function 'main':
main.c:38:1: error: expected declaration or statement at end of input
   38 | }
      | ^
Language: C

#include<stdio.h>
#define SMAX 100000
#define TMAX 50000

main(){

  int i,j,n,q,count = 0;
  int S[SMAX],T[TMAX];
  int left,right,mid;
  
  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++){
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right)/2;
      if(S[i] == T[mid]){
	count++;
	break;
      }
      else if(S[i] > T[mid]) left = mid + 1;
      
      else if(S[i] < T[mid]) right = mid;
      }
    }
  }
  printf("%d\n",count);
  
  return 0;
}

Compiler output:
main.c:5:1: error: return type defaults to 'int' [-Wimplicit-int]
    5 | main(){
      | ^~~~
main.c:35:10: error: expected declaration specifiers or '...' before string constant
   35 |   printf("%d\n",count);
      |          ^~~~~~
main.c:35:17: error: unknown type name 'count'
   35 |   printf("%d\n",count);
      |                 ^~~~~
main.c:37:3: error: expected identifier or '(' before 'return'
   37 |   return 0;
      |   ^~~~~~
main.c:38:1: error: expected identifier or '(' before '}' token
   38 | }
      | ^
Language: C

#include<stdio.h>
 
 main(){
   
  int i;
  int j;
  int n;
  int m;
  int c;
  int key;
  int NUM[100001];
  int NUM[500001];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&NUM[i]);
     }
   scanf("%d",&m);
   
  for(i=0;i<m;i++){
    scanf("%d",&key);
 int left=0,right=n,mid;
    
   while(left<right){
      mid=(left+right)/2;
      if(NUM[mid]==key){
	c = c + 1;
    break;
      }
      else if(key<NUM[mid])
    right=mid;
      
    }
  }
  printf("%d\n",c);  
  return 0;
}

Compiler output:
main.c:3:2: error: return type defaults to 'int' [-Wimplicit-int]
    3 |  main(){
      |  ^~~~
main.c: In function 'main':
main.c:12:7: error: conflicting types for 'NUM'; have 'int[500001]'
   12 |   int NUM[500001];
      |       ^~~
main.c:11:7: note: previous declaration of 'NUM' with type 'int[100001]'
   11 |   int NUM[100001];
      |       ^~~
Language: C

#include<stdio.h>
 
 main(){
   
  int i;
  int j;
  int n;
  int m;
  int c;
  int key;
  int NUM[100001];
  int NUM[500001];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&NUM[i]);
     }
   scanf("%d",&m);
   
  for(i=0;i<m;i++){
    scanf("%d",&key);
 int left=0,right=n,mid;
    
   while(left<right){
      mid=(left+right)/2;
      if(NUM[mid]==key){
	c = c + 1;
    break;
      }
      else if(key<NUM[mid])
    right=mid;
      
    }
  }
  printf("%d\n",c);  
  retrun 0;
}

Compiler output:
main.c:3:2: error: return type defaults to 'int' [-Wimplicit-int]
    3 |  main(){
      |  ^~~~
main.c: In function 'main':
main.c:12:7: error: conflicting types for 'NUM'; have 'int[500001]'
   12 |   int NUM[500001];
      |       ^~~
main.c:11:7: note: previous declaration of 'NUM' with type 'int[100001]'
   11 |   int NUM[100001];
      |       ^~~
main.c:36:3: error: 'retrun' undeclared (first use in this function)
   36 |   retrun 0;
      |   ^~~~~~
main.c:36:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:36:9: error: expected ';' before numeric constant
   36 |   retrun 0;
      |         ^~
      |         ;
Language: C

#include<stdio.h>
 
int main(){
  int i, j, n, q, c=0, l, rt, m;
  int S[100001], T[50001];
 
  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++){
    l = 0;
    r = n;
    while(l < r){
      mid = (l + r)/2;
      if(S[m] == T[i]){
        c++;
        break;
      }
      else if(S[m] < T[i]) l = m+1;
      else  r = m;
    }
  }
  printf("%d\n",c);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:5: error: 'r' undeclared (first use in this function)
   18 |     r = n;
      |     ^
main.c:18:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:20:7: error: 'mid' undeclared (first use in this function)
   20 |       mid = (l + r)/2;
      |       ^~~
Language: C

#include<stdio.h>
  
int main(){
  int i, j, n, q, c=0, l, r, m;
  int S[100001], T[50001];
  
  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++){
    l = 0;
    r = n;
    while(l < r){
      mid = (l + r)/2;
      if(S[m] == T[i]){
        c++;
        break;
      }
      else if(S[m] < T[i]) l = m+1;
      else  r = m;
    }
  }
  printf("%d\n",c);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:20:7: error: 'mid' undeclared (first use in this function)
   20 |       mid = (l + r)/2;
      |       ^~~
main.c:20:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define N 100000
#define M 50000


int main(void){
  int i, n, q, S[N], T[M], left, mid, right, key, count;
  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]);
  left = 0;
  right = n;

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

    }
  }
  printf("%d\n", count);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:25:22: error: expected ';' before 'left'
   25 |    else(key > S[mid]) left = mid;
      |                      ^~~~~
      |                      ;
Language: C++

#include <iostream>
using namespace std;

int main(){
	int n;
	cin>>n;
	int *A=new int[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){
    	cin>>k;
    	if(*(upper_bound(A,A+n,k))==k)sum++;
    }
    cout<<sum<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:14: error: 'upper_bound' was not declared in this scope
   13 |         if(*(upper_bound(A,A+n,k))==k)sum++;
      |              ^~~~~~~~~~~
Language: C++

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

int main(){
	int n;
	cin>>n;
	int *A=new int[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){
    	cin>>k;
    	if(*(binary_search(A,A+n,k))==k)sum++;
    }
    cout<<sum<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: invalid type argument of unary '*' (have 'bool')
   14 |         if(*(binary_search(A,A+n,k))==k)sum++;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
	int n;
	cin>>n;
	int *A=new int[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){
    	cin>>k;
    	if(*((upper_bound(A,A+n,k))-1)==k)sum++;
    }
    cout<<sum<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:15: error: 'upper_bound' was not declared in this scope
   13 |         if(*((upper_bound(A,A+n,k))-1)==k)sum++;
      |               ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

bool binary_search(vector<int> v, int kay, bool is_sorted){
    if (is_sorted) sort(AAL(v));

    int left = 0;
    int right = SZ(v);
    int mid;
    while(left < right){
        mid = (left + right)/2;
        if (v[mid] == kay) return true;
        else if (kay < v[mid]) right = mid;
        else left = mid+1; 
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> v;
    int t;
    REP(_, n){cin >> t; v.PB(t);}

    cin >> n;
    int count = 0;
    REP(_, n){
        cin >> t;
        if (binary_search(v, t, true)) count++;
    }

    cout << count << endl;
}


Compiler output:
a.cc: In function 'bool binary_search(std::vector<int>, int, bool)':
a.cc:19:25: error: 'AAL' was not declared in this scope; did you mean 'ALL'?
   19 |     if (is_sorted) sort(AAL(v));
      |                         ^~~
      |                         ALL
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int in_array(int x;int n; int a[]){
    int *point;
    int pos;
    point＝lower_bound(a,a+n,x);
    pos=distance(a,point);
    return a[pos]==x ? 1:0;
}
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];
    int ans=0;
    for (int i=0; i<q; i++){
        cin >> t[i];
        ans+=in_arrray(t[i],n,s);
    }
    cout << ans << endl;
}
    




Compiler output:
a.cc:4:19: error: expected ')' before ';' token
    4 | int in_array(int x;int n; int a[]){
      |             ~     ^
      |                   )
a.cc:4:34: error: expected initializer before ')' token
    4 | int in_array(int x;int n; int a[]){
      |                                  ^
a.cc: In function 'int main()':
a.cc:24:14: error: 'in_arrray' was not declared in this scope; did you mean 'in_array'?
   24 |         ans+=in_arrray(t[i],n,s);
      |              ^~~~~~~~~
      |              in_array
Language: C++

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

int search(int);

int main(void){
	int n, q;
	cin >> n;
	int s[n];

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

	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		count += search(t[i]);
	}
	cout << count << endl;
}

int search(int h){
	int low = 0;
	int high = n;
	while(low <= high){
		int mid = (low + high)/2;
		if(t[i] == s[mid]){
			return 1;
		}
		else if(t[i] > s[mid]){
			low = mid+1;
		}
		else{
			high = mid-1;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int search(int)':
a.cc:31:20: error: 'n' was not declared in this scope
   31 |         int high = n;
      |                    ^
a.cc:34:20: error: 't' was not declared in this scope
   34 |                 if(t[i] == s[mid]){
      |                    ^
a.cc:34:22: error: 'i' was not declared in this scope
   34 |                 if(t[i] == s[mid]){
      |                      ^
a.cc:34:28: error: 's' was not declared in this scope
   34 |                 if(t[i] == s[mid]){
      |                            ^
Language: C++

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

int search(int, int);

int main(void){
	int n, q;
	cin >> n;
	int s[n];

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

	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		count += search(t[i], n);
	}
	cout << count << endl;
}

int search(int h, int a){
	int low = 0;
	int high = a;
	while(low <= high){
		int mid = (low + high)/2;
		if(t[i] == s[mid]){
			return 1;
		}
		else if(t[i] > s[mid]){
			low = mid+1;
		}
		else{
			high = mid-1;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int search(int, int)':
a.cc:34:20: error: 't' was not declared in this scope
   34 |                 if(t[i] == s[mid]){
      |                    ^
a.cc:34:22: error: 'i' was not declared in this scope
   34 |                 if(t[i] == s[mid]){
      |                      ^
a.cc:34:28: error: 's' was not declared in this scope
   34 |                 if(t[i] == s[mid]){
      |                            ^
Language: C++

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

int search(int, int);

int main(void){
	int n, q;
	cin >> n;
	int s[n];

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

	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		count += search(t[i], n);
	}
	cout << count << endl;
}

int search(int h, int a, int b[]){
	int low = 0;
	int high = a;
	while(low <= high){
		int mid = (low + high)/2;
		if(b[i] == s[mid]){
			return 1;
		}
		else if(b[i] > s[mid]){
			low = mid+1;
		}
		else{
			high = mid-1;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int search(int, int, int*)':
a.cc:34:22: error: 'i' was not declared in this scope
   34 |                 if(b[i] == s[mid]){
      |                      ^
a.cc:34:28: error: 's' was not declared in this scope
   34 |                 if(b[i] == s[mid]){
      |                            ^
Language: C++

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

int search(int, int);

int main(void){
	int n, q;
	cin >> n;
	int s[n];

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

	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		count += search(t[i], n);
	}
	cout << count << endl;
}

int search(int h, int a){
	int low = 0;
	int high = a;
	while(low <= high){
		int mid = (low + high)/2;
		if(h == s[mid]){
			return 1;
		}
		else if(h > s[mid]){
			low = mid+1;
		}
		else{
			high = mid-1;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int search(int, int)':
a.cc:34:25: error: 's' was not declared in this scope
   34 |                 if(h == s[mid]){
      |                         ^
Language: C++

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

int search(int, int, int);

int main(void){
	int n, q;
	cin >> n;
	int s[];

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

	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		count += search(t[i], n, s);
	}
	cout << count << endl;
}

int search(int h, int a, int b[]){
	int low = 0;
	int high = a;
	while(low <= high){
		int mid = (low + high)/2;
		if(h == s[mid]){
			return 1;
		}
		else if(h > s[mid]){
			low = mid+1;
		}
		else{
			high = mid-1;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: storage size of 's' isn't known
   11 |         int s[];
      |             ^
a.cc: In function 'int search(int, int, int*)':
a.cc:34:25: error: 's' was not declared in this scope
   34 |                 if(h == s[mid]){
      |                         ^
Language: C++

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

int search(int, int, int);

int main(void){
	int n, q;
	cin >> n;
	int s[] = {};

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

	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		count += search(t[i], n, s);
	}
	cout << count << endl;
}

int search(int h, int a, int b[]){
	int low = 0;
	int high = a;
	while(low <= high){
		int mid = (low + high)/2;
		if(h == s[mid]){
			return 1;
		}
		else if(h > s[mid]){
			low = mid+1;
		}
		else{
			high = mid-1;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int search(int, int, int*)':
a.cc:34:25: error: 's' was not declared in this scope
   34 |                 if(h == s[mid]){
      |                         ^
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of '_ForwardIterator std::search(_ForwardIterator, _ForwardIterator, const _Searcher&) [with _ForwardIterator = int; _Searcher = int [0]]':
a.cc:24:18:   required from here
   24 |                 count += search(t[i], n, s);
      |                          ~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4186:24: error: expression cannot be used as a function
 4186 |     { return __searcher(__first, __last).first; }
      |              ~~~~~~~~~~^~~~~~~~~~~~~~~~~
Language: C++

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

int search(int, int, int);

int main(void){
	int n, q;
	cin >> n;
	int s[] = {};

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

	for(int i = 0; i < q; i++){
		cin >> t[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		count += search(t[i], n, s);
	}
	cout << count << endl;
}

int search(int h, int a, int b[]){
	int low = 0;
	int high = a;
	while(low <= high){
		int mid = (low + high)/2;
		if(h == b[mid]){
			return 1;
		}
		else if(h > b[mid]){
			low = mid+1;
		}
		else{
			high = mid-1;
		}
	}
	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of '_ForwardIterator std::search(_ForwardIterator, _ForwardIterator, const _Searcher&) [with _ForwardIterator = int; _Searcher = int [0]]':
a.cc:24:18:   required from here
   24 |                 count += search(t[i], n, s);
      |                          ~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4186:24: error: expression cannot be used as a function
 4186 |     { return __searcher(__first, __last).first; }
      |              ~~~~~~~~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;
void Binary_Search(vector<int> &s,int x,int &c);

int main()
{
    ios::sync_with_stdio(false);
    int n,x;
    cin>> n;
    vector<int> s;
    for(int i = 0; i < n; i++)
    {
        cin>> x;
        s.push_back(x);
    }
    int p;
    cin>>p;
    int c = 0;
    for( i = 0; i < p; i++)
    {
        cin >> x;
        Binary_Search( s , x , c);
    }
    cout << c << endl;
    return 0;
}
void Binary_Search(vector<int> &s,int x ,int &c)
{
    int mid,start,last;
    last = s.size();
    start = 0;
    while(start < last)
    {
        mid = (start+last) / 2;
        if(s[mid] == x)
        {
            c++;
            break;
        }

        else
            if(s[mid] > x)
            last = mid;

        else if(s[mid] < x)
            start = mid+1;
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:23:10: error: 'i' was not declared in this scope
   23 |     for( i = 0; i < p; i++)
      |          ^
Language: C++

# coding: utf-8
# Your code here!
#二分探索の実装

N=int(input())
S=[int(i) for i in input().split()]
Q=int(input())
T=[int(i) for i in input().split()] 
C=0
a=0;b=0
for i in T:
    b=len(S)-1
    a=0
    while(a+1<b):
        c=((a+b)//2)
        if(S[c]>=i):
            b=c
        elif(S[c]<i):
            a=c
    if(S[a]==i or S[b]==i):
        C+=1
print(C);



Compiler output:
a.cc:1:3: error: invalid preprocessing directive #coding
    1 | # coding: utf-8
      |   ^~~~~~
a.cc:2:3: error: invalid preprocessing directive #Your
    2 | # Your code here!
      |   ^~~~
a.cc:3:2: error: invalid preprocessing directive #\U00004e8c\U00005206\U000063a2\U00007d22\U0000306e\U00005b9f\U000088c5
    3 | #二分探索の実装
      |  ^~~~~~~~~~~~~~
a.cc:5:1: error: 'N' does not name a type
    5 | N=int(input())
      | ^
a.cc:10:5: error: 'b' does not name a type
   10 | a=0;b=0
      |     ^
Language: C++

typedef struct {
    char name[100];
    int t;
} data;
   
data array[100001];
int head=0,tail=0;


int main(void){
	int N,q,i,sum=0,cnt=0;
	scanf("%d %d",&N,&q);
	for(i=0;i<N;i++){
		scanf("%s %d",array[i].name,&array[i].t);
	}
	while(cnt!=N){
		if(q<array[head].t){
			array[head].t=array[head].t-q;
			sum+=q;
			array[tail]=array[head];
			if(tail==N-1) tail=0;
			else tail++;
		}
		else if(array[head].t!=0){
			sum+=array[head].t;
			array[head].t=0;
			printf("%s %d\n",array[head].name,sum);
			cnt++;
		}
		if(head==N-1) head=0;
		else	head++;
	}
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'scanf' was not declared in this scope
   12 |         scanf("%d %d",&N,&q);
      |         ^~~~~
a.cc:27:25: error: 'printf' was not declared in this scope
   27 |                         printf("%s %d\n",array[head].name,sum);
      |                         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | typedef struct {
Language: C++

#include<iostream>
using namespace std;

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

    int count = 0;
    for (int i = 0; i < q; i++){
        n2 = n;
        while(1){
            n2 /= 2;
            if (T[i] == S[n2]){
                count++;
                break;
            }
            else if (T[i] > S[n2]) n2 = n2 * 3 / 2;
            else n2 = n2 / 2;
        }
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'n2' was not declared in this scope; did you mean 'n'?
   17 |         n2 = n;
      |         ^~
      |         n
Language: C++

#include<iostream>
using namespace std;

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

    int count = 0;
    for (int i = 0; i < q; i++){
        int left = 0;
        int right = n;
        for (int j = 0; j < loop+100; j++) {
            int x = left + right;
            if (T[i] == S[x]){
                count++;
                break;
            }
            else if (T[i] > S[x]) left = x;
            else right = x + 1;
        }
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:29: error: 'loop' was not declared in this scope
   19 |         for (int j = 0; j < loop+100; j++) {
      |                             ^~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> S(n);
  REP(i, n) cin >> S[i];

  int q;
  cin >> q;
  vector<int> T(q);
  REP(i, q) cin >> T[i];

  int ans = 0;

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

  cout << ans << endl;
}

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:7: error: 'mid' was not declared in this scope
   26 |       mid = (left + right) / 2;
      |       ^~~
a.cc: At global scope:
a.cc:40:1: error: expected unqualified-id before 'return'
   40 | return 0;
      | ^~~~~~
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

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

 int n,q;
 vector<int>s(n);
 vector<int>t(q);

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

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


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #Include; did you mean #include?
    1 | #Include<iostream>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:25:5: error: 'cin' was not declared in this scope
   25 |     cin>>n;
      |     ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<algorithm>
  +++ |+#include <iostream>
    4 | using namespace std;
Language: C++

// ConsoleApplication2.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <deque>

using namespace std;

int main(){
	int n;
	int s[100001];
	int t[50001];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s[i];
	}
	int q;
	cin >> q;
	int count = 0;
	for (int i = 0; i < q; i++){
		cin >> t[i];
	}
	for (int i = 0; i < q; i++){
		for (int j = 0; j < n; j++){
			if (t[i] == s[j]){
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

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

// ConsoleApplication2.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <deque>

using namespace std;

int main(){
	int n;
	int s[100001];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s[i];
	}
	int q;
	cin >> q;
	int count = 0;
	for (int i = 0; i < q; i++){
		int t;
		cin >> t;
		int left = 0, right = n;
		while (left < right){
			int mid = (left + right) / 2;
			if (s[mid] == t){
				count++;
				break;
			}
			else if (t < s[mid]){
				right = mid;
			}
			else{
				left = mid + 1;
			}
		}
	}
	cout << count << endl;
	return 0;
}

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