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

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N;

int main(){
    cin>>N;
    double a[N],ave,sum=0;
    rep(i,N){
        cin>>a[i];
        sum+=a[i];
    }
    ave=sum/N;
    int min=0,sa=10000000;
    rep(i,N){
        if(abs(ave-a[i])<sa){
            sa=abs(ave-a[i]);
            min=i;
        }
    }
    out(i);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: 'i' was not declared in this scope
   38 |     out(i);
      |         ^
a.cc:16:26: note: in definition of macro 'out'
   16 | #define out(str) cout << str << endl
      |                          ^~~
Language: Java

import java.util.Scanner;
 
class Main  {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
 
        double[] s = new double[n];
        double sum = 0;
        for (int i = 0; i < n ; i++){
            s[i] = sc.nextInt();
            sum += s[i];
        }
 
        double min = Math.abs(avg - s[0]*n);
        int idx = 0;
 
        for (int i = 1; i < n ; i++){
            double tmp = Math.abs(avg - s[i]*n);            
            if (tmp < min){
                min = tmp;
                idx = i;
            }
        }
 
        System.out.println(idx);
    }
}

Compiler output:
Main.java:15: error: cannot find symbol
        double min = Math.abs(avg - s[0]*n);
                              ^
  symbol:   variable avg
  location: class Main
Main.java:19: error: cannot find symbol
            double tmp = Math.abs(avg - s[i]*n);            
                                  ^
  symbol:   variable avg
  location: class Main
2 errors
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;


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

    int sum = accumulate(ALL(v), 0);
    int res = INT_MAX;
    int ans = 0;
    REP(i, n){
        if (abs(n*v[i]-sum)<res){
            res = abs(n*v[i]-sum);
            ans = i;
        }
    }

    cout << i;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:13: error: 'i' was not declared in this scope
   41 |     cout << i;
      |             ^
Language: C

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

int bin_search(int a[], int num,float key);

int main(){
  int N,i;	
  int sum = 0;
  float avr;
  int *a;
  scanf("%d",&N);
 
  a = (int *)calloc(N,sizeof(int));
  for(i = 0;i < N;i++){
  	scanf("%d",&a[i]);
    sum += a[i];
  }
  avr = sum / N;
  printf("%d\n",bin_search(a,N,avr));
  
  free(a);
  return 0;
}

int bin_search(int a[], int num,int key){
  int pc = 0;
  int pr = num-1;
  int tmp = 101;
  int disc;
  int min = 101;
  while(pc <= pr){
    disc = abs(a[pc] - key);
    if(min > disc) {
      min = disc;
	  tmp = pc;
    }
    if(min == disc){
	  if(tmp > pc){
	    min = disc;
	    tmp = pc;
	  }
	}
    pc++;
  }
  return tmp;
}

Compiler output:
main.c:25:5: error: conflicting types for 'bin_search'; have 'int(int *, int,  int)'
   25 | int bin_search(int a[], int num,int key){
      |     ^~~~~~~~~~
main.c:4:5: note: previous declaration of 'bin_search' with type 'int(int *, int,  float)'
    4 | int bin_search(int a[], int num,float key);
      |     ^~~~~~~~~~
Language: C

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

int bin_search(int a[], int num,int key);

int main(){
  int N,i;	
  int sum = 0;
  float avr;
  int *a;
  scanf("%d",&N);
 
  a = (int *)calloc(N,sizeof(int));
  for(i = 0;i < N;i++){
  	scanf("%d",&a[i]);
    sum += a[i];
  }
  avr = sum / N;
  printf("%d\n",bin_search(a,N,avr));
  
  free(a);
  return 0;
}

int bin_search(int a[], int num,float key){
  int pc = 0;
  int pr = num-1;
  int tmp = 101;
  int disc;
  int min = 101;
  while(pc <= pr){
    disc = abs(a[pc] - key);
    if(min > disc) {
      min = disc;
	  tmp = pc;
    }
    if(min == disc){
	  if(tmp > pc){
	    min = disc;
	    tmp = pc;
	  }
	}
    pc++;
  }
  return tmp;
}

Compiler output:
main.c:25:5: error: conflicting types for 'bin_search'; have 'int(int *, int,  float)'
   25 | int bin_search(int a[], int num,float key){
      |     ^~~~~~~~~~
main.c:4:5: note: previous declaration of 'bin_search' with type 'int(int *, int,  int)'
    4 | int bin_search(int a[], int num,int key);
      |     ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
double a[10005];
int main() {
	int n;
	int m;
	cin>>n;
	double sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&m);
		sum+=m;
		a[i]=m*n;
	}
	double ave = sum/n;
	//if((sum/n*n)!=sum)
	//	cout<<"0"<<endl;
//	else{
	int temp;
		for(int i=0;i<n;i++){
			if(abs(a[i]-sum)<minn){
				minn=abs(a[i]-sum);
				temp=i;
			}
		}
	cout<<temp<<endl;
//	}
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:42: error: 'minn' was not declared in this scope
   20 |                         if(abs(a[i]-sum)<minn){
      |                                          ^~~~
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf("%d",&n);

     for (i=0;i<n;i++){
          scanf("%d", &a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf("%d",nu);
      return(0);
      }

Compiler output:
main.c: In function 'main':
main.c:32:7: error: expected declaration or statement at end of input
   32 |       }
      |       ^
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf("%d",&n);

     for (i=0;i<n;i++){
          scanf("%d", &a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);
      return(0);
      }

         


Compiler output:
main.c: In function 'main':
main.c:30:14: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:30:15: error: expected expression before '%' token
   30 |       printf(“%d”,nu);
      |               ^
main.c:30:17: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:32:7: error: expected declaration or statement at end of input
   32 |       }
      |       ^
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf("%d",n);

     for (i=0;i<n;i++){
          scanf("%d", a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);
      return(0);
      }

         


Compiler output:
main.c: In function 'main':
main.c:30:14: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:30:15: error: expected expression before '%' token
   30 |       printf(“%d”,nu);
      |               ^
main.c:30:17: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:32:7: error: expected declaration or statement at end of input
   32 |       }
      |       ^
Language: C++

#include <stdio.h>

int main(void) {
	int n;
	int a[4096];
	int i,ttl, avg, idx, diff;
	
	scanf("%d", &n);
	
	ttl = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		ttl += a[i];
	}
	
	avg = ttl / n;
	
	idx = 0;
	diff = a[0];
	for (i = 0; i < n; i++) {
		if (diff > abs(avg - a[i])) {
			diff = abs(avg - a[i]);
			idx = i;
		}
	}
	
	printf("%d", idx);


}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:28: error: 'abs' was not declared in this scope
   21 |                 if (diff > abs(avg - a[i])) {
      |                            ^~~
Language: C++

#include <stdio.h>

int main(void) {
	int n;
	int a[4096];
	int i,ttl, avg, idx, diff;
	
	scanf("%d", &n);
	
	ttl = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		ttl += [i];
	}
	
	avg = ttl / n;
	
	idx = 0;
	diff = a[0];
	for (i = 0; i < n; i++) {
		if (diff > abs(avg - a[i])) {
			diff = abs(avg - a[i]);
			idx = i;
		}
	}
	
	printf("%d", idx);


}

Compiler output:
a.cc: In lambda function:
a.cc:13:27: error: expected '{' before ';' token
   13 |                 ttl += [i];
      |                           ^
a.cc: In function 'int main()':
a.cc:13:21: error: no match for 'operator+=' (operand types are 'int' and 'main()::<lambda()>')
   13 |                 ttl += [i];
      |                 ~~~~^~~~~~
a.cc:21:28: error: 'abs' was not declared in this scope
   21 |                 if (diff > abs(avg - a[i])) {
      |                            ^~~
Language: C++

#include <stdio.h>

int main(void) {
	int n;
	int a[4096];
	int i,ttl, avg, idx, diff;
	
	scanf("%d", &n);
	
	ttl = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i];)
		ttl += [i];
	}
	
	avg = ttl / n;
	
	idx = 0;
	diff = a[0];
	for (i = 0; i < n; i++) {
		if (diff > abs(avg - a[i])) {
			diff = abs(avg - a[i]);
			idx = i;
		}
	}
	
	printf("%d", idx);


}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:34: error: expected ')' before ';' token
   12 |                 scanf("%d", &a[i];)
      |                      ~           ^
      |                                  )
a.cc:12:35: error: expected primary-expression before ')' token
   12 |                 scanf("%d", &a[i];)
      |                                   ^
a.cc:21:28: error: 'abs' was not declared in this scope
   21 |                 if (diff > abs(avg - a[i])) {
      |                            ^~~
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,&n);

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);
      return(0);
      }

         

Compiler output:
main.c: In function 'main':
main.c:9:11: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,&n);
      |           ^~~~~~~~
main.c:9:12: error: expected expression before '%' token
    9 |     scanf(“%d”,&n);
      |            ^
main.c:9:14: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,&n);
      |                     ^~~~~~~~
main.c:12:17: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                 ^~~~~~~~
main.c:12:18: error: expected expression before '%' token
   12 |           scanf(“%d”,a[i]);
      |                  ^
main.c:12:20: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                           ^~~~~~~~
main.c:30:14: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:30:15: error: expected expression before '%' token
   30 |       printf(“%d”,nu);
      |               ^
main.c:30:17: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:32:7: error: expected declaration or statement at end of input
   32 |       }
      |       ^
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,&n);

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     /*ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);*\
      return(0);
      }

         

Compiler output:
main.c: In function 'main':
main.c:9:11: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,&n);
      |           ^~~~~~~~
main.c:9:12: error: expected expression before '%' token
    9 |     scanf(“%d”,&n);
      |            ^
main.c:9:14: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,&n);
      |                     ^~~~~~~~
main.c:12:17: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                 ^~~~~~~~
main.c:12:18: error: expected expression before '%' token
   12 |           scanf(“%d”,a[i]);
      |                  ^
main.c:12:20: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                           ^~~~~~~~
main.c:15:6: error: unterminated comment
   15 |      /*ave = ave/n;
      |      ^
main.c:14:6: error: expected declaration or statement at end of input
   14 |      }
      |      ^
Language: C

#include <stdio.h>
int main(void){
  int a,b[100],i,c,
    scanf("%d",&a);
  for(i=0,i<100,i++){
	b[i]=0;
  }
  for(i=0,i<a,i++){
    scanf("%d",b[i]);
  }
  b[100]\a=c
  printf("%d",b[100]>b[100]-c);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:11: error: expected declaration specifiers or '...' before string constant
    4 |     scanf("%d",&a);
      |           ^~~~
main.c:4:16: error: expected declaration specifiers or '...' before '&' token
    4 |     scanf("%d",&a);
      |                ^
main.c:5:20: error: expected ';' before ')' token
    5 |   for(i=0,i<100,i++){
      |                    ^
      |                    ;
main.c:5:20: error: expected expression before ')' token
main.c:8:18: error: expected ';' before ')' token
    8 |   for(i=0,i<a,i++){
      |                  ^
      |                  ;
main.c:8:18: error: expected expression before ')' token
main.c:11:9: error: stray '\' in program
   11 |   b[100]\a=c
      |         ^
main.c:11:9: error: expected ';' before 'a'
   11 |   b[100]\a=c
      |         ^~
      |         ;
Language: C++

#include <bits/stdc++.h>
#define abs(x) (x>0?x:-x)
int main( ) {
int n, a[101], sum, ans;
for (int i=0; i<n; ++i) std::cin >> a[i], sum += s[i];
double av = (double)sum/n;
for (int i=1; i<n; ++i) if ( abs(a[ans]-av) > abs(a[i]-av) ) ans =i;
std::cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:50: error: 's' was not declared in this scope
    5 | for (int i=0; i<n; ++i) std::cin >> a[i], sum += s[i];
      |                                                  ^
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,&n);

     for (i=0;i<n;i++){
          scanf(“%d”,&a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);
      return(0);
      }

         

Compiler output:
main.c: In function 'main':
main.c:9:11: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,&n);
      |           ^~~~~~~~
main.c:9:12: error: expected expression before '%' token
    9 |     scanf(“%d”,&n);
      |            ^
main.c:9:14: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,&n);
      |                     ^~~~~~~~
main.c:12:17: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,&a[i]);
      |                 ^~~~~~~~
main.c:12:18: error: expected expression before '%' token
   12 |           scanf(“%d”,&a[i]);
      |                  ^
main.c:12:20: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,&a[i]);
      |                           ^~~~~~~~
main.c:30:14: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:30:15: error: expected expression before '%' token
   30 |       printf(“%d”,nu);
      |               ^
main.c:30:17: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:32:7: error: expected declaration or statement at end of input
   32 |       }
      |       ^
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,n);

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);
      return(0);
      }

         

Compiler output:
main.c: In function 'main':
main.c:9:11: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,n);
      |           ^~~~~~~~
main.c:9:12: error: expected expression before '%' token
    9 |     scanf(“%d”,n);
      |            ^
main.c:9:14: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,n);
      |                     ^~~~~~~~
main.c:12:17: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                 ^~~~~~~~
main.c:12:18: error: expected expression before '%' token
   12 |           scanf(“%d”,a[i]);
      |                  ^
main.c:12:20: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                           ^~~~~~~~
main.c:30:14: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:30:15: error: expected expression before '%' token
   30 |       printf(“%d”,nu);
      |               ^
main.c:30:17: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:32:7: error: expected declaration or statement at end of input
   32 |       }
      |       ^
Language: C

#include<stdio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,n);

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);
      return(0);
      }

 

Compiler output:
main.c: In function 'main':
main.c:9:11: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,n);
      |           ^~~~~~~~
main.c:9:12: error: expected expression before '%' token
    9 |     scanf(“%d”,n);
      |            ^
main.c:9:14: error: stray '\342' in program
    9 |     scanf(<U+201C>%d<U+201D>,n);
      |                     ^~~~~~~~
main.c:12:17: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                 ^~~~~~~~
main.c:12:18: error: expected expression before '%' token
   12 |           scanf(“%d”,a[i]);
      |                  ^
main.c:12:20: error: stray '\342' in program
   12 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                           ^~~~~~~~
main.c:30:14: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:30:15: error: expected expression before '%' token
   30 |       printf(“%d”,nu);
      |               ^
main.c:30:17: error: stray '\342' in program
   30 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:32:7: error: expected declaration or statement at end of input
   32 |       }
      |       ^
Language: C

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

int main(void)
{
	int i,n,ans;
	int a[102];
	double ab[102];
	long int sum = 0;
	double small;
	double ave;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d ", &a[i]);
		sum += a[i];
	}
	
	ave = sum/n;
	
	for (i = 0; i < n; i++){
		ab[i] = fabs(ave - a[i]);
	}
	
	small = ab[0];
	ans = 0;
	
	for (i = 0; i < n; i++){
		if(ab[i] < small){
			small = ab[i];
			ans = i;
	}
	
	printf("%d", ans);
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:38:1: error: expected declaration or statement at end of input
   38 | }
      | ^
Language: C


int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,n);

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      }
      printf(“%d”,nu);
      return(0);
      }

         

Compiler output:
main.c: In function 'main':
main.c:8:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    8 |     scanf(“%d”,n);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | 
main.c:8:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    8 |     scanf(“%d”,n);
      |     ^~~~~
main.c:8:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:8:11: error: stray '\342' in program
    8 |     scanf(<U+201C>%d<U+201D>,n);
      |           ^~~~~~~~
main.c:8:12: error: expected expression before '%' token
    8 |     scanf(“%d”,n);
      |            ^
main.c:8:14: error: stray '\342' in program
    8 |     scanf(<U+201C>%d<U+201D>,n);
      |                     ^~~~~~~~
main.c:11:17: error: stray '\342' in program
   11 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                 ^~~~~~~~
main.c:11:18: error: expected expression before '%' token
   11 |           scanf(“%d”,a[i]);
      |                  ^
main.c:11:20: error: stray '\342' in program
   11 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                           ^~~~~~~~
main.c:29:7: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   29 |       printf(“%d”,nu);
      |       ^~~~~~
main.c:29:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:29:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:29:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:29:14: error: stray '\342' in program
   29 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:29:15: error: expected expression before '%' token
   29 |       printf(“%d”,nu);
      |               ^
main.c:29:17: error: stray '\342' in program
   29 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:31:7: error: expected declaration or statement at end of input
   31 |       }
      |       ^
Language: C


int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,n);

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      printf(“%d”,nu);
      return(0);
      }

         

Compiler output:
main.c: In function 'main':
main.c:8:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    8 |     scanf(“%d”,n);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | 
main.c:8:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    8 |     scanf(“%d”,n);
      |     ^~~~~
main.c:8:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:8:11: error: stray '\342' in program
    8 |     scanf(<U+201C>%d<U+201D>,n);
      |           ^~~~~~~~
main.c:8:12: error: expected expression before '%' token
    8 |     scanf(“%d”,n);
      |            ^
main.c:8:14: error: stray '\342' in program
    8 |     scanf(<U+201C>%d<U+201D>,n);
      |                     ^~~~~~~~
main.c:11:17: error: stray '\342' in program
   11 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                 ^~~~~~~~
main.c:11:18: error: expected expression before '%' token
   11 |           scanf(“%d”,a[i]);
      |                  ^
main.c:11:20: error: stray '\342' in program
   11 |           scanf(<U+201C>%d<U+201D>,a[i]);
      |                           ^~~~~~~~
main.c:28:7: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   28 |       printf(“%d”,nu);
      |       ^~~~~~
main.c:28:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:28:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:28:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:28:14: error: stray '\342' in program
   28 |       printf(<U+201C>%d<U+201D>,nu);
      |              ^~~~~~~~
main.c:28:15: error: expected expression before '%' token
   28 |       printf(“%d”,nu);
      |               ^
main.c:28:17: error: stray '\342' in program
   28 |       printf(<U+201C>%d<U+201D>,nu);
      |                        ^~~~~~~~
main.c:30:7: error: expected declaration or statement at end of input
   30 |       }
      |       ^
main.c:30:7: error: expected declaration or statement at end of input
Language: C

#include<studio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;
    
    scanf(“%d”,n);

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     ave = ave/n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      printf(“%d”,nu);
      return(0);
      }

         

Compiler output:
main.c:1:9: fatal error: studio.h: No such file or directory
    1 | #include<studio.h>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include<studio.h>

int main(void)
{
     int nu,n,i,z,k;
     int a[101];
     float ave,sa,min;

     for (i=0;i<n;i++){
          scanf(“%d”,a[i]);
          ave+=a[i];
     }
     ave /=n;
     z=n-1;
     for(i=0;((i<n)||(i>z));i++){
     if(a[z]>=a[i]){
           sa=a[i]-ave;
           k=i;
      }
      else{
              sa=a[z]-ave;
              k=z;
      }
      if(sa<=0){
      if((sa==min)||(k <nu)){nu=k;}
      else{min=sa;nu=k;}
      printf(“%d”,nu);
      return(0);
      }

         

Compiler output:
main.c:1:9: fatal error: studio.h: No such file or directory
    1 | #include<studio.h>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int N;
int a[110]
int sum,minim;

int main()
{
	cin >> N;
	sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}
	//ave = sum / N;
	minim = 1000 * N;
	for (int i = 0; i < N; i++) {
		if (minim > abs(sum - a[i] * N)) {
			minim = abs(sum - a[i] * N);
		}
	}
	
	for (int i = 0; i < N; i++) {
		if (minim == abs(sum - a[i] * N)) {
			cout << i << endl;
			//system("pause");
			return 0;
		}
	}

    return 0;
}


Compiler output:
a.cc:7:1: error: expected initializer before 'int'
    7 | int sum,minim;
      | ^~~
a.cc: In function 'int main()':
a.cc:12:9: error: 'sum' was not declared in this scope
   12 |         sum = 0;
      |         ^~~
a.cc:14:24: error: 'a' was not declared in this scope
   14 |                 cin >> a[i];
      |                        ^
a.cc:18:9: error: 'minim' was not declared in this scope
   18 |         minim = 1000 * N;
      |         ^~~~~
a.cc:20:39: error: 'a' was not declared in this scope
   20 |                 if (minim > abs(sum - a[i] * N)) {
      |                                       ^
a.cc:26:40: error: 'a' was not declared in this scope
   26 |                 if (minim == abs(sum - a[i] * N)) {
      |                                        ^
Language: C++

#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n=0;
  cin>>n;
  int a[n];
  double sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  double ave=sum/n;
  for(int i=0;i<n;i++){
    if(a[i]==ave){
      cout<<i<<endl;
      exit(0);
    }
  }
  double b[n]
  for(int i=0;i<n;i++){
    b[i]=abs(ave-a[i]);
  }
  double min=b[0];
  int min_num=0;
  for(int i=0;i<n;i++){
    if(min>b[i]){
      min=b[i];
      min_num=i;
    }
  }
  cout<<min_num<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:3: error: expected initializer before 'for'
   23 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:23:15: error: 'i' was not declared in this scope
   23 |   for(int i=0;i<n;i++){
      |               ^
a.cc:26:14: error: 'b' was not declared in this scope
   26 |   double min=b[0];
      |              ^
Language: C++

int main(int , char*[])
{
        int num;
        float ave, min, sum = 0.0;
        std::vector<int> frames;
        std::cin >> num;
        frames.resize(num);
        for (int i = 0; i < num; i++) {
                int tmp;
                std::cin >> tmp;
                frames[i] = tmp;
                sum += frames[i];
        }
        ave = sum / num;
        min = FLT_MAX;
        int ret = 0;
        for (int i = 0; i < num; i++) {
                float diff = frames[i] - ave;
                if (diff < 0)
                        diff = 0 - diff;
                if (min > diff) {
                        min = diff;
                        ret = i;
                }
        }
        std::cout << ret << std::endl;

        return ret;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:5:14: error: 'vector' is not a member of 'std'
    5 |         std::vector<int> frames;
      |              ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int main(int , char*[])
a.cc:5:21: error: expected primary-expression before 'int'
    5 |         std::vector<int> frames;
      |                     ^~~
a.cc:6:14: error: 'cin' is not a member of 'std'
    6 |         std::cin >> num;
      |              ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int main(int , char*[])
a.cc:7:9: error: 'frames' was not declared in this scope
    7 |         frames.resize(num);
      |         ^~~~~~
a.cc:10:22: error: 'cin' is not a member of 'std'
   10 |                 std::cin >> tmp;
      |                      ^~~
a.cc:10:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:15: error: 'FLT_MAX' was not declared in this scope
   15 |         min = FLT_MAX;
      |               ^~~~~~~
a.cc:1:1: note: 'FLT_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
  +++ |+#include <cfloat>
    1 | int main(int , char*[])
a.cc:26:14: error: 'cout' is not a member of 'std'
   26 |         std::cout << ret << std::endl;
      |              ^~~~
a.cc:26:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:34: error: 'endl' is not a member of 'std'
   26 |         std::cout << ret << std::endl;
      |                                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int main(int , char*[])
Language: C++

#include <stdio.h>

int main(void){
int N;
int a[100];
double avg;
int sm;

scanf("%d", &N);

for(int i=0; i<N; i++){
scanf("%d", &a[i]);
}
for(int i=0; i<N; i++){
avg+=a[i];
}
avg/=N;

sa=(int)avg;
printf("%d", sa);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:1: error: 'sa' was not declared in this scope; did you mean 'sm'?
   19 | sa=(int)avg;
      | ^~
      | sm
Language: C++

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

int main(){int a,cou=0,ans,ans2=0(
                float ave=0,sa,p,q;
                vector<int> x(a);vector<int> y(a);
                cin>>a;
                for(int i=0;i<a;i++){
                    cin>>x[i];y[i]=x[i];cou+=x[i];
                }
                sort(y.begin(),y.end());
                ave=cou/a;
                sa=ave-y[0];
                for(int i=1;i<a;i++){
                     if(sa=0){ans=y[i];break;}
                     else if(sa<0){
                           p=ave-y[i-1];
                           q=y[i]-ave;
                             if(p>q){ans=y[i];break;}
                             else if(q>p){ans=y[i-1];break;}
                         else{ans=y[i];ans2=y[i-1];break;}
                      }
                     else{sa=ave-y[i];}
                 }
                 for(int i=0;i<a;i++){
                     if(ans==x[i]||ans2==x[i]){
                        cout<<i;return 0;
                     }
                 }
}
                      
                        
                


Compiler output:
a.cc: In function 'int main()':
a.cc:5:17: error: expected primary-expression before 'float'
    5 |                 float ave=0,sa,p,q;
      |                 ^~~~~
a.cc:5:29: error: 'sa' was not declared in this scope; did you mean 'a'?
    5 |                 float ave=0,sa,p,q;
      |                             ^~
      |                             a
a.cc:5:32: error: 'p' was not declared in this scope
    5 |                 float ave=0,sa,p,q;
      |                                ^
a.cc:5:34: error: 'q' was not declared in this scope
    5 |                 float ave=0,sa,p,q;
      |                                  ^
a.cc:12:17: error: 'ave' was not declared in this scope
   12 |                 ave=cou/a;
      |                 ^~~
Language: C++

#include <iostream>
#include <cstdio> 
#include <cstring>
#include <cmath>
#include <algorithm>
#define MAXN 100+10
using namespace std;
int main (void)
{
	int n;
	int a[MAXN];
	cin>>n;
	double sum = 0;
	for(int i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	sum/=(double) n;
	double min = 1e9;
	int t;
	for(int i=0;i<n;i++)
	{
		if(fabs(a[i]-sum)<min)
		{
			min = fabs(a[i]-sum);
			t = i;
		}
	}
	cout<<t<<endl;
	return 0;
}#include <iostream>
#include <cstdio> 
#include <cstring>
#include <cmath>
#include <algorithm>
#define MAXN 100+10
using namespace std;
int main (void)
{
	int n;
	int a[MAXN];
	cin>>n;
	double sum = 0;
	for(int i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	sum/=(double) n;
	double min = 1e9;
	int t;
	for(int i=0;i<n;i++)
	{
		if(fabs(a[i]-sum)<min)
		{
			min = fabs(a[i]-sum);
			t = i;
		}
	}
	cout<<t<<endl;
	return 0;
}

Compiler output:
a.cc:29:2: error: stray '#' in program
   29 | }#include <iostream>
      |  ^
a.cc:29:3: error: 'include' does not name a type
   29 | }#include <iostream>
      |   ^~~~~~~
a.cc:36:5: error: redefinition of 'int main()'
   36 | int main (void)
      |     ^~~~
a.cc:8:5: note: 'int main()' previously defined here
    8 | int main (void)
      |     ^~~~
Language: C++

#include <iostream>
#include <cstdio> 
#include <cstring>
#include <algorithm>
#define MAXN 100+10
using namespace std;
int main (void)
{
	int n;
	int a[MAXN];
	cin>>n;
	double sum = 0;
	for(int i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	sum/=(double) n;
	double min = 1e9;
	int t;
	for(int i=0;i<n;i++)
	{
		if(fabs(a[i]-sum)<min)
		{
			min = fabs(a[i]-sum);
			t = i;
		}
	}
	cout<<t<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:20: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   20 |                 if(fabs(a[i]-sum)<min)
      |                    ^~~~
      |                    labs
Language: C

#include <stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	float a[N];
	float alt[N];
	for (int i = 0; i < N; ++i)
	{
		scanf("%f",&a[i]);
	}
	int total=0;
	float average;
	for (int i = 0; i < N; ++i)
	{
		total += a[i];
	}
	average = total/N;
	for (int i = 0; i < N; ++i)
	{
		if(a[i]=<0){
			a[i] = (a[i]-average)*-1;
		}
		else{
			a[i] -= average;
		}
		alt[i] = a[i];
	}
	for (int i = N; i > 0; --i)
	{
		for (int j = 0; j < i; ++j)
		{
			if(a[j] < a[j-1]){
				int tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
			}
		}
	}
	int answer;
	for (int i = 0; i < N; ++i)
	{
		if(alt[i]==a[0]){
			answer = i;
		}	
	}
	printf("%d",answer);	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:21:25: error: expected expression before '<' token
   21 |                 if(a[i]=<0){
      |                         ^
Language: C

#include <stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	float a[N];
	float alt[N];
	for (int i = 0; i < N; ++i)
	{
		scanf("%f",&a[i]);
	}
	int total=0;
	float average;
	for (int i = 0; i < N; ++i)
	{
		total += a[i];
	}
	average = total/N;
	for (int i = 0; i < N; ++i)
	{
		if(a[i]=<0){
			a[i] = (a[i]-average)*-1;
		}
		else{
			a[i] -= average;
		}
		alt[i] = a[i];
	}
	for (int i = N; i > 0; --i)
	{
		for (int j = 0; j < i; ++j)
		{
			if(a[j] < a[j-1]){
				tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
			}
		}
	}
	int answer;
	for (int i = 0; i < N; ++i)
	{
		if(alt[i]==a[0]){
			answer = i;
		}	
	}
	printf("%d",answer);	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:21:25: error: expected expression before '<' token
   21 |                 if(a[i]=<0){
      |                         ^
main.c:34:33: error: 'tmp' undeclared (first use in this function)
   34 |                                 tmp = a[j];
      |                                 ^~~
main.c:34:33: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

// Contest.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include "pch.h"
#include <iostream>
#include <vector>
using namespace std;
vector<int> vc;
int n;
int num;
double sum;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> num;
		sum += num;
		vc.push_back(num);
		
	}
	double average = sum / n;
	for (int i = 0; i < vc.size(); i++)
	{
		if (vc[i]<average) {
			cout << vc[i] << endl;
			break;
		}
	}
}




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

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

int main(){int a,cou=0,ans,ans2=0(
                double ave=0,sa,p,q;
                vector<int> x(a);vector<int> y(a);
                cin>>a;
                for(int i=0;i<a;i++){
                    cin>>x[i];y[i]=x[i];cou+=x[i];
                }
                sort(y.begin(),y.end());
                ave=cou/a;
                sa=ave-y[0];
                for(int i=1;i<a;i++){
                     if(sa=0){ans=y[i];break;}
                     else if(sa<0){
                           p=ave-y[i-1];
                           q=y[i]-ave;
                             if(p>q){ans=y[i];break;}
                             else if(q>p){ans=y[i-1];break;}
                         else{ans=y[i];ans2=y[i-1];break;}
                      }
                     else{sa=ave-y[i];}
                 }
                 for(int i=0;i<a;i++){
                     if(ans==x[i]||ans2==x[i]){
                        cout<<i;return 0;
                     }
                 }
}
                      
                        
                


Compiler output:
a.cc: In function 'int main()':
a.cc:5:17: error: expected primary-expression before 'double'
    5 |                 double ave=0,sa,p,q;
      |                 ^~~~~~
a.cc:5:30: error: 'sa' was not declared in this scope; did you mean 'a'?
    5 |                 double ave=0,sa,p,q;
      |                              ^~
      |                              a
a.cc:5:33: error: 'p' was not declared in this scope
    5 |                 double ave=0,sa,p,q;
      |                                 ^
a.cc:5:35: error: 'q' was not declared in this scope
    5 |                 double ave=0,sa,p,q;
      |                                   ^
a.cc:12:17: error: 'ave' was not declared in this scope
   12 |                 ave=cou/a;
      |                 ^~~
Language: C++

#include <iostream.h>
using namespace std;

#define swap(type,x,y) do{type t = x;x = y;y = t} while(0)

void bubble(int a[],int n);
int bin_search(int a[], int num,int key);

int main(){
  int N;	
  int sum = 0;
  cin >> N;
 
  int a[N];
  for(int i = 0;i < N;i++){
  	cin >> a[i];
    sum += a[i];
  }
  float avr = sum / N;
  
  bubble(a,N);
  cout << bin_serach(a,N,avr) << \n;
  
  return 0;
}

void bubble(int a[],int n){
  int j,k;
  for(j = 0;j < n-1;n++){
  	for(k = n-1;k > j;k--){
      if(a[k-1] > a[k])
        swap(int,a[k-1],a[k]);
    }
  }
}

int bin_search(int a[], int num,int key){
  int pc = 0;
  int pr = num-1;
  int tmp,disc;
  int min = 100;
  do{
    disc = a[pc] - key;
    if(min > disc) {
      min = disc;
      tmp = a[pc];
    }
    pc++;
  }while(pc <= pr);
  return tmp;
}

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

#include <iostream>
#include <algorithm>
#include <stdlib.h>

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)
#define INF 1e9

int i,n;

int main(void){
    cin>>n;
    int a[n];
    FOR(i,n)cin>>a[i];
    int ttl=0;
    FOR(i,n)ttl+=a[i];
    double ave=ttl/n;
    ave*=1000;
    ave=int(ave);
    FOR(i,n)a[i]*=1000;
    int dif[n];
    FOR(i,n){
        dif[i]=a[i]-ave;
        dif[i]=abs(dif[i]);
    }
    int ans=0,difmin=100001;
    FOR(i,n){
        if(dif[i]==0){
            ans=i;
            break;
        }
        else if(difmin>dif[i]){
            difmin=dif[i];
            ans=i;
        }
    }
    
    cout<<ans;
    return 0;
    
}






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

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

int main(){
double a,cou=0,ave=0,sa,ans,ans2=-1;p,q;
                vector<int> x(a);vector<int> y(a);
                cin>>a;
                for(int i=0;i<a;i++){
                    cin>>x[i];y[i]=x[i];cou+=x[i];
                }
                sort(y.begin(),y.end());
                ave=cou/a;
                sa=ave-y[0];
                for(int i=1;i<a;i++){
                     if(sa=0){ans=y[i];break;}
                     else if(sa<0){
                           p=ave-y[i-1];
                           q=y[i]-ave;
                             if(p>q){ans=y[i];break;}
                             else if(q>p){ans=y[i-1];break;}
                         else{ans=y[i];ans2=y[i-1];break;}
                     else{sa=ave-y[i];}
                 }
                 for(int i=0;i<a;i++){
                     if(ans==x[i]||ans2==x[i]){
                        cout<<i;return 0;
                     }
                 }
}
                      
                        
                



Compiler output:
a.cc: In function 'int main()':
a.cc:5:37: error: 'p' was not declared in this scope
    5 | double a,cou=0,ave=0,sa,ans,ans2=-1;p,q;
      |                                     ^
a.cc:5:39: error: 'q' was not declared in this scope
    5 | double a,cou=0,ave=0,sa,ans,ans2=-1;p,q;
      |                                       ^
a.cc:22:22: error: expected '}' before 'else'
   22 |                      else{sa=ave-y[i];}
      |                      ^~~~
a.cc:16:35: note: to match this '{'
   16 |                      else if(sa<0){
      |                                   ^
Language: C++

#include <bits/stdc++.h>
#include <cmath>  
using namespace std;
int main(){
int N;
int answer;
 int i;
flaot min=0;
cin>>N;
float sum=0;
vector<int> vec(500);
vector<float>vec2(500);
for(i=0;i<N;i++){
cin >>  vec.at(i);
sum=sum+vec.at(i);
}
sum=sum/N;
for(i=0;i<N;i++){
vec2.at(i)=abs(vec.at(i)-sum);
}
for(i=0;i<N;i++){
if(min<vec2.at(i)){
min=vec2.at(i);
}
}
for(i=0;i<N;i++){
if(min==vec2.at(i)){
answer = i;
min=min-1;
}
}
cout << answer;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:1: error: 'flaot' was not declared in this scope; did you mean 'float'?
    8 | flaot min=0;
      | ^~~~~
      | float
a.cc:22:15: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = float; _Alloc = std::allocator<float>; reference = float&; size_type = long unsigned int]'
   22 | if(min<vec2.at(i)){
      |        ~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = float; _Alloc = std::allocator<float>; reference = float&; size_type = long unsigned int]' declared here
 1180 |       at(size_type __n)
      |       ^~
a.cc:22:4: error: parse error in template argument list
   22 | if(min<vec2.at(i)){
      |    ^~~~~~~~~~~~~~
a.cc:22:18: error: cannot resolve overloaded function 'min' based on conversion to type 'bool'
   22 | if(min<vec2.at(i)){
      |                  ^
a.cc:23:14: error: overloaded function with no contextual type information
   23 | min=vec2.at(i);
      |              ^
a.cc:27:7: error: invalid operands of types '<unresolved overloaded function type>' and '__gnu_cxx::__alloc_traits<std::allocator<float>, float>::value_type' {aka 'float'} to binary 'operator=='
   27 | if(min==vec2.at(i)){
      |    ~~~^~~~~~~~~~~~
a.cc:29:8: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator-'
   29 | min=min-1;
      |     ~~~^~