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

// Last Change:           11/29/2018 22:15:28.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <list>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, K, x[100000];
  int pNum = 0, nNum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    if (x[i] > 0) {
      pNum++;
    } else if (x[i] == 0) {
      N--;
      i--;
      K--;
    }
  }
  nNum = N - pNum;

  int left, right;
  if (nNum >= K) {
    left = nNum - K;
    right = nNum - 1;
  } else {
    left = 0;
    right = K - 1;
  }

  int tmp = abs(x[left]) + abs(x[right]) + abs(min(x[left], x[right]));
  while (left < =nNum && right < N) {
    tmp = min(tmp, abs(x[left]) + abs(x[right]) + abs(min(x[left], x[right])));
    right++;
    left++;
  }

  cout << tmp << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:17: error: expected primary-expression before '=' token
   39 |   while (left < =nNum && right < N) {
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, k;
	cin >> N >> k;
	int x[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	long long ans=1000000000;
	sort(x, x + N);
	ans = 1000000000;
	for (int i = 0; i < N; i++) {
		long long time1, time2=1000000000;
		if (A[i] >= 0) {
			time1 = A[i + k - 1];
		}
		else if (A[i + k - 1] <= 0) {
			time1 = -A[i];
		}
		else {
			time1 = (A[i + k - 1] - A[i]) * 2 - A[i + k - 1];
			time2 = (A[i + k - 1] - A[i]) * 2 + A[i];
			time1 = min(time1, time2);
		}
		ans = min(ans, time1);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'A' was not declared in this scope
   15 |                 if (A[i] >= 0) {
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int x[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	long long ans;
	sort(x, x + N);
	if (0 <= x[0]) {
		ans = x[K - 1];
		cout << ans << endl;;
	}
	else if (x[N - 1] <= 0) {
		ans = -x[N - 1 - k + 1];
		cout << ans << endl;
	}
	else {
		int time1, time2;
		int border;
		for (int i = 0; i< N-1; i++) {
			if (x[i] < 0 && x[i + 1] >= 0) {
				border = i + 1;
			}
		}
		for (int i = 0; i < border; i++) {
			time1 = -x[i]*2 + x[i + k - 1];
			time2= -x[i]  + x[i + k - 1]*2;
			ans = min(time1, time2);
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:34: error: 'k' was not declared in this scope
   17 |                 ans = -x[N - 1 - k + 1];
      |                                  ^
a.cc:29:49: error: 'k' was not declared in this scope
   29 |                         time1 = -x[i]*2 + x[i + k - 1];
      |                                                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
static const int NMAX = 100000;
int N,K,x[NMAX+1];

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

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

    int rf_time,lf_time;
    if(left != 0) rf_time = 2*right - left;
    else rf_time = right;

    if(right != 0) lf_time = (-2)*left + right;
    else lf_time = -left;

    min_time = min(min_time,rf_time);
    min_time = min(min_time,lf_time);
  }
  cout << min_time << endl;
  return 0;
}


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

#include <iostream>
#include <vector>
 
using namespace std;
 
int main () {
  long N, K;
  cin >> N >> K;
  vector<long> x;
  for (long i = 0; i < N; i++) {
    long tmp;
    cin >> tmp;
    x.push_back(tmp);
  }

  vector<long> left;
  vector<long> right;

  long i;
  for (i = 0; x[i] < 0; i++) {
    left.push_back(-x[i]);
  }
  reverse(left.begin(), left.end());
  if (x[i] == 0) {
    K--;
    i++;
  }
  for(; i < N; i++) {
    right.push_back(x[i]);
  }

  if (K == 0) {
    cout << 0 << endl;
    return 0;
  }

  long ans = 0;
  if (left.size() > 0) ans += left.back();
  if (right.size() > 0) ans += right.back();

  for (long j = 0; j < left.size() && j < K; j++) {
    if (j + 1 == K) {
      if (ans > left[j]) {
        ans = left[j];
      }
    } else {
      if (K - j - 1 < right.size()) {
        long tmp = left[j] * 2 + right[K - j - 2];
        if (tmp < ans) ans = tmp;
      }
    }
  }
  for (long j = 0; j < right.size() && j < K; j++) {
    if (j + 1 == K) {
      if (ans > right[j]) {
        ans = right[j];
      }
    } else {
      if (K - j - 1 < left.size()) {
        long tmp = right[j] * 2 + left[K - j - 2];
        if (tmp < ans) ans = tmp;
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:3: error: 'reverse' was not declared in this scope
   23 |   reverse(left.begin(), left.end());
      |   ^~~~~~~
Language: C++

#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int n, k, x[100000], ans = INT_MAX;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i <= n - k; i++){
        ans = min(ans, x[i+k-1] - x[i] + min(abs(x[i]), abs(x[i+k-1]));
    }
    cout << ans << endl;
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
int n , k;
const int maxn = 2e5 + 25
long long a[maxn];
long long ans=1e18 + 7;
int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    for (i = 1;i + k - 1 <= n ; i++)
    {
        long long tmp=a[i+k-1] - a[i];
        if ((a[i]<0) && (a[i+k-1]<0)) tmp += abs(a[i+k-1]);
        if ((a[i]>0) && (a[i+k-1]>0)) tmp += a[i];
        if ((a[i]<0) && (a[i+k-1]>0)) tmp += min(-a[i],a[i+k-1]);
        ans=min(ans,tmp);
    }
    cout << ans;
    return 0;
}
//salam

Compiler output:
a.cc:5:1: error: expected ',' or ';' before 'long'
    5 | long long a[maxn];
      | ^~~~
a.cc: In function 'int main()':
a.cc:13:16: error: 'a' was not declared in this scope
   13 |         cin >> a[i];
      |                ^
a.cc:15:10: error: 'i' was not declared in this scope
   15 |     for (i = 1;i + k - 1 <= n ; i++)
      |          ^
a.cc:17:23: error: 'a' was not declared in this scope
   17 |         long long tmp=a[i+k-1] - a[i];
      |                       ^
Language: C++

// nullbyte

#include <bits/stdc++.h>

using namespace std ;

const int MAXN = 1e5 + 69 ;

#define pb push_back

ll n , k , ans , arr[MAXN] , dist[MAXN] , part[MAXN] ;

int main() {
        cin >> n >> k ;
        for ( int i = 0 ; i < n ; i ++ )
                cin >> arr[i] ;
        for ( int i = 1 ; i < n ; i ++ )
                dist[i] = arr[i] - arr[i - 1] ;
        for ( int i = 1 ; i < n ; i ++ )
                part[i] = part[i - 1] + dist[i] ;
        for ( int i = k - 1 ; i < n ; i ++ )
                ans = max(ans , part[i] - part[i - k + 1] + arr[i - k]) ;
        cout << ans << "\n" ;
}

Compiler output:
a.cc:11:1: error: 'll' does not name a type
   11 | ll n , k , ans , arr[MAXN] , dist[MAXN] , part[MAXN] ;
      | ^~
a.cc: In function 'int main()':
a.cc:14:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   14 |         cin >> n >> k ;
      |                ^
      |                yn
a.cc:14:21: error: 'k' was not declared in this scope
   14 |         cin >> n >> k ;
      |                     ^
a.cc:16:24: error: 'arr' was not declared in this scope
   16 |                 cin >> arr[i] ;
      |                        ^~~
a.cc:18:17: error: 'dist' was not declared in this scope
   18 |                 dist[i] = arr[i] - arr[i - 1] ;
      |                 ^~~~
a.cc:18:27: error: 'arr' was not declared in this scope
   18 |                 dist[i] = arr[i] - arr[i - 1] ;
      |                           ^~~
a.cc:20:17: error: 'part' was not declared in this scope
   20 |                 part[i] = part[i - 1] + dist[i] ;
      |                 ^~~~
a.cc:20:41: error: 'dist' was not declared in this scope
   20 |                 part[i] = part[i - 1] + dist[i] ;
      |                                         ^~~~
a.cc:22:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |                 ans = max(ans , part[i] - part[i - k + 1] + arr[i - k]) ;
      |                 ^~~
      |                 abs
a.cc:22:33: error: 'part' was not declared in this scope
   22 |                 ans = max(ans , part[i] - part[i - k + 1] + arr[i - k]) ;
      |                                 ^~~~
a.cc:22:61: error: 'arr' was not declared in this scope
   22 |                 ans = max(ans , part[i] - part[i - k + 1] + arr[i - k]) ;
      |                                                             ^~~
a.cc:23:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |         cout << ans << "\n" ;
      |                 ^~~
      |                 abs
Language: C

#include<iostream>
using namespace std;
const int N=1e5+100;
int x[N];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>x[i];
    int ans=1e8+100;
    for(int i=1;i<=n-k+1;i++)
    {
        int left=i;int right=i+k-1;
        if(x[left]<0&&x[right]<0)
        {
            ans=min(ans,-x[left]);
        }
        else if(x[left]<0&&x[right]>0)
        {
            ans=min(ans,2*x[left]*(-1)+x[right]);
        }
        else ans=min(ans,x[right]);
    }
    cout<<ans<<endl;
}


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

#include<bits/stdc++.h>
using namespace std;
long long x[3000010],n,k,pos=-1,an=0x3f3f3f3f;
int main()
{
	scanf("%lld%lld",&n,&k);
	for (long long i=1;i<=n;i++) scanf("%lld",&x[i]);
	for(int i=k-1;i<n;i++) an=min(an,x[i]-x[i-k+1]+abs(x[i]),abs(x[i-k+1]));
	printf("%lld",an);
}

Compiler output:
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: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:8:31:   required from here
    8 |         for(int i=k-1;i<n;i++) an=min(an,x[i]-x[i-k+1]+abs(x[i]),abs(x[i-k+1]));
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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<limits>
using namespace std;

int n;
int a[2000];

int main()
{
    int k,n,i;
    cin >> n >> k;

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

    int ans=INT_MAX;

    for(i=1; i+k-1<=n; i++)
    {
        int tmp = a[i+k-1]-a[i];
        // 头尾都是负数
        if ((a[i]<0) && (a[i+k-1]<0)) 
        {
        	tmp+=abs(a[i+k-1]);
        }
        // 头尾都是正数
        if ((a[i]>0) && (a[i+k-1]>0)) 
        {
        	tmp+=a[i];
        }
        // 头尾符号不一样
        if ((a[i]<0) && (a[i+k-1]>0)) 
        {
        	tmp+=min(-a[i],a[i+k-1]);
        }

        ans=min(ans,tmp);
    }

    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: 'INT_MAX' was not declared in this scope
   18 |     int ans=INT_MAX;
      |             ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<limits>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
long longx[3000010],n,k,pos=-1,an=0x3f3f3f3f;
int main()
{
	scanf("%d%d",&n,&k);
	for (long longi=1;i<=n;i++) scanf("%d",&x[i]);
	for (long longi=1;i<=n-1;i++)
		if (x[i]<=0 && x[i+1]>0) pos=i; 
	if (pos==-1)
	{
		if (x[1]>0) printf("%d",x[k]);
		else printf("%d",abs(x[n-k+1]));
		return 0;
	}
	for (long longi=1;i<=pos;i++) an=min(an,abs(x[i])+x[i+k-1]-x[i]);
	printf("%d",an);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:27: error: 'i' was not declared in this scope
    7 |         for (long longi=1;i<=n;i++) scanf("%d",&x[i]);
      |                           ^
a.cc:7:49: error: 'x' was not declared in this scope
    7 |         for (long longi=1;i<=n;i++) scanf("%d",&x[i]);
      |                                                 ^
a.cc:8:27: error: 'i' was not declared in this scope
    8 |         for (long longi=1;i<=n-1;i++)
      |                           ^
a.cc:9:21: error: 'x' was not declared in this scope
    9 |                 if (x[i]<=0 && x[i+1]>0) pos=i;
      |                     ^
a.cc:12:21: error: 'x' was not declared in this scope
   12 |                 if (x[1]>0) printf("%d",x[k]);
      |                     ^
a.cc:16:27: error: 'i' was not declared in this scope
   16 |         for (long longi=1;i<=pos;i++) an=min(an,abs(x[i])+x[i+k-1]-x[i]);
      |                           ^
a.cc:16:53: error: 'x' was not declared in this scope
   16 |         for (long longi=1;i<=pos;i++) an=min(an,abs(x[i])+x[i+k-1]-x[i]);
      |                                                     ^
Language: C++

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAX=200000000;
int ans=MAX,a[100001];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a[i]);
	}
	for(int i=1;i<=n-k+1;i++)
	{
		int xx=min(abs(a[i+k-1]),abs(a[i]))
		ans=min(ans,a[i+k-1]-a[i]+xx);
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: expected ',' or ';' before 'ans'
   18 |                 ans=min(ans,a[i+k-1]-a[i]+xx);
      |                 ^~~
Language: Java

import java.util.Scanner;

public class Main107 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        if (K == 1) {
            System.out.println(sc.nextInt());
            return;
        }

        int[] candles = new int[N];
        int[] candleCum = new int[N+1];
        for (int i = 0; i < N; i++) {
            candles[i] = sc.nextInt();
            if (i - K + 1 >= 0) {
                if (candles[i] > 0 && candles[i-K+1] < 0) {
                    candleCum[i - K + 1] = candles[i] - candles[i - K + 1] + Math.min(Math.abs(candles[i - K + 1]), candles[i]);
                } else if (candles[i] > 0 && candles[i-K+1] > 0) {
                    candleCum[i - K + 1] = candles[i];
                } else {
                    candleCum[i - K + 1] = candles[i - K + 1];
                }
            }
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < candleCum.length; i++) {
            if (candleCum[i] == 0) {
                continue;
            }
            min = Math.min(candleCum[i], min);
        }

        System.out.println(min);


    }
}


Compiler output:
Main.java:3: error: class Main107 is public, should be declared in a file named Main107.java
public class Main107 {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int k = Integer.parseInt(lines[1]);

      String line = in.readLine();
      int offset=0,next=0;
      char regx = ' ';
      int[] ax = new int[n];
      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        ax[i] = Integer.parseInt(line.substring(offset, next));
        offset = next + 1;
      }

      int min = Integer.MAX_VALUE;
      int sumF = sumB = sum = 0;
      for(int i=0; i<n-k+1; i++) {
        sumF = Math.abs(ax[i]) + Math.abs(ax[i+k-1] - ax[i]);
        sumB = Math.abs(ax[i+k-1] + Math.abs(ax[i+k-1]) - ax[i]);
        sum = Math.min(sumF, sumB);
        if(i == 0 || sum < min) min = sum;
      }

      System.out.println(min);
    }
    catch(IOException e) {
      System.out.println(e);
    }
  }
}

Compiler output:
Main.java:32: error: cannot find symbol
      int sumF = sumB = sum = 0;
                 ^
  symbol:   variable sumB
  location: class Main
Main.java:32: error: cannot find symbol
      int sumF = sumB = sum = 0;
                        ^
  symbol:   variable sum
  location: class Main
Main.java:35: error: cannot find symbol
        sumB = Math.abs(ax[i+k-1] + Math.abs(ax[i+k-1]) - ax[i]);
        ^
  symbol:   variable sumB
  location: class Main
Main.java:36: error: cannot find symbol
        sum = Math.min(sumF, sumB);
        ^
  symbol:   variable sum
  location: class Main
Main.java:36: error: cannot find symbol
        sum = Math.min(sumF, sumB);
                             ^
  symbol:   variable sumB
  location: class Main
Main.java:37: error: cannot find symbol
        if(i == 0 || sum < min) min = sum;
                     ^
  symbol:   variable sum
  location: class Main
Main.java:37: error: cannot find symbol
        if(i == 0 || sum < min) min = sum;
                                      ^
  symbol:   variable sum
  location: class Main
7 errors
Language: C++

using namespace std;
int main()
{
    long long int n,k,x[100000],sum=0;
    cin>> n >> k;
    for(int i=0;i<n;i++)
    {
      if(i<=k)
      {
          sum=sum+i;
      }
      else if(i>k)
      {
          break;
      }
    }
    cout << sum << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     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 | using namespace std;
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout << sum << endl;
      |     ^~~~
a.cc:17:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:20: error: 'endl' was not declared in this scope
   17 |     cout << sum << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include <iostresm>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int X[N];
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  int result = INT_MAX;
  for (int i = 0; i <= N-K; i++) {
    int l = X[i];
    int r = X[i+K-1];
    result = min(result, min(abs(l)+abs(r-l),abs(r)+abs(r-l)));
  }
  cout << result << endl;
  return 0;
}


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

#include <iostream>
#include <vector>

int cost(int now_k, const int max_k, int now_pos, std::vector< std::pair<int, bool> > x, int now_cost);

int main()
{
	int min_cost = INT_MAX;

	int N, K;
	std::vector< std::pair<int, bool> > x;

	std::cin >> N >> K;

	x.resize(N);
	for (auto &it : x) {
		std::cin >> it.first;
		it.second = false;
	}

	for (auto &it : x) {
		it.second = true;

		int c = cost(1, K, it.first, x, std::abs(it.first));
		if (c < min_cost)
			min_cost = c;

		it.second = false;
	}

	std::cout << min_cost << std::endl;
}

int cost(int now_k, const int max_k, int now_pos, std::vector< std::pair<int,bool> > x, int now_cost)
{
	if (now_k != max_k) {
		int min_cost = INT_MAX;

		for (auto &it : x)
		{
			if (!it.second) {
				it.second = true;
				int c = cost(now_k + 1, max_k, it.first, x, std::abs(now_pos - it.first) + now_cost);

				if (c < min_cost)
					min_cost = c;

				it.second = false;
			}
		}
		return min_cost;
	}

	return now_cost;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:24: error: 'INT_MAX' was not declared in this scope
    8 |         int min_cost = INT_MAX;
      |                        ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 | 
a.cc: In function 'int cost(int, int, int, std::vector<std::pair<int, bool> >, int)':
a.cc:37:32: error: 'INT_MAX' was not declared in this scope
   37 |                 int min_cost = INT_MAX;
      |                                ^~~~~~~
a.cc:37:32: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include<iostream>
#include<algorithm>
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int N,K,x[110000],r,ans,t;
int main(){
	cin >> N >> K;
	ans=0x7fffffff;
	fo(i,1,n)
        cin >> x[i];
	fo(l,1,N-K+1){
		r=l+K-1;
		if((x[l]>=0)^(x[r]>=0))
            t=-x[l]+x[r]+min(-x[l],x[r]);
        else
            t=max(abs(x[l]),abs(x[r]));
		if(ans>t)
            ans=t;
	}
    cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'i' was not declared in this scope
   11 |         fo(i,1,n)
      |            ^
a.cc:11:16: error: 'n' was not declared in this scope
   11 |         fo(i,1,n)
      |                ^
a.cc:11:9: error: 'fo' was not declared in this scope; did you mean 'fd'?
   11 |         fo(i,1,n)
      |         ^~
      |         fd
a.cc:13:12: error: 'l' was not declared in this scope
   13 |         fo(l,1,N-K+1){
      |            ^
Language: C++

#include <iostream>
#include <cstdlib>
#include <cmath>

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

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

	int min = 10000000;
	int minl;

	for (int i = 0; i <= N - K; i++) {
		int temp = 0;
		for (int t = i + 1; t < i + K; t++) {
			temp += ar[t] - ar[t - 1];
		}
		if (temp + abs(ar[i]) < min + minl) {
			minl = abs(ar[i]);
			min = temp;
		}
	}

	cout << min + minl << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |         cin >> N >> K;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:28:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   28 |         cout << min + minl << 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:28:31: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   28 |         cout << min + minl << 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++

#include<iostream>
#include<vector>
#include<numeric>

using namespace std;

int jikan(vector<int> num);

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> x(N, 0);
	vector<int> num(K, 0);
	for(int i = 0; i < N; i++) {
		cin >> x[i];
		if(i < K)
			num[i] = x[i];
	}

	int min = jikan(num);
	for(int i = K; i < N; i++) {
		num.erase(num.begin());
		num.push_back(x[i]);
		int t = jikan(num);
		if(t < min)
			min = t;
	}

	cout << min << endl;

	return 0;
}

Compiler output:
/usr/bin/ld: /tmp/ccLgpuHh.o: in function `main':
a.cc:(.text+0x173): undefined reference to `jikan(std::vector<int, std::allocator<int> >)'
/usr/bin/ld: a.cc:(.text+0x21b): undefined reference to `jikan(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status
Language: C++

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

int main(){
    int ans=INT_MAX, n, k;

    cin >> n >> k;

    int *x = new int[k];

    
    for(int i=0, cnt=0; i<n; ++i){
        cin >> x[cnt];

        if(cnt == k-1){
            ans = min(ans, abs(x[0]) + abs(x[cnt] - x[0]));
            ans = min(ans, abs(x[cnt]) + abs(x[0] - x[cnt]));

            for(int j=0; j<k-1; ++j){
                x[j] = x[j+1];
            }
        }else{
            ++cnt;
        }
    }

    cout << ans << endl;

    delete[] x;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: 'INT_MAX' was not declared in this scope
    6 |     int ans=INT_MAX, n, k;
      |             ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<algorithm>
  +++ |+#include <climits>
    3 | using namespace std;
a.cc:8:12: error: 'n' was not declared in this scope
    8 |     cin >> n >> k;
      |            ^
a.cc:8:17: error: 'k' was not declared in this scope
    8 |     cin >> n >> k;
      |                 ^
Language: Java

import java.util.*;
 
public class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] box = new int[n];
        for (int i = 0; i < n; i++) {
        	box[i] = sc.nextInt();
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - k + 1; i++) {
        	int diff = Math.abs(box[i] - box[i+k-1]);
            int tmp = diff + Math.min(Math.abs(x[i]), Math.abs(x[i + k - 1]));
            min = Math.min(min, tmp);
        }
        System.out.println(min);
    }
}

Compiler output:
Main.java:16: error: cannot find symbol
            int tmp = diff + Math.min(Math.abs(x[i]), Math.abs(x[i + k - 1]));
                                               ^
  symbol:   variable x
  location: class Main
Main.java:16: error: cannot find symbol
            int tmp = diff + Math.min(Math.abs(x[i]), Math.abs(x[i + k - 1]));
                                                               ^
  symbol:   variable x
  location: class Main
2 errors
Language: Java

import java.util.*

public class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] box = new int[n];
        for (int i = 0; i < n; i++) {
        	box[i] = sc.nextInt();
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - k + 1; i++) {
        	int diff = Math.abs(box[i] - box[i+k-1])
            int tmp = diff + Math.min(Math.abs(x[i]), Math.abs(x[i + k - 1]));
            min = Math.min(min, tmp);
        }
        System.out.println(min);
    }
}

Compiler output:
Main.java:1: error: ';' expected
import java.util.*
                  ^
Main.java:15: error: ';' expected
        	int diff = Math.abs(box[i] - box[i+k-1])
        	                                        ^
2 errors
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int N=1e5+5;
int n,k,mn=200000005,AA[N];
inline int Read(){
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	n=Read();k=Read()--k;
	for(int i=0;i<n;++i)AA[i]=Read();
	for(int i=0;i+k<n;++i)
		if(AA[i+k]-AA[i]+min(abs(AA[i]),abs(AA[i+k]))<mn)mn=AA[i+k]-AA[i]+min(abs(AA[i]),abs(AA[i+k]));
	printf("%d",mn);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:24: error: lvalue required as decrement operand
   14 |         n=Read();k=Read()--k;
      |                    ~~~~^~
Language: C++

#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int x[n],i0 = 0;
  for(int i=0;i<n;i++) {
    cin >> x[i];
    if (i > 0 && x[i] >= 0 && x[i-1] < 0) i0 = i;
  }
  int t_min=INT_MAX;
  for(int i=0;i<n-k+1;i++){
    int t = min(x[i+k-1]-x[i]+abs(x[i+k-1]), x[i+k-1]-x[i]+abs(x[i]));
    if(t < t_min)t_min = t;
  }
  cout << t_min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: 'INT_MAX' was not declared in this scope
   12 |   int t_min=INT_MAX;
      |             ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<cstdlib>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define INF 0x3f3f3f3f
#define ll long long
#define EPS 1e-8
using namespace std;
int ar[100005];
int main()
{
    //freopen("stdin.in","r",stdin);
    //freopen("stdout.out","w",stdout);
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&ar[i]);
    }
    int ans = INF;
    for(int i=1;i+k-1<=n;i++){
        int r = i+k-1;
        int tmp = ar[r]-ar[i]+min(abs(ar[i],abs(ar[r])));
        ans = min(tmp,ans);
    }
    printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:38: error: no matching function for call to 'abs(int&, int)'
   22 |         int tmp = ar[r]-ar[i]+min(abs(ar[i],abs(ar[r])));
      |                                   ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/std_abs.h:38,
                 from /usr/include/c++/14/cmath:49,
                 from a.cc:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:980:12: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided
Language: C++

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

using namespace std;

int main(int argc, char const *argv[])
{
  int n, k;
  int x[100000];

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

  int min = INT_MAX;
  for (int i = 0; i < n - k + 1; i++)
  {
    int distance = abs(x[i]);
    if (distance > abs(x[i + k - 1]))
    {
      distance = abs(x[i + k - 1]);
    }
    distance = distance + abs(x[i + k - 1] - x[i]);
    min = min > distance ? distance : min;
  }
  cout << min;

  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:19:13: error: 'INT_MAX' was not declared in this scope
   19 |   int min = INT_MAX;
      |             ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 |
Language: C++

#include <iostream>
#include <cstdint>

using namespace std;

int main(int argc, char const *argv[])
{
  int n, k;
  int x[100000];

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

  int min = INT_MAX;
  for (int i = 0; i < n - k + 1; i++)
  {
    //int64_t distance = x[i] >= 0 ? x[i] : -1 * x[i];
    int distance = abs(x[i]);
    distance += abs(x[i + k - 1] - x[i]);
    min = min > distance ? distance : min;
  }
  cout << min;
  return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:17:13: error: 'INT_MAX' was not declared in this scope
   17 |   int min = INT_MAX;
      |             ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <cstdint>
  +++ |+#include <climits>
    3 |
Language: C++

#include <iostream>
using namespace std;

int main(int argc, char const *argv[])
{
  int n, k;
  int x[10000];

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

  int min = INT_MAX;
  for (int i = 0; i < n - k + 1; i++)
  {
    int distance = abs(x[i]);
    distance += (x[i + k - 1] - x[i]);
    min = min > distance ? distance : min;
  }
  cout << min;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:15:13: error: 'INT_MAX' was not declared in this scope
   15 |   int min = INT_MAX;
      |             ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C

#include <stdio.h>

int n,k,x[200000],y,border = 20000;
long long an = 9000000000000000000;

int main() {

    scanf("%d %d",&n,&k);
    for(y=1;y<=n;y++){
        scanf("%d", &x[y]);
        if(x[y] == 0){
            y--;
            n--;
            k--;
            continue;
        }
        if(x[y]>0 && border == 20000 ) border = y-1;
    }
    if(x[1]>0){
        printf("%d\n",x[k]);
        return 0;
    }

    if(border >= k) an = x[border-k+1]*-1;
    if(n-border >= k && x[border+k] < an) an = x[border+k];

    k--;

    if(x[n]<0){
        printf("%d\n",x[n-k]*-1);
        return 0;
    }


    for(y=1;x[y]<0;y++){
        if( y+k >= n || x[y+k] < 0 || x[y]>0 ) break;
        if( x[y]*-2 + x[y+k] < an ) an = x[y]*-2 + x[y+k];
        if( x[y]*-1 + x[y+k]*2 < an ) an = x[y]*-1 + x[y+k]*2;
    }
    printf("%lld\n",an);

    return 0;
}


    return 0;
}

Compiler output:
main.c:46:5: error: expected identifier or '(' before 'return'
   46 |     return 0;
      |     ^~~~~~
main.c:47:1: error: expected identifier or '(' before '}' token
   47 | }
      | ^
Language: C++

#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  cin >> n >> k;
 
  for(int i=0; i<n; i++){
   cin >> vec.at(i);
  }
  ll s = INF;
  int center = 0;
  int centerzero = 0;
  bool flag = true;
  for(int i=0; i<n; i++){
    if(flag && vec.at(0) >= 0){
        s = 0;
        flag = false;
    }
    else if(flag && vec.at(0) < 0){
      if(i<n-1 && vec.at(i) <0 && vec.at(i+1) > 0){
        center = i+1;
        flag = false;
      }
      else if(i<n-1 && vec.at(i) <0 && vec.at(i+1) == 0){
        centerzero = i+1;
        flag = false;
      }
      else if(vec.at(n-1) <= 0){
        s = n-1;
        flag = false;
      }
    }
  }
   if(s == 0)
     cout << vec.at(k-1) << endl;
   else if(s == n-1)
     cout << vec.at(n-k) << endl;
   else{
     ll ans = INF;
     if(center){
       for(int i = center-k;i<=center;i++){
         ll a=0;
         ll b=0;
         if(i>=0 && i+k <= n){
           if(vec.at(i) < 0)
             a -= vec.at(i);
           else
             a = 0;
           if(vec.at(i+k-1) <0)
             b = 0;
           else
             b = vec.at(i+k-1);
           if(a<b)
           a *= 2;
           else
             b *= 2;
           if(ans > a+b)
           ans = a+b;
         }
       }
     }
     else if(centerzero){
       for(int i = center-k+1;i<=center;i++){
         ll a = 0
         ll b = 0;
         if(i>=0 && i+k <= n){
           if(vec.at(i) < 0)
             a -= vec.at(i);
           else
             a = 0;
             b = vec.at(i+k-1);
         }
         if(a<b)
           a *= 2;
         else
           b *= 2;
         if(ans > a+b)
         ans = a+b;
     }
   }
     cout << ans << endl;
   }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:10: error: expected ',' or ';' before 'll'
   79 |          ll b = 0;
      |          ^~
a.cc:85:14: error: 'b' was not declared in this scope
   85 |              b = vec.at(i+k-1);
      |              ^
a.cc:87:15: error: 'b' was not declared in this scope
   87 |          if(a<b)
      |               ^
a.cc:91:21: error: 'b' was not declared in this scope
   91 |          if(ans > a+b)
      |                     ^
Language: C++

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

#define ALL(a)     (a).begin(),(a).end()
#define EACH(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c)    sort((c).begin(),(c).end())
#define RSORT(c)    sort((c).rbegin(),(c).rend())
#define MAXINDEX(c) distance((c).begin(),max_element((c).begin(),(c).end()))
#define MININDEX(c) distance((c).begin(),min_element((c).begin(),(c).end()))
#define DEBUG(x)   std::cerr <<#x<<" = "<<(x)<<" ("<<__FILE__<<"::"<<__LINE__<<")"<<std::endl;
#define ERROR(s)   std::cerr <<"Error::"<<__FILE__<<"::"<<__LINE__<<"::"<<__FUNCTION__<<"::"<<(s)<<std::endl;
#define FOR(i,a,b) for (auto i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)

constexpr bool __debugFlag = false;

int main(int argc, char **argv){
    
    // get inputs 
    size_t numberOfCandle;
    size_t numberOfLight;

    cin >> numberOfCandle >> numberOfLight;
    
    vector <int> candleCordinates( numberOfCandle ); 
    for(size_t i=0; i<numberOfCandle; i++) {
        cin >> candleCordinates[i] ;
    }


    int64_t globalMinTime = 2 * ( abs(candleCordinates[0]) + abs(candleCordinates[numberOfCandle-1])  );
    for(size_t i=0; i<=numberOfCandle-numberOfLight; i++){
        int beginValue = candleCordinates[i];
        int64_t minusSideTime = beginValue < 0 ? abs(beginValue) : 0;

        int endValue = candleCordinates[i + numberOfLight - 1];
        int64_t plusSideTime = endValue > 0 ? abs(candleCordinates[i + numberOfLight - 1]) : 0;

        int64_t localMinTime = min ( 2 * minusSideTime + plusSideTime , minusSideTime + 2 * plusSideTime ) ;
        globalMinTime = min ( globalMinTime , localMinTime) ;       
    }   


    if(__debugFlag ){
        
        cout << "N," << numberOfCandle << ",K,"  << numberOfLight << endl;
        for(size_t i=0; i<numberOfCandle; i++) {
            cout << candleCordinates[i] << ",";
        }
        cout << endl;
        cout << indexOfminus2plus << endl;
        cout << headIndex_start << "," << headIndex_end << endl;
    }


    cout << globalMinTime << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:56:17: error: 'indexOfminus2plus' was not declared in this scope
   56 |         cout << indexOfminus2plus << endl;
      |                 ^~~~~~~~~~~~~~~~~
a.cc:57:17: error: 'headIndex_start' was not declared in this scope
   57 |         cout << headIndex_start << "," << headIndex_end << endl;
      |                 ^~~~~~~~~~~~~~~
a.cc:57:43: error: 'headIndex_end' was not declared in this scope
   57 |         cout << headIndex_start << "," << headIndex_end << endl;
      |                                           ^~~~~~~~~~~~~
Language: C++

int N, K, X[101010];
vector<int> mi, pr;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> X[i];
 
    mi.push_back(0);
    pr.push_back(0);
    rep(i, 0, N) {
        if (X[i] <= 0) mi.push_back(-X[i]);
        else pr.push_back(X[i]);
    }
    sort(all(mi));
    sort(all(pr));
 
    int n = mi.size();
    int m = pr.size();
    
    int ans = inf * 2;
    rep(i, 0, n) {
        int j = K - i;
        if (0 <= j and j < m) chmin(ans, mi[i] * 2 + pr[j]);
    }
    rep(i, 0, m) {
        int j = K - i;
        if (0 <= j and j < n) chmin(ans, pr[i] * 2 + mi[j]);
    }
    cout << ans << endl;
}

Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<int> mi, pr;
      | ^~~~~~
a.cc: In function 'void _main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> N >> K;
      |     ^~~
a.cc:6:9: error: 'i' was not declared in this scope
    6 |     rep(i, 0, N) cin >> X[i];
      |         ^
a.cc:6:5: error: 'rep' was not declared in this scope
    6 |     rep(i, 0, N) cin >> X[i];
      |     ^~~
a.cc:8:5: error: 'mi' was not declared in this scope
    8 |     mi.push_back(0);
      |     ^~
a.cc:9:5: error: 'pr' was not declared in this scope
    9 |     pr.push_back(0);
      |     ^~
a.cc:14:10: error: 'all' was not declared in this scope
   14 |     sort(all(mi));
      |          ^~~
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |     sort(all(mi));
      |     ^~~~
      |     short
a.cc:20:15: error: 'inf' was not declared in this scope; did you mean 'int'?
   20 |     int ans = inf * 2;
      |               ^~~
      |               int
a.cc:29:5: error: 'cout' was not declared in this scope
   29 |     cout << ans << endl;
      |     ^~~~
a.cc:29:20: error: 'endl' was not declared in this scope
   29 |     cout << ans << endl;
      |                    ^~~~
Language: C++

int main (void) {
  int N, K;
  std::cin >> N >> K;
  int x[N];
  for (int i = 0; i < N; ++i) {
    std::cin >> x[i];
  }

  int len;
  int min_len = std::abs(x[0]) + std::abs(x[0] - x[0 + K - 1]);
  int min_l = x[0], min_r = x[0 + K - 1];
  for (int i = 0; i + K - 1< N; ++i) {
    len = std::abs(x[i]) + std::abs(x[i] - x[i + K - 1]);
    if (len < min_len) {
      min_len = len;
      min_l = x[i];
      min_r = x[i + K - 1];
    }
    len = std::abs(x[i + K - 1]) + std::abs(x[i] - x[i + K - 1]);
    if (len < min_len) {
      min_len = len;
      min_l = x[i + K - 1];
      min_r = x[i];
    }
  }
  std::cout << min_len << std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:8: error: 'cin' is not a member of 'std'
    3 |   std::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 | int main (void) {
a.cc:6:10: error: 'cin' is not a member of 'std'
    6 |     std::cin >> x[i];
      |          ^~~
a.cc:6:10: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:10:22: error: 'abs' is not a member of 'std'
   10 |   int min_len = std::abs(x[0]) + std::abs(x[0] - x[0 + K - 1]);
      |                      ^~~
a.cc:10:39: error: 'abs' is not a member of 'std'
   10 |   int min_len = std::abs(x[0]) + std::abs(x[0] - x[0 + K - 1]);
      |                                       ^~~
a.cc:13:16: error: 'abs' is not a member of 'std'
   13 |     len = std::abs(x[i]) + std::abs(x[i] - x[i + K - 1]);
      |                ^~~
a.cc:13:33: error: 'abs' is not a member of 'std'
   13 |     len = std::abs(x[i]) + std::abs(x[i] - x[i + K - 1]);
      |                                 ^~~
a.cc:19:16: error: 'abs' is not a member of 'std'
   19 |     len = std::abs(x[i + K - 1]) + std::abs(x[i] - x[i + K - 1]);
      |                ^~~
a.cc:19:41: error: 'abs' is not a member of 'std'
   19 |     len = std::abs(x[i + K - 1]) + std::abs(x[i] - x[i + K - 1]);
      |                                         ^~~
a.cc:26:8: error: 'cout' is not a member of 'std'
   26 |   std::cout << min_len << std::endl;
      |        ^~~~
a.cc:26:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:32: error: 'endl' is not a member of 'std'
   26 |   std::cout << min_len << std::endl;
      |                                ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int main (void) {
Language: C++

/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 1e5 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

;; n, k, mn = INF, x[N];

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n >> k;

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

  for(int i = 1; i <= n - k; i++){
    ll j = i + k - 1;
    ll d = abs(x[j] - x[i]) + min(abs(x[i]), abs(x[j]));
    mn = min(mn, d);
  }

  cout << mn;
}


Compiler output:
a.cc:44:4: error: 'n' does not name a type
   44 | ;; n, k, mn = INF, x[N];
      |    ^
a.cc: In function 'int main()':
a.cc:57:10: error: 'n' was not declared in this scope
   57 |   cin >> n >> k;
      |          ^
a.cc:57:15: error: 'k' was not declared in this scope
   57 |   cin >> n >> k;
      |               ^
a.cc:60:12: error: 'x' was not declared in this scope
   60 |     cin >> x[i];
      |            ^
a.cc:65:16: error: 'x' was not declared in this scope
   65 |     ll d = abs(x[j] - x[i]) + min(abs(x[i]), abs(x[j]));
      |                ^
a.cc:66:5: error: 'mn' was not declared in this scope; did you mean 'yn'?
   66 |     mn = min(mn, d);
      |     ^~
      |     yn
a.cc:69:11: error: 'mn' was not declared in this scope; did you mean 'yn'?
   69 |   cout << mn;
      |           ^~
      |           yn