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

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    return 0;
    double n;
    cin >> n;
    int a[n];
    int ans = 0;
    REP(i,n){
        cin >> a[i];
        ans += a[i];
    }
    int some = ans/n;
    int min1 = INF,index=0;
    REP(i,n){
        if(min1>abs(a[i]-some)){
            min1 = abs(a[i]-some);
            index = i;
        }
    }
    COUT(index)
    return 0;
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:19:11: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   19 |     int a[n];
      |           ^
a.cc:19:11: error: could not convert 'n' from 'double' to 'long unsigned int'
   19 |     int a[n];
      |           ^
      |           |
      |           double
a.cc:19:11: error: size of array 'a' has non-integral type 'double'
a.cc:34:5: error: expected ';' before 'return'
   34 |     return 0;
      |     ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vector<vll> a(n, vll(2));
  long double avg = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i][0];
    avg += a[i][0];
    a[i][1] = i;
  }
  avg /= n;
  ll m = -1;
  sort(all(a));
  for (ll i = 0; i < n; i++) {
    if (a[i][0] == avg) {
      cout << a[i][1] << endl;
      return 0;
    }
    if (a[i][0] > avg) {
      while (i > 0 && a[i][0] == a[i - 1][0]) i--;
      m = i;
      break;
    }
  }
  if (m == 0) {
    cout << a[m][1] << endll
    return 0;
  }
  ll x = m - 1;
  while (x > 0 && a[x][0] == a[x - 1][0]) x--;
  if (a[m][0] - avg > avg - a[x][0]) cout << a[x][1] << endl;
  else cout << a[m][1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:24: error: 'endll' was not declared in this scope; did you mean 'endl'?
   40 |     cout << a[m][1] << endll
      |                        ^~~~~
      |                        endl
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vector<vll> a(n, vll(2));
  double avg = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i][0];
    avg += a[i][0];
    a[i][1] = i;
  }
  avg /= n;
  ll m = -1;
  sort(all(a));
  for (ll i = 0; i < n; i++) {
    if (a[i][0] == avg) {
      cout << a[i][1] << endl;
      return 0;
    }
    if (a[i][0] > avg) {
      while (i > 0 && a[i][0] == a[i - 1][0]) i--;
      memo = i;
      break;
    }
  }
  if (m == -1) {
    ll x = n - 1;
    while (x > 0 && a[x][0] == a[x - 1][0]) x--;
    cout << a[x][1] << endl;
  }
  else if (m == 0) cout << a[0][1] << endl;
  else {
    if (a[m][0] - avg < avg - a[m - 1][0]) cout << a[m][1] << endl;
    else if (a[m][0] - avg > avg - a[m - 1][0]) {
      ll x = m - 1;
      while (x > 0 && a[x][0] == a[x - 1][0]) x--;
      cout << a[x][1] << endl;
    }
    else {
      ll x = m - 1;
      while (x > 0 && a[x][0] == a[x - 1][0]) x--;
      cout << a[x][1] << endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:7: error: 'memo' was not declared in this scope
   35 |       memo = i;
      |       ^~~~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
int main()
{
  int n;
  
  scanf("%d",&n);
  int a[n];
  int i,sum=0;
  int num;
  int min=32000;
  for(i=0;i<n;++i)
  {
    scanf("%ld%ld",&a[i],&b[i]);
    sum+=a[i];
  }
  
  float avg=(float)sum/n;
  
  sort(a,a+n);
  for(i=0;i<n;++i)
  {
     if(min>(avg-a[i]))
     {
       min=avg-a[i];
       num=i;
     }
  }
  
    printf("%d",num);
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:27: error: 'b' was not declared in this scope
   15 |     scanf("%ld%ld",&a[i],&b[i]);
      |                           ^
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
int main()
{
  int n;
  
  scanf("%d",&n);
  int a[n];
  int i,sum=0;
  int num;
  int min=32000;
  for(i=0;i<n;++i)
  {
    scanf("%ld%ld",&a[i],&b[i]);
    sum+=a[i];
  }
  
  float avg=(float)sum/n;
  
  sort(a,a+n);
  for(i=0;i<n;++i)
  {
     if(min>abs(avg-a[i]))
     { min=abs(avg-a[i]);
       num=i;
     }
  }
  
    printf("%d",num);
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:27: error: 'b' was not declared in this scope
   15 |     scanf("%ld%ld",&a[i],&b[i]);
      |                           ^
Language: C++


#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	int n;
	cin >> n;
	vector<double> a(n);
	double sum = 0;
	rep(i, n){
		cin >> a[i];
		sum += a[i];
	}

	double k = sum / n;
	double mi = INT_MAX;
	int ans = 0;
	rep(i, n){
		if(mi > abs(a[i]-k)){
			mi = abs(a[i]-k);
			ans = i;
		}
	}
	cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:21: error: 'INT_MAX' was not declared in this scope
   26 |         double mi = INT_MAX;
      |                     ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <set>
  +++ |+#include <climits>
    7 | using namespace std;
Language: C++

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

int main() {
  int n, b, c = 100000000, r;
  cin >> n;
  long double a = 0.0, tmp = 10000;
  vector<int> v(n);
  rep(i, n){
    cin >> v[i];
    a += v[i];
  }
  a /= n;
  rep(i, n){
    if(tmp > abs(a-v[i]){
      tmp = abs(a-v[i]);
      r = i;
    }
  }
  cout << r << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:25: error: expected ')' before '{' token
   17 |     if(tmp > abs(a-v[i]){
      |       ~                 ^
      |                         )
a.cc:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  double mean = 0.0;
  vector <int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    mean += vec.at(i);
  }
  mean /= n;
  int dif = 100;
  int ans;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) >= mean) {
      if (dif > (vec.at(i)-mean)) {
        dif = vec.at(i) - mean;
        ans = i;
      }
    } else {
      if (dif > (mean-vec.at(i)) {
        dif = mean - vec.at(i);
        ans = i;
      }
    }
  }
          
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:33: error: expected ')' before '{' token
   23 |       if (dif > (mean-vec.at(i)) {
      |          ~                      ^~
      |                                 )
a.cc:27:5: error: expected primary-expression before '}' token
   27 |     }
      |     ^
Language: C

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

int main() {
  double n, a[2525], num, ans, plas, ave, i, min, sa;

  scanf("%lf", &n);

  for(num = 0;num < n;num++) {
    scanf("%lf", &[num]);
    plas = plas + a[num];
  }

  ave = plas / num;

  for(num = n - 1;num < 0;num--) {
    sa = a[num] - ave;
    if(sa <= min) {
      min = sa;
      i = num;
    }
  }

  printf("%d", (int)i);

  return 0;

}


Compiler output:
main.c: In function 'main':
main.c:10:19: error: expected expression before '[' token
   10 |     scanf("%lf", &[num]);
      |                   ^
main.c:11:20: error: array subscript is not an integer
   11 |     plas = plas + a[num];
      |                    ^
main.c:17:11: error: array subscript is not an integer
   17 |     sa = a[num] - ave;
      |           ^
Language: C

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

int main() {
  double n, a[2525], num, ans, plas, ave, i, min, sa;

  scanf("%lf", &n);

  for(num = 0;num < n;num++) {
    scanf("%lf", &a[num]);
    plas = plas + a[num];
  }

  ave = plas / num;

  for(num = n - 1;num < 0;num--) {
    sa = a[num] - ave;
    if(sa <= min) {
      min = sa;
      i = num;
    }
  }

  printf("%d", (int)i);

  return 0;

}


Compiler output:
main.c: In function 'main':
main.c:10:20: error: array subscript is not an integer
   10 |     scanf("%lf", &a[num]);
      |                    ^
main.c:11:20: error: array subscript is not an integer
   11 |     plas = plas + a[num];
      |                    ^
main.c:17:11: error: array subscript is not an integer
   17 |     sa = a[num] - ave;
      |           ^
Language: C

# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

average = 0
for i in range(n):
    average += a[i]
average = average / n

ans = 0
tmp = 10000
for i in range(n):
    if abs(a[i] - average) < abs(tmp - average):
        tmp = a[i]
        ans = i
print(ans)


Compiler output:
main.c:1:3: error: invalid preprocessing directive #-
    1 | # -*- coding: utf-8 -*-
      |   ^
main.c:2:1: warning: data definition has no type or storage class
    2 | n = int(input())
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:2:5: error: expected expression before 'int'
    2 | n = int(input())
      |     ^~~
Language: C++

#include <iostream>
#inlude <math.h>
using namespace std;

int main()
{
  int n;
  cin>>n;
  int a[100];
  int sum;
  int i=0;
  while(i<n)
  {
    cin>>a[i];
    sum+=a[i];
   i++;
  }
  int ii=0;
  while(true)
  {
    i=0;
    while(i<n)
    {
      if(abs(n*a[i]-sum)==ii)
      {
        cout<<i<<endl;
        brake;
      }
      i++;
    }
    ii++;
  }
    return 0;
}



Compiler output:
a.cc:2:2: error: invalid preprocessing directive #inlude; did you mean #include?
    2 | #inlude <math.h>
      |  ^~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:27:9: error: 'brake' was not declared in this scope
   27 |         brake;
      |         ^~~~~
Language: C++

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

signed main() {
  int N;
cin >> N;

double heikin = 0;
vector<double> A(N);
for( int i = 0; i < N; i++ ){
cin >> A.at(i);
heikin += A.at(i);
}

heikin = heikin/ (double)N;

 sa = 1000;
int ans;
for( int i = 0; i < N; i++){
if( abs( heikin - A.at(i) ) < sa ){
ans = i;
sa = abs( heikin - A.at(i) );
}
}

cout << ans << endl;




            
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:2: error: 'sa' was not declared in this scope
   18 |  sa = 1000;
      |  ^~
Language: C++

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

signed main() {
  int N;
cin >> N;

double heikin = 0;
vector<int> A(N);
for( int i = 0; i < N; i++ ){
cin >> A.at(i);
heikin += A.at(i);
}

heikin = heikin/ (double)N;

int sa = 1000;
int ans;
for( int i = n - 1; i >= 0; i-- ){
if( abs( heikin - A.at(i) ) < sa ){
ans = i;
sa = abs( heikin - A.at(i) );
}
}

cout << ans << endl;




            
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:14: error: 'n' was not declared in this scope
   20 | for( int i = n - 1; i >= 0; i-- ){
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std
  int main(){
int n;
cin >>n;
vector<int>vec(n);
for(int i=0;i<n;i++){
cin >> vec.at(i);}
  int kouho;
  for(int i=0;i<n;i++){
  kouho+=vec.at(i);}
  kouho/=n;
  int thumb=10000;
  for(int i=0;i<n;i++){
    if(abs(kouho-vec.at(i))<thumb){thumb=kouho-vec.at(i);}
  }
  cout << thumb <<endl;
}

Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
    3 |   int main(){
      |   ~~~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,sum=0,ans;
  double m,ave;
  cin>>N;
  int a[N];
  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(i==0) m=abs(a[0]-ave);
    if(m>abs(ave-a[i])) ans=i;
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: lvalue required as left operand of assignment
   13 |   (double)ave=sum/N;
      |   ^~~~~~~~~~~
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double[] a = new double[n];
    double sum = 0;
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextDouble;
      sum += a[i];
    }
    double av = sum / (double)n;
    double t = 1000;
    for(int i = 0; i < n; i++) {
      t = Math.min(t, Math.abs(av - a[i]));
    }
    for(int i = 0; i < n; i++) {
      if(Math.abs(av - a[i]) == t) {
        System.out.println(i);
        break;
      }
    }
  }
}

Compiler output:
Main.java:10: error: cannot find symbol
      a[i] = sc.nextDouble;
               ^
  symbol:   variable nextDouble
  location: variable sc of type Scanner
1 error
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int a[n];
  int s = 0;
  REP(i,n){
    cin>>a[i];
    m += a[i];
    a[i] *= n;
  }
  vector<pair<int, int>> vec;
  REP(i,n){
    vec.push_back(make_pair(abs(a[i]-m), i));
  }
  sort(ALL(vec));
  
  int ans = vec[0].second;
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:5: error: 'm' was not declared in this scope
   58 |     m += a[i];
      |     ^
a.cc:63:38: error: 'm' was not declared in this scope
   63 |     vec.push_back(make_pair(abs(a[i]-m), i));
      |                                      ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  vector<pair<double,int>> num(n) ;
  double sum, ave ;
  
  REP(i,n){
    double a ;
    cin >> a ;
    sum += a ;
    num.at(i) = make_pair(a,i+1) ;
  }
  
  ave = sum/n ;
  
  REP(i,n){
    num.at(i).FI -= ave ;
  }
  
  sort(ALL(num)) ;
  
  cout << num.at(i).SE <<endl ;
  
    


  return 0 ;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:51:18: error: 'i' was not declared in this scope
   51 |   cout << num.at(i).SE <<endl ;
      |                  ^
Language: C++

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

int main()
{
 int n;
  cin >> n;
  vector<int> a;
  double ave = 0;
  for (int i = 0;i < n;i++)
  {
   int tmp;
    cin >> tmp;
    a.push_back(tmp);
    ave += tmp;
  }
  ave /= n;
  
  double mn = 1000;
  int idx = 0;
  for (int i = 0; i < n; i++)
  {
    if (abs(ave-a[i]) < mn)
    {
      mn = abs(ave-a[i]);
      idx = i;
    }
  }
  cout << i << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

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

    double ave = 0;
    for(int i = 0; i < n; i++){
        ave += a[i];
    }
    ave /= n;

    double mi[n];
    for(int i = 0; i < n; i++){
        mi[i] = abs(ave - a[i]);
    }

    int ans_min = 100000;
    for(int i = 0; i < n; i++){
        ans_min = min(ans_min, mi[i]);
    }

    for(int i = 0; i < n; i++){
        if(ans_min == mi[i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:22: error: no matching function for call to 'min(int&, double&)'
   30 |         ans_min = min(ans_min, mi[i]);
      |                   ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:30:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   30 |         ans_min = min(ans_min, mi[i]);
      |                   ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:30:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         ans_min = min(ans_min, mi[i]);
      |                   ~~~^~~~~~~~~~~~~~~~
Language: Java

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
      int N = reader.nextInt();
      double[] a = new double[N];
      double sum = 0.0;
      for (int i=0; i<N; i++) {
        a[i] = (double)reader.nextInt();
        sum += a[i];
      }
      double ave   = sum/(double)N;
      double min   = Double.MAX_VALUE;
      double minId = -1;
      for (int i=0; i<N; i++) {
        double tmp = Math.abs(a[i]-ave);
        if (tmp < min) {
          min = tmp;
          minId = i;
        }
      }
      System.out.println(i+1);
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Compiler output:
Main.java:27: error: cannot find symbol
      System.out.println(i+1);
                         ^
  symbol:   variable i
  location: class Main
1 error
Language: C

#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,a[100],r;
  double ave=0,min=1e9
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    ave+=a[i];
  }
  ave/=n;
  for(int i=0;i<n;i++)if(abs(a[i]-ave)<min){
    r=i;
    min=abs(a[i]-ave);
  }
  printf("%d",r);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:3: error: expected ',' or ';' before 'scanf'
    6 |   scanf("%d",&n);
      |   ^~~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,a[100],ave=0,min=1e9,r;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    ave+=a[i];
  }
  ave/=n;
  for(int i=0;i<n;i++)if(abs(a[i]-ave)<min){
    r=i;
    min=a[i]
  }
  printf("%d",r);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:13: error: expected ';' before '}' token
   13 |     min=a[i]
      |             ^
      |             ;
   14 |   }
      |   ~
Language: C++

#include<bits/stdc++.c>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> vi(N);
  for(int i=0;i<N;i++){
    cin>>vi.at(i);
  }
  int ave=0;
  for(int i=0;i<N;i++){
    ave+=vi.at(i);
  }
  vector<int> va(N);
  for(int i=0;i<N;i++){
    va.at(i)=N*va.at(i)-ave;
    if(va.at(i)<0) va.at(i)=(-1)*va.at(i);
  }
  int n=0; int min=va.at(0);
  for(int i=0;i<N;i++){
    if(min>va.at(i)){
      min = va.at(i);
      n=i;
    }
  }
  cout<<n<<endl;
}

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

#include<cstring>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  int n; cin >> n;

  int sum = 0;
  int a[110];

  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  double average = double(sum) / n;
  double tmp = INF;
  int ans;

  rep(i, n) {
    tmp = min(tmp, abs(average - double(a[i])) );
  }

  rep(i, n) {
    if( abs(average - double(a[i])) == tmp ) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc:9:9: error: 'vector' does not name a type
    9 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:10:9: error: 'vector' does not name a type
   10 | typedef vector<ll> vl;
      |         ^~~~~~
a.cc:11:9: error: 'pair' does not name a type
   11 | typedef pair<int, int> pii;
      |         ^~~~
a.cc:12:9: error: 'pair' does not name a type
   12 | typedef pair<ll, ll> pll;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:18:3: error: 'cin' was not declared in this scope
   18 |   cin.tie(0); ios::sync_with_stdio(false);
      |   ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<cstring>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:18:15: error: 'ios' has not been declared
   18 |   cin.tie(0); ios::sync_with_stdio(false);
      |               ^~~
a.cc:35:20: error: 'abs' was not declared in this scope; did you mean 'ans'?
   35 |     tmp = min(tmp, abs(average - double(a[i])) );
      |                    ^~~
      |                    ans
a.cc:35:11: error: 'min' was not declared in this scope; did you mean 'main'?
   35 |     tmp = min(tmp, abs(average - double(a[i])) );
      |           ^~~
      |           main
a.cc:39:9: error: 'abs' was not declared in this scope; did you mean 'ans'?
   39 |     if( abs(average - double(a[i])) == tmp ) {
      |         ^~~
      |         ans
a.cc:45:3: error: 'cout' was not declared in this scope
   45 |   cout << ans << endl;
      |   ^~~~
a.cc:45:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main () {
  int N; 
  cin>>N; int sum=0; vector<int> vec(N);
  for(int i=0;i<N;i++){
    int n;
    cin>>n; vec.at(i)=n;
    sum+=n;
  }
  int a = sum/N;
  
  vector<int> vec2(N);
  for(int i=0;i<N;i++) 
   if(vec.at(i)>=a) vec2.at(i)=vec.at(i)-a;
    else vec2.at(i)=a-vec.at(i);
  int x=vec2.(1); int y=0;
  for(int i=0;i<N;i++)
    if(vec2.at(i)<x) {x=vec2.at(i); y=i;}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: expected unqualified-id before '(' token
   17 |   int x=vec2.(1); int y=0;
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main () {
  int N; 
  cin>>N; int sum=0; victor<int> vic(N);
  for(int i=0;i<N;i++){
    int n;
    cin>>n; vic.at(i)=n;
    sum+=n;
  }
  int a = sum/N;
  
  victor<int> vic2(N);
  for(int i=0;i<N;i++) 
   if(vic.at(i)>=a) vic2.at(i)=vic.at(i)-a;
    else vic2.at(i)=a-vic.at(i);
  int x=vic2.(0); int y=0;
  for(int i=0;i<N;i++)
    if(vic2.at(i)<x) {x=vic2.at(i); y=i;}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:22: error: 'victor' was not declared in this scope
    5 |   cin>>N; int sum=0; victor<int> vic(N);
      |                      ^~~~~~
a.cc:5:29: error: expected primary-expression before 'int'
    5 |   cin>>N; int sum=0; victor<int> vic(N);
      |                             ^~~
a.cc:8:13: error: 'vic' was not declared in this scope
    8 |     cin>>n; vic.at(i)=n;
      |             ^~~
a.cc:13:10: error: expected primary-expression before 'int'
   13 |   victor<int> vic2(N);
      |          ^~~
a.cc:15:7: error: 'vic' was not declared in this scope
   15 |    if(vic.at(i)>=a) vic2.at(i)=vic.at(i)-a;
      |       ^~~
a.cc:15:21: error: 'vic2' was not declared in this scope
   15 |    if(vic.at(i)>=a) vic2.at(i)=vic.at(i)-a;
      |                     ^~~~
a.cc:16:10: error: 'vic2' was not declared in this scope
   16 |     else vic2.at(i)=a-vic.at(i);
      |          ^~~~
a.cc:17:9: error: 'vic2' was not declared in this scope
   17 |   int x=vic2.(0); int y=0;
      |         ^~~~
a.cc:17:14: error: expected unqualified-id before '(' token
   17 |   int x=vic2.(0); int y=0;
      |              ^
Language: C++

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

int main()
{
  int N;
  
  cin >> N;
  
  vector<double> a(N);
  double sum = 0.0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  
  double ave = sum / a.size();
  
  double minv = 100000000;
  int frame_idx = N;
  for (int i = 0; i < N; i++) {
    if (minv > abs((a[i] * N) - (ave * N))) {
      minv = abs((a[i] * N) - (ave * N));
      frame_idx = i;
    }
  }
  
  cout << minidx << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:11: error: 'minidx' was not declared in this scope
   32 |   cout << minidx << endl;
      |           ^~~~~~
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  double a[10010] = {};
  double av = 0;
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    av += a[i];
  }
  
  av /= n;
  double min = 100010;
  int sub;
  
  for (int i = 0; i < n; i++) {
    if (min > fabs(av - a[i])) {
      min = fabs(av - a[i]);
      sub = i;
    }
  }
  
  cout << sub << endl;
}
  
  

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

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

int n,d,v[3000][3000],s[3][3000][3000];

int S(int x1,int y1,int x2,int y2,int t)
{
	return s[t][x2][y2]-s[t][x2][y1-1]-s[t][x1-1][y2]+s[t][x1-1][y1-1];
}

int check(int x)
{
	int r=x%d;
	for(int i=1;i<=d;i++)
		for(int j=1;j<=d;j++)
		{
			int x1=i,y1=j,x2=x1+r,y2=y1+r,x3=x1+d-1,y3=y1+d-1;
			if(!S(x1,y2+1,x3,y3,1)&&!S(x2+1,y1,x3,y3,1)&&!S(x2+1,y2+1,x3,y3,0))
				return 1;
		}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&d);
	memset(v,0,sizeof v);
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x%d+1][y%d+1]++;
	}
	int Mx=0,t;
	for(int i=1;i<=d;i++)
		for(int j=1;j<=d;j++)
			v[i+d][j]=v[i][j+d]=v[i+d][j+d]=v[i][j],Mx=max(Mx,v[i][j]);
	for(t=0;(t+1)*(t+1)<Mx;t++);
	int l[3]={t*t+1,t*(t+1)+1,1e9};
	for(int i=1;i<=d*2;i++)
		for(int j=1;j<=d*2;j++)
			for(int t=0;t<2;t++)
			{
				s[t][i][j]=s[t][i-1][j]+s[t][i][j-1]-s[t][i-1][j-1];
				if(l[t]<=v[i][j])
					s[t][i][j]++;
			}
	int L=t*d,R=t*d+d,ans=R,mid;
	while(L<=R)
		if(check(mid=(L+R)>>1))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:35: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
   39 |         int l[3]={t*t+1,t*(t+1)+1,1e9};
      |                                   ^~~
Language: C++

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

int main() {
	int N, count = 0;
	double A[100], B[100], flame, out;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		count += A[i];
	}
	flame = count / N;
	for (int i = 0; i < N; i++) {
		B[i] = fabs(flame - A[i]);
	}
	sort(B, B + N);
	for (int i = 0; i < N; i++) {
		if (A[i] == flame + B[0] || A[i] == flame - B[0]) {
			out = i;
			break;
		}
	}
	cout << out << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:24: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   15 |                 B[i] = fabs(flame - A[i]);
      |                        ^~~~
      |                        labs
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  int sum=0;
  rep(i,n) {
    cin >> v[i];
    sum+=v[i];
  }
  double x = (double)sum /n;
  int ans = 10000, res;
  rep(i,n){
    if(ans > abs(x-v[i]){
      ans = abs(x-v[i]);
      res = i;
    }
  }
  cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:25: error: expected ')' before '{' token
   17 |     if(ans > abs(x-v[i]){
      |       ~                 ^
      |                         )
a.cc:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  int sum=0;
  rep(i,n) {
    cin >> v[i];
    sum+=v[i];
  }
  double x = (double)sum /n;
  int ans = 10000, res;
  rep(i,n){
    if(ans > abs(x-v[i]){
      ans = abs(x-v[i]);
      res = i;
    }
  }
  cout<<res<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   rep(i,n) {
      |       ^
a.cc:3:22: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(i=0;i<n;i++)
      |                      ^
a.cc:16:7: error: 'i' was not declared in this scope
   16 |   rep(i,n){
      |       ^
a.cc:3:22: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(i=0;i<n;i++)
      |                      ^
a.cc:17:25: error: expected ')' before '{' token
   17 |     if(ans > abs(x-v[i]){
      |       ~                 ^
      |                         )
a.cc:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
Language: C++

#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

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

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:20: error: 'i' was not declared in this scope
   44 |   int near = abs(a[i] - ave);
      |                    ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    vector<double> a(n);
    double sum = 0;
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double mid = sum/(double)n;
    Int res = 0;
    double dif = a[0]
    for (Int i = 0; i < n; i++) {
        if (dif > fabs(a[i] - mid)) {
            dif = fabs(a[i] - mid);
            res = i+1;
        }
    }
    dump(res);
    return 0;  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:5: error: expected ',' or ';' before 'for'
   31 |     for (Int i = 0; i < n; i++) {
      |     ^~~
a.cc:31:21: error: 'i' was not declared in this scope
   31 |     for (Int i = 0; i < n; i++) {
      |                     ^
Language: C++

#include <stdio.h>
int main(void){

    int N, a[100], MIN, i;
    double sum = 0, ave, min = 100;
    
    if(scanf("%d", &N) < 2) {
    exit(1);
}
    
    for(i = 0 ; i < N ; i++){
           if(scanf("%d", &a[i]) < 2) {
    exit(1);
}
        sum += a[i];
    }
    
    ave = sum / (double)N;
    
    for(i = N-1; i >= 0; i--){

    if(a[i] >= ave){
        if(min >= a[i] - ave){
            min = a[i] - ave;
            MIN = i;
        }
    }else{
        if(min > ave - a[i]){
            min = ave - a[i];
            MIN = i;
        }
    }
    }
    
    printf("%d", MIN);
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'exit' was not declared in this scope
    8 |     exit(1);
      |     ^~~~
a.cc:2:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    1 | #include <stdio.h>
  +++ |+#include <cstdlib>
    2 | int main(void){
a.cc:13:5: error: 'exit' was not declared in this scope
   13 |     exit(1);
      |     ^~~~
a.cc:13:5: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
Language: C

#include <stdio.h>
int main(void){

    int N, a[100], MIN, i, u, v[100];
    double sum = 0, ave, min = 100;
    
	u = scanf("%d", &N);
    
    for(i = 0 ; i < N ; i++){
       v = scanf("%d", &a[i]);
        sum += a[i];
    }
    
    ave = sum / (double)N;
    
    for(i = N-1; i >= 0; i--){

    if(a[i] >= ave){
        if(min >= a[i] - ave){
            min = a[i] - ave;
            MIN = i;
        }
    }else{
        if(min > ave - a[i]){
            min = ave - a[i];
            MIN = i;
        }
    }
    }
    
    printf("%d", MIN);
    
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:10:10: error: assignment to expression with array type
   10 |        v = scanf("%d", &a[i]);
      |          ^
Language: C++

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

int main() {
  int N, ans = 1000, index;
  double = sum = 0;
  int a[100];
  cin >> N;
  for(int i=0;i<N;++i) {
    cin >> a[i];
    sum += a[i];
  }

  sum/=N;

  for(int i=0; i<N; ++i) {
    if(abs(ans-sum)>abs(a[i]-sum)) {
      ans = a[i];
      index = i;
    }
  }

  cout << index << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: expected unqualified-id before '=' token
    8 |   double = sum = 0;
      |          ^
a.cc:13:5: error: 'sum' was not declared in this scope
   13 |     sum += a[i];
      |     ^~~
a.cc:16:3: error: 'sum' was not declared in this scope
   16 |   sum/=N;
      |   ^~~
Language: C++

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

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

    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

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

    // aの合計を求める
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += a[i];
    }

    // 平均値に一番近いフレーム番号を求める
    double dist_min = 10001;
    int ans;
    for (int i = 0; i < N; i++) {
        double dist = abs(sum) - a[i] * N);
        if (dist < dist_min) {
            dist_min = dist;
            ans = i;
        }
    }
    cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:42: error: expected ',' or ';' before ')' token
   28 |         double dist = abs(sum) - a[i] * N);
      |                                          ^
Language: C

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

int main(void){
	int i,n,ans=0,a[n],sum=0;
	scanf("%d", &n);
  
  	for(i=0;i<n;i++){
      	scanf("％d",&a[i]);
      	sum+=a[i];
    }
	
  	for(i=0;i<n;i++){
		if(abs(a[i]*n-sum)<abs(a[ans]*n-sum){
          ans = i;
        }
    }
  printf("%d", ans);
}
  	


Compiler output:
main.c: In function 'main':
main.c:14:53: error: expected ')' before '{' token
   14 |                 if(abs(a[i]*n-sum)<abs(a[ans]*n-sum){
      |                   ~                                 ^
      |                                                     )
main.c:17:5: error: expected expression before '}' token
   17 |     }
      |     ^
Language: C

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

int main(void){
	int i,n,ans=0,a[n],sum=0;
	scanf("%d", &n);
  
  	for(i=0;i<n;i++){
      	scanf("%lf",&a[i]);
      	sum+=a[i];
    }
	
  	for(i=0;i<n;i++){
		if(abs(a[i]*n-sum)<abs(a[ans]*n-sum){
          ans = i;
        }
    }
  printf("%d", ans);
}
  	


Compiler output:
main.c: In function 'main':
main.c:14:53: error: expected ')' before '{' token
   14 |                 if(abs(a[i]*n-sum)<abs(a[ans]*n-sum){
      |                   ~                                 ^
      |                                                     )
main.c:17:5: error: expected expression before '}' token
   17 |     }
      |     ^
Language: C

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

int main(void){
	int i,n,ans;
  	double a[n],sum=0;
	scanf("%d", &n);
  
  	for(i=0;i<n;i++){
      	scanf("%f",&a[i]);
      	sum+=a[i];
    }
  	double ave = sum/(double)n;
	
  	for(i=0;i<n-1;i++){
		if(abs(a[i]-ave)<abs(a[i+1]-ave){
          ans = i;
        }
    }
  
  printf("%d", ans);
}
  	



Compiler output:
main.c: In function 'main':
main.c:16:49: error: expected ')' before '{' token
   16 |                 if(abs(a[i]-ave)<abs(a[i+1]-ave){
      |                   ~                             ^
      |                                                 )
main.c:19:5: error: expected expression before '}' token
   19 |     }
      |     ^
Language: C

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

int main(void){
	int i,n,ans;
  	double a[n],sum=0,min=101.0;
	scanf("%d", &n);
  
  	for(i=0;i<n;i++){
      	scanf("%f",&a[i]);
      	sum+=a[i];
    }
  	double ave = sum/(double)n;
	
  	for(i=0;i<n;i++){
		if(abs(a[i]-ave)<min){
          if(abs(a[i]-ave)==0){
            ans=i;
            break;
          }else{
          ans = i;
          min = abs(a[i]-ave);
        }
    }
  printf("%d", ans);
}
  	



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

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

int main(void){
	int n,ans;
  	double a[n],sum=0,min=101.0;
	scanf("%d", &n);
  
  	for(i=0;i<n;i++){
      	scanf("%lf",&a[i]);
      	sum+=a[i];
    }
  	double ave = sum/(double)n;
	
  	for(i=0;i<n;i++){
		if(abs(a[i]-ave)<min){
          ans = i;
        }
    }
  printf("%d", ans);
}
  	

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

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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef double ld;

const int N = 100 + 10, M = 1000 + 10; 

int a[N];

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, sum = 0;
	for(int i = 0; i < n; i++)
		cin>> a[i], sum += a[i];
	int id = 0;
	for(int i = 1; i < n; i++)
		if(abs(a[i]*n-sun)<abs(a[id]*n-sum))
			id = i;
	cout<< id << endl;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:25:31: error: 'sun' was not declared in this scope; did you mean 'sum'?
   25 |                 if(abs(a[i]*n-sun)<abs(a[id]*n-sum))
      |                               ^~~
      |                               sum
Language: C++

#include<cstdio>
int n;
int a[105];
int myabs(int x) {
if(x>0) return x;
return -x;
}
int main() {
	int avg = 0;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		avg += a[i];
		a[i] *= n;
	}
	int min = 2147483647,w=-1;
	for (i = 0; i < n; i++) {
		if (abs(avg - a[i]) < min) {
			min = myabs(avg - a[i]);
			w = i;
		}
	}
	printf("%d", w);
	return 0;
}

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

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long

int main () {
  ll n, K;
  cin >> n >> K;
  ll a[n];
  ll sum[n + 1];
  sum[0] = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  vector<ll> ans;
  for (ll i = 0; i < n + 1; i++) {
    for (ll j = i + 1; j < n + 1; j++) {
      ans.push_back(sum[j] - sum[i]);  
    }  
  }
  ll sub = 1;
  ll itr = 0;
  ll dp[40];
  for (int i = 0; i < 40; i++) {
    dp[i] = 0;  
  }
  vector<unordered_map<ll, ll> > box;
  box.resize(40);
  for (ll i = 0; i < ans.size(); i++) {
    if (ans[i] == 0) {
      // 何もしない  
    }  
    itr = 0;
    while (ans[i] != 0) {
      if ((ans[i] & 1) == 1) {
        box[itr][i] = 1;
      }    
      ans[i] >>= 1;  
      itr++;
    }
  }
  /*
  while (itr < 41) {
    for (ll i = 0; i < ans.size(); i++) {
      if ((sub & ans[i]) != 0) {
        dp[itr]++;
        box[itr][i] = 1;  
      }    
    }  
    sub = sub * 2;
    itr++;  
  }
  */
  sub = 1;
  for (int i = 0; i < 40; i++) {
    /*
    cout << sub << " " << dp[i] << endl;
    for (auto x = box[i].begin(); x != box[i].end(); ++x) {
      cout << *x << " ";  
    }
    cout << endl;
    */
    sub = sub * 2;  
  }
  ll answer = 0;
  ll ssss = 0;
  bool ok = false;
  unordered_map<ll, ll> finish;
  for (ll i = 0; i < 40; i++) {
    sub = sub / 2;
    if (ok == false) {
      if (box[39 - i].size() >= K) {
        answer = answer + sub;
        ok = true;
        itr = 39 - i;
      }
    }
    else {
      ssss = 0;
      if (box[39 - i].size() >= K) {
        for (auto j = box[39 - i].begin(); j != box[39 - i].end(); ++j) {
          if (box[itr][j->first] == 1) {
              ssss++;      
          } 
          else {
            box[39 - i][j->first] = 0;    
          }
        }  
        if (ssss >= K) {
          answer = answer + sub;  
          itr = 39 - i;
        }
        else {
          // 何もしない.    
        }
      }     
    }
  }
  cout << answer << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: 'unordered_map' was not declared in this scope
   31 |   vector<unordered_map<ll, ll> > box;
      |          ^~~~~~~~~~~~~
a.cc:6:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
    5 | #include <set>
  +++ |+#include <unordered_map>
    6 | using namespace std;
a.cc:31:30: error: template argument 1 is invalid
   31 |   vector<unordered_map<ll, ll> > box;
      |                              ^
a.cc:31:30: error: template argument 2 is invalid
a.cc:31:32: error: expected unqualified-id before '>' token
   31 |   vector<unordered_map<ll, ll> > box;
      |                                ^
a.cc:32:3: error: 'box' was not declared in this scope
   32 |   box.resize(40);
      |   ^~~
a.cc:7:12: error: expected primary-expression before 'long'
    7 | #define ll long long
      |            ^~~~
a.cc:72:17: note: in expansion of macro 'll'
   72 |   unordered_map<ll, ll> finish;
      |                 ^~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
double zettai(double a) {
  if(a < 0) {
    return -a;
  }else {
    return a;
  }
}
int main () {
  int N;
  bool half = true;
  cin >> N;
  vector<int>a(N);
  int k = 0;
  for(int i = 0; i < N; i ++) {
    cin >> a[i];
    k += a[i];
  }
  double ave = static_cast<double>(k) / N;
  vector<double>b(N);
  vector<double>c(N);
  for (int i = 0; i < N; i ++) {
    b[i] = c[i] = zettai(a[i] - ave);
  }
  sort (b.begin(),b.end());
  bool ans = false;
  for (int i = 0; i < N; i ++) {
    if(c[i] == b[0]) {
      cout << i << endl;
      ans = true;
    }
    if(ans) break;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   27 |   sort (b.begin(),b.end());
      |   ^~~~
      |   short