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

#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

const int N = 1e5 + 5;
int n;
int a[N], b[N];
ll sum[N], nums[2 * N];

void input() {
  scanf("%d", &n);
  forn(i, 1, n + 1) {
    scanf(" %d", &a[i]);
    b[i] = a[i];
  }
}

ll calc(int in) {
  ll res = 0;
  memset(sum, 0, sizeof sum);
  memset(num, 0, sizeof num);
  for (int i = 1; i <= n; i++) {
    if (a[i] >= in)
      sum[i] = sum[i - 1] + 1;
    else
      sum[i] = sum[i - 1] - 1;
  }
  ll pre = 0;
  num[N] = 1;
  for (int i = 1; i <= n; i++) {
    if (sum[i] > sum[i - 1])
      pre += num[sum[i] + N] + 1;
    else
      pre -= num[sum[i - 1] + N] - 1;
    num[sum[i] + N]++;
    res += pre;
  }
  return res;
}

void solve() {
  sort(b + 1, b + n + 1);
  int l = 1;
  int r = unique(b + 1, b + n + 1) - b - 1;
  ll med = n * (n + 1) / 2 - n * (n + 1) / 2 / 2;
  // ll med = n * n / 2 + ((n * n) % 2 != 0);
  int ans;
  while (l <= r) {
    int mid = (l + r) / 2;
    ll count = calc(b[mid]);
    if (count >= med) {
      ans = b[mid];
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  printf("%d\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
    input();
    solve();
    scanf(" ");
  }
#else
  input();
  solve();
#endif
  return 0;
}


Compiler output:
a.cc: In function 'll calc(int)':
a.cc:36:10: error: 'num' was not declared in this scope; did you mean 'sum'?
   36 |   memset(num, 0, sizeof num);
      |          ^~~
      |          sum
Language: C++

#include <iostream>
#include <vector>
#define ll long long

ll min (ll x, ll y){
  if(x<y) return x;
  else return y;
}

int main(void) {
  int N;
  std::cin >> N;
  std::vector<ll> a(N);
  for(int i =  0; i < N; i++) std::cin >> a[i];
  if(N%2==0)
  	std::cout << min(a[N/2], a[N/2-1]);
  else
    std::cout << min(a[N/2]);
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:21: error: too few arguments to function 'long long int min(long long int, long long int)'
   18 |     std::cout << min(a[N/2]);
      |                  ~~~^~~~~~~~
a.cc:5:4: note: declared here
    5 | ll min (ll x, ll y){
      |    ^~~
Language: C

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

void strsort(int* a,int len) {
	int tmp;
	for (int i=0;i<len;i++) {
		for (int j=0;j<len;j++) {
			if (a[i]<a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
}

int main(void) {
	int n;
	scanf("%d",&n);
	int str[n];
	int strbuf[n];
	int strmed[(n*n)];
	int strmed_i = 0;
	for (int i=0;i<n;i++) {
		scanf(" %d",str+i);
	}
	for (int l=0;l<n;l++) {
		for (int r=l;r<n;r++) {
			memcpy(strbuf,str+l,sizeof(int)*(r-l+1));			
			strsort(strbuf,r-l+1);
			strmed[strmed_i] = strbuf[((r-l+1)/2)];
			strmed_i++;
		}
	}
	strsort(strmed,strmed_i);
	printf("%d\n",strmed[strmed_i/2ax2]);
	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:36:39: error: invalid suffix "ax2" on integer constant
   36 |         printf("%d\n",strmed[strmed_i/2ax2]);
      |                                       ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#define int long long

using namespace std;

const int maxn = 100005;

int n;
int a[maxn], b[maxn];
long long M;

void init() {
    cin >> n;
    M = n*(n+1)/2; M = (M+1)/2;
    for(int i = 0 ; i < n ; i++) { cin >> a[i]; b[i] = a[i]; }
}

int c[maxn], s[maxn], t[maxn], t2[maxn];

long long inversion_cnt(int l, int r) {
    if(l == r) return 0;
    long long ans = 0;
    int m = (l+r)/2;
    ans += inversion_cnt(l, m);
    ans += inversion_cnt(m+1, r);
    
    int i = l, j = m+1;
    for(int i = l ; i <= m ; i++) {
        while(s[i] > s[j] && j <= r) j++;
        if(j <= r) ans += r-j+1;
    }
    
    int k = l; i = l, j = m+1;
    while(i <= m && j <= r) {
        if(s[i] <= s[j]) t[k++] = s[i++];
        else t[k++] = s[j++];
    }
    while(i <= m) t[k++] = s[i++];
    while(j <= r) t[k++] = s[j++];
    for(int i = l ; i <= r ; i++) s[i] = t[i];
    
    return ans;
}

bool ok(int x) {
    for(int i = 0 ; i < n ; i++) c[i] = (a[i] >= x ? 1 : -1);
    s[0] = 0;
    for(int i = 1 ; i <= n ; i++) s[i] = s[i-1] + c[i-1];
    
    if(inversion_cnt(0, n) >= M) return true;
    else return false;
}

void solve() {
    sort(b, b+n);
    int x = unique(b, b+n) - b;
    
    int l = 0, r = x, m;
    while(l+1 < r) {
        m = (l+r)/2;
        if(ok(b[m])) l = m;
        else r = m;
    }
    
    cout << b[l] << "\n";
}

int main() {
    init();
    solve();
}


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

#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;

const int N = 1e5 + 10;
int n, k, x, F[N], a[N], pre[N];

void upd(int x){
    for(; x<N; x += (x&-x)){
        F[x]++;
    }
}

int que(int x){
    int ans = 0;
    for(; x>0; x-=(x&-x))
        ans += F[x];
    return ans;
}

ll get(int x){
    REP(i, N) pre[i] = 0;
    for(int i=1; i<n+1; i++){
        if(a[i]>x) pre[i] = -1;
        else pre[i] = 1;
        pre[i] += pre[i-1];
    }
    int T = min(*min_element(pre+1, pre+n+1), 0);
    REP(i, n+1) pre[i] -= T-1;
    REP(i, N) F[i] = 0;
    ll cur = 0;
    upd(pre[0]);
    for(int i=1; i<n+1; i++){
        cur += que(pre[i]-1);
        upd(pre[i]);
    }
    return cur;
}

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

    int bas = 1, son = 1e9;
    ll look = n*(ll)(n+1) / 2 / 2 + 1;
    while(bas < son){
        int mid = (bas+son)/2;
        if(get(mid) >= look) son = mid;
        else bas = mid + 1;
    }
    cout << bas << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:5: error: 'FAST' was not declared in this scope
   55 |     FAST;
      |     ^~~~
Language: Java

import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
      int num[]=new int[n];
      for(int i=0;i<n;i++){
      	num[i]=sc.nextInt();
      }
      if(n==1)System.out.println(num[0]);
     else if(n==2)System.out.println(Math.max(num[1],num[0]));
      else{
        max=Math.max(num[n/2+1],num[n/2]);
        System.out.println(max);
      }
        
    }
}

Compiler output:
Main.java:18: error: cannot find symbol
        max=Math.max(num[n/2+1],num[n/2]);
        ^
  symbol:   variable max
  location: class Main
Main.java:19: error: cannot find symbol
        System.out.println(max);
                           ^
  symbol:   variable max
  location: class Main
2 errors
Language: C++

#include <cstdio>
#include <iostream>
10
using namespace std;
int main()
{
int i, f, n, j, x, m, L, r;
cin >> n;
int a[n+1];
 
for(i=1; i<=n; i++) cin >> a[i];
 
 
 
L = 1; r = n;
cin >> x;
L <= r
 m = (L+r) / 2;
erturn 0}

Compiler output:
a.cc:3:1: error: expected unqualified-id before numeric constant
    3 | 10
      | ^~
a.cc: In function 'int main()':
a.cc:8:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 | cin >> n;
      | ^~~
      | std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:17:7: error: expected ';' before 'm'
   17 | L <= r
      |       ^
      |       ;
   18 |  m = (L+r) / 2;
      |  ~     
a.cc:19:1: error: 'erturn' was not declared in this scope; did you mean 'extern'?
   19 | erturn 0}
      | ^~~~~~
      | extern
Language: C++

#include <cstdio>
#include <iostream>
10
using namespace std;
int main()
{
int i, f, n, j, x, m, L, r;
cin >> n;
int a[n+1];
 
for(i=1; i<=n; i++) cin >> a[i];
 

 
L = 1; r = n;
cin >> x;
L <= r
 m = (L+r) / 2;
 
 cout << m<< endl;
 return 0;
 
}

Compiler output:
a.cc:3:1: error: expected unqualified-id before numeric constant
    3 | 10
      | ^~
a.cc: In function 'int main()':
a.cc:8:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 | cin >> n;
      | ^~~
      | std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:17:7: error: expected ';' before 'm'
   17 | L <= r
      |       ^
      |       ;
   18 |  m = (L+r) / 2;
      |  ~     
a.cc:20:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |  cout << m<< endl;
      |  ^~~~
      |  std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:20:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   20 |  cout << m<< endl;
      |              ^~~~
      |              std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

int M_Search(int A[], int B[],int n) {
    int s1=0, d1=n-1, ml, s2=0, d2=n-1, m2;
    //分别表示序列A和B的首位数、末位数和中位数
    while(s1!=d1 || s2!=d2){
        m1=(s1+d1)/2;
        m2=(s2+d2)/2;
        if(A[m1]==B[m2])
            return A[m1];  //满足条件 1)
        if(A[m1]<B[m2]){  // 满足条件 2)
            if((s1+d1)%2==0) {  //若元素个数为奇数
                s1=m1;  //舍弃A中间点以前的部分且保留中间点
                d2=m2;  //舍弃B中间点以后的部分且保留中间点
            }else{  //元素个数为偶数
                s1=m1+1;  //舍弃A中间点及中间点以前部分
                d2=m2;  //舍弃B中间点以后部分且保留中间点
            }
        }else{  //满足条件3)
            if((s2+d2)%2==0){  //若元素个数为奇数
                d1=m1;    //舍弃A中间点以后的部分且保留中间点
                s2-m2;    //舍弃B中间点以前的部分且保留中间点
            }else {  //元素个数为偶数
                d1=m1;    //舍弃A中间点以后部分且保留中间点
                s2=m2 + 1;    //舍弃B中间点及中间点以前部分
            }
        }
    }
    rerurn A[s1]<B[s2]?A[s1]:B[s2];
}

Compiler output:
a.cc: In function 'int M_Search(int*, int*, int)':
a.cc:5:9: error: 'm1' was not declared in this scope; did you mean 'm2'?
    5 |         m1=(s1+d1)/2;
      |         ^~
      |         m2
a.cc:27:5: error: 'rerurn' was not declared in this scope
   27 |     rerurn A[s1]<B[s2]?A[s1]:B[s2];
      |     ^~~~~~
Language: C++

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n;
int a[100010];
int sum=0;

signed main(){
    cin>>n;
    int ans;
    rep(i,0,n){
        cin>>a[i];
    if(n==1){
        cout<<a[0]<<endl;
        return 0;
    }
    sort(a,a+n);
    if(n%2==0)ans=a[n/2+1];
    else ans=a[n/2+1];
    
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:2: error: expected '}' at end of input
   45 | }
      |  ^
a.cc:31:14: note: to match this '{'
   31 | signed main(){
      |              ^
Language: C

#include<stdio.h>

int main()
{
    int i,j,n,temp,m;
    scanf("%d",&n);
    int arr[n+1]
    for(i=0;i<n;i++)
     {
          scanf("%d",&arr[i]);
      }
     for (i = 0; i <= n-1 ; i++){
for ( j = i+1;  j<=n;  j++){
if (arr[i] > arr[j]){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
m=(n/2)+1;
printf("%d\n",arr[m]);
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:8:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'for'
    8 |     for(i=0;i<n;i++)
      |     ^~~
main.c:10:23: error: 'arr' undeclared (first use in this function)
   10 |           scanf("%d",&arr[i]);
      |                       ^~~
main.c:10:23: note: each undeclared identifier is reported only once for each function it appears in
Language: Java

package kmp_algorithms;

import java.util.HashMap;
import java.util.Scanner;

public class Permutation {

    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        int n=input.nextInt();
        int arr[]=new int [n];
        for(int i=0;i<n;i++)
            arr[i]=input.nextInt();
        System.out.print(arr[n/2]);
    }

}


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

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

//read_kaisetsu
int main() {
    int n,k;cin>>n>>k;
    int a[n];rep(i,n)cin>>a[i];
    int ans = 400000007;
    rep(i,n-k+1){
        ans = min(ans,abs(a[i])+abs(a[i+k]-a[i]);
        ans = min(ans,abs(a[i+k])+abs(a[i+k]-a[i]);
    }
    cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:49: error: expected ')' before ';' token
   12 |         ans = min(ans,abs(a[i])+abs(a[i+k]-a[i]);
      |                  ~                              ^
      |                                                 )
a.cc:13:51: error: expected ')' before ';' token
   13 |         ans = min(ans,abs(a[i+k])+abs(a[i+k]-a[i]);
      |                  ~                                ^
      |                                                   )
Language: C++

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

const int N = 1e5 + 10;
ll x[N];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> x[i];
    ll ans = 1e18, tmp = 0;
    for (int i = k; i <= n; i++) {
        ll xl = x[i - k + 1], xr = x[i];
        if (xr <= 0) tmp = xl;
        else if (xl >= 0) tmp = xr;
        else tmp = xr - xl + min(labs(xl), labs(xr));
        ans = min(ans, labs(tmp));
    }
    cout << ans << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: no matching function for call to 'min(ll&, long int)'
   18 |         ans = min(ans, labs(tmp));
      |               ~~~^~~~~~~~~~~~~~~~
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:18:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   18 |         ans = min(ans, labs(tmp));
      |               ~~~^~~~~~~~~~~~~~~~
/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:18:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         ans = min(ans, labs(tmp));
      |               ~~~^~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<limits>
#include<algorithm>
using namespace std;
long long INF = numeric_limits<long long>max();
int main(){
  int n;
  cin>>n;
  long long arr[n+1];
  for(int i=1; i<=n; i++) cin>>arr[i];
  long long mindist = INF;
  int p1 = 1;
  int p2 = k;
  while(p2<=n){
    if(arr[p2]<=0) mindist = min(mindist,arr[p1]*-1);
    else if(arr[p1]>=0) mindist = min(mindist,arr[p2]);
    else{
      mindist = min(mindist,arr[p2]-arr[p1]-arr[p1]);
      mindist = min(mindist,arr[p2]-arr[p1]+arr[p2]);
    }
    p1++;
    p2++;
  }
  cout<<mindist;
}

Compiler output:
a.cc:5:42: error: expected primary-expression before 'max'
    5 | long long INF = numeric_limits<long long>max();
      |                                          ^~~
a.cc: In function 'int main()':
a.cc:13:12: error: 'k' was not declared in this scope
   13 |   int p2 = k;
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
long long n,k;
cin>>n>>k;
long long a[n+1]={};
long long b[n+1]={};
long long r;
long long ca=0;
long long cb=0;
for(long long i=0; i<n;i++){
cin>>r;
if(r>0){
a[ca]=r
ca++;}
else if(r<0){
b[cb]=-1*r;
cb++;
}
else
k--;}
sort(a,ca+a);
sort(b,b+cb);
long long counter=0;
for(long long i=0; i<cb;i++){
counter=max(counter,2*b[i]+a[k-i-2]);}
cout<<counter<<endl;}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:8: error: expected ';' before 'ca'
   14 | a[ca]=r
      |        ^
      |        ;
   15 | ca++;}
      | ~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int c=0;
  for(int i=0;i<n;++i)
   cin>>a[i];
  long long ans=9999999999;
  for(int i=0;i<n-k;++i)
  { 
    int x=min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i]));
    ans=min(ans,x);
  }
 cout<<ans<<endl;
            return 0;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: no matching function for call to 'min(long long int&, int&)'
   15 |     ans=min(ans,x);
      |         ~~~^~~~~~~
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:15:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   15 |     ans=min(ans,x);
      |         ~~~^~~~~~~
/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:15:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   15 |     ans=min(ans,x);
      |         ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int c=0;
  for(int i=0;i<n;++i)
   cin>>a[i];
  long long ans=9999999999;
  for(int i=0;i<n-k;++i)
  { 
    int x=min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i]))
    ans=min(ans,x);
  }
 cout<<ans<<endl;
            return 0;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: expected ',' or ';' before 'ans'
   15 |     ans=min(ans,x);
      |     ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int c=0;
  for(int i=0;i<n;++i)
   cin>>a[i];
  long long ans=9999999999;
  for(int i=0;i<n-k;++i)
  {
    ans=min(ans,min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i])));
  }
 cout<<ans<<endl;
            return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: no matching function for call to 'min(long long int&, const int&)'
   14 |     ans=min(ans,min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[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:14:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |     ans=min(ans,min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[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:14:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |     ans=min(ans,min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i])));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int c=0;
  for(int i=0;i<n;++i)
   cin>>a[i];
  long long ans=9999999999;
  for(int i=0;i<n-k;++i)
  {
    ans=min(ans,min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i]));
  }
 cout<<ans<<endl;
            retrun 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:83: error: expected ')' before ';' token
   14 |     ans=min(ans,min(abs(a[i])+abs(a[i+k-1]-a[i]),abs(a[i+k-1])+abs(a[i+k-1]-a[i]));
      |            ~                                                                      ^
      |                                                                                   )
a.cc:17:13: error: 'retrun' was not declared in this scope
   17 |             retrun 0;
      |             ^~~~~~
Language: C++

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

int main() {
ll n,k ;
cin >>n >>k;
ll ans=1e10 ;
vector<ll> x(n)  ;
rep(i,n){
cin >>x[i] ;
}
for(ll i=0;i<n-k+1 ;i++ ){
    if(0<x[i])
    ans=min(ans,x[i+k-1]) ;
    else if(x[i]<=0 &&0<=x[i+k-1])
    ans=min(ans,min(x[i+k-1]-2*x[i],x[i+k-1]-2*x[i])) ;
    else if(x[i+k-1]<0]
    ans=min(ans,0-x[i+k-1]) ;
}
  cout <<ans<<endl ; 
    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:23: error: expected ')' before ']' token
   20 |     else if(x[i+k-1]<0]
      |            ~          ^
      |                       )
a.cc:20:23: error: expected primary-expression before ']' token
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include <set>
typedef long long ll;
using namespace std;
int a[1000005],maxx=-1,minn=1e9,mid;
double midd;
ll sum,sum1,ans;
int main() {
    int n,k,r;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i+k-1<=n;i++)
	{
    r=i+k-1;
    ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
	}
	cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:12: error: no matching function for call to 'min(ll&, int)'
   20 |     ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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_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:20:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |     ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:5:
/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:20:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |     ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include <set>
typedef long long ll;
using namespace std;
using namespace std;
int a[1000005],maxx=-1,minn=1e9,mid;
double midd;
ll sum,sum1,ans;
int main() {
    int n,k,r;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i+k-1<=n;i++)
	{
    r=i+k-1;
    ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
	}
	cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: no matching function for call to 'min(ll&, int)'
   21 |     ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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_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:21:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |     ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:5:
/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:21:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |     ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int n,k;
int A[100010];
int main() {
	cin >> n >> k;
	for (int i =0;i<n;i++) cin >> A[i];
	int ans = LLONG_MAX/2;
	for (int i =0;i<=n-k;i++) {
		ans = min(ans,(A[i] < 0 ? abs(A[i])*2 : 0) + A[i+k-1]); 
	}
	cout << ans;
}


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

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

int n,k;
int A[100010];
int main() {
	cin >> n >> k;
	for (int i =0;i<n;i++) cin >> A[i];
	int ans = INT_MAX/2;
	for (int i =0;i<=n-k;i++) {
		ans = min(ans,(A[i] < 0 ? abs(A[i])*2 : 0) + A[i+k-1]); 
	}
	cout << ans;
}


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

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

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	vector<ll> a(n+1);
	for (int i = 0; i< n; ++i) cin >> a[i];
	sort(a.begin(),a.end());
	ll ans = 1e18+7;
	for (int i = 0; i < n-k+1; ++i) {
		ll left = a[i];
		ll right = a[i+k-1];
		if (right < 0) ans = main(ans,abs(left));
		else if (left < 0) ans = min(abs(left)*2+right,right*2+abs(left));
		else ans = min(ans,abs(right));
	}
	cout << ans;
	return 0;
}

// -30, -20, -10


Compiler output:
a.cc: In function 'int main()':
a.cc:18:42: error: too many arguments to function 'int main()'
   18 |                 if (right < 0) ans = main(ans,abs(left));
      |                                      ~~~~^~~~~~~~~~~~~~~
a.cc:6:5: note: declared here
    6 | int main() {
      |     ^~~~
Language: C++

 #ifdef 1
    #include <bits/stdc++.h>
    #ifdef LOCAL
        #include "cxx-prettyprint-master/prettyprint.hpp"
        #define print(x) cout << x << endl
    #else
        #define print(...) 42
    #endif
    using namespace std;
    using ll = long long;
    #define INF 1'010'000'000'000'000'017LL
    #define mod 1000000007LL
    #define eps 0.0001
    #define all(x) (x).begin(), (x).end()
    #define FOR(i,a,b) for(ll i=(a);i<(b);++i)
    #define rep(i,n)  FOR(i,0,n)
    #define reverse(x) (x).rbegin(), (x).rend()
    #define SZ(x) ((ll)(x).size())
    #define sum(x) accumulate(ALL(x), 0LL)//?
    #define pb(x) push_back(x)
    template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
    public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
#endif
int main() { 
    
    return 0;
}

Compiler output:
a.cc:1:9: error: macro names must be identifiers
    1 |  #ifdef 1
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
  
int main(){
 
long long int n,k;
cin>>n;
cin>>k;
long long int x[n];
for(int i=0;i<n;i++){
    cin>>x[i];
}
int l,r;
long long int mini= INT_MAX;
if(n==1){
    cout<<"0"; return 0;
}
for(long long int i=0;i<n-k;i++){
    l=i;
    r=i+k-1;
    int d1= abs(x[r]-x[l]) + abs(x[l]);
    int d2= abs(x[r]-x[l]) + abs(x[r]);
    mini = min(mini,(min(d1,d2));
}
cout<<mini;
 
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:33: error: expected ')' before ';' token
   24 |     mini = min(mini,(min(d1,d2));
      |               ~                 ^
      |                                 )
Language: C++

#inlcude<bits/stdc++.h>

using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> arr(n);
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int mindist=1e8+1;
  for(int left=0;left<n-k;left++){
    int right=left+k-1;
    int leftans=abs(arr[left])+abs(arr[right]-arr[left]);
    int rightans=abs(arr[right])+abs(arr[right]-arr[left]);
    
    mindist=min(mindist,min(leftans,rightans));
  }
   cout<<mindist<<"\n;
     return 0;

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inlcude; did you mean #include?
    1 | #inlcude<bits/stdc++.h>
      |  ^~~~~~~
      |  include
a.cc:20:19: warning: missing terminating " character
   20 |    cout<<mindist<<"\n;
      |                   ^
a.cc:20:19: error: missing terminating " character
   20 |    cout<<mindist<<"\n;
      |                   ^~~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin>>n>>k;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inlcude<bits/stdc++.h>
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> arr(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #inlcude<bits/stdc++.h>
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> arr(n);
      |          ^~~
a.cc:10:10: error: 'arr' was not declared in this scope
   10 |     cin>>arr[i];
      |          ^~~
a.cc:15:21: error: 'arr' was not declared in this scope
   15 |     int leftans=abs(arr[left])+abs(arr[right]-arr[left]);
      |                     ^~~
a.cc:15:17: error: 'abs' was not declared in this scope
   15 |     int leftans=abs(arr[left])+abs(arr[right]-arr[left]);
      |                 ^~~
a.cc:18:25: error: 'min' was not declared in this scope; did you mean 'main'?
   18 |     mindist=min(mindist,min(leftans,rightans));
      |                         ^~~
      |                         main
a.cc:18:13: error: 'min' was not declared in this scope; did you mean 'main'?
   18 |     mindist=min(mindist,min(leftans,rightans));
      |             ^~~
      |             main
a.cc:20:4: error: 'cout' was not declared in this scope
   20 |    cout<<mindist<<"\n;
      |    ^~~~
a.cc:20:4: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:6: error: expected primary-expression before 'return'
   21 |      return 0;
      |      ^~~~~~
a.cc:21:15: error: expected '}' at end of input
   21 |      return 0;
      |               ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k;
  cin>>n>>k;
  vll t(n);
  rep(i,n){
    cin>>t[i];
  }
  ll ans=INF;
  for(int i=0;i<n-k+1;i++){
    int d=min(abs(t[i]),abs(t[i+k-1]));
    d+=abs(t[i+k-1]-t[i]);
    ans=max(d,ans);
  }
  COUT(ans);
}
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:42:12: error: no matching function for call to 'max(int&, long long int&)'
   42 |     ans=max(d,ans);
      |         ~~~^~~~~~~
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:42:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   42 |     ans=max(d,ans);
      |         ~~~^~~~~~~
/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:42:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |     ans=max(d,ans);
      |         ~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int N=1000006, INF=1000000009;
long long a[N], b[N], t[N], n, u;
void upd(int i) {
   	while(i <= 200002){ ++t[i]; i+=(i&-i); }
}    
int sum(int i) {
    int x=0;
   	while(i){ x+=t[i]; i-=(i&-i); }
    return x;
}     
        
int main(){ ios_base::sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++)
      	cin>>a[i];
    int l=1, r=1e9;
	ll x=((ll)n*((ll)n+1ll)/(ll)2+(ll)1)/(ll)2;
    while(l<=r){
       	int mid=(l+r)/2, ans=0, k=100001;
      	for (int i=0; i<=200002; i++)t[i]=0;
       	upd(k);
    	for (int i=1; i<=n; i++){
     		if(a[i]>mid) ans+=sum(k+1), upd(++k);
      		else 		 ans+=sum(k-1), upd(--k);
     	}
       	if(ans>=x) l=mid+1;
       	else		   r=mid-1;
    }
    cout<<r+1;
   	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'll' was not declared in this scope; did you mean 'l'?
   19 |         ll x=((ll)n*((ll)n+1ll)/(ll)2+(ll)1)/(ll)2;
      |         ^~
      |         l
a.cc:28:17: error: 'x' was not declared in this scope
   28 |         if(ans>=x) l=mid+1;
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
signed main(){
  int a,b,e,f=100000000000;
  cin>>a>>b;
  vector<int> c,d;
  fo(i,a){
    cin>>e;
    if(e<0)
      c.pp(-e);
    else
      d.pp(e);
  }
  Sort(c);
  for(int i=max<int>(0,b-c.sz);i<min<int>(b,d.sz);i++){
    f=min<int>({f,d[i]*2+c[b-i-1],d[i]+c[b-i-1]*2});
  }
  if(c.sz==0)
    f=d[b-1];
  if(d.sz==0)
    f=c[b-1];
  cout<<f<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:144:9: error: 'class std::vector<long long int>' has no member named 'pp'
  144 |       c.pp(-e);
      |         ^~
a.cc:146:9: error: 'class std::vector<long long int>' has no member named 'pp'
  146 |       d.pp(e);
      |         ^~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int n , k, ans = 1e9;
    cin >> n >> k;
    vector <int> a , b;
    for (int i = 0; i < n; ++i) {
        int tr;
        cin >> tr;
        if(x >= 0) {
            a.push_back(tr);
        }
        else
            b.push_back(-tr);
    }
    sort((a).begin() , (a).end());
    sort((b).begin() , (b).end());
    int P = a.size();
    int M = b.size();
    for (int i = 0; i < k + 1; ++i) {
        int j = k - i;
        if(i > P || j > M) {
            continue;
        }
        int pd = 0;
        if(i) {
            pd = a[i - 1];
        }
        int md = 0;
        if(j) {
            md = b[j - 1];
        }
        ans = min(ans , 2 * min(pd , md) + max(pd , md));
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: 'x' was not declared in this scope
   12 |         if(x >= 0) {
      |            ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
 
int main() {
    int n , k, ans = 1e9;
    cin >> n >> k;
    vector <int> a , b;
    for (int i = 0; i < n; ++i) {
        int tr;
        cin >> tr;
        if(x >= 0) {
            a.push_back(tr);
        }
        else
            b.push_back(-tr);
    }
    sort((a).begin() , (a).end());
    sort((b).begin() , (b).end());
    int P = p.size();
    int M = m.size();
    for (int i = 0; i < k + 1; ++i) {
        int j = k - i;
        if(i > P || j > M) {
            continue;
        }
        int pd = 0;
        if(i) {
            pd = p[i - 1];
        }
        int md = 0;
        if(j) {
            md = m[j - 1];
        }
        ans = min(ans , 2 * min(pd , md) + max(pd , md));
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: 'x' was not declared in this scope
   12 |         if(x >= 0) {
      |            ^
a.cc:20:13: error: 'p' was not declared in this scope
   20 |     int P = p.size();
      |             ^
a.cc:21:13: error: 'm' was not declared in this scope
   21 |     int M = m.size();
      |             ^
Language: Java


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

public class Main {
	public static void main(String[] args) {
		c();
	}
		
	private void c() {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] candies = new int[n];
		int res = Integer.MAX_VALUE;
 		for (int i = 0; i < n; i++) {
 			candies[i] = sc.nextInt();
		}
 		
 		for (int i = 0; i < n - k + 1; i++) {
 			int left = Math.abs(candies[i]) + (candies[i + k - 1] - candies[i]);
 			int right = Math.abs(candies[i + k - 1]) + (candies[i + k - 1] - candies[i]);
 			int tmp = Math.min(left, right);
 			res = Math.min(res, tmp);
 		}
 		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Compiler output:
Main.java:10: error: non-static method c() cannot be referenced from a static context
		c();
		^
1 error