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

#include <bits/stdc++.h>

using namespace std;

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

    sort(d.begin(),d,end());

    cout << d[N/2] -d[N/2 -1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:25: error: no matching function for call to 'end()'
   13 |     sort(d.begin(),d,end());
      |                      ~~~^~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1265:5: note:   candidate expects 1 argument, 0 provided
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

    sort(d.begin(),d,end());

    cout << d[N/2] -d[N/2 -1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: expected ';' before '}' token
   10 |         cin >> d[i]
      |                    ^
      |                    ;
   11 |     }
      |     ~               
a.cc:13:25: error: no matching function for call to 'end()'
   13 |     sort(d.begin(),d,end());
      |                      ~~~^~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
 1249 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1249:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/valarray:1265:5: note:   candidate expects 1 argument, 0 provided
Language: C++

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  cout<<v[n/2]-v[(n/2)-1]<<endl;
///////////////////////////

Compiler output:
a.cc: In function 'int main()':
a.cc:75:33: error: expected '}' at end of input
   75 |   cout<<v[n/2]-v[(n/2)-1]<<endl;
      |                                 ^
a.cc:69:12: note: to match this '{'
   69 | int main() {
      |            ^
Language: C++

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) cin >> d[i];

    sort(d.begin(), d.end());
    cout << [N/2+1]-d[N/2] << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: expected ',' before '/' token
   18 |     cout << [N/2+1]-d[N/2] << endl;
      |               ^
      |               ,
a.cc:18:15: error: expected identifier before '/' token
a.cc: In lambda function:
a.cc:18:20: error: expected '{' before '-' token
   18 |     cout << [N/2+1]-d[N/2] << endl;
      |                    ^
a.cc: In function 'int main()':
a.cc:18:20: error: no match for 'operator-' (operand types are 'main()::<lambda()>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   18 |     cout << [N/2+1]-d[N/2] << endl;
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:18:26: note:   'main()::<lambda()>' is not derived from 'const std::reverse_iterator<_Iterator>'
   18 |     cout << [N/2+1]-d[N/2] << endl;
      |                          ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:18:26: note:   'main()::<lambda()>' is not derived from 'const std::move_iterator<_IteratorL>'
   18 |     cout << [N/2+1]-d[N/2] << endl;
      |                          ^
Language: Java

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

public class ABC132_DivideTheProblems {

	public static void main(String[] args) {

		int array[] = null;
		int temp = 0;

		Scanner scanner = new Scanner(System.in);

		//入力値を扱いやすいように配列化
		for(int i = 0; scanner.hasNext(); i++) {

			//最初の入力で配列作成
			if(i == 0) {

				temp = Integer.parseInt(scanner.next());

				array = new int[temp];

			}
			
			array[i] = Integer.parseInt(scanner.next());
			
		}

		//照準ソート
		Arrays.sort(array);

		//間の値の差を求める
		System.out.println((array[(temp / 2)] - array[((temp / 2) -1)]));
		
	}

}

Compiler output:
Main.java:4: error: class ABC132_DivideTheProblems is public, should be declared in a file named ABC132_DivideTheProblems.java
public class ABC132_DivideTheProblems {
       ^
1 error
Language: C++

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n,;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
  	cin >> a.at(i);
  }
  
  cout << a.at(n/2) - a.at(n/2 -1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: expected unqualified-id before ';' token
   23 |   int n,;
      |         ^
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  
  for(int i=0;i<n;i++) cin >> d[i];
  
  sort(d.begin(),d.end());
  
  int ans = d[n/2] - d[n/2 - 1];
  
  cout << ans << endl:
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:22: error: expected ';' before ':' token
   15 |   cout << ans << endl:
      |                      ^
      |                      ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[N / 2] - v[N / 2 - 1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     rep(i, N) cin >> v[i];
      |         ^
a.cc:7:5: error: 'rep' was not declared in this scope
    7 |     rep(i, N) cin >> v[i];
      |     ^~~
Language: C++

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

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

    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    
    sort(d.begin(), d.end());

    int ans = d[n / 2] - d[n / 2 - 1];
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | v#include <bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'v' does not name a type
    1 | v#include <bits/stdc++.h>
      | ^
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> n;
      |     ^~~
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> d(n);
      |     ^~~~~~
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> d(n);
      |            ^~~
a.cc:12:16: error: 'd' was not declared in this scope
   12 |         cin >> d[i];
      |                ^
a.cc:15:10: error: 'd' was not declared in this scope
   15 |     sort(d.begin(), d.end());
      |          ^
a.cc:15:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |     sort(d.begin(), d.end());
      |     ^~~~
      |     short
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout << ans << endl;
      |     ^~~~
a.cc:18:20: error: 'endl' was not declared in this scope
   18 |     cout << ans << endl;
      |                    ^~~~
Language: C++

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

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

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

int main(void){
	int N,ans;
	scin(N)
	int d[N];
	rep(i,0,N){
		scin(N[i])
	}
	qsort(d,N,sizeof(int),asc);
	if(N % 2) ans = 0 ; else ans = d[N / 2 + 1] - d[N / 2];
	anin(N)
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:23: error: invalid types 'int[int]' for array subscript
   23 |                 scin(N[i])
      |                       ^
a.cc:7:29: note: in definition of macro 'scin'
    7 | #define scin(a) scanf("%d",&a);
      |                             ^
Language: C++

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

int main(){
  int n;cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  ll abc=0;
  ll arc=0;
  ll sum=0;
  ll h=0;
  rep(i,n) h=max(h,d[i]);
  for(ll i=1;i<h;i++){
    for(ll p=0;p<n;p++){
      if(d[p]>=i) arc++;
      else abc++;
    }
    if(abc==arc){
      sum++;
    }
    arc=0;
    abc=0;
  }
  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   14 |   rep(i,n) h=max(h,d[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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:14:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   14 |   rep(i,n) h=max(h,d[i]);
      |              ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:14:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |   rep(i,n) h=max(h,d[i]);
      |              ~~~^~~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    
    for(int i = 0; i < n ; i++){
        // printf("---------\n");
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    
    
    int tmp1, tmp2;
    tmp1 = d[(n/2) - 1];
    tmp2 = d[(n/2)];

    int ans = 0;
    for (int i = tmp1 + 1; i <= tmp2; i++){
        ans += 1;
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |     sort(d.begin(), d.end());
      |     ^~~~
      |     short
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    sort(a.begin(),a.end());
    
    int left = a[n/2-1];
    int right = a[n/2];
    
    cout << right - left;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'i' was not declared in this scope
    8 |     rep(i,n) cin >> a[i];
      |         ^
a.cc:8:5: error: 'rep' was not declared in this scope
    8 |     rep(i,n) cin >> a[i];
      |     ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    VI pro(n);
    rep(i,n) cin >> pro[i];
    SORT(pro);
    cout << pro[n/2] - d[n/2-1] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:24: error: 'd' was not declared in this scope
   26 |     cout << pro[n/2] - d[n/2-1] << endl;
      |                        ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
  	cin >> d[i];
  }
  sort(d.begin(), d.end());
  if(d(n/2-1)==d(n/2))
    cout << 0;
  else if(d(n/2-1)<d(n/2))
    cout << d(n/2)-d(n/2-1);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: no match for call to '(std::vector<int>) (int)'
   12 |   if(d(n/2-1)==d(n/2))
      |      ~^~~~~~~
a.cc:12:17: error: no match for call to '(std::vector<int>) (int)'
   12 |   if(d(n/2-1)==d(n/2))
      |                ~^~~~~
a.cc:14:12: error: no match for call to '(std::vector<int>) (int)'
   14 |   else if(d(n/2-1)<d(n/2))
      |           ~^~~~~~~
a.cc:14:21: error: no match for call to '(std::vector<int>) (int)'
   14 |   else if(d(n/2-1)<d(n/2))
      |                    ~^~~~~
a.cc:15:14: error: no match for call to '(std::vector<int>) (int)'
   15 |     cout << d(n/2)-d(n/2-1);
      |             ~^~~~~
a.cc:15:21: error: no match for call to '(std::vector<int>) (int)'
   15 |     cout << d(n/2)-d(n/2-1);
      |                    ~^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
      cin >> d[i];
  }
  sort(d.begin(),d.end());
  if(d.size() % 2 != 0)//要素が偶数個あるとき//{
      cout << 0 << endl;
  }
  if(d.size() % 2 == 0){
     int a = d[(N-1)/2], b = d[(N+1)/2];
     cout << b - a << endl;
  }
}

Compiler output:
a.cc:14:3: error: expected unqualified-id before 'if'
   14 |   if(d.size() % 2 == 0){
      |   ^~
a.cc:18:1: error: expected declaration before '}' token
   18 | }
      | ^
Language: C++

n = int(input())
d = list(map(int,input().split()))

d.sort()

if n % 2 == 0:
    if d[n // 2 - 1] == d[n // 2]:
        print(0)
    else:
        print(d[n // 2] - d[n // 2 - 1])
else:
    print(0)

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

#include<bit/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  cout << d[N/2]-d[N/2-1] << endl;
}

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

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

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> d(N);
    for (int i = 0; i < N; i++) {
        std::cin >> d[i];
    }

    std::sort(std::begin(d), std::end(d));
    int h = d[N/2] - d[N/2-1]
    if (h > 0) h -= 1;

    std::cout << h << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: expected ',' or ';' before 'if'
   17 |     if (h > 0) h -= 1;
      |     ^~
Language: C++

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int main() {
    ll n;
    cin>>n;
    ll d[n];
    ll k=0;


    rep(i,n){
        cin>>d[i];
    }

    sort(d.begin(),d.end());
    k=d[d.size()/2]-d[d.size()/2-1];

    cout<<k<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:12: error: request for member 'begin' in 'd', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   52 |     sort(d.begin(),d.end());
      |            ^~~~~
a.cc:52:22: error: request for member 'end' in 'd', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   52 |     sort(d.begin(),d.end());
      |                      ^~~
a.cc:53:11: error: request for member 'size' in 'd', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   53 |     k=d[d.size()/2]-d[d.size()/2-1];
      |           ^~~~
a.cc:53:25: error: request for member 'size' in 'd', which is of non-class type 'll [n]' {aka 'long long int [n]'}
   53 |     k=d[d.size()/2]-d[d.size()/2-1];
      |                         ^~~~
Language: C++

using namespace std;
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
 
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  int a=d[n/2-1], b=d[n/2], ans=0;
  if(a==b){
      ans++;
  }
  else{
      for(int i=a+1; i<=b; i++){
          ans++;
      }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> d(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> d(n);
      |          ^~~
a.cc:9:20: error: 'd' was not declared in this scope
    9 |   rep(i, n) cin >> d[i];
      |                    ^
a.cc:10:8: error: 'd' was not declared in this scope
   10 |   sort(d.begin(), d.end());
      |        ^
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |   sort(d.begin(), d.end());
      |   ^~~~
      |   short
a.cc:12:9: error: 'b' was not declared in this scope
   12 |   if(a==b){
      |         ^
a.cc:13:7: error: 'ans' was not declared in this scope
   13 |       ans++;
      |       ^~~
a.cc:17:11: error: 'ans' was not declared in this scope
   17 |           ans++;
      |           ^~~
a.cc:20:3: error: 'cout' was not declared in this scope
   20 |   cout << ans << endl;
      |   ^~~~
a.cc:20:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:11: error: 'ans' was not declared in this scope
   20 |   cout << ans << endl;
      |           ^~~
a.cc:20:18: error: 'endl' was not declared in this scope
   20 |   cout << ans << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace kp
{
    public class Program
    {
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());
            int[] d = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            List<int> difficult = new List<int>(d);
            difficult.Sort();
            int k = difficult[difficult.Count / 2]; // ARC用で一番簡単
            int abc = difficult[difficult.Count / 2 -1]; // ABC用で一番難しい

            if (k == abc)
                Console.WriteLine("0");
            else
            {
                // abcより大きくて、kまでの整数を選べる
                Console.WriteLine((k - abc) + "");
            }
            
        }
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Text;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Text.RegularExpressions;
      |       ^~~~~~
a.cc:9:5: error: expected unqualified-id before 'public'
    9 |     public class Program
      |     ^~~~~~
Language: C++

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

int main(){
  int N; cin>>N;
  vector<int> d(N);
  for (int i=0;i<N;++i)cin>>d[i];
  
  sort(d.begin(),d.end());
  int left d[N/2-1];
  int right d[N/2];
  
  cout<<right-left<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: expected initializer before 'd'
   12 |   int left d[N/2-1];
      |            ^
a.cc:13:13: error: expected initializer before 'd'
   13 |   int right d[N/2];
      |             ^
a.cc:15:14: error: ISO C++ forbids using pointer to a function in subtraction [-fpermissive]
   15 |   cout<<right-left<<endl;
      |         ~~~~~^~~~~
Language: C++

#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int d[N];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d, d+N);
  if(d[N/2-1]==d[N/2]){
    cout << 0;
  }else{
    cout << d[N/2-1]-d[N/2];
  }
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |   sort(d, d+N);
      |   ^~~~
      |   short
Language: C++

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

vector<int> v;
int main( ) {
	int n;
	cin>>n;
	int i;
	for(i=1;i<=n;i++) {
		int x;
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	cout<<v[n/2] - v[n/2 -1]<<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |         sort(v.begin(), v.end());
      |         ^~~~
      |         short
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define rep(i,m,n) for(int i=m;i<n;i++)

int main() {
  int n, a;
  vector<int> d;

  cin >> n;
  rep(i,0,n){ cin >> a; d.push_back(a); }

  std::sort(d.begin(),d.end());
  cout << d[n/2] - d[n/2-1] << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   13 |   std::sort(d.begin(),d.end());
      |        ^~~~
      |        qsort
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define rep(i,m,n) for(int i=m;i<n;i++)

int main() {
  int n, a;
  vector<int> d;

  cin >> n;
  rep(i,0,n){ cin >> a; d.push_back(a); }

  sort(d.begin(),d.end());
  cout << d[n/2] - d[n/2-1] << endl;
  
  return 0;
}


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

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

int main(){
  int N;
  cin>>N;
  vector<int> d(n);
  for(int i=0;i<n;i++) cin >> d.at(i);
  sort(d.begin(),d.end());
  int ans=d.at(d.size()/2)-d.at(d.size()/2-1);
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: 'n' was not declared in this scope
    7 |   vector<int> d(n);
      |                 ^
Language: C++

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> d(n);
    for(ll i=0;i<n;i++) cin>>d[i];
    sort(all(d));
    cout<<max(0,d[n/2]-d[n/2-1])<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   12 |     cout<<max(0,d[n/2]-d[n/2-1])<<endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:12:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   12 |     cout<<max(0,d[n/2]-d[n/2-1])<<endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:12:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |     cout<<max(0,d[n/2]-d[n/2-1])<<endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	cout << A[N/2] - A[N/2-1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |         sort(A, A + N);
      |         ^~~~
      |         short
Language: C++

#include<stdio.h>
int main(){
  int d[100000];
  int n;
  scanf("%d",&n);
  for(int i = 0;i<n;i++){
    scanf("%d", &d[i]);
    }
  for(int i = 0;i<n-1;i++){
    for(int j = i;j<n-1;j++){
      if(d[j]>d[j+1]){
        int a=d[j];
        d[j]=d[j+1];
        d[j+1]=a;
          }
      }
    }
  int b;
  b=d[n/2+1]-d[n/2];
  printf("%d",b);
  return 0;
      
    

Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: expected '}' at end of input
   21 |   return 0;
      |            ^
a.cc:2:11: note: to match this '{'
    2 | int main(){
      |           ^
Language: C++

#include<stdio.h>
int main(){
  int d[100000];
  int n;
  scanf("%d",&n);
  for(int i = 0;i<n;i++){
    scanf("%d", &d[i]);
    }
  for(int i = 0;i<n-1;i++){
    for(int j = i;j<n-1;j++){
      if(d[j]>d[j+1]){
        int a=d[j];
        int d[j]=d[j+1];
        int d[j+1]=a;
          }
      }
    }
  int b;
  b=d[n/2+1]-d[n/2];
  printf("%d",b);
  return 0;
      
    

Compiler output:
a.cc: In function 'int main()':
a.cc:13:23: error: array must be initialized with a brace-enclosed initializer
   13 |         int d[j]=d[j+1];
      |                  ~~~~~^
a.cc:14:13: error: conflicting declaration 'int d [(j + 1)]'
   14 |         int d[j+1]=a;
      |             ^
a.cc:13:13: note: previous declaration as 'int d [j]'
   13 |         int d[j]=d[j+1];
      |             ^
a.cc:21:12: error: expected '}' at end of input
   21 |   return 0;
      |            ^
a.cc:2:11: note: to match this '{'
    2 | int main(){
      |           ^
Language: C++

#include<stdio.h>
int main(){
  int d[100000];
  int n;
  scanf("%d",n);
  for(int i = 0;i<n;i++){
    scanf("%d", d[i]);
    }
  for(int i = 0;i<n-1;i++){
    for(int j = i;j<n-1;j++){
      if(d[j]>d[j+1]){
        int a=d[j];
        int d[j]=d[j+1];
        int d[j+1]=a;
          }
      }
    }
  int b;
  b=d[n/2+1]-d[n/2];
  printf("%d",b);
  return 0;
      
    

Compiler output:
a.cc: In function 'int main()':
a.cc:13:23: error: array must be initialized with a brace-enclosed initializer
   13 |         int d[j]=d[j+1];
      |                  ~~~~~^
a.cc:14:13: error: conflicting declaration 'int d [(j + 1)]'
   14 |         int d[j+1]=a;
      |             ^
a.cc:13:13: note: previous declaration as 'int d [j]'
   13 |         int d[j]=d[j+1];
      |             ^
a.cc:21:12: error: expected '}' at end of input
   21 |   return 0;
      |            ^
a.cc:2:11: note: to match this '{'
    2 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<math.h>

using namespace std;
int d[100001], N;
int main() {
   cin>>N;
   for(int i = 0; i < N; i++){
   	cin>>d[i];
   }
   sort(d, d + N);
   cout<<d[N/2] - d[N/2 -1] <<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:4: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   11 |    sort(d, d + N);
      |    ^~~~
      |    sqrt
Language: C++

#include <iostream>
using namespace std;
int d[10000];
int main(){
	int a=0,b=0,s=0,n,k;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
		a[d[i]]++;
	}
	sort(d,d+n);
	cout<<d[n/2+1]-d[n/2];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: invalid types 'int[int]' for array subscript
    9 |                 a[d[i]]++;
      |                  ^
a.cc:11:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |         sort(d,d+n);
      |         ^~~~
      |         short
Language: C++

#include <iostream>
using namespace std;
int d[10000]
int main(){
	int a=0,b=0,s=0,n,k;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	for(int i=0;i<n;i++){
		k=i;
		for(int i=0;i<n;i++){
			if(d[i]<k)a++;
			else b++;
		}
		if(a==b)s++;
	}
	cout<<s;
}

Compiler output:
a.cc:4:1: error: expected initializer before 'int'
    4 | int main(){
      | ^~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e5+1
int n,a[maxn];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int ans=0;
	if(n%2==0)
		ans=a[n/2]-a[n/2-1];
	cout<<ans<<endl;
	return 0; 

}

Compiler output:
a.cc:5:1: error: expected ',' or ';' before 'int'
    5 | int n,a[maxn];
      | ^~~
a.cc: In function 'int main()':
a.cc:8:14: error: 'n' was not declared in this scope
    8 |         cin>>n;
      |              ^
a.cc:10:22: error: 'a' was not declared in this scope
   10 |                 cin>>a[i];
      |                      ^
a.cc:11:14: error: 'a' was not declared in this scope
   11 |         sort(a+1,a+n+1);
      |              ^
Language: C++

#include<stdio.h>
using namespace std;

int main(void)
{
	int n, d, sum=0, num=0, cnt[100000]={};
  	cin >> n;
	for(int i=0;i<n;i++)
	{
	  cin >> d;
	  cnt[d]++;
	}
	for(int i =0;i<100000;i++)
	{
	  sum += cnt[i];
	  if(sum > n/2)
	  	break;
	  if(sum == n/2)
	  	num++;
	}
  	cout << num;
  	return 0;   
}

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

#include<stdio.h>
using namespace std;

int main(void)
{
	int n, d, sum=0, num=0, cnt[100000]={};
  cin >> n;
	for(int i=0;i<n;i++)
	{
	  cin >> d;
	  cnt[d]++;
	}
	for(int i =0;i<100000;i++)
	{
	  sum += cnt[i];
	  if(sum > n/2)
	  	break;
	  if(sum == n/2)
	  	num++;
	}
  cout << num;
  return 0;   
}

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

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

public class Solution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        Arrays.sort(arr);

        int res = arr[arr.length / 2] - arr[arr.length / 2 - 1];
        System.out.println(res);
    }
}


Compiler output:
Main.java:4: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: C++

#include <cstdio>
#include <algorithm>

const int MAXN = 1e5 + 5;

int n;
int arr[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
    }
    sort(arr + 1, arr + n + 1);
    printf("%d", arr[(n >> 1) + 1] - arr[n >> 1]);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   14 |     sort(arr + 1, arr + n + 1);
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class F {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = 0, i = 0;
		while(i < occ.length) {
			if(cnt + occ[i] > n/2)
				break;
			cnt += occ[i++];
		}
		// i contains (n/2+1)th element
		--occ[i];
		int k = 0;
		while(i >= 0 && occ[i--] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}
}


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

#include <stdio.h>
#include <iostream>
#include <vector>

#define ll long long int

int main() {
  int n, k;
  std::cin >> n;
  std::vector<int> v;
  for(int i = 0; i < n; i++) {
    std::cin >> k;
    v.push_back(k);
  }
  std::sort(v.begin(), v.end());
  
  std::cout << v.at(n/2) -  v.at(n/2-1) << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   15 |   std::sort(v.begin(), v.end());
      |        ^~~~
      |        qsort
Language: C++

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];

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

	sort(a, a+n);
	cout << a[n/2] - a[n/2-1] << endl;
	return 0;
}

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

#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

using namespace std;

typedef long long Int;
const Int mod = 1000000007;
const Int INF = mod * mod;

unsigned main() {
	Int n;
	cin >> n;
	vector<Int> d(n);
	for (Int i = 0; i < n; i++)cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<iostream>
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int d[n-1];
  for(int i=0;i<n;i++)
    cin >> d[i];
  
  int ans;
  
  int m=n/2;
  d.sort();
  ans=d[m]-d[m-1];
  
  /*
  for(int j=1;j<100001;j++){
    for(int i=0;i<n;i++){
      if(j>d[i])
        less++;
      else
        more++;
    }
    if(more==less)
      ans++;
  }
  */
  cout << ans;
  
  return 0;
}
        


Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: request for member 'sort' in 'd', which is of non-class type 'int [(n + -1)]'
   16 |   d.sort();
      |     ^~~~
Language: C++

#include<iostream>
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int d[n-1];
  for(int i=0;i<n;i++)
    cin >> d[i];
  
  int m=n/2;
  d.sort();
  ans=d[m]-d[m-1];
  
  /*
  for(int j=1;j<100001;j++){
    for(int i=0;i<n;i++){
      if(j>d[i])
        less++;
      else
        more++;
    }
    if(more==less)
      ans++;
  }
  */
  cout << ans;
  
  return 0;
}
        


Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: request for member 'sort' in 'd', which is of non-class type 'int [(n + -1)]'
   14 |   d.sort();
      |     ^~~~
a.cc:15:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |   ans=d[m]-d[m-1];
      |   ^~~
      |   abs
Language: C++

#include<iostream>
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int d[n-1];
  for(int i=0;i<n;i++)
    cin >> d[i];
  
  int less,more;
  int ans=0;
  for(int j=1;i<100001;i++){
    for(int i=0;i<n;i++){
      if(j<d[i])
        more++;
      else
        less++;
    }
    if(more==less)
      ans++;
  }
  
  cout << ans;
  
  return 0;
}
        

Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: 'i' was not declared in this scope
   15 |   for(int j=1;i<100001;i++){
      |               ^
Language: C

#include <stdio.h>

int main() {
    int N = scanf("%d", &N);
    int num[N];

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

    int tmp;
    for(int i = 0; i < N i++) {
        for (int j = i+1; j < N j++) {
            if (num[i] > num[j]) {
                tmp = num[i];
                num[i] = num[j];
                num[j] = tmp;
            }
        }
    }

    int r = num[(N/2) + 1] - num[N/2];
    printf("%d", r);
}

Compiler output:
main.c: In function 'main':
main.c:7:25: error: expected ';' before 'i'
    7 |     for(int i = 0; i < N i++) {
      |                         ^~
      |                         ;
main.c:12:25: error: expected ';' before 'i'
   12 |     for(int i = 0; i < N i++) {
      |                         ^~
      |                         ;
main.c:13:32: error: expected ';' before 'j'
   13 |         for (int j = i+1; j < N j++) {
      |                                ^~
      |                                ;