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

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 123456789012345
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

ll N, K;
ll A, B, C;
ll ans = INF;

ll Data[123456];
ll Right, Left, Start;

ll _LData[123456];
ll LData[123456];
ll RData[123456];

int main()
{
	IN >> N >> K;

	for (int a = 0; a < N; ++a)
	{
		IN >> Data[a];
		if (Data[a] < 0)
		{
			_LData[Left] = Data[a];
			Left++;
		}
		else if (Data[a] > 0)
		{
			RData[Right] = Data[a];
			Right++;
		}
		else Start++;
	}

	for (int a = 0; a < Left; ++a)
	{
		LData[a] = _LData[Left - a - 1];
	}

	K -= Start;

	ll buf = 0;
	// 右に行く
	if (Right >= K)
	{
		buf += std::abs(RData[K - 1]);
		ans = std::min(ans, buf);
	}

	// 左に行く
	buf = 0;
	if (Left >= K)
	{
		buf += std::abs(LData[K - 1]);
		ans = std::min(ans, buf);
	}

	for (ll a = std::max(1LL, K - Right); a < std::min(K, Left, K - Right + Left); ++a)
	{
		buf = 0;
		buf += std::abs(LData[a - 1]);
		buf *= 2;
		buf += std::abs(RData[K - a - 1]);
		ans = std::min(ans, buf);


	}

	for (ll a = std::max(1LL, K - Left); a < std::min(K, Right, K - Left + Right); ++a)
	{
		buf = 0;
		buf += std::abs(RData[a - 1]);
		buf *= 2;
		buf += std::abs(LData[K - a - 1]);
		ans = std::min(ans, buf);
	}

	OUT << ans << endl;
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:82:52:   required from here
   82 |         for (ll a = std::max(1LL, K - Right); a < std::min(K, Left, K - Right + Left); ++a)
      |                                                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
// #include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    long x[n];
    long zeroIndex = 0;
    bool f=true;
    for(int i = 0; i < n; i++){
        scanf_s("%ld", &x[i]);
        if(f && x[i]>=0){
            zeroIndex = i;
            f = false;
        }
    }
    // cout << zeroIndex << endl;
    int min_r = 1<<30;
    for(int i = 0; i <= k; i++){
        // cout << zeroIndex - k + i << endl;
        if (zeroIndex - k + i >= 0 && zeroIndex+i-1 < n){
            long a = x[zeroIndex - k + i];
            long b = x[zeroIndex + i-1];
            cout << a << " " << b << endl;
            if(abs(a) > abs(b)){
                int c = abs(b) * 2 + abs(a);
                min_r = min(min_r, c);
            }else{
                int c = abs(a) * 2 + abs(b);
                min_r = min(min_r, c);
            }
        }
        cout << min_r << endl;
    }

    cout << min_r << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   17 |         scanf_s("%ld", &x[i]);
      |         ^~~~~~~
      |         scanf
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	long N, K;

	cin >> N >> K;
	vector<long> ro = vector<long>(N);
	vector<long> p;
	vector<long> m;

	p.push_back(0);
	m.push_back(0);
	long zero = 0;
	for(int i=0;i<N;i++){
		cin >> ro[i];
		if(ro[i] == 0){
			zero++;
		} else if( ro[i] > 0){
			p.push_back(ro[i]);
		} else {
			m.push_back(-ro[i]);
		}
	}

	K -= zero;

	int i = 1, j=1;
	sort(m.begin(), m.end());

	for(int x = 0; x < K; x++){
		long nextm, nextp;
		if(i < m.size()){
			if(m[i] < p[j-1]){
				nextm = m[i] * 2;
			} else {
				nextm = m[i];
			}
		} else {
			nextm = LONG_MAX;
		}
		if(j < p.size()){
			if(p[j] < m[i-1]){
				nextp = p[j] * 2;
			} else {
				nextp = p[j];
			} 
		} else {
			nextp = LONG_MAX;
		}
		if(nextm < nextp){
			i++;
		} else {
			j++;
		}
	}
			
	i--;j--;
	long ans = 0;
	ans += 2 * min(p[j], m[i]);
	ans += max(p[j], m[i]);

	cout << ans << endl;

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:61:33: error: 'LONG_MAX' was not declared in this scope
   61 |                         nextm = LONG_MAX;
      |                                 ^~~~~~~~
a.cc:19:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   18 | #include <utility>
  +++ |+#include <climits>
   19 | #include <vector>
a.cc:70:33: error: 'LONG_MAX' was not declared in this scope
   70 |                         nextp = LONG_MAX;
      |                                 ^~~~~~~~
a.cc:70:33: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C

#include<stdio.h>

long int v(long int select[],long int K);
long int sa(long int x,long int y);

long int x[100000];

int main(void)
{
	long int N,K,count=0;
	int i,jikan=0;
	
	scanf("%ld %ld",&N,&K);
	for(i=0;i<N;i++){
		scanf("%d",&x[i]);
	}
	
	return 0;
}

long int v(long int select[],long int K)
{
	long int ve,sa,i;
	
	ve=select[0];
	for(i=1;i<K-1;i++){
		sa=sasa(select[i],select[i+1]);
		ve+=sa*1;
	}
}
			
long int sa(long int x,long int y)
{
	long int sasa=x-y;
	
	if(sasa<0){
		return sasa*=-1;
	} else{
		return sasa;
	}
}

Compiler output:
main.c: In function 'v':
main.c:27:20: error: implicit declaration of function 'sasa'; did you mean 'sa'? [-Wimplicit-function-declaration]
   27 |                 sa=sasa(select[i],select[i+1]);
      |                    ^~~~
      |                    sa
Language: C++

#include <bits/stdc++.h>
using namespace std;
vector<int>v;
vector<int>s;
int main(){
	int n,k;
	int x[100000];
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=n-1;i>=0;i--){
		if(x[i]<=0)v.push_back(x[i]);
		else s.push_back(x[i]);
	}
	if(s.size()==0){
		cout<<abs(v[k-1])<<endl;
		return 0;
	}
	reverse(s.begin(),s.end());
	
	if(v.size()==0){
		cout<<s[k-1]<<endl;
		return 0;
	}
	if(k==1){
		cout<<min(abs(v[0]),s[0])<<endl;
		return 0;
	}
  int ans=1000000000;
  if(s.size()>=k)ans=s[k-1];
	for(int i=0;i<v.size();i++){
		if(i==k)break;
		if(i==k-1)ans=min(ans,abs(v[i]));
		else if(k-i-2<s.size())ans=min(ans,min(abs(v[i])*2+s[k-i-2],abs(v[i])+(s[k-i-2]*2));
		else break;
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:100: error: expected ')' before ';' token
   33 |                 else if(k-i-2<s.size())ans=min(ans,min(abs(v[i])*2+s[k-i-2],abs(v[i])+(s[k-i-2]*2));
      |                                               ~                                                    ^
      |                                                                                                    )
Language: C++

#include <bits/stdc++.h>
using namespace std;
vector<int>v;
vector<int>s;
int main(){
	int n,k;
	int x[100000];
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=n-1;i>=0;i--){
		if(x[i]<=0)v.push_back(x[i]);
		else s.push_back(x[i]);
	}
	if(s.size()==0){
		cout<<abs(v[k-1])<<endl;
		return 0;
	}
	reverse(s.begin(),s.end());
	
	if(v.size()==0){
		cout<<s[k-1]<<endl;
		return 0;
	}
	if(k==1){
		cout<<min(abs(v[0]),s[0])<<endl;
		return 0;
	}
  int ans=1000000000;
  if(s.size()>=k)ans=s[k-1];
	for(int i=0;i<v.size();i++){
		if(i==k)break;
		if(i==k-1)ans=min(ans,abs(v[i]);
		else if(k-i-2<s.size())ans=min(ans,abs(v[i])*2+s[k-i-2]);
		else break;
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:48: error: expected ')' before ';' token
   32 |                 if(i==k-1)ans=min(ans,abs(v[i]);
      |                                  ~             ^
      |                                                )
Language: C++

#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
int N;
int check=0;

long long int Min(long long int a, long long int b){
 if(a<=b)return a;
 else return b;
}

long long int Abs(long long int a){
  if(a>0)return a; 
  else return a*-1;
}

int main(void){
 int n,k;
 int x;
 int a;
 long long int ans=300000000000;
 vector<int> A;
 vector<int> B;
 

 cin>>n>>k;

 for(int i=0; i<n; i++){
  cin>>a;
  if(a<0)A.push_back(Abs(a));  
  else B.push_back(a);
 }
 
 sort(A.begin(),A.end());
 sort(B.begin(),B.end());
 
 if(A.size()>=k)ans=Min(ans,A[k-1]);
 if(B.size()>=k)ans=Min(ans,B[k-1]);
 //for(int i=0; i<A.size();i++)std::cout<<A[i]<<std::endl;

 for(int i=0; i<A.size(); i++){
  long long int sum=300000000000:
  if(k-1-(i+1)<B.size())sum=(long long int)A[i]*2+B[k-1-(i+1)];
  ans=Min(ans,sum);
  if(k-1-(i+1)<B.size())sum=A[i]+(long long int) B[k-1-(i+1)]*2;
  ans=Min(ans,sum);
 }
 std::cout<<ans<<std::endl;
}
 



Compiler output:
a.cc: In function 'int main()':
a.cc:49:33: error: expected ',' or ';' before ':' token
   49 |   long long int sum=300000000000:
      |                                 ^
Language: C++

#include<bits/stdc++.h>
#define INF 1000000009
#define INFL 1000000000000000018
#define int long long
#define mod 10007
#define pb push_back
#define MAXN 505
#define ff first
#define sf second.first
#define ss second.second
using namespace std;
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef vector<int> VE;
typedef map<int, int> MAP;

int n, k, x[200000], ans3 = INFL, pos1, pos2;

signed main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        if(i > 0){
            if(x[i] > 0 && x[i - 1] < 0){
                pos1 = i;
                pos2 = i - 1;
            }
        }
    }
    if(k == 1){
        cout << 0 << endl;
        return 0;
    }
    if(x[0] >= 0){
        for(int i = 0; i < n; i++){
            if(i == k - 1){
                cout << x[i] << endl;
                return 0;
            }
        }
    }
    else if(x[n - 1] =< 0){
        int s = 0;
        for(int i = n - 1; i >= 0; i++){
            s++;
            if(s == k){
                cout << abs(x[i]) << endl;
                return 0;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(x[i] < 0){
            if(pos1 - i < k){
                if(k + i - 1 >= 0 && k + i - 1 < n){
                    ans3 = min(ans3, abs(x[i] * 2) + x[k + i - 1]);
                }
            }
            else if(pos1 - i == k){
                ans3 = min(ans3, abs(x[i]));
            }
        }
        else if(x[i] > 0){
            if(i - pos2 < k){
                if(i + 1 - k >= 0 && i + 1 - k < n){
                    ans3 = min(ans3, x[i] * 2 + abs(x[i + 1 - k]));
                }
            }
            else if(i - pos2 == k){
                ans3 = min(ans3, abs(x[i]));
            }
        }
    }
    cout << ans3 << endl;


    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:43:23: error: expected primary-expression before '<' token
   43 |     else if(x[n - 1] =< 0){
      |                       ^
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a[100001];
    int b,k=0,n=0,i,h,w,j,mi=0,pl=0,ans;
    scanf("%d %d",&n,&k);
    for(i=0;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>=0){pl++;
    }else if(a[i]<0){
        mi++;
    }}
    for(i=0;i<=n;i++){
        if(a[0]<0&&a[i]>=0){
            b=i;
            break;
        }
    }
    if(pl>=k&&mi>=k){
        if(abs(a[b-1]-0)>abs(a[b]-0)){ans=a[b+k];}
        else{ans=abs(a[b-k]);}
        
    }else if(pl>=k){
        ans=a[b+k];
        printf("%d",ans);
    }else if(mi>=k||(a[b]==0&&mi>k)){
        ans=a[b-k];
        printf("%d",ans);
    }else if(pl<k&&mi<k){
        if(pl>mi){
            ans=
        }
    }

    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:34:9: error: expected expression before '}' token
   34 |         }
      |         ^
Language: C++

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

int main () {

    int N, K;
    scanf("%d %d", &N, &K);

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

    sort(x, x + N, greater<int>());

    long long ans = INT_MAX;

    for (int i = 0; i < N-K+1; i++) {
        int left = x[i], right = x[i+K-1];

        if (left * right >= 0) {
            ans = min(ans, max(abs(left), abs(right)));
        }
        else {
            ans = min(ans, min(2LL*abs(left)+abs(right), 2LL*abs(right)+abs(left)));
        }
    }
    printf("%lld\n", ans);

    return 0;
}

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

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        long sum = 0;
        long min = Long.MAX_VALUE;
        for (int i = 0; i < n - (k - 1); i++) {
            if (arr[i] < 0 && arr[i + (k - 1)] < 0) {
                sum = Math.abs(arr[i]);
            } else if (arr[i] < 0 && arr[i + (k - 1)] > 0) {
                sum = Math.abs(arr[i] * 2) + arr[i + (k - 1)];
            } else {
                sum = arr[i + (k - 1)];
            }
            min = Math.min(min, sum);

        }
        for (int i = n - 1; i > n - (k - 1); i--) {
            if (arr[i] < 0 && arr[i - (k - 1)] < 0) {
                sum = Math.abs(i - (k - 1));
            } else if (arr[i] > 0 && arr[i - (k - 1)] < 0) {
                sum = (arr[i]) + Math.abs(arr[i - (k - 1)] * 2);
            } else {
                sum = arr[i];
            }
            min = Math.min(min, sum);

        }
        out.println(min);

    }


    public static void main(String[] args) {
        new Solution().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }


        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }
}


Compiler output:
Main.java:45: error: cannot find symbol
        new Solution().run();
            ^
  symbol:   class Solution
  location: class Main
1 error
Language: C

#include <stdio.h>

int main(void)
{
	int a,b,i,x[10001],y,min=10000000,c,z=0;
	int z[10001];
	scanf("%d %d",&a,&b);
	c=a-b;
	for(i=0;i<a;i++){
		scanf("%d",&x[i]);
	}
	if(b==1){
		for(i=0;i<a;i++){
			y=x[i];
			if(y<min){
				min=y;
			}
		}
	}else{
		for(i=0;i<a;i++){
			if(x[i]<0){
				z[i]=x[i]*(2);
			}else{
				z[i]=x[i];
			}
		}
		for(i=0;i<c;i++){
			y=z[i+c]-z[i];
			if(y<min){
				min=y;
			}
		}
	}
	printf("%d",min);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:13: error: conflicting types for 'z'; have 'int[10001]'
    6 |         int z[10001];
      |             ^
main.c:5:45: note: previous definition of 'z' with type 'int'
    5 |         int a,b,i,x[10001],y,min=10000000,c,z=0;
      |                                             ^
Language: C

#include <stdio.h>

int abs(int x){
    if (x>=0) return x;
    else      return -x;
}

int main(){
   int n,k,i,x[100000],m,mi,s,e,l;

   scanf("%d %d",&n,&k);
   for (i=0;i<n;i++) {
      scanf("%d",&x[i]);
      if (i==0) {
         m=x[0];mi=0;
      } else if (abs(x[i])<abs[m]) {
         m=x[i];mi=i;
      }
   }

   s=mi-k-1;
   if (s<0) s=0;
   e=mi+k+1;
   if (e>n) e=n;
   for (i=s;i<e-k;i++) {
      l=abs(x[i])+x[i+k-1]-x[i];
      if (i==s) m=l;
      else if (m>l) m=l;
   }
   printf("%d\n",m);
   return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:31: error: subscripted value is neither array nor pointer nor vector
   16 |       } else if (abs(x[i])<abs[m]) {
      |                               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,k,place=0;
  long long int ans=1000000000;
  long long int dis,disad;
  bool b=false;
  cin>>n>>k;
  long long int c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]<0) place=i;
  }
  for(int i=0;i<n-k;i++){
    if((i+k-1)<place) continue;
    if((place+1)<i) continue;
    dis=c[i+k-1]-c[i];
    disad=c[i];
    disad=abs(disad);
    disad=min(disad,c[i+k-1]);
    dis+=disad;
    ans=min(ans,dis);
  }
  if(k==1){
    for(int i=0;i<n;i++){
      dis=abs(c[i]);
      ans=min(ans,dis);
    }
  }
  if(c[n-1]<0){
    ans=abs[n-k];
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:12: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   31 |     ans=abs[n-k];
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=1;i<=N;i++){
    cin >> x.at(i);}
  int a,b;
  for(int i=1;i<=N;i++){
    if(x[i]>=0){a=i;  break;}
  }
  if(x[N]<=0){cout << (-1)*x[N-K+1] << endl;}
  else if(x[1]>=0){cout << x[K] << endl;}
  else if(a-1>=K){
    b=(-1)*x[a-K];
    for(int i=1;i<=K;i++){
      if(b<(-1)*x[a-K+i]



Compiler output:
a.cc: In function 'int main()':
a.cc:19:25: error: expected ')' at end of input
   19 |       if(b<(-1)*x[a-K+i]
      |         ~               ^
      |                         )
a.cc:19:25: error: expected statement at end of input
a.cc:19:25: error: expected '}' at end of input
a.cc:18:26: note: to match this '{'
   18 |     for(int i=1;i<=K;i++){
      |                          ^
a.cc:19:25: error: expected '}' at end of input
   19 |       if(b<(-1)*x[a-K+i]
      |                         ^
a.cc:16:18: note: to match this '{'
   16 |   else if(a-1>=K){
      |                  ^
a.cc:19:25: error: expected '}' at end of input
   19 |       if(b<(-1)*x[a-K+i]
      |                         ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    long long a[200000];
    int start = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] < 0)
            start = i;
    }
    start++;
    long long min = LONG_LONG_MAX;
    for (int i = 1; i <= n; i++) {
        long long p;
        if (i < start) {
            if (start - i < k) {
                p = 2 * abs(a[i]) + abs(a[k + i - 1]);
                if (min > p)
                min = p;
            }
            else if(start - i == k) {
                p = 2 * abs(a[i]);
                if (min > p)
                    min = p;
            }
        }
        else {
            if (i - start + 1 < k) {
                p = 2 * abs(a[i]) + abs(a[i - k + 1]);
                if (min > p)
                min = p;
            }
            else if (i - start + 1 == k){
                p = 2 * abs(a[i]);
                if (min > p)
                    min = p;
            }
        }


    }
    cout << min;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: 'LONG_LONG_MAX' was not declared in this scope
   17 |     long long min = LONG_LONG_MAX;
      |                     ^~~~~~~~~~~~~
Language: C++

//**************************
//*** writer  :  Alan Hu **
//************************

//傅思程你敢抄我程序？？？ 
//傅思程你敢抄我程序？？？	                
//傅思程你敢抄我程序？？？ 

#include<bits/stdc++.h>

using namespace std;
     
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>

int main(void) {
    int n,k,x[100000],max = -1999999999,min = 1999999999,i;
    scanf("%d %d",&n,&k);
    for (i = 0;i < k;i++) {
        scanf("%d",&x[i]);
    }
    for (i = 0;i < k;i++) {
        if (x[i] < min) min = x[i];
        if (x[i] > max) max = x[i];
    }
    if (min >= 0) {
        printf("%d\n",max);
    } else if (max <= 0) {
        printf("%d\n",min)
    } else {
        if (max >= min * -1) {
            printf("%d\n",min * 2 + max);
        } else {
            printf("%d\n",max * 2 + min);
        }
    }
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:27: error: expected ';' before '}' token
   16 |         printf("%d\n",min)
      |                           ^
      |                           ;
   17 |     } else {
      |     ~
Language: C++

#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100010];
int inf = 1000000000;
ll INF = (1 << 29);
int main() {
	ll n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	ll zero = upper_bound(a, a + n, 0) - lower_bound(a, a + n, 0);
	ll minus = lower_bound(a, a + n, 0) - zero - a;
	ll plus = n - minus - zero;
	k -= zero;
	ll ans = INF;
	if (plus >= k)ans = a[minus + zero + k - 1];
	if (minus >= k)ans = min(ans, -a[minus + zero + 1 - k]);
	for (int i = min(minus - 1, n - k); i >= 0; i--) {
		ans = min(ans, a[i] * -2 + a[i + (k - 1)]);
	}
	for (int i = max(n - plus, k); i < n; i++) {
		ans = min(ans, a[i] * 2 + -a[i - (k - 1)]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin >> n >> k;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:26:9: error: 'cout' was not declared in this scope
   26 |         cout << ans << endl;
      |         ^~~~
a.cc:26:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:24: error: 'endl' was not declared in this scope
   26 |         cout << ans << endl;
      |                        ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<algorithm>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

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

size_t calc(ssize_t l, ssize_t r) {
  size_t abs_l = std::abs(l);
  size_t abs_r = std::abs(r);
  if (l < 0 && r > 0) {
    size_t min = std::min(abs_l, abs_r);
    size_t max = std::max(abs_l, abs_r);
    return 2 * min + max;
  } else if (l < 0) {
    return abs_l;
  } else {
    return abs_r;
  }
}


int main() {
  size_t N, K;
  std::cin >> N >> K;

  std::vector<ssize_t> X(N);

  for (size_t i=0; i<N; i++) {
    std::cin >> X[i];
  }

  size_t ans = calc(X[i], X[N-1]);

  for (size_t i=0; i<N-K; i++) {
    size_t tmp = calc(X[i], X[i+K-1]);
    ans = std::min(ans, tmp);
  }

  std::cout << ans << std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:23: error: 'i' was not declared in this scope
   31 |   size_t ans = calc(X[i], X[N-1]);
      |                       ^
Language: C++

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

int main()
{
  int N, K;
  cin >> N >> K;

  int x[N];
  for(int i = 0; i < N; ++i) cin >> x[i];

  bool n[N];
  vector<int> l, r;
  for(int i = 0; i < N; ++i){
    if(x[i] < 0){
      l.emplace_back(x[i]);
      n[i] = false;
    }else{
      r.emplace_back(x[i]);
      n[i] = true;
    }
  }

  if(l.empty()){
    cout << x[K-1] << endl;
    return 0;
  }else if(r.empty()){
    reverse(x,x+N);
    cout << -x[K-1] << endl;
    return 0;
  }

  
  int s[N];
  for(int i = 0; i < l.size(); ++i){
    s[i] = l.size()-i;
  }
  for(int i = l.size(); i < N; ++i){
    s[i] = i-l.size()+1;
  }

  int ans = INT_MAX;
  for(int i = 0; i < N; ++i){
    if(n[i]){
      if(K > s[i]){
        ans = min(ans, x[i]-2*x[l.size()-K+s[i]]);
      }else if(K == s[i]){
        ans = min(ans, x[i]);
      }
    }else{
      if(K > s[i]){
        ans = min(ans, -x[i]+2*x[l.size()+K-s[i]-1]);
      }else if(K == s[i]){
        ans = min(ans, x[i]);
      }
    }
  }

  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:5: error: 'reverse' was not declared in this scope
   30 |     reverse(x,x+N);
      |     ^~~~~~~
Language: C++

#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;



int N, K, ans = 0;
int counter = 0;
vector<lli> A;

lli calc(int pos)
{
	int need = K + pos - 1;
	if (need > N - 1) {
		return LLONG_MAX;
	}
	int dist = 0;
	if (pos < counter) {
		if (need < counter) {
			return calc(pos + 1);
		}
		//cerr << abs(A[pos] * 2) + abs(A[need]) << endl;
		return min(abs(A[pos] * 2) + abs(A[need]), calc(pos + 1));
	}
	else {
		//cerr << abs(A[need]) << endl;
		return abs(A[need]);
	}
}


int main()
{
	
	scanf("%d %d", &N, &K);
	A = vector<lli>(N);
	
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		if (A[i] < 0) {
			counter++;
		}
	}
	if (K == 1) {
		if (counter == 0) {
			cout << A[counter] << endl;
			return 0;
		}
		cout << min(abs(A[counter - 1]), A[counter]) << endl;
		return 0;
	}

	cout << calc(0) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'lli calc(int)':
a.cc:59:24: error: 'LLONG_MAX' was not declared in this scope
   59 |                 return LLONG_MAX;
      |                        ^~~~~~~~~
a.cc:17:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   16 | #include <functional>
  +++ |+#include <climits>
   17 |
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
using ll = long long;
const ll INF = INT_MAX;
ll n, m, a,b, add, ans=INF, A[101010], B[101010];
void solve() {
	if (B[0] < 0 && 0 <= B[m-1]) ans = min(ans, min(abs(B[0]), B[m-1]) * 2 + max(abs(B[0]), B[m-1]));
	else ans = min(ans, max(abs(B[0]), abs(B[m-1])));
}
int main() {
	cin >> n >> m;
	rep(i, n) cin >> A[i];
	rep(i, n - m + 1) {
		for (int j = 0; j < m; j++) {
			B[j] = A[i + j];
		}
		solve();
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:16:16: error: 'INT_MAX' was not declared in this scope
   16 | const ll INF = INT_MAX;
      |                ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <functional>
  +++ |+#include <climits>
   12 | #define rep(i,n) for(int i=0;i<n;++i)
Language: C++

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

int l=0,r=0,n,k,ans = 2000000000;
int x[100005] = {0};

int main(){
int i,j;
  cin >> n >> k;
  for(i=0;i<n;++i){
    cin >> x[i];
    if(x[i]>0)++r;
    else if (x[i] == 0){
      --k;
      --n;
      --i;
    }
    else ++l;
  }
  if(k==0)ans = 0;
  for(i=l-min(l,k);i<l;++i){
    if(l-i+r<k)break;
    ans = min(ans,-x[i]+x[k-i-1]);
    cout << ans << endl;
    return 0;
}


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

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

int main(void) {
  int all;
  int today;
  int answer;
  scanf("%d", &all);
  scanf("%d", &today);
  for(int i = 0; i <= all; i++){
  int candle[i];
  scanf("%d", &candle[i]);
  }
for(int i = 0; i <= all - today + 1; i++){
for(int j = 0; j <= today; j++){
int member[i];
member[i] = member[i-1] + candle[i+j];
answer = member.min();
}

}
printf("%d", answer);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: 'candle' was not declared in this scope
   17 | member[i] = member[i-1] + candle[i+j];
      |                           ^~~~~~
a.cc:18:17: error: request for member 'min' in 'member', which is of non-class type 'int [i]'
   18 | answer = member.min();
      |                 ^~~
Language: C++

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

int l=0,r=0,n,k,ans = 2000000000;
int x[100005] = {0};

int main(){
int i,j;
  cin >> n >> k;
  for(i=0;i<n;++i){
    cin >> x[i];
    if(x[i]>0)++r;
    else if (x[i] == 0){
      --k;
      --n;
      --i;
    }
    else ++l;
  }
  if(k==0)ans = 0;
  for(i=l-min(l,k);i<l;++i){
    if(l-i+r<k)break;
    ans = min(ans,-x[i]+x[k-i-1]);
    cout << ans << endl;
    return 0;
}

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

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

int main(void) {
  int all;
  int today;

  scanf("%d", &all);
  scanf("%d", &today);
  for(int i = 0; i <= all; i++){
  int candle[i];
  scanf("%d", &candle[i]);
  }
for(int i = 0; i <= all - today + 1; i++){
for(int j = 0; j <= today; j++){
int member[i];
member[i] = member[i-1] + candle[i+j];
}
}
int answer = member.min();
      printf("%d", answer);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: 'candle' was not declared in this scope
   17 | member[i] = member[i-1] + candle[i+j];
      |                           ^~~~~~
a.cc:20:14: error: 'member' was not declared in this scope
   20 | int answer = member.min();
      |              ^~~~~~
Language: C++

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

int main(void) {
  int all;
  int today;

  scanf("%d", &all);
  scanf("%d", &today);
  for(int i = 0; i <= all; i++){
  int candle[i];
  scanf("%d", &candle[i]);
  }
for(int i = 0; i <= all - today + 1; i++){
int counter[i] = 0;
for(int j = 0; j <= today; j++){
int member[i] += candle[i+j];
}
}
int answer = member.min();
      printf("%d", answer);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:18: error: array must be initialized with a brace-enclosed initializer
   15 | int counter[i] = 0;
      |                  ^
a.cc:17:15: error: expected initializer before '+=' token
   17 | int member[i] += candle[i+j];
      |               ^~
a.cc:20:14: error: 'member' was not declared in this scope
   20 | int answer = member.min();
      |              ^~~~~~
Language: C++

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

int main(void) {
  int all;
  int today;

  scanf("%d", &all);
  scanf("%d", &today);
  for(int i = 0; i <= all; i++){
  int candle[i];
  scanf("%d", &candle[i]);
  }
for(int i = 0; i <= all - today + 1; i++){
int counter[i] = 0;
for(int j = 0; j <= today; j++){
int member[i] += candle[i+j];
}
}
int answer = *std::min_element(member.begin(), member.end());
      printf("%d", answer);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:18: error: array must be initialized with a brace-enclosed initializer
   15 | int counter[i] = 0;
      |                  ^
a.cc:17:15: error: expected initializer before '+=' token
   17 | int member[i] += candle[i+j];
      |               ^~
a.cc:20:20: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'?
   20 | int answer = *std::min_element(member.begin(), member.end());
      |                    ^~~~~~~~~~~
      |                    tuple_element
a.cc:20:32: error: 'member' was not declared in this scope
   20 | int answer = *std::min_element(member.begin(), member.end());
      |                                ^~~~~~
Language: C++

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

int main(){
  int n,k;
  cin>>n>>k;
  int x[n],y[n];
  int po=0,ne=0;
  for(int i=0;i<n;i++){
    cin>>x[i];
    if(x[i]>=0){
      po++;
    }
    if(x[i]<=0){
      ne++;
    }
    y(i)=abs(x[i]);
  }
  int a,b,c;
  sort(y,y+n);
  if(k==1){
    cout<<y[0]<<endl;
  }else{
    a=2*y[k-2]+y[k-1];
    if(po>=k){
      int s[po];
      int d=0;
      for(int j=0;j<n;j++){
        if(x[j]>=0){
          s[d]=x[j];
        }
        d++;
      }
      sort(s,s+po);
      b=s[k-1];
    }
    if(ne>=k){
      int t[ne];
      int e=0;
      for(int j=0;j<n;j++){
        if(x[j]<=0){
          t(e)=-x[j];
        }
        e++;
      }
      sort(t,t+ne);
      c=t[k-1];
    }
    cout<<min({a,b,c})<<endl;
  }
}
          

Compiler output:
a.cc: In function 'int main()':
a.cc:19:6: error: 'y' cannot be used as a function
   19 |     y(i)=abs(x[i]);
      |     ~^~~
a.cc:44:12: error: 't' cannot be used as a function
   44 |           t(e)=-x[j];
      |           ~^~~
Language: Java

import java.util.Scanner;
public class Main3 {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main3 tr = new Main3();
		tr.test(sc);
		sc.close();
	}
	
	void test(Scanner sc){
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] a = new int[N+1];
		a[1] = sc.nextInt();
		int here=-1;
		for (int i = 2; i <= N; i++) {
			a[i] = sc.nextInt();
			if(a[i-1]< 0 && a[i] > 0){
				here = i;
			}
		}
		int out=0;
		if(here==-1){
			// all in one side
			if(a[1]>=0){
				out += a[K]; 
			}else{
				out += (-1 * a[N+1-K]);
			}
		}else{
			out  = Integer.MAX_VALUE;
			here--;
			int left = here>K?here-1-K:1;
			int right = left + K -1;
			here++;
			while(left<=here && right <= N){
				int dist = a[right]-a[left];
				if(a[left]<0){
					dist += (-1 * a[left]);
				}else{
					dist+=a[left];
				}
				if(out>dist){
					out=dist;
				}
				left++;
				right++;
			}
		}
		System.out.println(out);
	}
}


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

#include <iostream>
#include <cstdint>
#include <algorithm>
#include <limits>

int main() {
  std::int_fast64_t n, k;
  std::cin >> n >> k;
  std::vector<std::int_fast64_t> positive;
  std::vector<std::int_fast64_t> negative;
  std::int_fast64_t zero = 0;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t x_i;
    std::cin >> x_i;
    if (x_i > 0) {
      positive.push_back(x_i);
    } else if (x_i < 0) {
      negative.push_back(-x_i);
    } else {
      ++zero;
    }
  }
  k -= zero;
  std::sort(positive.begin(), positive.end());
  std::sort(negative.begin(), negative.end());
  std::int_fast64_t result;
  if (k == 0) {
    result = 0;
  } else {
    result = std::numeric_limits<std::int_fast64_t>::max();
    if (k - 1 < static_cast<std::int_fast64_t>(positive.size())) result = std::min(result, positive[k - 1]);
    if (k - 1 < static_cast<std::int_fast64_t>(negative.size())) result = std::min(result, negative[k - 1]);
    for (std::int_fast64_t i = 1; i < k; ++i) {
      if (i - 1 < static_cast<std::int_fast64_t>(positive.size()) && k - i - 1 < static_cast<std::int_fast64_t>(negative.size())) {
        result = std::min(result, 2 * positive[i - 1] + negative[k - i - 1]);
      }
      if (i - 1 < static_cast<std::int_fast64_t>(negative.size()) && k - i - 1 < static_cast<std::int_fast64_t>(positive.size())) {
        result = std::min(result, 2 * negative[i - 1] + positive[k - i - 1]);
      }
    }
  }
  std::cout << result << std::endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: 'vector' is not a member of 'std'
    9 |   std::vector<std::int_fast64_t> positive;
      |        ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <limits>
  +++ |+#include <vector>
    5 | 
a.cc:9:32: error: expected primary-expression before '>' token
    9 |   std::vector<std::int_fast64_t> positive;
      |                                ^
a.cc:9:34: error: 'positive' was not declared in this scope
    9 |   std::vector<std::int_fast64_t> positive;
      |                                  ^~~~~~~~
a.cc:10:8: error: 'vector' is not a member of 'std'
   10 |   std::vector<std::int_fast64_t> negative;
      |        ^~~~~~
a.cc:10:8: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:10:32: error: expected primary-expression before '>' token
   10 |   std::vector<std::int_fast64_t> negative;
      |                                ^
a.cc:10:34: error: 'negative' was not declared in this scope
   10 |   std::vector<std::int_fast64_t> negative;
      |                                  ^~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int main{
int N;
cin>>N;
int K;
cin>>K;
int x[100000];
for(i=0;i<N;i++){
cin>>x[i];
}

int max=300000000;

int pm=N;

for(j=0;1==1;j++){
if(x[j]>0){pm=j;break;}
}

for(k=0;k<pm;k++){
if(max<x[k+K-1]*2-x[k]){max=x[k+K-1]*2-x[k];}
if(max<x[k+K-1]-x[k]*2){max=x[k+K-1]*2-x[k]*2;}
}

cout<<max;}

Compiler output:
a.cc:3:5: error: cannot declare '::main' to be a global variable
    3 | int main{
      |     ^~~~
a.cc:4:1: error: expected primary-expression before 'int'
    4 | int N;
      | ^~~
a.cc:4:1: error: expected '}' before 'int'
a.cc:3:9: note: to match this '{'
    3 | int main{
      |         ^
a.cc:5:1: error: 'cin' does not name a type
    5 | cin>>N;
      | ^~~
a.cc:7:1: error: 'cin' does not name a type
    7 | cin>>K;
      | ^~~
a.cc:9:1: error: expected unqualified-id before 'for'
    9 | for(i=0;i<N;i++){
      | ^~~
a.cc:9:9: error: 'i' does not name a type
    9 | for(i=0;i<N;i++){
      |         ^
a.cc:9:13: error: 'i' does not name a type
    9 | for(i=0;i<N;i++){
      |             ^
a.cc:15:8: error: 'N' was not declared in this scope
   15 | int pm=N;
      |        ^
a.cc:17:1: error: expected unqualified-id before 'for'
   17 | for(j=0;1==1;j++){
      | ^~~
a.cc:17:9: error: expected unqualified-id before numeric constant
   17 | for(j=0;1==1;j++){
      |         ^
a.cc:17:14: error: 'j' does not name a type
   17 | for(j=0;1==1;j++){
      |              ^
a.cc:21:1: error: expected unqualified-id before 'for'
   21 | for(k=0;k<pm;k++){
      | ^~~
a.cc:21:9: error: 'k' does not name a type
   21 | for(k=0;k<pm;k++){
      |         ^
a.cc:21:14: error: 'k' does not name a type
   21 | for(k=0;k<pm;k++){
      |              ^
a.cc:26:1: error: 'cout' does not name a type
   26 | cout<<max;}
      | ^~~~
a.cc:26:11: error: expected declaration before '}' token
   26 | cout<<max;}
      |           ^
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
using namespace atcoder;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

//inversion
ll inversion(vector<int> a) {
    ll ret = 0;
    int max_ = 400010;
    fenwick_tree<ll> fw(2*a.size() + 1);
    for (int i = 0; i < int(a.size());i++){
        cout << a[i] << endl;
        ret += fw.sum(0,a[i] + a.size()) ;
        fw.add(a[i] + a.size(), 1);
    }
    return ret;
}

bool check(const vector<ll>& a,ll v){
    ll n = a.size();
    
    // v以上のものが、半数以上あるか
    // bの部分列で、和が0以上になるなら半数以上
    vector<ll> b(a.size() + 1);
    rep(i, a.size()) b[i + 1] = a[i] >= v ? 1 : -1;

    vector<ll> c(a.size() + 1);
    rep(i, a.size()) c[i + 1] = c[i] + b[i + 1];

    //c[i] <= c[j] となるような(i,j) の組み合わせ. BITで求められる
    fenwick_tree<ll> fw(2 * n + 1);

    //中央値がv以上になるi,jの組み合わせ
    ll sum = 0;
    rep(j,n+1){
        sum += fw.sum(0,c[j] + n + 1);
        fw.add(n + c[j], 1);
    }
    // cout << sum << endl;

    bool ok = sum >= n * (n + 1) / 4;
    // ok = 1: medianはv以上が確実
    // ok = 0: medianはv未満が確実
    return ok;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> s = a;
    sort(s.begin(), s.end());

    ll left = 0;
    ll right = s.size();

    while(right - left > 1){
        // cout << ng << " " << ok << endl;
        ll mid = (left + right) / 2;
        if(check(a,s[mid])){
            left = mid;
        }else{
            right = mid;
        }
    }

    cout << s[left] << endl;

    return 0;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
using namespace atcoder;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}
int main(){
    long long N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    int low = 0, high = 100001;
    const int geta = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        long long num = 0;
        fenwick_tree<long long> bit(N*2+10);
        int sum = 0;
        bit.add(sum+geta, 1);
        for (int i = 0; i < N; ++i) {
            int val;
            if (a[i] <= mid) val = 1; else val = -1;
            sum += val;
            num += bit.sum(0, sum+geta);
            bit.add(sum+geta, 1);
        }
        if (num > (N+1)*N/4) high = mid;
        else low = mid;
    }
    cout << high << endl;
    return 0;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
using namespace atcoder;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}
int main(){
    long long N; cin >> N;
    vector<int> a(N); for (int i = 0; i < N; ++i) cin >> a[i];
    int low = 0, high = 1<<30;
    const int geta = N+1;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        long long num = 0;
        fenwick_tree<long long> bit(N*2+10);
        int sum = 0;
        bit.add(sum+geta, 1);
        for (int i = 0; i < N; ++i) {
            int val;
            if (a[i] <= mid) val = 1; else val = -1;
            sum += val;
            num += bit.sum(0, sum+geta);
            bit.add(sum+geta, 1);
        }
        if (num > (N+1)*N/2/2) high = mid;
        else low = mid;
    }
    cout << high << endl;
    return 0;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.